Skip to content

Commit 012f6b3

Browse files
committed
fix icons
1 parent 7033035 commit 012f6b3

File tree

5 files changed

+51
-22
lines changed

5 files changed

+51
-22
lines changed

socket.ini

+21-3
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ version = 1.0.0
186186
; The icon to use for identifying your app on Android.
187187
icon = "icons/icon.png"
188188

189+
; The various sizes and scales of the icons to create, required minimum are listed by default.
190+
icon_sizes = "512@1x"
191+
189192
; Extensions of files that will not be stored compressed in the APK.
190193
aapt_no_compress = ""
191194

@@ -226,6 +229,11 @@ simulator_device = "iPhone 14"
226229
; default value: false
227230
; nonexempt_encryption = false
228231

232+
; iOS icon!
233+
icon ="icons/icon.png"
234+
235+
; The various sizes and scales of the icons to create, required minimum are listed by default.
236+
icon_sizes = "20@1x 20@2x 20@3x"
229237

230238
[linux]
231239
; Helps to make your app searchable in Linux desktop environments.
@@ -237,6 +245,9 @@ categories = "Developer Tools"
237245
; The icon to use for identifying your app in Linux desktop environments.
238246
icon = "icons/icon.png"
239247

248+
; The various sizes and scales of the icons to create, required minimum are listed by default.
249+
icon_sizes = "512@1x"
250+
240251

241252
[mac]
242253

@@ -246,9 +257,6 @@ category = ""
246257
; The command to execute to spawn the "back-end" process.
247258
; cmd = "node backend/index.js"
248259

249-
; The icon to use for identifying your app on MacOS.
250-
icon = "icons/icon.png"
251-
252260
; TODO Signing guide: https://socketsupply.co/guides/#code-signing-certificates
253261
codesign_identity = ""
254262

@@ -260,6 +268,13 @@ codesign_paths = ""
260268
; minimum_supported_version = "13.0.0"
261269

262270

271+
; The icon to use for identifying your app on MacOS.
272+
icon = "icons/icon.png"
273+
274+
; The various sizes and scales of the icons to create, required minimum are listed by default.
275+
icon_sizes = "16@1x 32@1x 128@1x"
276+
277+
263278
[native]
264279

265280
; Files that should be added to the compile step.
@@ -286,6 +301,9 @@ logo = "icons/icon.ico"
286301
; The signing information needed by the appx api.
287302
; publisher = "CN=Beep Boop Corp., O=Beep Boop Corp., L=San Francisco, S=California, C=US"
288303

304+
; The various sizes and scales of the icons to create, required minimum are listed by default.
305+
icon_sizes = "512@1x"
306+
289307

290308
[window]
291309

src/icon/index.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ export function resizePNG (imageArrayBuffer, size) {
5151
/**
5252
* Converts a PNG file to an ICO file.
5353
* @param {string} pngFilePath Path to the source PNG file.
54-
* @param {string} icoFilePath Path where the ICO file will be saved.
5554
*/
56-
export async function convertToICO (bytes, icoFilePath) {
55+
export async function convertToICO (bytes) {
5756
const icoHeader = Buffer.alloc(6)
5857
icoHeader.writeUInt16LE(0, 0) // Reserved
5958
icoHeader.writeUInt16LE(1, 2) // Type (1 = ICO)

src/index.js

+17-3
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,25 @@ class AppView extends Tonic {
3939
const paths = {}
4040
project.walk(project.state.tree.children[0], child => {
4141
if (child.type === 'dir') return
42-
paths[path.join(this.state.cwd, child.id)] = child.data
42+
43+
let dir = child.id
44+
let data = child.data
45+
46+
if (child.id.includes('icon.assets')) {
47+
if (process.platform === 'win') {
48+
data = convertToICO(node.data)
49+
dir = path.join('icons', 'icon.ico')
50+
} else {
51+
dir = path.join('icons', 'icon.png')
52+
}
53+
}
54+
55+
paths[path.join(this.state.cwd, dir)] = data
4356
})
4457

45-
for (const [path, data] of Object.entries(paths)) {
46-
await fs.promises.writeFile(path, data)
58+
for (const [pathToFile, data] of Object.entries(paths)) {
59+
await fs.promises.mkdir(path.dirname(pathToFile), { recursive: true })
60+
await fs.promises.writeFile(pathToFile, data)
4761
}
4862

4963
const args = [

src/project.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fs from 'socket:fs'
22
import path from 'socket:path'
33
import Tonic from '@socketsupply/tonic'
4+
import { convertToICO } from './icon/index.js'
45

56
const EXPANDED_STATE = 1
67
const CLOSED_STATE = 0
@@ -84,14 +85,6 @@ class AppProject extends Tonic {
8485
})
8586
}
8687

87-
exportData (prefix) {
88-
this.walk(this.state.tree, node => {
89-
const p = path.join(prefix, node.id)
90-
fs.mkdir(path.dirname(p), { recursive: true })
91-
fs.promises.writeFile(p, node.data)
92-
})
93-
}
94-
9588
click (e) {
9689
const el = Tonic.match(e.target, '[data-path]')
9790
if (!el) return

src/templates/socket.ini

+11-6
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ version = 1.0.0
185185

186186
[android]
187187
; The icon to use for identifying your app on Android.
188-
icon = "src/icon.png"
188+
icon = "icons/icon.png"
189+
icon_sizes = "512@1x"
189190

190191
; Extensions of files that will not be stored compressed in the APK.
191192
aapt_no_compress = ""
@@ -227,6 +228,8 @@ simulator_device = "iPhone 14"
227228
; default value: false
228229
; nonexempt_encryption = false
229230

231+
icon = "icons/icon.png"
232+
icon_sizes = "20@1x 20@2x 20@3x"
230233

231234
[linux]
232235
; Helps to make your app searchable in Linux desktop environments.
@@ -236,7 +239,7 @@ categories = "Developer Tools"
236239
; cmd = "node backend/index.js"
237240

238241
; The icon to use for identifying your app in Linux desktop environments.
239-
icon = "src/icon.png"
242+
icon = "icons/icon.png"
240243

241244

242245
[mac]
@@ -248,7 +251,8 @@ category = ""
248251
; cmd = "node backend/index.js"
249252

250253
; The icon to use for identifying your app on MacOS.
251-
icon = "src/icon.png"
254+
icon = "icons/icon.png"
255+
icon_sizes = "16@1x 32@1x 128@1x"
252256

253257
; TODO Signing guide: https://socketsupply.co/guides/#code-signing-certificates
254258
codesign_identity = ""
@@ -276,10 +280,11 @@ headers = native-module1.hh
276280
; cmd = "node backend/index.js"
277281

278282
; The icon to use for identifying your app on Windows.
279-
icon = "src/icon.ico"
283+
icon = "icons/icon.ico"
284+
icon_sizes = "16@1x 32@1x 128@1x"
280285

281286
; The icon to use for identifying your app on Windows, relative to copied path resources
282-
logo = "icon.ico"
287+
logo = "icons/icon.ico"
283288

284289
; A relative path to the pfx file used for signing.
285290
; pfx = "certs/cert.pfx"
@@ -340,7 +345,7 @@ width = 50%
340345
[tray]
341346
; The icon to be displayed in the operating system tray. On Windows, you may need to use ICO format.
342347
; defalut value = ""
343-
; icon = "icon.png"
348+
; icon = "icons/icon.png"
344349

345350

346351
[headless]

0 commit comments

Comments
 (0)