iconpeek 1.0.1 → 1.1.0
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 -21
- package/README.md +136 -77
- package/assets/iconpeek.png +0 -0
- package/assets/logos/iconpeek.png +0 -0
- package/assets/mockups/mockup-apple-iphone-18-pro-max-2026-transparent.webp +0 -0
- package/assets/mockups/mockup-samsung-galaxy-s24-2024-transparent.webp +0 -0
- package/assets/showcase/dual-mockup-dark.png +0 -0
- package/assets/showcase/dual-mockup-light.png +0 -0
- package/assets/showcase/size-matrix-preview.png +0 -0
- package/assets/showcase/splash-screen-preview.png +0 -0
- package/dist/bundle.css +2 -0
- package/dist/bundle.js +120 -0
- package/generate_icons.py +233 -218
- package/index.html +33 -0
- package/package.json +47 -24
- package/server.js +666 -1453
- package/style.css +2 -0
package/server.js
CHANGED
|
@@ -1,1454 +1,667 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const http = require('http');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
const { exec } = require('child_process');
|
|
7
|
-
|
|
8
|
-
const DEFAULT_PORT = 4200;
|
|
9
|
-
const PLACEHOLDER_ICON = path.join(__dirname, 'assets', 'placeholder-icon.png');
|
|
10
|
-
const PNG_SIGNATURE = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
]
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
'
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
return
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
return
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
.
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
.
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
.
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
.
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
.
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
gap: 0.75rem;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
.spec-pill {
|
|
671
|
-
padding: 0.75rem 0.85rem;
|
|
672
|
-
border-radius: 12px;
|
|
673
|
-
background: var(--surface);
|
|
674
|
-
border: 1px solid var(--border);
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
.spec-pill strong {
|
|
678
|
-
display: block;
|
|
679
|
-
font-size: 0.68rem;
|
|
680
|
-
text-transform: uppercase;
|
|
681
|
-
letter-spacing: 0.07em;
|
|
682
|
-
color: var(--muted);
|
|
683
|
-
margin-bottom: 0.28rem;
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
.spec-pill span {
|
|
687
|
-
font-size: 0.93rem;
|
|
688
|
-
font-weight: 600;
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
.size-row {
|
|
692
|
-
display: flex;
|
|
693
|
-
justify-content: center;
|
|
694
|
-
gap: 1.2rem;
|
|
695
|
-
flex-wrap: wrap;
|
|
696
|
-
padding: 1rem;
|
|
697
|
-
border-radius: 14px;
|
|
698
|
-
background: var(--surface);
|
|
699
|
-
border: 1px solid rgba(46,46,53,0.9);
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
.size-item {
|
|
703
|
-
display: flex;
|
|
704
|
-
flex-direction: column;
|
|
705
|
-
align-items: center;
|
|
706
|
-
gap: 0.45rem;
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
.size-label {
|
|
710
|
-
color: var(--muted);
|
|
711
|
-
font-size: 0.73rem;
|
|
712
|
-
line-height: 1.3;
|
|
713
|
-
text-align: center;
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
.mini-mask, .launcher-mask {
|
|
717
|
-
position: relative;
|
|
718
|
-
overflow: hidden;
|
|
719
|
-
background: #fff;
|
|
720
|
-
box-shadow: 0 10px 20px rgba(0,0,0,0.35);
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
.mini-bg, .mini-fg, .launcher-bg, .launcher-fg {
|
|
724
|
-
position: absolute;
|
|
725
|
-
background-position: center;
|
|
726
|
-
background-repeat: no-repeat;
|
|
727
|
-
background-size: contain;
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
.ios-preview {
|
|
731
|
-
display: flex;
|
|
732
|
-
flex-direction: column;
|
|
733
|
-
align-items: center;
|
|
734
|
-
gap: 1rem;
|
|
735
|
-
padding: 1rem;
|
|
736
|
-
border-radius: 14px;
|
|
737
|
-
background: linear-gradient(180deg, rgba(24,24,27,0.95), rgba(12,12,14,0.96));
|
|
738
|
-
border: 1px solid rgba(46,46,53,0.9);
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
.ios-mask {
|
|
742
|
-
width: 216px;
|
|
743
|
-
height: 216px;
|
|
744
|
-
border-radius: 47px;
|
|
745
|
-
overflow: hidden;
|
|
746
|
-
background: #fff;
|
|
747
|
-
box-shadow: 0 16px 44px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.04);
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
.ios-mask img {
|
|
751
|
-
width: 100%;
|
|
752
|
-
height: 100%;
|
|
753
|
-
object-fit: cover;
|
|
754
|
-
display: block;
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
.context {
|
|
758
|
-
display: grid;
|
|
759
|
-
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
760
|
-
gap: 1.5rem;
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
.screen {
|
|
764
|
-
border-radius: 16px;
|
|
765
|
-
padding: 1rem;
|
|
766
|
-
overflow: hidden;
|
|
767
|
-
position: relative;
|
|
768
|
-
min-height: 250px;
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
.android-screen {
|
|
772
|
-
background: linear-gradient(155deg, #231942, #1d3557 55%, #0b1020);
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
.ios-screen {
|
|
776
|
-
background: linear-gradient(160deg, #11324d, #0b1c2d 55%, #191936);
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
.screen::before {
|
|
780
|
-
content: '';
|
|
781
|
-
position: absolute;
|
|
782
|
-
inset: 0;
|
|
783
|
-
background:
|
|
784
|
-
radial-gradient(circle at 20% 10%, rgba(255,255,255,0.06), transparent 18%),
|
|
785
|
-
radial-gradient(circle at 80% 40%, rgba(255,255,255,0.06), transparent 20%);
|
|
786
|
-
pointer-events: none;
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
.screen-grid {
|
|
790
|
-
position: relative;
|
|
791
|
-
display: grid;
|
|
792
|
-
grid-template-columns: repeat(4, 1fr);
|
|
793
|
-
gap: 0.8rem;
|
|
794
|
-
align-items: start;
|
|
795
|
-
justify-items: center;
|
|
796
|
-
z-index: 1;
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
.app-chip {
|
|
800
|
-
display: flex;
|
|
801
|
-
flex-direction: column;
|
|
802
|
-
align-items: center;
|
|
803
|
-
gap: 0.4rem;
|
|
804
|
-
width: 100%;
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
.app-label {
|
|
808
|
-
width: 100%;
|
|
809
|
-
text-align: center;
|
|
810
|
-
color: rgba(255,255,255,0.92);
|
|
811
|
-
text-shadow: 0 1px 3px rgba(0,0,0,0.6);
|
|
812
|
-
font-size: 0.7rem;
|
|
813
|
-
overflow: hidden;
|
|
814
|
-
text-overflow: ellipsis;
|
|
815
|
-
white-space: nowrap;
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
.placeholder {
|
|
819
|
-
width: 96px;
|
|
820
|
-
height: 96px;
|
|
821
|
-
border-radius: 24px;
|
|
822
|
-
display: flex;
|
|
823
|
-
align-items: center;
|
|
824
|
-
justify-content: center;
|
|
825
|
-
font-size: 1.7rem;
|
|
826
|
-
box-shadow: 0 10px 20px rgba(0,0,0,0.35);
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
.ios-placeholder {
|
|
830
|
-
border-radius: 21px;
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
.ring {
|
|
834
|
-
box-shadow: 0 0 0 3px rgba(249,115,22,0.95), 0 10px 20px rgba(0,0,0,0.35);
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
.splash-pair {
|
|
838
|
-
display: flex;
|
|
839
|
-
justify-content: center;
|
|
840
|
-
gap: 1.4rem;
|
|
841
|
-
flex-wrap: wrap;
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
.phone {
|
|
845
|
-
width: 200px;
|
|
846
|
-
height: 420px;
|
|
847
|
-
border-radius: 34px;
|
|
848
|
-
border: 7px solid #232329;
|
|
849
|
-
overflow: hidden;
|
|
850
|
-
position: relative;
|
|
851
|
-
box-shadow: 0 22px 60px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(255,255,255,0.04);
|
|
852
|
-
background: #000;
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
.notch {
|
|
856
|
-
position: absolute;
|
|
857
|
-
top: 0;
|
|
858
|
-
left: 50%;
|
|
859
|
-
transform: translateX(-50%);
|
|
860
|
-
width: 82px;
|
|
861
|
-
height: 14px;
|
|
862
|
-
border-bottom-left-radius: 10px;
|
|
863
|
-
border-bottom-right-radius: 10px;
|
|
864
|
-
background: #18181b;
|
|
865
|
-
z-index: 3;
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
.statusbar {
|
|
869
|
-
position: absolute;
|
|
870
|
-
top: 0;
|
|
871
|
-
left: 0;
|
|
872
|
-
right: 0;
|
|
873
|
-
height: 26px;
|
|
874
|
-
display: flex;
|
|
875
|
-
justify-content: space-between;
|
|
876
|
-
align-items: flex-end;
|
|
877
|
-
padding: 0 14px 4px;
|
|
878
|
-
font-size: 0.62rem;
|
|
879
|
-
font-weight: 700;
|
|
880
|
-
z-index: 4;
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
.splash-surface {
|
|
884
|
-
position: absolute;
|
|
885
|
-
inset: 0;
|
|
886
|
-
display: flex;
|
|
887
|
-
align-items: center;
|
|
888
|
-
justify-content: center;
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
.splash-image {
|
|
892
|
-
width: 38%;
|
|
893
|
-
height: auto;
|
|
894
|
-
object-fit: contain;
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
.theme-chip {
|
|
898
|
-
position: absolute;
|
|
899
|
-
bottom: 15px;
|
|
900
|
-
left: 50%;
|
|
901
|
-
transform: translateX(-50%);
|
|
902
|
-
padding: 0.28rem 0.7rem;
|
|
903
|
-
border-radius: 999px;
|
|
904
|
-
font-size: 0.64rem;
|
|
905
|
-
letter-spacing: 0.08em;
|
|
906
|
-
text-transform: uppercase;
|
|
907
|
-
font-weight: 700;
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
.theme-chip.light {
|
|
911
|
-
color: rgba(0,0,0,0.52);
|
|
912
|
-
background: rgba(0,0,0,0.08);
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
.theme-chip.dark {
|
|
916
|
-
color: rgba(255,255,255,0.72);
|
|
917
|
-
background: rgba(255,255,255,0.08);
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
.footnote {
|
|
921
|
-
color: var(--muted);
|
|
922
|
-
font-size: 0.78rem;
|
|
923
|
-
line-height: 1.5;
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
@media (max-width: 900px) {
|
|
927
|
-
.summary, .grid, .context {
|
|
928
|
-
grid-template-columns: 1fr;
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
.header {
|
|
932
|
-
padding: 1rem;
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
.page {
|
|
936
|
-
padding: 1rem;
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
.spec-grid {
|
|
940
|
-
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
@media (max-width: 640px) {
|
|
945
|
-
.spec-grid {
|
|
946
|
-
grid-template-columns: 1fr;
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
.screen-grid {
|
|
950
|
-
grid-template-columns: repeat(2, 1fr);
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
</style>
|
|
954
|
-
</head>
|
|
955
|
-
<body>
|
|
956
|
-
<header class="header">
|
|
957
|
-
<div class="brand">
|
|
958
|
-
<div class="brand-mark"></div>
|
|
959
|
-
<div>
|
|
960
|
-
<h1 class="brand-title">iconpeek</h1>
|
|
961
|
-
<p class="brand-copy">Local Expo icon and splash previewer</p>
|
|
962
|
-
</div>
|
|
963
|
-
</div>
|
|
964
|
-
<div class="header-pill">Zero Dependencies</div>
|
|
965
|
-
</header>
|
|
966
|
-
|
|
967
|
-
<main class="page">
|
|
968
|
-
<section class="summary">
|
|
969
|
-
<div class="hero">
|
|
970
|
-
<h2>Preview Android adaptive icons, iOS icons, and splash screens without a native build.</h2>
|
|
971
|
-
<p>iconpeek reads your Expo config directly, mirrors Android adaptive icon canvas and safe-zone math, and gives you instant browser feedback while you tweak assets in your project.</p>
|
|
972
|
-
</div>
|
|
973
|
-
<aside class="meta-card">
|
|
974
|
-
<div>
|
|
975
|
-
<div class="meta-label">Project Root</div>
|
|
976
|
-
<div class="meta-value">${escapeHtml(state.projectRoot)}</div>
|
|
977
|
-
</div>
|
|
978
|
-
<div>
|
|
979
|
-
<div class="meta-label">Config Source</div>
|
|
980
|
-
<div class="meta-value">${escapeHtml(state.configName || 'Not found')}</div>
|
|
981
|
-
</div>
|
|
982
|
-
<div>
|
|
983
|
-
<div class="meta-label">App Label</div>
|
|
984
|
-
<div class="meta-value" id="appLabelMeta">${escapeHtml(state.expo.name)}</div>
|
|
985
|
-
</div>
|
|
986
|
-
</aside>
|
|
987
|
-
</section>
|
|
988
|
-
|
|
989
|
-
<section class="warning-banner" id="warningBanner"></section>
|
|
990
|
-
|
|
991
|
-
<section class="grid">
|
|
992
|
-
<article class="card">
|
|
993
|
-
<div class="card-head">
|
|
994
|
-
<h3 class="card-title">Android Adaptive Icon Simulator</h3>
|
|
995
|
-
<div class="controls">
|
|
996
|
-
<div class="segment" id="shapeControl">
|
|
997
|
-
<button type="button" data-shape="squircle" class="active">Squircle</button>
|
|
998
|
-
<button type="button" data-shape="rounded">Rounded</button>
|
|
999
|
-
<button type="button" data-shape="circle">Circle</button>
|
|
1000
|
-
<button type="button" data-shape="square">Square</button>
|
|
1001
|
-
</div>
|
|
1002
|
-
<label class="toggle">
|
|
1003
|
-
<input type="checkbox" id="safeZoneToggle">
|
|
1004
|
-
Show safe zone
|
|
1005
|
-
</label>
|
|
1006
|
-
</div>
|
|
1007
|
-
</div>
|
|
1008
|
-
|
|
1009
|
-
<div class="stage">
|
|
1010
|
-
<div class="adaptive-wrap">
|
|
1011
|
-
<div class="adaptive-mask mask-squircle" id="adaptiveMask">
|
|
1012
|
-
<div class="adaptive-layer adaptive-bg" id="adaptiveBg"></div>
|
|
1013
|
-
<div class="adaptive-layer adaptive-fg" id="adaptiveFg"></div>
|
|
1014
|
-
<div class="safe-zone" id="safeZone">
|
|
1015
|
-
<span>66dp Safe Zone</span>
|
|
1016
|
-
</div>
|
|
1017
|
-
</div>
|
|
1018
|
-
<div class="shape-caption" id="shapeCaption">Android 12+ default squircle mask</div>
|
|
1019
|
-
</div>
|
|
1020
|
-
</div>
|
|
1021
|
-
|
|
1022
|
-
<div class="spec-grid">
|
|
1023
|
-
<div class="spec-pill"><strong>Layer Canvas</strong><span>108dp / 324px</span></div>
|
|
1024
|
-
<div class="spec-pill"><strong>Visible Mask</strong><span>72dp / 216px</span></div>
|
|
1025
|
-
<div class="spec-pill"><strong>Safe Zone</strong><span>66dp / 198px</span></div>
|
|
1026
|
-
<div class="spec-pill"><strong>BG Color</strong><span id="bgColorValue">#FFFFFF</span></div>
|
|
1027
|
-
<div class="spec-pill"><strong>Crop Margin</strong><span>18dp / 54px</span></div>
|
|
1028
|
-
<div class="spec-pill"><strong>Preview Scale</strong><span>3x</span></div>
|
|
1029
|
-
</div>
|
|
1030
|
-
|
|
1031
|
-
<div class="size-row" id="androidSizeRow"></div>
|
|
1032
|
-
</article>
|
|
1033
|
-
|
|
1034
|
-
<article class="card">
|
|
1035
|
-
<div class="card-head">
|
|
1036
|
-
<h3 class="card-title">iOS Icon Preview</h3>
|
|
1037
|
-
<div class="header-pill" style="padding:0.35rem 0.65rem;font-size:0.66rem;">Flat Asset</div>
|
|
1038
|
-
</div>
|
|
1039
|
-
<div class="ios-preview">
|
|
1040
|
-
<div class="ios-mask">
|
|
1041
|
-
<img src="/assets/ios-icon" alt="iOS app icon">
|
|
1042
|
-
</div>
|
|
1043
|
-
<div class="hint">iOS app icons should be opaque; this preview approximates the system mask so you can judge edge composition quickly.</div>
|
|
1044
|
-
</div>
|
|
1045
|
-
<div class="size-row" id="iosSizeRow"></div>
|
|
1046
|
-
</article>
|
|
1047
|
-
</section>
|
|
1048
|
-
|
|
1049
|
-
<section class="context">
|
|
1050
|
-
<article class="card">
|
|
1051
|
-
<div class="card-head">
|
|
1052
|
-
<h3 class="card-title">Android Launcher Context</h3>
|
|
1053
|
-
<div class="hint">96x96 highlight ring in a mock launcher grid</div>
|
|
1054
|
-
</div>
|
|
1055
|
-
<div class="screen android-screen">
|
|
1056
|
-
<div class="screen-grid">
|
|
1057
|
-
<div class="app-chip">
|
|
1058
|
-
<div class="placeholder" style="background:linear-gradient(135deg,#2563eb,#38bdf8)">MSG</div>
|
|
1059
|
-
<div class="app-label">Messages</div>
|
|
1060
|
-
</div>
|
|
1061
|
-
<div class="app-chip">
|
|
1062
|
-
<div class="launcher-mask ring mask-squircle" id="launcherMask" style="width:96px;height:96px;">
|
|
1063
|
-
<div class="launcher-bg" id="launcherBg"></div>
|
|
1064
|
-
<div class="launcher-fg" id="launcherFg"></div>
|
|
1065
|
-
</div>
|
|
1066
|
-
<div class="app-label" id="androidAppLabel">${escapeHtml(state.expo.name)}</div>
|
|
1067
|
-
</div>
|
|
1068
|
-
<div class="app-chip">
|
|
1069
|
-
<div class="placeholder" style="background:linear-gradient(135deg,#16a34a,#4ade80)">IMG</div>
|
|
1070
|
-
<div class="app-label">Gallery</div>
|
|
1071
|
-
</div>
|
|
1072
|
-
<div class="app-chip">
|
|
1073
|
-
<div class="placeholder" style="background:linear-gradient(135deg,#9333ea,#c084fc)">AUD</div>
|
|
1074
|
-
<div class="app-label">Music</div>
|
|
1075
|
-
</div>
|
|
1076
|
-
</div>
|
|
1077
|
-
</div>
|
|
1078
|
-
</article>
|
|
1079
|
-
|
|
1080
|
-
<article class="card">
|
|
1081
|
-
<div class="card-head">
|
|
1082
|
-
<h3 class="card-title">iOS Homescreen Context</h3>
|
|
1083
|
-
<div class="hint">96x96 highlight ring in a mock homescreen grid</div>
|
|
1084
|
-
</div>
|
|
1085
|
-
<div class="screen ios-screen">
|
|
1086
|
-
<div class="screen-grid">
|
|
1087
|
-
<div class="app-chip">
|
|
1088
|
-
<div class="placeholder ios-placeholder" style="background:linear-gradient(135deg,#0ea5e9,#67e8f9)">TEL</div>
|
|
1089
|
-
<div class="app-label">Phone</div>
|
|
1090
|
-
</div>
|
|
1091
|
-
<div class="app-chip">
|
|
1092
|
-
<div class="ios-placeholder ring" style="width:96px;height:96px;border-radius:21px;overflow:hidden;background:#fff;">
|
|
1093
|
-
<img src="/assets/ios-icon" alt="iOS homescreen icon" style="width:100%;height:100%;object-fit:cover;display:block;">
|
|
1094
|
-
</div>
|
|
1095
|
-
<div class="app-label" id="iosAppLabel">${escapeHtml(state.expo.name)}</div>
|
|
1096
|
-
</div>
|
|
1097
|
-
<div class="app-chip">
|
|
1098
|
-
<div class="placeholder ios-placeholder" style="background:linear-gradient(135deg,#f59e0b,#fcd34d)">SET</div>
|
|
1099
|
-
<div class="app-label">Settings</div>
|
|
1100
|
-
</div>
|
|
1101
|
-
<div class="app-chip">
|
|
1102
|
-
<div class="placeholder ios-placeholder" style="background:linear-gradient(135deg,#dc2626,#fb7185)">HLT</div>
|
|
1103
|
-
<div class="app-label">Health</div>
|
|
1104
|
-
</div>
|
|
1105
|
-
</div>
|
|
1106
|
-
</div>
|
|
1107
|
-
</article>
|
|
1108
|
-
</section>
|
|
1109
|
-
|
|
1110
|
-
<section class="card">
|
|
1111
|
-
<div class="card-head">
|
|
1112
|
-
<h3 class="card-title">Splash Screen Preview</h3>
|
|
1113
|
-
<div class="hint">Light and dark frames with auto-inverted status bar text based on background luminance</div>
|
|
1114
|
-
</div>
|
|
1115
|
-
<div class="splash-pair">
|
|
1116
|
-
<div class="phone">
|
|
1117
|
-
<div class="notch"></div>
|
|
1118
|
-
<div class="statusbar" id="statusbarLight">
|
|
1119
|
-
<span>9:41</span>
|
|
1120
|
-
<span>||| 100%</span>
|
|
1121
|
-
</div>
|
|
1122
|
-
<div class="splash-surface" id="splashLightSurface">
|
|
1123
|
-
<img class="splash-image" src="/assets/splash" alt="Light splash preview">
|
|
1124
|
-
<div class="theme-chip light">Light Mode</div>
|
|
1125
|
-
</div>
|
|
1126
|
-
</div>
|
|
1127
|
-
<div class="phone">
|
|
1128
|
-
<div class="notch"></div>
|
|
1129
|
-
<div class="statusbar" id="statusbarDark">
|
|
1130
|
-
<span>9:41</span>
|
|
1131
|
-
<span>||| 100%</span>
|
|
1132
|
-
</div>
|
|
1133
|
-
<div class="splash-surface" id="splashDarkSurface">
|
|
1134
|
-
<img class="splash-image" src="/assets/splash-dark" alt="Dark splash preview">
|
|
1135
|
-
<div class="theme-chip dark">Dark Mode</div>
|
|
1136
|
-
</div>
|
|
1137
|
-
</div>
|
|
1138
|
-
</div>
|
|
1139
|
-
<div class="footnote" id="splashFootnote">Splash image width defaults to 38% of the frame width unless imageWidth is set in Expo config.</div>
|
|
1140
|
-
</section>
|
|
1141
|
-
</main>
|
|
1142
|
-
|
|
1143
|
-
<script>
|
|
1144
|
-
const STATE = ${payload};
|
|
1145
|
-
const shapeMap = {
|
|
1146
|
-
squircle: { className: 'mask-squircle', caption: 'Android 12+ default squircle mask' },
|
|
1147
|
-
rounded: { className: 'mask-rounded', caption: 'Rounded rectangle mask' },
|
|
1148
|
-
circle: { className: 'mask-circle', caption: 'Circle mask' },
|
|
1149
|
-
square: { className: 'mask-square', caption: 'Square mask' }
|
|
1150
|
-
};
|
|
1151
|
-
const maskClasses = Object.values(shapeMap).map((entry) => entry.className);
|
|
1152
|
-
const androidSizes = [
|
|
1153
|
-
{ px: 36, label: 'Status bar', dp: '24dp' },
|
|
1154
|
-
{ px: 54, label: 'Notification', dp: '36dp' },
|
|
1155
|
-
{ px: 72, label: 'Launcher', dp: '48dp' },
|
|
1156
|
-
{ px: 96, label: 'App drawer', dp: '64dp' }
|
|
1157
|
-
];
|
|
1158
|
-
const iosSizes = [
|
|
1159
|
-
{ px: 40, label: 'Settings', pt: '29pt' },
|
|
1160
|
-
{ px: 57, label: 'Spotlight', pt: '40pt' },
|
|
1161
|
-
{ px: 86, label: 'Home Screen', pt: '60pt' },
|
|
1162
|
-
{ px: 128, label: 'App Store display', pt: '1024px source' }
|
|
1163
|
-
];
|
|
1164
|
-
|
|
1165
|
-
function isDarkColor(hex) {
|
|
1166
|
-
const normalized = (hex || '#FFFFFF').replace('#', '');
|
|
1167
|
-
const expanded = normalized.length === 3
|
|
1168
|
-
? normalized.split('').map((char) => char + char).join('')
|
|
1169
|
-
: normalized;
|
|
1170
|
-
const r = parseInt(expanded.slice(0, 2), 16);
|
|
1171
|
-
const g = parseInt(expanded.slice(2, 4), 16);
|
|
1172
|
-
const b = parseInt(expanded.slice(4, 6), 16);
|
|
1173
|
-
return (0.299 * r + 0.587 * g + 0.114 * b) < 128;
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
function buildAndroidSizeRow() {
|
|
1177
|
-
const container = document.getElementById('androidSizeRow');
|
|
1178
|
-
container.innerHTML = '';
|
|
1179
|
-
const bgColor = STATE.expo.adaptiveBackgroundColor;
|
|
1180
|
-
androidSizes.forEach((item) => {
|
|
1181
|
-
const mask = document.createElement('div');
|
|
1182
|
-
mask.className = 'mini-mask mask-squircle';
|
|
1183
|
-
mask.style.width = item.px + 'px';
|
|
1184
|
-
mask.style.height = item.px + 'px';
|
|
1185
|
-
|
|
1186
|
-
const layerSize = item.px * (108 / 72);
|
|
1187
|
-
const offset = (layerSize - item.px) / 2;
|
|
1188
|
-
|
|
1189
|
-
const bg = document.createElement('div');
|
|
1190
|
-
bg.className = 'mini-bg';
|
|
1191
|
-
bg.style.width = layerSize + 'px';
|
|
1192
|
-
bg.style.height = layerSize + 'px';
|
|
1193
|
-
bg.style.left = (-offset) + 'px';
|
|
1194
|
-
bg.style.top = (-offset) + 'px';
|
|
1195
|
-
bg.style.backgroundColor = bgColor;
|
|
1196
|
-
|
|
1197
|
-
const fg = document.createElement('div');
|
|
1198
|
-
fg.className = 'mini-fg';
|
|
1199
|
-
fg.style.width = layerSize + 'px';
|
|
1200
|
-
fg.style.height = layerSize + 'px';
|
|
1201
|
-
fg.style.left = (-offset) + 'px';
|
|
1202
|
-
fg.style.top = (-offset) + 'px';
|
|
1203
|
-
fg.style.backgroundImage = "url('/assets/icon')";
|
|
1204
|
-
|
|
1205
|
-
mask.appendChild(bg);
|
|
1206
|
-
mask.appendChild(fg);
|
|
1207
|
-
|
|
1208
|
-
const itemNode = document.createElement('div');
|
|
1209
|
-
itemNode.className = 'size-item';
|
|
1210
|
-
itemNode.appendChild(mask);
|
|
1211
|
-
|
|
1212
|
-
const label = document.createElement('div');
|
|
1213
|
-
label.className = 'size-label';
|
|
1214
|
-
label.innerHTML = item.px + '×' + item.px + 'px<br>' + item.dp + ' ' + item.label;
|
|
1215
|
-
itemNode.appendChild(label);
|
|
1216
|
-
|
|
1217
|
-
container.appendChild(itemNode);
|
|
1218
|
-
});
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1221
|
-
function buildIosSizeRow() {
|
|
1222
|
-
const container = document.getElementById('iosSizeRow');
|
|
1223
|
-
container.innerHTML = '';
|
|
1224
|
-
iosSizes.forEach((item) => {
|
|
1225
|
-
const itemNode = document.createElement('div');
|
|
1226
|
-
itemNode.className = 'size-item';
|
|
1227
|
-
|
|
1228
|
-
const mask = document.createElement('div');
|
|
1229
|
-
mask.style.width = item.px + 'px';
|
|
1230
|
-
mask.style.height = item.px + 'px';
|
|
1231
|
-
mask.style.borderRadius = Math.round(item.px * 0.2237) + 'px';
|
|
1232
|
-
mask.style.overflow = 'hidden';
|
|
1233
|
-
mask.style.background = '#fff';
|
|
1234
|
-
mask.style.boxShadow = '0 10px 20px rgba(0,0,0,0.35)';
|
|
1235
|
-
|
|
1236
|
-
const img = document.createElement('img');
|
|
1237
|
-
img.src = '/assets/ios-icon';
|
|
1238
|
-
img.alt = item.label;
|
|
1239
|
-
img.style.width = '100%';
|
|
1240
|
-
img.style.height = '100%';
|
|
1241
|
-
img.style.objectFit = 'cover';
|
|
1242
|
-
img.style.display = 'block';
|
|
1243
|
-
mask.appendChild(img);
|
|
1244
|
-
|
|
1245
|
-
const label = document.createElement('div');
|
|
1246
|
-
label.className = 'size-label';
|
|
1247
|
-
label.innerHTML = item.px + '×' + item.px + 'px<br>' + item.pt;
|
|
1248
|
-
|
|
1249
|
-
itemNode.appendChild(mask);
|
|
1250
|
-
itemNode.appendChild(label);
|
|
1251
|
-
container.appendChild(itemNode);
|
|
1252
|
-
});
|
|
1253
|
-
}
|
|
1254
|
-
|
|
1255
|
-
function setShape(shape) {
|
|
1256
|
-
const mapping = shapeMap[shape] || shapeMap.squircle;
|
|
1257
|
-
const adaptiveMask = document.getElementById('adaptiveMask');
|
|
1258
|
-
const launcherMask = document.getElementById('launcherMask');
|
|
1259
|
-
|
|
1260
|
-
[adaptiveMask, launcherMask].forEach((element) => {
|
|
1261
|
-
maskClasses.forEach((className) => element.classList.remove(className));
|
|
1262
|
-
element.classList.add(mapping.className);
|
|
1263
|
-
});
|
|
1264
|
-
|
|
1265
|
-
document.getElementById('shapeCaption').textContent = mapping.caption;
|
|
1266
|
-
document.querySelectorAll('#shapeControl button').forEach((button) => {
|
|
1267
|
-
button.classList.toggle('active', button.dataset.shape === shape);
|
|
1268
|
-
});
|
|
1269
|
-
}
|
|
1270
|
-
|
|
1271
|
-
function applyState() {
|
|
1272
|
-
const warnings = STATE.warnings || [];
|
|
1273
|
-
const warningBanner = document.getElementById('warningBanner');
|
|
1274
|
-
if (warnings.length) {
|
|
1275
|
-
warningBanner.style.display = 'block';
|
|
1276
|
-
warningBanner.innerHTML = warnings.map((warning) => '<div>' + warning + '</div>').join('');
|
|
1277
|
-
}
|
|
1278
|
-
|
|
1279
|
-
document.getElementById('adaptiveBg').style.backgroundColor = STATE.expo.adaptiveBackgroundColor;
|
|
1280
|
-
document.getElementById('launcherBg').style.backgroundColor = STATE.expo.adaptiveBackgroundColor;
|
|
1281
|
-
document.getElementById('bgColorValue').textContent = STATE.expo.adaptiveBackgroundColor;
|
|
1282
|
-
|
|
1283
|
-
document.getElementById('adaptiveFg').style.backgroundImage = "url('/assets/icon')";
|
|
1284
|
-
document.getElementById('launcherFg').style.backgroundImage = "url('/assets/icon')";
|
|
1285
|
-
|
|
1286
|
-
document.getElementById('splashLightSurface').style.backgroundColor = STATE.expo.splashBackgroundColor;
|
|
1287
|
-
document.getElementById('splashDarkSurface').style.backgroundColor = STATE.expo.splashDarkBackgroundColor;
|
|
1288
|
-
document.getElementById('statusbarLight').style.color = isDarkColor(STATE.expo.splashBackgroundColor) ? '#FFFFFF' : '#000000';
|
|
1289
|
-
document.getElementById('statusbarDark').style.color = isDarkColor(STATE.expo.splashDarkBackgroundColor) ? '#FFFFFF' : '#000000';
|
|
1290
|
-
if (STATE.expo.splashImageWidth) {
|
|
1291
|
-
document.querySelectorAll('.splash-image').forEach((image) => {
|
|
1292
|
-
image.style.width = Math.max(24, Math.min(70, (STATE.expo.splashImageWidth / 200) * 100)) + '%';
|
|
1293
|
-
});
|
|
1294
|
-
document.getElementById('splashFootnote').textContent = 'Splash image width reflects Expo imageWidth: ' + STATE.expo.splashImageWidth + 'px.';
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
buildAndroidSizeRow();
|
|
1298
|
-
buildIosSizeRow();
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
document.getElementById('shapeControl').addEventListener('click', (event) => {
|
|
1302
|
-
if (event.target.tagName === 'BUTTON') {
|
|
1303
|
-
setShape(event.target.dataset.shape);
|
|
1304
|
-
}
|
|
1305
|
-
});
|
|
1306
|
-
|
|
1307
|
-
document.getElementById('safeZoneToggle').addEventListener('change', (event) => {
|
|
1308
|
-
document.getElementById('safeZone').style.display = event.target.checked ? 'block' : 'none';
|
|
1309
|
-
});
|
|
1310
|
-
|
|
1311
|
-
const adaptiveMask = document.getElementById('adaptiveMask');
|
|
1312
|
-
adaptiveMask.addEventListener('mousemove', (event) => {
|
|
1313
|
-
const rect = adaptiveMask.getBoundingClientRect();
|
|
1314
|
-
const x = event.clientX - rect.left;
|
|
1315
|
-
const y = event.clientY - rect.top;
|
|
1316
|
-
const dx = ((x / rect.width) - 0.5) * 32;
|
|
1317
|
-
const dy = ((y / rect.height) - 0.5) * 32;
|
|
1318
|
-
document.getElementById('adaptiveFg').style.transform = 'translate3d(' + dx.toFixed(2) + 'px,' + dy.toFixed(2) + 'px,0)';
|
|
1319
|
-
});
|
|
1320
|
-
adaptiveMask.addEventListener('mouseleave', () => {
|
|
1321
|
-
document.getElementById('adaptiveFg').style.transform = 'translate3d(0,0,0)';
|
|
1322
|
-
});
|
|
1323
|
-
|
|
1324
|
-
const launcherBg = document.getElementById('launcherBg');
|
|
1325
|
-
const launcherFg = document.getElementById('launcherFg');
|
|
1326
|
-
launcherBg.style.width = '144px';
|
|
1327
|
-
launcherBg.style.height = '144px';
|
|
1328
|
-
launcherBg.style.left = '-24px';
|
|
1329
|
-
launcherBg.style.top = '-24px';
|
|
1330
|
-
launcherFg.style.width = '144px';
|
|
1331
|
-
launcherFg.style.height = '144px';
|
|
1332
|
-
launcherFg.style.left = '-24px';
|
|
1333
|
-
launcherFg.style.top = '-24px';
|
|
1334
|
-
|
|
1335
|
-
setShape('squircle');
|
|
1336
|
-
applyState();
|
|
1337
|
-
</script>
|
|
1338
|
-
</body>
|
|
1339
|
-
</html>`;
|
|
1340
|
-
}
|
|
1341
|
-
|
|
1342
|
-
function openBrowser(url) {
|
|
1343
|
-
const command =
|
|
1344
|
-
process.platform === 'darwin'
|
|
1345
|
-
? `open "${url}"`
|
|
1346
|
-
: process.platform === 'win32'
|
|
1347
|
-
? `start "" "${url}"`
|
|
1348
|
-
: `xdg-open "${url}"`;
|
|
1349
|
-
|
|
1350
|
-
exec(command, (error) => {
|
|
1351
|
-
if (error) {
|
|
1352
|
-
process.stdout.write(`Open manually: ${url}\n`);
|
|
1353
|
-
}
|
|
1354
|
-
});
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
function servePng(res, filePath) {
|
|
1358
|
-
fs.readFile(filePath, (error, data) => {
|
|
1359
|
-
if (error || !data || data.length < PNG_SIGNATURE.length || !data.subarray(0, PNG_SIGNATURE.length).equals(PNG_SIGNATURE)) {
|
|
1360
|
-
res.writeHead(404, {
|
|
1361
|
-
'Content-Type': 'text/plain; charset=utf-8',
|
|
1362
|
-
'Cache-Control': 'no-store',
|
|
1363
|
-
});
|
|
1364
|
-
res.end('Not Found');
|
|
1365
|
-
return;
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
|
-
res.writeHead(200, {
|
|
1369
|
-
'Content-Type': 'image/png',
|
|
1370
|
-
'Cache-Control': 'no-store',
|
|
1371
|
-
});
|
|
1372
|
-
res.end(data);
|
|
1373
|
-
});
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1376
|
-
function createServer(options) {
|
|
1377
|
-
return http.createServer((req, res) => {
|
|
1378
|
-
const requestUrl = new URL(req.url, 'http://localhost');
|
|
1379
|
-
const state = buildState(options.projectRoot);
|
|
1380
|
-
|
|
1381
|
-
if (requestUrl.pathname === '/') {
|
|
1382
|
-
const html = createHtml(state);
|
|
1383
|
-
res.writeHead(200, {
|
|
1384
|
-
'Content-Type': 'text/html; charset=utf-8',
|
|
1385
|
-
'Cache-Control': 'no-store',
|
|
1386
|
-
});
|
|
1387
|
-
res.end(html);
|
|
1388
|
-
return;
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
|
-
if (requestUrl.pathname === '/assets/icon') {
|
|
1392
|
-
servePng(res, state.assets.icon.path);
|
|
1393
|
-
return;
|
|
1394
|
-
}
|
|
1395
|
-
|
|
1396
|
-
if (requestUrl.pathname === '/assets/ios-icon') {
|
|
1397
|
-
servePng(res, state.assets.iosIcon.path);
|
|
1398
|
-
return;
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
if (requestUrl.pathname === '/assets/splash') {
|
|
1402
|
-
servePng(res, state.assets.splash.path);
|
|
1403
|
-
return;
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
if (requestUrl.pathname === '/assets/splash-dark') {
|
|
1407
|
-
servePng(res, state.assets.splashDark.path);
|
|
1408
|
-
return;
|
|
1409
|
-
}
|
|
1410
|
-
|
|
1411
|
-
res.writeHead(404, {
|
|
1412
|
-
'Content-Type': 'text/plain; charset=utf-8',
|
|
1413
|
-
'Cache-Control': 'no-store',
|
|
1414
|
-
});
|
|
1415
|
-
res.end('Not Found');
|
|
1416
|
-
});
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
|
-
function startServer(options) {
|
|
1420
|
-
const server = createServer(options);
|
|
1421
|
-
let currentPort = options.port;
|
|
1422
|
-
let browserOpened = false;
|
|
1423
|
-
|
|
1424
|
-
server.on('error', (error) => {
|
|
1425
|
-
if (error && error.code === 'EADDRINUSE') {
|
|
1426
|
-
currentPort += 1;
|
|
1427
|
-
server.listen(currentPort);
|
|
1428
|
-
return;
|
|
1429
|
-
}
|
|
1430
|
-
|
|
1431
|
-
process.stderr.write(`${error.message}\n`);
|
|
1432
|
-
process.exit(1);
|
|
1433
|
-
});
|
|
1434
|
-
|
|
1435
|
-
server.on('listening', () => {
|
|
1436
|
-
const url = `http://localhost:${currentPort}`;
|
|
1437
|
-
process.stdout.write(`iconpeek running at ${url}\n`);
|
|
1438
|
-
if (options.open && !browserOpened) {
|
|
1439
|
-
browserOpened = true;
|
|
1440
|
-
openBrowser(url);
|
|
1441
|
-
}
|
|
1442
|
-
});
|
|
1443
|
-
|
|
1444
|
-
server.listen(currentPort);
|
|
1445
|
-
}
|
|
1446
|
-
|
|
1447
|
-
try {
|
|
1448
|
-
const options = parseArgs(process.argv.slice(2));
|
|
1449
|
-
startServer(options);
|
|
1450
|
-
} catch (error) {
|
|
1451
|
-
process.stderr.write(`${error.message}\n\n`);
|
|
1452
|
-
printHelp();
|
|
1453
|
-
process.exit(1);
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const http = require('http');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const { exec } = require('child_process');
|
|
7
|
+
|
|
8
|
+
const DEFAULT_PORT = 4200;
|
|
9
|
+
const PLACEHOLDER_ICON = path.join(__dirname, 'assets', 'placeholder-icon.png');
|
|
10
|
+
const PNG_SIGNATURE = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
|
|
11
|
+
|
|
12
|
+
const sseClients = [];
|
|
13
|
+
const activeWatchers = new Map();
|
|
14
|
+
let notifyDebounceTimeout = null;
|
|
15
|
+
|
|
16
|
+
function notifyClients() {
|
|
17
|
+
clearTimeout(notifyDebounceTimeout);
|
|
18
|
+
notifyDebounceTimeout = setTimeout(() => {
|
|
19
|
+
for (const client of sseClients) {
|
|
20
|
+
client.write('data: reload\n\n');
|
|
21
|
+
}
|
|
22
|
+
}, 100);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function updateWatchers(projectRoot) {
|
|
26
|
+
const state = buildState(projectRoot);
|
|
27
|
+
const filesToWatch = [
|
|
28
|
+
path.join(__dirname, 'style.css'),
|
|
29
|
+
path.join(__dirname, 'index.html')
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
if (state.configPath) filesToWatch.push(state.configPath);
|
|
33
|
+
if (state.assets.icon.path && !state.assets.icon.placeholder) filesToWatch.push(state.assets.icon.path);
|
|
34
|
+
if (state.assets.iosIcon.path && !state.assets.iosIcon.placeholder) filesToWatch.push(state.assets.iosIcon.path);
|
|
35
|
+
if (state.assets.splash.path && !state.assets.splash.placeholder) filesToWatch.push(state.assets.splash.path);
|
|
36
|
+
if (state.assets.splashDark.path && !state.assets.splashDark.placeholder) filesToWatch.push(state.assets.splashDark.path);
|
|
37
|
+
|
|
38
|
+
// Clean up old watchers
|
|
39
|
+
for (const [filePath, watcher] of activeWatchers.entries()) {
|
|
40
|
+
if (!filesToWatch.includes(filePath)) {
|
|
41
|
+
watcher.close();
|
|
42
|
+
activeWatchers.delete(filePath);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Add new watchers
|
|
47
|
+
for (const filePath of filesToWatch) {
|
|
48
|
+
if (!activeWatchers.has(filePath)) {
|
|
49
|
+
try {
|
|
50
|
+
if (fs.existsSync(filePath)) {
|
|
51
|
+
const watcher = fs.watch(filePath, () => {
|
|
52
|
+
notifyClients();
|
|
53
|
+
// Re-evaluate files in case config path or assets changed
|
|
54
|
+
updateWatchers(projectRoot);
|
|
55
|
+
});
|
|
56
|
+
activeWatchers.set(filePath, watcher);
|
|
57
|
+
}
|
|
58
|
+
} catch (e) {
|
|
59
|
+
// File may be missing or locked
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
function parseArgs(argv) {
|
|
67
|
+
const options = {
|
|
68
|
+
projectRoot: process.cwd(),
|
|
69
|
+
port: DEFAULT_PORT,
|
|
70
|
+
open: true,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
74
|
+
const arg = argv[index];
|
|
75
|
+
if (arg === '--project') {
|
|
76
|
+
const value = argv[index + 1];
|
|
77
|
+
if (!value) {
|
|
78
|
+
throw new Error('Missing value for --project');
|
|
79
|
+
}
|
|
80
|
+
options.projectRoot = path.resolve(value);
|
|
81
|
+
index += 1;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (arg === '--port') {
|
|
86
|
+
const value = argv[index + 1];
|
|
87
|
+
const parsed = value && /^\d+$/.test(value) ? Number(value) : NaN;
|
|
88
|
+
if (!value || Number.isNaN(parsed) || parsed < 1 || parsed > 65535) {
|
|
89
|
+
throw new Error('Missing or invalid value for --port (expected 1-65535)');
|
|
90
|
+
}
|
|
91
|
+
options.port = parsed;
|
|
92
|
+
index += 1;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (arg === '--no-open') {
|
|
97
|
+
options.open = false;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (arg === '--help' || arg === '-h') {
|
|
102
|
+
printHelp();
|
|
103
|
+
process.exit(0);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
throw new Error(`Unknown argument: ${arg}`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return options;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function printHelp() {
|
|
113
|
+
process.stdout.write(
|
|
114
|
+
[
|
|
115
|
+
'iconpeek',
|
|
116
|
+
'',
|
|
117
|
+
'Usage:',
|
|
118
|
+
' npx iconpeek',
|
|
119
|
+
' npx iconpeek --project /path/to/expo/app',
|
|
120
|
+
' npx iconpeek --port 5000',
|
|
121
|
+
' npx iconpeek --no-open',
|
|
122
|
+
'',
|
|
123
|
+
'Flags:',
|
|
124
|
+
' --project <path> Expo project root (default: current working directory)',
|
|
125
|
+
' --port <number> Starting port (default: 4200)',
|
|
126
|
+
' --no-open Do not open a browser window',
|
|
127
|
+
'',
|
|
128
|
+
].join('\n')
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function ensurePlaceholderAsset() {
|
|
133
|
+
if (fs.existsSync(PLACEHOLDER_ICON)) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
fs.mkdirSync(path.dirname(PLACEHOLDER_ICON), { recursive: true });
|
|
138
|
+
const placeholderBase64 =
|
|
139
|
+
'iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAARwElEQVR4nO3dQXLkxrWGUUghr8PrUnjgNfRIEVqAIzTqNXjg0Lq8Dg/0Bv0oFdlFslAAMu/N/5yxbQEJIu9XWaT8w8ZQX778+sfsawCo6OvXf/0w+xqSWOwLGPIA5xIH57OgBxn2AHOIgmMs3k4GPkBNgmAfi/UAQx+gFzHwOQt0h4EPsBZB8D0LcsPgB1ibEPhL/EIY+gCZ0mMg9uYNfgC2LTcE4m7a4AfgnrQQiLhZQx+APRJiYOkbNPgBOGLlEPhx9gVcxfAH4KiVZ8lyZbPywwJgntVOA5a5GYMfgBFWCYH2N2HwAzBD9xBo/TsAhj8As3SfQS3rpfuiA7CWjqcB7U4ADH8Aquk4m1oFQMcFBiBDtxnV4sii26ICkK3DVwLlTwAMfwC66TC7SgdAhwUEgHuqz7CSRxTVFw0A9qj4lUC5EwDDH4DVVJxtpQKg4gIBwBmqzbgyAVBtYQDgbJVmXYkAqLQgAHClKjNvegBUWQgAGKXC7JsaABUWAABmmD0DpwXA7BsHgNlmzsIpAWD4A8A3s2bi8AAw/AHgtRmzcWgAGP4AcN/oGTksAAx/APjYyFk5JAAMfwB4zKiZeXkAGP4AsM+I2XlpABj+APCcq2fo9H8TIAAw3mUB4NM/ABxz5Sy9JAAMfwA4x1Uz9fQAMPwB4FxXz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YII=';
|
|
140
|
+
fs.writeFileSync(PLACEHOLDER_ICON, Buffer.from(placeholderBase64, 'base64'));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function parseConfigFile(filePath) {
|
|
144
|
+
if (!fs.existsSync(filePath)) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
try {
|
|
149
|
+
const raw = fs.readFileSync(filePath, 'utf8');
|
|
150
|
+
return JSON.parse(raw);
|
|
151
|
+
} catch (error) {
|
|
152
|
+
return {
|
|
153
|
+
__error: `Failed to parse ${path.basename(filePath)}: ${error.message}`,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function parseJsConfigFile(filePath, baseConfig = {}) {
|
|
159
|
+
if (!fs.existsSync(filePath)) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
delete require.cache[require.resolve(filePath)];
|
|
165
|
+
const loaded = require(filePath);
|
|
166
|
+
const config = loaded && loaded.default ? loaded.default : loaded;
|
|
167
|
+
if (typeof config === 'function') {
|
|
168
|
+
return config({ config: baseConfig });
|
|
169
|
+
}
|
|
170
|
+
return config;
|
|
171
|
+
} catch (error) {
|
|
172
|
+
// Node 20.19+/22.12+ ship require(esm) unflagged, so "export default" in
|
|
173
|
+
// app.config.js works natively there and this branch won't be hit. On
|
|
174
|
+
// older Node (down to this package's declared >=14 floor), require()
|
|
175
|
+
// still throws ERR_REQUIRE_ESM on ESM syntax, so give a specific,
|
|
176
|
+
// actionable message instead of a generic parse failure.
|
|
177
|
+
const looksLikeEsm =
|
|
178
|
+
error.code === 'ERR_REQUIRE_ESM' ||
|
|
179
|
+
(error instanceof SyntaxError && /export|import/.test(error.message));
|
|
180
|
+
|
|
181
|
+
const message = looksLikeEsm
|
|
182
|
+
? `Failed to load ${path.basename(filePath)}: it uses ES module syntax (import/export). ` +
|
|
183
|
+
`This Node.js version (${process.version}) can't require() that. Either upgrade to ` +
|
|
184
|
+
`Node 20.19+/22.12+ (which support this natively), convert the file to ` +
|
|
185
|
+
`"module.exports = ({ config }) => ({ ...config })", or use app.json / app.config.json instead.`
|
|
186
|
+
: `Failed to load ${path.basename(filePath)}: ${error.message}`;
|
|
187
|
+
|
|
188
|
+
return { __error: message };
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function detectConfig(projectRoot) {
|
|
192
|
+
const jsonCandidates = ['app.json', 'app.config.json'];
|
|
193
|
+
let baseJsonParsed = null;
|
|
194
|
+
let baseJsonPath = null;
|
|
195
|
+
let baseJsonName = null;
|
|
196
|
+
|
|
197
|
+
for (const name of jsonCandidates) {
|
|
198
|
+
const filePath = path.join(projectRoot, name);
|
|
199
|
+
const parsed = parseConfigFile(filePath);
|
|
200
|
+
if (parsed) {
|
|
201
|
+
baseJsonParsed = parsed;
|
|
202
|
+
baseJsonPath = filePath;
|
|
203
|
+
baseJsonName = name;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// If app.config.js exists, it takes precedence in Expo projects (dynamic config)
|
|
209
|
+
const jsConfigPath = path.join(projectRoot, 'app.config.js');
|
|
210
|
+
if (fs.existsSync(jsConfigPath)) {
|
|
211
|
+
const baseConfig = baseJsonParsed && baseJsonParsed.expo ? baseJsonParsed.expo : (baseJsonParsed || {});
|
|
212
|
+
const parsedJsConfig = parseJsConfigFile(jsConfigPath, baseConfig);
|
|
213
|
+
if (parsedJsConfig) {
|
|
214
|
+
return {
|
|
215
|
+
configPath: jsConfigPath,
|
|
216
|
+
configName: 'app.config.js',
|
|
217
|
+
raw: parsedJsConfig,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (baseJsonParsed) {
|
|
223
|
+
return {
|
|
224
|
+
configPath: baseJsonPath,
|
|
225
|
+
configName: baseJsonName,
|
|
226
|
+
raw: baseJsonParsed,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return {
|
|
231
|
+
configPath: null,
|
|
232
|
+
configName: null,
|
|
233
|
+
raw: null,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function normalizeHexColor(value, fallback) {
|
|
237
|
+
if (typeof value !== 'string') {
|
|
238
|
+
return fallback;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const trimmed = value.trim();
|
|
242
|
+
if (/^#[0-9a-fA-F]{6}$/.test(trimmed)) {
|
|
243
|
+
return trimmed.toUpperCase();
|
|
244
|
+
}
|
|
245
|
+
if (/^#[0-9a-fA-F]{3}$/.test(trimmed)) {
|
|
246
|
+
return `#${trimmed[1]}${trimmed[1]}${trimmed[2]}${trimmed[2]}${trimmed[3]}${trimmed[3]}`.toUpperCase();
|
|
247
|
+
}
|
|
248
|
+
// Expo allows 8-digit #RRGGBBAA colors. CSS background-color in this preview
|
|
249
|
+
// doesn't need the alpha channel, so keep the RGB and drop AA rather than
|
|
250
|
+
// silently discarding the whole value to the fallback.
|
|
251
|
+
if (/^#[0-9a-fA-F]{8}$/.test(trimmed)) {
|
|
252
|
+
return trimmed.slice(0, 7).toUpperCase();
|
|
253
|
+
}
|
|
254
|
+
return fallback;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function safeProjectAsset(projectRoot, relativePath) {
|
|
258
|
+
if (typeof relativePath !== 'string' || !relativePath.trim()) {
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const resolvedRoot = path.resolve(projectRoot);
|
|
263
|
+
const resolvedPath = path.resolve(resolvedRoot, relativePath);
|
|
264
|
+
const relativeFromRoot = path.relative(resolvedRoot, resolvedPath);
|
|
265
|
+
|
|
266
|
+
// Reject anything that escapes the project root (e.g. "../../etc/foo.png")
|
|
267
|
+
// so a hostile or malformed app.json can't be used to read arbitrary files.
|
|
268
|
+
if (relativeFromRoot.startsWith('..') || path.isAbsolute(relativeFromRoot)) {
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return resolvedPath;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function resolveAsset(projectRoot, relativePath) {
|
|
276
|
+
const absolutePath = safeProjectAsset(projectRoot, relativePath);
|
|
277
|
+
if (!absolutePath) {
|
|
278
|
+
return {
|
|
279
|
+
path: PLACEHOLDER_ICON,
|
|
280
|
+
relative: 'assets/placeholder-icon.png',
|
|
281
|
+
placeholder: true,
|
|
282
|
+
missing: false,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
try {
|
|
287
|
+
if (fs.existsSync(absolutePath) && fs.statSync(absolutePath).isFile()) {
|
|
288
|
+
return {
|
|
289
|
+
path: absolutePath,
|
|
290
|
+
relative: path.relative(projectRoot, absolutePath).replace(/\\/g, '/'),
|
|
291
|
+
placeholder: false,
|
|
292
|
+
missing: false,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
} catch (error) {
|
|
296
|
+
return {
|
|
297
|
+
path: PLACEHOLDER_ICON,
|
|
298
|
+
relative: 'assets/placeholder-icon.png',
|
|
299
|
+
placeholder: true,
|
|
300
|
+
missing: true,
|
|
301
|
+
error: error.message,
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return {
|
|
306
|
+
path: PLACEHOLDER_ICON,
|
|
307
|
+
relative: 'assets/placeholder-icon.png',
|
|
308
|
+
placeholder: true,
|
|
309
|
+
missing: true,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function findFallbackAsset(projectRoot, candidates) {
|
|
314
|
+
for (const rel of candidates) {
|
|
315
|
+
const resolved = safeProjectAsset(projectRoot, rel);
|
|
316
|
+
if (resolved && fs.existsSync(resolved) && fs.statSync(resolved).isFile()) {
|
|
317
|
+
return {
|
|
318
|
+
path: resolved,
|
|
319
|
+
relative: path.relative(projectRoot, resolved).replace(/\\/g, '/'),
|
|
320
|
+
placeholder: false,
|
|
321
|
+
missing: false,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function buildState(projectRoot) {
|
|
329
|
+
ensurePlaceholderAsset();
|
|
330
|
+
const detected = detectConfig(projectRoot);
|
|
331
|
+
const rawConfig = detected.raw && !detected.raw.__error ? detected.raw : {};
|
|
332
|
+
const expo = (rawConfig && rawConfig.expo) || rawConfig || {};
|
|
333
|
+
const android = expo.android || {};
|
|
334
|
+
const adaptiveIcon = android.adaptiveIcon || {};
|
|
335
|
+
let splashPluginConfig = {};
|
|
336
|
+
if (Array.isArray(expo.plugins)) {
|
|
337
|
+
for (const plugin of expo.plugins) {
|
|
338
|
+
if (Array.isArray(plugin) && plugin[0] === 'expo-splash-screen' && typeof plugin[1] === 'object') {
|
|
339
|
+
splashPluginConfig = plugin[1];
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
const splash = { ...splashPluginConfig, ...(expo.splash || {}) };
|
|
345
|
+
const splashDark = splash.dark || {};
|
|
346
|
+
|
|
347
|
+
let iconAsset = resolveAsset(projectRoot, adaptiveIcon.foregroundImage || expo.icon);
|
|
348
|
+
let iosIconAsset = resolveAsset(projectRoot, expo.icon);
|
|
349
|
+
let splashAsset = resolveAsset(projectRoot, splash.image);
|
|
350
|
+
let splashDarkAsset = resolveAsset(projectRoot, splashDark.image || splash.image);
|
|
351
|
+
|
|
352
|
+
let usedFallback = false;
|
|
353
|
+
if (iconAsset.placeholder) {
|
|
354
|
+
const fallback = findFallbackAsset(projectRoot, [
|
|
355
|
+
'icon_output/android/mipmap-xxxhdpi/ic_launcher_foreground.png',
|
|
356
|
+
'android/mipmap-xxxhdpi/ic_launcher_foreground.png',
|
|
357
|
+
'icon_output/android/mipmap-xxhdpi/ic_launcher_foreground.png',
|
|
358
|
+
'android/mipmap-xxhdpi/ic_launcher_foreground.png',
|
|
359
|
+
'icon_output/android/play-store/play_store_icon.png',
|
|
360
|
+
'android/play-store/play_store_icon.png',
|
|
361
|
+
'assets/adaptive-icon.png',
|
|
362
|
+
'assets/iconpeek.png',
|
|
363
|
+
'assets/icon.png',
|
|
364
|
+
'adaptive-icon.png',
|
|
365
|
+
'iconpeek.png',
|
|
366
|
+
'icon.png',
|
|
367
|
+
]);
|
|
368
|
+
if (fallback) {
|
|
369
|
+
iconAsset = fallback;
|
|
370
|
+
usedFallback = true;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (iosIconAsset.placeholder) {
|
|
375
|
+
const fallback = findFallbackAsset(projectRoot, [
|
|
376
|
+
'icon_output/ios/AppIcon.appiconset/icon_ios-marketing_1024x1024@1x.png',
|
|
377
|
+
'ios/AppIcon.appiconset/icon_ios-marketing_1024x1024@1x.png',
|
|
378
|
+
'icon_output/android/play-store/play_store_icon.png',
|
|
379
|
+
'android/play-store/play_store_icon.png',
|
|
380
|
+
'assets/iconpeek.png',
|
|
381
|
+
'assets/icon.png',
|
|
382
|
+
'iconpeek.png',
|
|
383
|
+
'icon.png',
|
|
384
|
+
]);
|
|
385
|
+
if (fallback) {
|
|
386
|
+
iosIconAsset = fallback;
|
|
387
|
+
usedFallback = true;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
if (splashAsset.placeholder) {
|
|
392
|
+
const fallback = findFallbackAsset(projectRoot, [
|
|
393
|
+
'assets/splash.png',
|
|
394
|
+
'assets/splash-icon.png',
|
|
395
|
+
'assets/iconpeek.png',
|
|
396
|
+
'splash.png',
|
|
397
|
+
'icon_output/android/play-store/play_store_icon.png',
|
|
398
|
+
'android/play-store/play_store_icon.png',
|
|
399
|
+
]);
|
|
400
|
+
if (fallback) {
|
|
401
|
+
splashAsset = fallback;
|
|
402
|
+
usedFallback = true;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
if (splashDarkAsset.placeholder) {
|
|
407
|
+
const fallback = findFallbackAsset(projectRoot, [
|
|
408
|
+
'assets/splash-dark.png',
|
|
409
|
+
'splash-dark.png',
|
|
410
|
+
'assets/splash.png',
|
|
411
|
+
'assets/iconpeek.png',
|
|
412
|
+
]);
|
|
413
|
+
if (fallback) {
|
|
414
|
+
splashDarkAsset = fallback;
|
|
415
|
+
usedFallback = true;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
const warningMessages = [];
|
|
420
|
+
if (!detected.configPath) {
|
|
421
|
+
if (usedFallback) {
|
|
422
|
+
warningMessages.push('No app.json, app.config.json, or app.config.js found. Using assets found in icon_output / assets.');
|
|
423
|
+
} else {
|
|
424
|
+
warningMessages.push('No app.json, app.config.json, or app.config.js found. Showing placeholder assets and default colors.');
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
if (detected.raw && detected.raw.__error) {
|
|
428
|
+
warningMessages.push(detected.raw.__error);
|
|
429
|
+
}
|
|
430
|
+
if (iconAsset.missing) {
|
|
431
|
+
warningMessages.push('Android foreground icon was missing. Using the bundled placeholder.');
|
|
432
|
+
}
|
|
433
|
+
if (iosIconAsset.missing) {
|
|
434
|
+
warningMessages.push('Expo icon was missing. Using the bundled placeholder for iOS.');
|
|
435
|
+
}
|
|
436
|
+
if (splashAsset.missing) {
|
|
437
|
+
warningMessages.push('Splash image was missing. Using the bundled placeholder.');
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
return {
|
|
441
|
+
projectRoot,
|
|
442
|
+
configName: detected.configName,
|
|
443
|
+
configPath: detected.configPath,
|
|
444
|
+
warnings: warningMessages,
|
|
445
|
+
assets: {
|
|
446
|
+
icon: iconAsset,
|
|
447
|
+
iosIcon: iosIconAsset,
|
|
448
|
+
splash: splashAsset,
|
|
449
|
+
splashDark: splashDarkAsset,
|
|
450
|
+
},
|
|
451
|
+
expo: {
|
|
452
|
+
name: typeof expo.name === 'string' && expo.name.trim() ? expo.name.trim() : 'Your App',
|
|
453
|
+
icon: expo.icon || null,
|
|
454
|
+
androidForegroundImage: adaptiveIcon.foregroundImage || null,
|
|
455
|
+
adaptiveBackgroundColor: normalizeHexColor(adaptiveIcon.backgroundColor, '#FFFFFF'),
|
|
456
|
+
splashImage: splash.image || null,
|
|
457
|
+
splashImageWidth: typeof splash.imageWidth === 'number' ? splash.imageWidth : null,
|
|
458
|
+
splashBackgroundColor: normalizeHexColor(splash.backgroundColor, '#FFFFFF'),
|
|
459
|
+
splashDarkBackgroundColor: normalizeHexColor(splashDark.backgroundColor, '#121212'),
|
|
460
|
+
splashDarkImage: splashDark.image || null,
|
|
461
|
+
},
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
function escapeHtml(value) {
|
|
466
|
+
return String(value)
|
|
467
|
+
.replace(/&/g, '&')
|
|
468
|
+
.replace(/</g, '<')
|
|
469
|
+
.replace(/>/g, '>')
|
|
470
|
+
.replace(/"/g, '"')
|
|
471
|
+
.replace(/'/g, ''');
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function createHtml(state) {
|
|
475
|
+
const payload = JSON.stringify({
|
|
476
|
+
warnings: state.warnings,
|
|
477
|
+
projectRoot: state.projectRoot,
|
|
478
|
+
configName: state.configName,
|
|
479
|
+
assets: {
|
|
480
|
+
iconPath: state.assets.icon.relative,
|
|
481
|
+
iosIconPath: state.assets.iosIcon.relative,
|
|
482
|
+
splashPath: state.assets.splash.relative,
|
|
483
|
+
splashDarkPath: state.assets.splashDark.relative,
|
|
484
|
+
},
|
|
485
|
+
expo: state.expo,
|
|
486
|
+
}).replace(/</g, '\\u003c');
|
|
487
|
+
|
|
488
|
+
const htmlTemplate = fs.readFileSync(path.join(__dirname, 'index.html'), 'utf8');
|
|
489
|
+
const styles = fs.readFileSync(path.join(__dirname, 'style.css'), 'utf8');
|
|
490
|
+
|
|
491
|
+
return htmlTemplate
|
|
492
|
+
.replace('<style id="main-styles"></style>', `<style>\n${styles}\n </style>`)
|
|
493
|
+
.replace('{{PROJECT_ROOT}}', escapeHtml(state.projectRoot))
|
|
494
|
+
.replace('{{CONFIG_NAME}}', escapeHtml(state.configName || 'Not found'))
|
|
495
|
+
.replace(/\{\{EXPO_NAME\}\}/g, escapeHtml(state.expo.name))
|
|
496
|
+
.replace('let STATE = {};', `let STATE = ${payload};`);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function openBrowser(url) {
|
|
500
|
+
const command =
|
|
501
|
+
process.platform === 'darwin'
|
|
502
|
+
? `open "${url}"`
|
|
503
|
+
: process.platform === 'win32'
|
|
504
|
+
? `start "" "${url}"`
|
|
505
|
+
: `xdg-open "${url}"`;
|
|
506
|
+
|
|
507
|
+
exec(command, (error) => {
|
|
508
|
+
if (error) {
|
|
509
|
+
process.stdout.write(`Open manually: ${url}\n`);
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function servePng(res, filePath) {
|
|
515
|
+
fs.readFile(filePath, (error, data) => {
|
|
516
|
+
if (error || !data || data.length < PNG_SIGNATURE.length || !data.subarray(0, PNG_SIGNATURE.length).equals(PNG_SIGNATURE)) {
|
|
517
|
+
res.writeHead(404, {
|
|
518
|
+
'Content-Type': 'text/plain; charset=utf-8',
|
|
519
|
+
'Cache-Control': 'no-store',
|
|
520
|
+
});
|
|
521
|
+
res.end('Not Found');
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
res.writeHead(200, {
|
|
526
|
+
'Content-Type': 'image/png',
|
|
527
|
+
'Cache-Control': 'no-store',
|
|
528
|
+
});
|
|
529
|
+
res.end(data);
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
function createServer(options) {
|
|
534
|
+
return http.createServer((req, res) => {
|
|
535
|
+
const requestUrl = new URL(req.url, 'http://localhost');
|
|
536
|
+
const state = buildState(options.projectRoot);
|
|
537
|
+
|
|
538
|
+
if (requestUrl.pathname === '/') {
|
|
539
|
+
const html = createHtml(state);
|
|
540
|
+
res.writeHead(200, {
|
|
541
|
+
'Content-Type': 'text/html; charset=utf-8',
|
|
542
|
+
'Cache-Control': 'no-store',
|
|
543
|
+
});
|
|
544
|
+
res.end(html);
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
if (requestUrl.pathname === '/events') {
|
|
549
|
+
res.writeHead(200, {
|
|
550
|
+
'Content-Type': 'text/event-stream',
|
|
551
|
+
'Cache-Control': 'no-cache',
|
|
552
|
+
'Connection': 'keep-alive',
|
|
553
|
+
});
|
|
554
|
+
res.write('\n');
|
|
555
|
+
sseClients.push(res);
|
|
556
|
+
|
|
557
|
+
req.on('close', () => {
|
|
558
|
+
const index = sseClients.indexOf(res);
|
|
559
|
+
if (index !== -1) {
|
|
560
|
+
sseClients.splice(index, 1);
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
if (requestUrl.pathname === '/bundle.js') {
|
|
567
|
+
const bundlePath = path.join(__dirname, 'dist', 'bundle.js');
|
|
568
|
+
if (fs.existsSync(bundlePath)) {
|
|
569
|
+
res.writeHead(200, {
|
|
570
|
+
'Content-Type': 'application/javascript; charset=utf-8',
|
|
571
|
+
'Cache-Control': 'no-store',
|
|
572
|
+
});
|
|
573
|
+
fs.createReadStream(bundlePath).pipe(res);
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
if (requestUrl.pathname === '/assets/iconpeek.png' || requestUrl.pathname === '/favicon.ico') {
|
|
579
|
+
const filePath = path.join(__dirname, 'assets', 'iconpeek.png');
|
|
580
|
+
if (fs.existsSync(filePath)) {
|
|
581
|
+
res.writeHead(200, {
|
|
582
|
+
'Content-Type': 'image/png',
|
|
583
|
+
'Cache-Control': 'public, max-age=86400',
|
|
584
|
+
});
|
|
585
|
+
fs.createReadStream(filePath).pipe(res);
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
if (requestUrl.pathname.startsWith('/assets/mockups/')) {
|
|
591
|
+
const fileName = path.basename(requestUrl.pathname);
|
|
592
|
+
const filePath = path.join(__dirname, 'assets', 'mockups', fileName);
|
|
593
|
+
if (fs.existsSync(filePath)) {
|
|
594
|
+
res.writeHead(200, {
|
|
595
|
+
'Content-Type': 'image/webp',
|
|
596
|
+
'Cache-Control': 'public, max-age=86400',
|
|
597
|
+
});
|
|
598
|
+
fs.createReadStream(filePath).pipe(res);
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
if (requestUrl.pathname === '/assets/icon') {
|
|
604
|
+
servePng(res, state.assets.icon.path);
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
if (requestUrl.pathname === '/assets/ios-icon') {
|
|
609
|
+
servePng(res, state.assets.iosIcon.path);
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
if (requestUrl.pathname === '/assets/splash') {
|
|
614
|
+
servePng(res, state.assets.splash.path);
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
if (requestUrl.pathname === '/assets/splash-dark') {
|
|
619
|
+
servePng(res, state.assets.splashDark.path);
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
res.writeHead(404, {
|
|
624
|
+
'Content-Type': 'text/plain; charset=utf-8',
|
|
625
|
+
'Cache-Control': 'no-store',
|
|
626
|
+
});
|
|
627
|
+
res.end('Not Found');
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
function startServer(options) {
|
|
632
|
+
const server = createServer(options);
|
|
633
|
+
let currentPort = options.port;
|
|
634
|
+
let browserOpened = false;
|
|
635
|
+
|
|
636
|
+
server.on('error', (error) => {
|
|
637
|
+
if (error && error.code === 'EADDRINUSE') {
|
|
638
|
+
currentPort += 1;
|
|
639
|
+
server.listen(currentPort);
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
process.stderr.write(`${error.message}\n`);
|
|
644
|
+
process.exit(1);
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
server.on('listening', () => {
|
|
648
|
+
const url = `http://localhost:${currentPort}`;
|
|
649
|
+
process.stdout.write(`iconpeek running at ${url}\n`);
|
|
650
|
+
updateWatchers(options.projectRoot);
|
|
651
|
+
if (options.open && !browserOpened) {
|
|
652
|
+
browserOpened = true;
|
|
653
|
+
openBrowser(url);
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
|
|
657
|
+
server.listen(currentPort);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
try {
|
|
661
|
+
const options = parseArgs(process.argv.slice(2));
|
|
662
|
+
startServer(options);
|
|
663
|
+
} catch (error) {
|
|
664
|
+
process.stderr.write(`${error.message}\n\n`);
|
|
665
|
+
printHelp();
|
|
666
|
+
process.exit(1);
|
|
1454
667
|
}
|