iqc-maker 1.0.0 → 1.0.4
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/CHANGELOG.md +23 -0
- package/README.md +69 -13
- package/index.d.ts +28 -3
- package/package.json +2 -2
- package/src/constants.js +30 -2
- package/src/icons.js +31 -5
- package/src/index.js +5 -0
- package/src/render.js +203 -13
- package/src/themes.js +60 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.4 — 2026-11-30
|
|
4
|
+
|
|
5
|
+
### Dokumentasi
|
|
6
|
+
- Thumbnail di awal README.
|
|
7
|
+
- Bagian kredit diganti jadi **Kontributor**.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Ditambahkan
|
|
11
|
+
- Tema bawaan baru **`whatsapp`** (dark) dan **`whatsapp-light`**, mirip menu WhatsApp iOS versi terbaru:
|
|
12
|
+
- background chat WhatsApp yang di-blur
|
|
13
|
+
- status bar klasik (sinyal + operator di kiri, jam di tengah, Wi-Fi + persen baterai di kanan)
|
|
14
|
+
- reaction bar gelap dengan border tipis, tetap ada tombol **+**
|
|
15
|
+
- bubble tanpa ekor
|
|
16
|
+
- menu dalam kartu, ikon outline di kanan, garis pemisah tiap baris, **Lainnya...** di kartu terpisah
|
|
17
|
+
- Gaya menu `native` / `glass` yang bisa dipaksa lewat opsi `style` untuk tema apa pun.
|
|
18
|
+
- Opsi `statusBarStyle`, `carrier`, `wifi`, dan `batteryPercent`.
|
|
19
|
+
- Key tema baru: `style`, `statusBar.style`, `background.chat`, `pill.border`, `bubble.tail`, `menu.card`, `menu.cardBorder`, `menu.separator`.
|
|
20
|
+
- Alias tema: `default`, `bawaan`, `wa`, `wa-dark`, `wa-light`, `wa-terang`.
|
|
21
|
+
|
|
22
|
+
### Diubah
|
|
23
|
+
- Tema default sekarang `whatsapp` (sebelumnya `blue`). Tema lain dan tema custom tetap pakai gaya `glass`.
|
|
24
|
+
- Emoji di reaction bar gaya `native` diberi jarak supaya nggak ketimpa tombol **+**.
|
|
25
|
+
|
|
3
26
|
## 1.0.0 — 2026-11-30
|
|
4
27
|
|
|
5
28
|
Rilis pertama sebagai package npm.
|
package/README.md
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
+
<img src="https://raw.githubusercontent.com/its-dinda/image/main/1796010343636.jpeg" alt="iqc-maker" width="100%" style="aspect-ratio: 16 / 9; object-fit: cover; border-radius: 12px;" />
|
|
4
|
+
|
|
3
5
|
# iqc-maker
|
|
4
6
|
|
|
5
7
|
**Generator fake chat WhatsApp gaya iPhone (iQC)**
|
|
6
|
-
lengkap dengan bubble reply, font SF Pro, emoji Apple, dan **
|
|
8
|
+
lengkap dengan bubble reply, font SF Pro, emoji Apple, dan **88 tema warna** yang bisa diatur sampai detail terkecil.
|
|
7
9
|
|
|
8
10
|
[](https://www.npmjs.com/package/iqc-maker)
|
|
9
11
|
[](https://nodejs.org)
|
|
10
12
|
[](./LICENSE)
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
[Instalasi](#instalasi) • [Mulai Cepat](#mulai-cepat) • [Tema](#tema) • [API](#api) • [Contoh Bot](#contoh-plugin-bot-whatsapp-baileys)
|
|
13
15
|
|
|
14
16
|
</div>
|
|
15
17
|
|
|
@@ -35,7 +37,7 @@ Dibuat pertama kali oleh **Ditzzx** • Disempurnakan oleh **Lynx Decode**
|
|
|
35
37
|
- [Contoh plugin bot WhatsApp (Baileys)](#contoh-plugin-bot-whatsapp-baileys)
|
|
36
38
|
- [TypeScript](#typescript)
|
|
37
39
|
- [FAQ & troubleshooting](#faq--troubleshooting)
|
|
38
|
-
- [
|
|
40
|
+
- [Kontributor](#kontributor)
|
|
39
41
|
- [Lisensi](#lisensi)
|
|
40
42
|
|
|
41
43
|
---
|
|
@@ -46,7 +48,8 @@ Dibuat pertama kali oleh **Ditzzx** • Disempurnakan oleh **Lynx Decode**
|
|
|
46
48
|
- 💬 **Reply chat**: nama pengirim + kutipan 2 baris, warna bar bisa diatur per pesan.
|
|
47
49
|
- 🔤 **Font SF Pro Text asli**: Regular, Semibold, Bold. Jarak antarbaris dan jarak teks ke jam sudah dirapikan.
|
|
48
50
|
- 😀 **Emoji Apple** di teks, nama, reply, dan reaction bar.
|
|
49
|
-
-
|
|
51
|
+
- 📱 **Tema bawaan `whatsapp`** yang mirip menu WhatsApp iOS asli: ikon di kanan, garis pemisah, kotak "Lainnya..." terpisah, background chat blur, dan status bar operator.
|
|
52
|
+
- 🎨 **88 tema**: tema WhatsApp iOS, warna dasar, versi dark tiap warna, hitam/AMOLED, sampai tema alam (laut, hutan, aurora, galaksi, gunung berapi, ...).
|
|
50
53
|
- 🛠️ **Kustom penuh**: tiap warna bisa di-override, bisa bikin tema sendiri, bisa pakai wallpaper sendiri.
|
|
51
54
|
- 🖼️ **Gambar** di dalam bubble (dengan atau tanpa caption).
|
|
52
55
|
- 🌐 Label menu dalam **9 bahasa**, atau tulis sendiri.
|
|
@@ -150,6 +153,39 @@ Pakai nama tema:
|
|
|
150
153
|
await render({ text: 'halo', theme: 'aurora' })
|
|
151
154
|
```
|
|
152
155
|
|
|
156
|
+
### Tema bawaan: `whatsapp`
|
|
157
|
+
|
|
158
|
+
Kalau `theme` nggak diisi, yang dipakai adalah **`whatsapp`**, tampilan menu WhatsApp iOS dark mode versi terbaru:
|
|
159
|
+
|
|
160
|
+
- Background chat WhatsApp yang di-blur.
|
|
161
|
+
- Status bar gaya lama: sinyal + operator di kiri, jam di tengah, Wi-Fi + persen baterai di kanan.
|
|
162
|
+
- Reaction bar gelap dengan tombol **+**.
|
|
163
|
+
- Bubble tanpa ekor.
|
|
164
|
+
- Menu dalam kartu, teks di kiri, ikon outline di kanan, garis pemisah di tiap baris, dan **Lainnya...** di kartu terpisah.
|
|
165
|
+
|
|
166
|
+
```js
|
|
167
|
+
await render({ text: 'anjay kamu bohong' }) // otomatis tema whatsapp
|
|
168
|
+
await render({ text: 'versi terang', theme: 'whatsapp-light' })
|
|
169
|
+
await render({ text: 'halo', carrier: 'TELKOMSEL', network: 'LTE', battery: 88 })
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
#### Gaya menu: `native` vs `glass`
|
|
173
|
+
|
|
174
|
+
Ada dua gaya tampilan:
|
|
175
|
+
|
|
176
|
+
| Gaya | Dipakai oleh | Ciri |
|
|
177
|
+
|------|--------------|------|
|
|
178
|
+
| `native` | `whatsapp`, `whatsapp-light` | Kartu menu ala WhatsApp iOS, ikon di kanan, ada garis pemisah. |
|
|
179
|
+
| `glass` | Semua tema lain & tema custom | Panel kaca melengkung, ikon di kiri (gaya iQC klasik). |
|
|
180
|
+
|
|
181
|
+
Gaya bisa dipaksa untuk tema apa pun:
|
|
182
|
+
|
|
183
|
+
```js
|
|
184
|
+
await render({ text: 'pink tapi gaya WA', theme: 'pink', style: 'native' })
|
|
185
|
+
await render({ text: 'WA tapi gaya kaca', theme: 'whatsapp', style: 'glass' })
|
|
186
|
+
await render({ text: 'status bar notch', theme: 'whatsapp', statusBarStyle: 'notch' })
|
|
187
|
+
```
|
|
188
|
+
|
|
153
189
|
### Daftar tema bawaan
|
|
154
190
|
|
|
155
191
|
Lihat semuanya lewat kode:
|
|
@@ -162,9 +198,13 @@ listThemes('dark') // semua tema mode gelap (sesuai mode)
|
|
|
162
198
|
listThemes('earth') // tema alam
|
|
163
199
|
```
|
|
164
200
|
|
|
201
|
+
#### 📱 WhatsApp iOS (`whatsapp`): 2
|
|
202
|
+
|
|
203
|
+
`whatsapp` (default) · `whatsapp-light`
|
|
204
|
+
|
|
165
205
|
#### 🎨 Warna dasar (`colors`): 22
|
|
166
206
|
|
|
167
|
-
`blue`
|
|
207
|
+
`blue` · `pink` · `red` · `orange` · `yellow` · `lime` · `green` · `mint` · `teal` · `cyan` · `navy` · `indigo` · `purple` · `lavender` · `magenta` · `peach` · `brown` · `gray` · `white` · `gold` · `silver` · `rosegold`
|
|
168
208
|
|
|
169
209
|
#### 🌑 Versi gelap tiap warna (`colors-dark`): 19
|
|
170
210
|
|
|
@@ -197,7 +237,9 @@ Nama tema nggak case-sensitive, dan spasi/underscore otomatis jadi `-`.
|
|
|
197
237
|
| `hitam`, `item` | `black` |
|
|
198
238
|
| `gelap`, `ios` | `dark` |
|
|
199
239
|
| `putih`, `light` | `white` |
|
|
200
|
-
| `
|
|
240
|
+
| `default`, `bawaan`, `wa`, `wa-dark` | `whatsapp` |
|
|
241
|
+
| `wa-light`, `wa-terang` | `whatsapp-light` |
|
|
242
|
+
| `biru` | `blue` |
|
|
201
243
|
| `biru-tua` / `biru-muda` | `navy` / `sky` |
|
|
202
244
|
| `merah` · `merah-muda` | `red` · `pink` |
|
|
203
245
|
| `oren`, `oranye`, `jingga` | `orange` |
|
|
@@ -312,14 +354,18 @@ Semua key di bawah ini bisa di-override lewat `colors`, `registerTheme`, atau `c
|
|
|
312
354
|
```js
|
|
313
355
|
{
|
|
314
356
|
name: 'blue', label: 'Blue', mode: 'light', category: 'colors',
|
|
357
|
+
style: 'glass', // 'glass' | 'native'
|
|
315
358
|
background: {
|
|
316
359
|
image: null, // path | url | Buffer
|
|
317
360
|
gradient: ['#e8f4fa', '#d4ebf8', '#bfe0f6'],
|
|
318
361
|
blobs: ['rgba(255,255,255,0.9)', '#5dade2', '#85c1e9', '#3498db', '#2e86c1'],
|
|
319
362
|
solid: undefined, // isi untuk warna polos
|
|
320
363
|
dim: undefined, // penggelap wallpaper
|
|
364
|
+
chat: null, // background chat blur (tema whatsapp)
|
|
365
|
+
// chat: { header, avatar, accent, incoming, outgoing, blur: 16, overlay }
|
|
321
366
|
},
|
|
322
367
|
statusBar: {
|
|
368
|
+
style: 'notch', // 'notch' | 'classic'
|
|
323
369
|
text: '#000000', // jam, sinyal, 4G
|
|
324
370
|
inactive: 'rgba(0,0,0,0.3)', // bar sinyal kosong
|
|
325
371
|
battery: { body, border, cap, fill, low, charging, bolt, boltStroke },
|
|
@@ -327,16 +373,19 @@ Semua key di bawah ini bisa di-override lewat `colors`, `registerTheme`, atau `c
|
|
|
327
373
|
pill: { // reaction bar
|
|
328
374
|
bg: '#ffffff', underlay: '#b6dff4', shadow: 'rgba(...)',
|
|
329
375
|
plusBg: '#e7e7e9', plusIcon: '#7b7b80',
|
|
376
|
+
border: null, // garis tepi reaction bar
|
|
330
377
|
},
|
|
331
378
|
bubble: {
|
|
332
379
|
bg: '#ffffff', text: '#000000', time: '#7d7d82', shadow: 'rgba(0,0,0,0.08)',
|
|
333
380
|
mediaTimeBg: 'rgba(0,0,0,0.38)', mediaTimeText: '#ffffff',
|
|
381
|
+
tail: true, // ekor bubble
|
|
334
382
|
},
|
|
335
383
|
reply: { bg: '#e8f3fc', bar: '#3a8ee6', name: '#2b7fd8', text: '#5b5b60' },
|
|
336
384
|
menu: {
|
|
337
385
|
shadow, overlay, // overlay = penggelap glass (dark mode)
|
|
338
386
|
tintTop, tintBottom, sheen, glow, spec, rimTop, rimBottom,
|
|
339
387
|
text: '#000000', icon: '#000000', danger: '#c10b27', divider: 'rgba(0,0,0,0.15)',
|
|
388
|
+
card, cardBorder, separator, // dipakai gaya native
|
|
340
389
|
},
|
|
341
390
|
}
|
|
342
391
|
```
|
|
@@ -352,7 +401,12 @@ Format warna yang didukung: `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`, `rgb()`, `r
|
|
|
352
401
|
| `text` | `string` | — | Isi pesan. Mendukung `\n` dan emoji. Wajib diisi kalau `image` kosong. |
|
|
353
402
|
| `image` | `Buffer \| string` | `null` | Gambar di dalam bubble (path / URL / Buffer). |
|
|
354
403
|
| `reply` | `{ name, text, color? }` | `null` | Bubble reply. |
|
|
355
|
-
| `theme` | `string \| object` | `'
|
|
404
|
+
| `theme` | `string \| object` | `'whatsapp'` | Nama tema, alias, atau objek tema. |
|
|
405
|
+
| `style` | `'native' \| 'glass'` | ikut tema | Paksa gaya menu. |
|
|
406
|
+
| `statusBarStyle` | `'classic' \| 'notch'` | ikut tema | Paksa gaya status bar. |
|
|
407
|
+
| `carrier` | `string` | `'INDOSAT'` | Nama operator (status bar `classic`). `''` untuk menyembunyikan. |
|
|
408
|
+
| `wifi` | `boolean` | `true` | Ikon Wi-Fi di status bar `classic`. |
|
|
409
|
+
| `batteryPercent` | `boolean` | `true` | Persen baterai di status bar `classic`. |
|
|
356
410
|
| `colors` | `object` | — | Override sebagian warna tema. |
|
|
357
411
|
| `background` | `string \| Buffer \| object` | — | Wallpaper / warna polos / override background. |
|
|
358
412
|
| `time` | `string` | jam sekarang | Jam di status bar, misalnya `'00.56'`. |
|
|
@@ -482,8 +536,8 @@ Contoh untuk struktur plugin `handler` ala bot MD (ESM):
|
|
|
482
536
|
import { render, resolveTheme, listThemes } from 'iqc-maker'
|
|
483
537
|
|
|
484
538
|
let handler = async (m, { conn, args, usedPrefix, command }) => {
|
|
485
|
-
let theme = '
|
|
486
|
-
if (args[0] && args[0].startsWith('-')) theme = resolveTheme(args.shift().slice(1)) || '
|
|
539
|
+
let theme = 'whatsapp'
|
|
540
|
+
if (args[0] && args[0].startsWith('-')) theme = resolveTheme(args.shift().slice(1)) || 'whatsapp'
|
|
487
541
|
|
|
488
542
|
const q = m.quoted ? m.quoted : m
|
|
489
543
|
const mime = (q.msg || q).mimetype || ''
|
|
@@ -570,14 +624,16 @@ Pakai `scale: 2` (1180×2560) atau `format: 'webp'`.
|
|
|
570
624
|
|
|
571
625
|
---
|
|
572
626
|
|
|
573
|
-
##
|
|
627
|
+
## Kontributor
|
|
574
628
|
|
|
575
|
-
| | Peran |
|
|
629
|
+
| Kontributor | Peran |
|
|
576
630
|
|---|---|
|
|
631
|
+
| **[Lynx Decode](https://github.com/Lynxcode-id)** | Maintainer: reply chat, font SF Pro, perbaikan spacing, sistem tema, tema WhatsApp iOS, versi npm |
|
|
577
632
|
| **[Ditzzx](https://github.com/Ditzzx-vibecoder)** | Pembuat pertama iQC canvas & penyedia emoji map Apple |
|
|
578
|
-
| **[Lynx Decode](https://github.com/Lynxcode-id)** | Penyempurna & maintainer: reply chat, font SF Pro, perbaikan spacing, sistem tema, versi npm |
|
|
579
633
|
|
|
580
|
-
|
|
634
|
+
Ikon menu gaya `native` diadaptasi dari [Lucide](https://lucide.dev) (lisensi ISC).
|
|
635
|
+
|
|
636
|
+
Kalau memakai atau memodifikasi package ini, tolong tetap cantumkan nama para kontributor di atas. 🙏
|
|
581
637
|
|
|
582
638
|
---
|
|
583
639
|
|
package/index.d.ts
CHANGED
|
@@ -4,11 +4,14 @@ import type { Canvas } from '@napi-rs/canvas'
|
|
|
4
4
|
|
|
5
5
|
export type ImageSource = Buffer | string
|
|
6
6
|
export type ThemeMode = 'light' | 'dark'
|
|
7
|
-
export type ThemeCategory = 'colors' | 'colors-dark' | 'dark' | 'earth' | 'custom'
|
|
7
|
+
export type ThemeCategory = 'whatsapp' | 'colors' | 'colors-dark' | 'dark' | 'earth' | 'custom'
|
|
8
8
|
export type OutputFormat = 'png' | 'jpg' | 'jpeg' | 'webp' | 'avif'
|
|
9
|
+
export type MenuStyle = 'native' | 'glass'
|
|
10
|
+
export type StatusBarStyle = 'classic' | 'notch'
|
|
9
11
|
export type LocaleCode = 'id' | 'en' | 'ms' | 'jv' | 'su' | 'es' | 'pt' | 'ar' | 'ja'
|
|
10
12
|
|
|
11
13
|
export type BuiltinThemeName =
|
|
14
|
+
| 'whatsapp' | 'whatsapp-light'
|
|
12
15
|
| 'blue' | 'pink' | 'red' | 'orange' | 'yellow' | 'lime' | 'green' | 'mint' | 'teal' | 'cyan' | 'navy' | 'indigo'
|
|
13
16
|
| 'purple' | 'lavender' | 'magenta' | 'peach' | 'brown' | 'gray' | 'white' | 'gold' | 'silver' | 'rosegold'
|
|
14
17
|
| 'dark-blue' | 'dark-pink' | 'dark-red' | 'dark-orange' | 'dark-yellow' | 'dark-lime' | 'dark-green' | 'dark-mint'
|
|
@@ -26,6 +29,7 @@ export interface Theme {
|
|
|
26
29
|
name: string
|
|
27
30
|
label: string
|
|
28
31
|
mode: ThemeMode
|
|
32
|
+
style: MenuStyle
|
|
29
33
|
category: ThemeCategory | string
|
|
30
34
|
background: {
|
|
31
35
|
image: ImageSource | null
|
|
@@ -33,8 +37,18 @@ export interface Theme {
|
|
|
33
37
|
blobs: string[]
|
|
34
38
|
solid?: string
|
|
35
39
|
dim?: number | string
|
|
40
|
+
chat?: {
|
|
41
|
+
header?: string
|
|
42
|
+
avatar?: string
|
|
43
|
+
accent?: string
|
|
44
|
+
incoming?: string
|
|
45
|
+
outgoing?: string
|
|
46
|
+
blur?: number
|
|
47
|
+
overlay?: string
|
|
48
|
+
} | null
|
|
36
49
|
}
|
|
37
50
|
statusBar: {
|
|
51
|
+
style: StatusBarStyle
|
|
38
52
|
text: string
|
|
39
53
|
inactive: string
|
|
40
54
|
battery: {
|
|
@@ -48,8 +62,8 @@ export interface Theme {
|
|
|
48
62
|
boltStroke: string
|
|
49
63
|
}
|
|
50
64
|
}
|
|
51
|
-
pill: { bg: string; underlay: string; shadow: string; plusBg: string; plusIcon: string }
|
|
52
|
-
bubble: { bg: string; text: string; time: string; shadow: string; mediaTimeBg: string; mediaTimeText: string }
|
|
65
|
+
pill: { bg: string; underlay: string | null; shadow: string; plusBg: string; plusIcon: string; border: string | null }
|
|
66
|
+
bubble: { bg: string; text: string; time: string; shadow: string; mediaTimeBg: string; mediaTimeText: string; tail: boolean }
|
|
53
67
|
reply: { bg: string; bar: string; name: string; text: string }
|
|
54
68
|
menu: {
|
|
55
69
|
shadow: string
|
|
@@ -65,6 +79,9 @@ export interface Theme {
|
|
|
65
79
|
icon: string
|
|
66
80
|
danger: string
|
|
67
81
|
divider: string
|
|
82
|
+
card: string
|
|
83
|
+
cardBorder: string | null
|
|
84
|
+
separator: string
|
|
68
85
|
}
|
|
69
86
|
}
|
|
70
87
|
|
|
@@ -74,6 +91,8 @@ export interface ThemeDefinition {
|
|
|
74
91
|
name?: string
|
|
75
92
|
label?: string
|
|
76
93
|
mode?: ThemeMode
|
|
94
|
+
style?: MenuStyle
|
|
95
|
+
statusBarStyle?: StatusBarStyle
|
|
77
96
|
category?: string
|
|
78
97
|
background: string[]
|
|
79
98
|
blobs?: string[]
|
|
@@ -82,6 +101,7 @@ export interface ThemeDefinition {
|
|
|
82
101
|
highlight?: string
|
|
83
102
|
surface?: string
|
|
84
103
|
danger?: string
|
|
104
|
+
chat?: NonNullable<Theme['background']['chat']>
|
|
85
105
|
overrides?: DeepPartial<Theme>
|
|
86
106
|
}
|
|
87
107
|
|
|
@@ -125,6 +145,11 @@ export interface RenderOptions extends AssetOptions {
|
|
|
125
145
|
signal?: 0 | 1 | 2 | 3 | 4
|
|
126
146
|
battery?: number
|
|
127
147
|
charging?: boolean
|
|
148
|
+
carrier?: string
|
|
149
|
+
wifi?: boolean
|
|
150
|
+
batteryPercent?: boolean
|
|
151
|
+
style?: MenuStyle
|
|
152
|
+
statusBarStyle?: StatusBarStyle
|
|
128
153
|
reactions?: string[]
|
|
129
154
|
locale?: LocaleCode | (string & {})
|
|
130
155
|
labels?: Partial<MenuLabels>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iqc-maker",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Generator fake chat WhatsApp gaya iPhone (iQC) dengan reply chat, font SF Pro, emoji Apple, dan
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "Generator fake chat WhatsApp gaya iPhone (iQC) dengan reply chat, font SF Pro, emoji Apple, tema bawaan WhatsApp iOS, dan 88 tema warna yang bisa dikustom penuh.",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"module": "./index.mjs",
|
|
7
7
|
"types": "./index.d.ts",
|
package/src/constants.js
CHANGED
|
@@ -32,6 +32,29 @@ const LAYOUT = Object.freeze({
|
|
|
32
32
|
{ y: 1035, key: 'more', icon: 'more' },
|
|
33
33
|
],
|
|
34
34
|
},
|
|
35
|
+
native: {
|
|
36
|
+
menu: {
|
|
37
|
+
top: 20, x: 26, w: 372, r: 20, rowH: 64, gap: 12,
|
|
38
|
+
labelX: 50, iconCx: 357, fontSize: 21.5, weight: 'regular',
|
|
39
|
+
rows: [
|
|
40
|
+
{ key: 'reply', icon: 'reply' },
|
|
41
|
+
{ key: 'forward', icon: 'forward' },
|
|
42
|
+
{ key: 'copy', icon: 'copy' },
|
|
43
|
+
{ key: 'star', icon: 'star' },
|
|
44
|
+
{ key: 'delete', icon: 'trash', danger: true },
|
|
45
|
+
],
|
|
46
|
+
more: { key: 'more', icon: 'more' },
|
|
47
|
+
},
|
|
48
|
+
chat: [
|
|
49
|
+
['outgoing', 318, 128, 272, 160],
|
|
50
|
+
['incoming', 6, 318, 220, 40],
|
|
51
|
+
['incoming', 6, 378, 480, 84],
|
|
52
|
+
['outgoing', 88, 492, 502, 172],
|
|
53
|
+
['incoming', 6, 690, 250, 40],
|
|
54
|
+
['outgoing', 390, 760, 200, 280],
|
|
55
|
+
['incoming', 6, 1066, 300, 60],
|
|
56
|
+
],
|
|
57
|
+
},
|
|
35
58
|
blobs: [
|
|
36
59
|
{ x: 0, y: 330, w: 350, h: 150, r: 40, blur: 50 },
|
|
37
60
|
{ x: 175, y: 205, w: 385, h: 115, r: 30, blur: 44 },
|
|
@@ -55,8 +78,10 @@ const LOCALES = Object.freeze({
|
|
|
55
78
|
|
|
56
79
|
const DEFAULT_REACTIONS = Object.freeze(['😈', '🥱', '⚡', '🔥', '😒', '😹', '🤭'])
|
|
57
80
|
|
|
81
|
+
const DEFAULT_THEME = 'whatsapp'
|
|
82
|
+
|
|
58
83
|
const DEFAULTS = Object.freeze({
|
|
59
|
-
theme: '
|
|
84
|
+
theme: 'whatsapp',
|
|
60
85
|
locale: 'id',
|
|
61
86
|
network: '4G',
|
|
62
87
|
signal: 4,
|
|
@@ -66,6 +91,9 @@ const DEFAULTS = Object.freeze({
|
|
|
66
91
|
format: 'png',
|
|
67
92
|
quality: 92,
|
|
68
93
|
scale: 1,
|
|
94
|
+
carrier: 'INDOSAT',
|
|
95
|
+
wifi: true,
|
|
96
|
+
batteryPercent: true,
|
|
69
97
|
})
|
|
70
98
|
|
|
71
99
|
const SOURCES = Object.freeze({
|
|
@@ -78,4 +106,4 @@ const SOURCES = Object.freeze({
|
|
|
78
106
|
emoji: 'https://media.githubusercontent.com/media/Ditzzx-vibecoder/entahlah/main/emoji-apple.json',
|
|
79
107
|
})
|
|
80
108
|
|
|
81
|
-
module.exports = { LAYOUT, LOCALES, DEFAULT_REACTIONS, DEFAULTS, SOURCES }
|
|
109
|
+
module.exports = { LAYOUT, LOCALES, DEFAULT_REACTIONS, DEFAULTS, DEFAULT_THEME, SOURCES }
|
package/src/icons.js
CHANGED
|
@@ -26,22 +26,48 @@ const ICONS = {
|
|
|
26
26
|
],
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
const NATIVE_ICONS = {
|
|
30
|
+
reply: [{ d: 'M9 14 4 9l5-5' }, { d: 'M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5 5.5 5.5 0 0 1-5.5 5.5H11' }],
|
|
31
|
+
forward: [{ d: 'm15 14 5-5-5-5' }, { d: 'M20 9H9.5A5.5 5.5 0 0 0 4 14.5 5.5 5.5 0 0 0 9.5 20H13' }],
|
|
32
|
+
copy: [
|
|
33
|
+
{ d: 'M10 8h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2z' },
|
|
34
|
+
{ d: 'M4 16a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2' },
|
|
35
|
+
],
|
|
36
|
+
star: [{ d: 'M12 2.5l2.94 5.96 6.58.96-4.76 4.64 1.12 6.55L12 17.52l-5.88 3.09 1.12-6.55L2.48 9.42l6.58-.96L12 2.5z' }],
|
|
37
|
+
trash: [
|
|
38
|
+
{ d: 'M3 6h18' },
|
|
39
|
+
{ d: 'M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6' },
|
|
40
|
+
{ d: 'M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2' },
|
|
41
|
+
{ d: 'M10 11v6' },
|
|
42
|
+
{ d: 'M14 11v6' },
|
|
43
|
+
],
|
|
44
|
+
more: [
|
|
45
|
+
{ d: 'M3.4 12a1.6 1.6 0 1 0 3.2 0a1.6 1.6 0 1 0-3.2 0z', fill: true },
|
|
46
|
+
{ d: 'M10.4 12a1.6 1.6 0 1 0 3.2 0a1.6 1.6 0 1 0-3.2 0z', fill: true },
|
|
47
|
+
{ d: 'M17.4 12a1.6 1.6 0 1 0 3.2 0a1.6 1.6 0 1 0-3.2 0z', fill: true },
|
|
48
|
+
],
|
|
49
|
+
}
|
|
50
|
+
|
|
29
51
|
const SIZE = { reply: 30, forward: 30, copy: 37, star: 32, trash: 36, more: 32 }
|
|
30
52
|
const STROKE = { default: 2.6, trash: 2.3 }
|
|
53
|
+
const NATIVE_SIZE = { reply: 29, forward: 29, copy: 27, star: 30, trash: 29, more: 30 }
|
|
54
|
+
const NATIVE_STROKE = 2.2
|
|
31
55
|
const cache = new Map()
|
|
32
56
|
|
|
33
|
-
function drawIcon(ctx, name, cx, cy, color) {
|
|
34
|
-
const
|
|
57
|
+
function drawIcon(ctx, name, cx, cy, color, set = 'glass') {
|
|
58
|
+
const native = set === 'native'
|
|
59
|
+
const ops = native ? NATIVE_ICONS[name] : ICONS[name]
|
|
60
|
+
const size = (native ? NATIVE_SIZE[name] : SIZE[name]) || 30
|
|
35
61
|
const k = size / 24
|
|
36
62
|
ctx.save()
|
|
37
63
|
ctx.translate(cx - size / 2, cy - size / 2)
|
|
38
64
|
ctx.scale(k, k)
|
|
39
65
|
ctx.strokeStyle = color
|
|
40
66
|
ctx.fillStyle = color
|
|
41
|
-
ctx.lineWidth = (STROKE[name] || STROKE.default) / k
|
|
67
|
+
ctx.lineWidth = (native ? NATIVE_STROKE : STROKE[name] || STROKE.default) / k
|
|
42
68
|
ctx.lineCap = 'round'
|
|
43
69
|
ctx.lineJoin = 'round'
|
|
44
|
-
for (const op of
|
|
70
|
+
for (const op of ops) {
|
|
45
71
|
let p = cache.get(op.d)
|
|
46
72
|
if (!p) { p = new Path2D(op.d); cache.set(op.d, p) }
|
|
47
73
|
if (op.fill) ctx.fill(p)
|
|
@@ -50,4 +76,4 @@ function drawIcon(ctx, name, cx, cy, color) {
|
|
|
50
76
|
ctx.restore()
|
|
51
77
|
}
|
|
52
78
|
|
|
53
|
-
module.exports = { drawIcon, ICONS }
|
|
79
|
+
module.exports = { drawIcon, ICONS, NATIVE_ICONS }
|
package/src/index.js
CHANGED
|
@@ -82,6 +82,11 @@ class IQC {
|
|
|
82
82
|
signal: o.signal,
|
|
83
83
|
battery: o.battery,
|
|
84
84
|
charging: o.charging,
|
|
85
|
+
carrier: o.carrier,
|
|
86
|
+
wifi: o.wifi,
|
|
87
|
+
batteryPercent: o.batteryPercent,
|
|
88
|
+
style: o.style,
|
|
89
|
+
statusBarStyle: o.statusBarStyle,
|
|
85
90
|
reactions,
|
|
86
91
|
statusBar: o.statusBar,
|
|
87
92
|
reactionBar: o.reactionBar,
|
package/src/render.js
CHANGED
|
@@ -180,6 +180,8 @@ async function makeBackground(theme, timeout) {
|
|
|
180
180
|
;(bg.blobs || []).slice(0, LAYOUT.blobs.length).forEach((color, i) => color && blurBlob(g, LAYOUT.blobs[i], color))
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
+
if (bg.chat && !bg.image) drawFakeChat(g, bg.chat)
|
|
184
|
+
|
|
183
185
|
if (bg.image) {
|
|
184
186
|
const img = await loadInputImage(bg.image, timeout)
|
|
185
187
|
const s = Math.max(W / img.width, H / img.height)
|
|
@@ -198,6 +200,107 @@ async function makeBackground(theme, timeout) {
|
|
|
198
200
|
return c
|
|
199
201
|
}
|
|
200
202
|
|
|
203
|
+
function drawFakeChat(g, chat) {
|
|
204
|
+
const { W, H } = LAYOUT
|
|
205
|
+
const shapes = [
|
|
206
|
+
[chat.header, 0, 0, W, 132, 0],
|
|
207
|
+
[chat.avatar, 98, 58, 46, 46, 23],
|
|
208
|
+
[chat.avatar, 158, 70, 120, 18, 9],
|
|
209
|
+
[chat.accent, 476, 66, 34, 22, 11],
|
|
210
|
+
[chat.accent, 532, 66, 34, 22, 11],
|
|
211
|
+
...LAYOUT.native.chat.map(([type, x, y, w, h]) => [chat[type], x, y, w, h, 20]),
|
|
212
|
+
[chat.header, 0, H - 92, W, 92, 0],
|
|
213
|
+
[chat.avatar, 70, H - 70, 400, 40, 20],
|
|
214
|
+
]
|
|
215
|
+
g.save()
|
|
216
|
+
g.filter = `blur(${chat.blur == null ? 16 : chat.blur}px)`
|
|
217
|
+
for (const [color, x, y, w, h, r] of shapes) {
|
|
218
|
+
if (!color) continue
|
|
219
|
+
g.fillStyle = color
|
|
220
|
+
roundRect(g, x, y, w, h, r)
|
|
221
|
+
g.fill()
|
|
222
|
+
}
|
|
223
|
+
g.restore()
|
|
224
|
+
if (chat.overlay) {
|
|
225
|
+
g.fillStyle = chat.overlay
|
|
226
|
+
g.fillRect(0, 0, W, H)
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function drawWifiClassic(ctx, cx, cy, color) {
|
|
231
|
+
const a0 = Math.PI * 1.25, a1 = Math.PI * 1.75
|
|
232
|
+
ctx.save()
|
|
233
|
+
ctx.fillStyle = color
|
|
234
|
+
ctx.strokeStyle = color
|
|
235
|
+
ctx.beginPath()
|
|
236
|
+
ctx.moveTo(cx, cy)
|
|
237
|
+
ctx.arc(cx, cy, 4.6, a0, a1)
|
|
238
|
+
ctx.closePath()
|
|
239
|
+
ctx.fill()
|
|
240
|
+
ctx.lineWidth = 2.6
|
|
241
|
+
ctx.lineCap = 'butt'
|
|
242
|
+
for (const r of [8.4, 12.8]) {
|
|
243
|
+
ctx.beginPath()
|
|
244
|
+
ctx.arc(cx, cy, r, a0 + 0.04, a1 - 0.04)
|
|
245
|
+
ctx.stroke()
|
|
246
|
+
}
|
|
247
|
+
ctx.restore()
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function drawStatusBarClassic(P, opt) {
|
|
251
|
+
const { ctx, theme: t } = P
|
|
252
|
+
const sb = t.statusBar
|
|
253
|
+
const cy = 31
|
|
254
|
+
const bars = Math.max(0, Math.min(4, Math.round(Number(opt.signal) || 0)))
|
|
255
|
+
const lvl = Math.max(0, Math.min(100, Math.round(Number(opt.battery) || 0)))
|
|
256
|
+
const net = String(opt.network || '')
|
|
257
|
+
const isWifi = net.toLowerCase() === 'wifi'
|
|
258
|
+
|
|
259
|
+
ctx.save()
|
|
260
|
+
;[5, 7.5, 10, 12.5].forEach((h, i) => {
|
|
261
|
+
ctx.fillStyle = i < bars ? sb.text : sb.inactive
|
|
262
|
+
roundRect(ctx, 18 + i * 6.2, cy + 6 - h, 4.4, h, 1.2)
|
|
263
|
+
ctx.fill()
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
ctx.fillStyle = sb.text
|
|
267
|
+
ctx.textBaseline = 'middle'
|
|
268
|
+
ctx.textAlign = 'left'
|
|
269
|
+
const carrier = [opt.carrier, isWifi ? '' : net].filter(Boolean).join(' ')
|
|
270
|
+
if (carrier) P.text(carrier.toUpperCase(), 50, cy + 1, 15.5, 'bold')
|
|
271
|
+
|
|
272
|
+
ctx.textAlign = 'center'
|
|
273
|
+
P.text(String(opt.time), LAYOUT.W / 2, cy, 18.5, 'bold')
|
|
274
|
+
|
|
275
|
+
const bx = 541, bw = 31, bh = 15, by = cy - bh / 2
|
|
276
|
+
const c = sb.battery
|
|
277
|
+
ctx.strokeStyle = c.border
|
|
278
|
+
ctx.lineWidth = 1.3
|
|
279
|
+
roundRect(ctx, bx, by, bw, bh, 4)
|
|
280
|
+
ctx.stroke()
|
|
281
|
+
const fw = (bw - 4) * lvl / 100
|
|
282
|
+
if (fw > 0.5) {
|
|
283
|
+
ctx.fillStyle = opt.charging ? c.charging : lvl <= 20 ? c.low : c.fill
|
|
284
|
+
roundRect(ctx, bx + 2, by + 2, fw, bh - 4, 2.4)
|
|
285
|
+
ctx.fill()
|
|
286
|
+
}
|
|
287
|
+
ctx.fillStyle = c.cap
|
|
288
|
+
roundRect(ctx, bx + bw + 1.5, cy - 3, 2, 6, 1)
|
|
289
|
+
ctx.fill()
|
|
290
|
+
|
|
291
|
+
let right = bx - 8
|
|
292
|
+
if (opt.batteryPercent !== false) {
|
|
293
|
+
ctx.fillStyle = sb.text
|
|
294
|
+
ctx.textAlign = 'right'
|
|
295
|
+
const pct = `${lvl}%`
|
|
296
|
+
P.text(pct, right, cy + 1, 15.5, 'bold')
|
|
297
|
+
ctx.font = P.font(15.5, 'bold')
|
|
298
|
+
right -= ctx.measureText(pct).width + 10
|
|
299
|
+
}
|
|
300
|
+
if (isWifi || opt.wifi) drawWifiClassic(ctx, right - 9, cy + 6, sb.text)
|
|
301
|
+
ctx.restore()
|
|
302
|
+
}
|
|
303
|
+
|
|
201
304
|
function drawWifi(ctx, cx, cy, color) {
|
|
202
305
|
ctx.save()
|
|
203
306
|
ctx.strokeStyle = color
|
|
@@ -253,6 +356,7 @@ function drawBattery(ctx, opt, t) {
|
|
|
253
356
|
|
|
254
357
|
function drawStatusBar(P, opt) {
|
|
255
358
|
const { ctx, theme: t } = P
|
|
359
|
+
if ((opt.statusBarStyle || t.statusBar.style) === 'classic') return drawStatusBarClassic(P, opt)
|
|
256
360
|
const s = LAYOUT.status
|
|
257
361
|
const bars = Math.max(0, Math.min(4, Math.round(Number(opt.signal) || 0)))
|
|
258
362
|
ctx.save()
|
|
@@ -283,8 +387,8 @@ async function drawEmojiBar(P, opt) {
|
|
|
283
387
|
ctx.shadowColor = t.pill.shadow
|
|
284
388
|
ctx.shadowBlur = 16
|
|
285
389
|
ctx.shadowOffsetY = 4
|
|
286
|
-
ctx.fillStyle = t.pill.underlay
|
|
287
|
-
roundRect(ctx, p.x, p.y + 2.5, p.w, p.h, p.r)
|
|
390
|
+
ctx.fillStyle = t.pill.underlay || t.pill.bg
|
|
391
|
+
roundRect(ctx, p.x, p.y + (t.pill.underlay ? 2.5 : 0), p.w, p.h, p.r)
|
|
288
392
|
ctx.fill()
|
|
289
393
|
ctx.restore()
|
|
290
394
|
|
|
@@ -292,10 +396,20 @@ async function drawEmojiBar(P, opt) {
|
|
|
292
396
|
ctx.fillStyle = t.pill.bg
|
|
293
397
|
roundRect(ctx, p.x, p.y, p.w, p.h, p.r)
|
|
294
398
|
ctx.fill()
|
|
399
|
+
if (t.pill.border) {
|
|
400
|
+
ctx.strokeStyle = t.pill.border
|
|
401
|
+
ctx.lineWidth = 1
|
|
402
|
+
roundRect(ctx, p.x + 0.5, p.y + 0.5, p.w - 1, p.h - 1, p.r)
|
|
403
|
+
ctx.stroke()
|
|
404
|
+
}
|
|
295
405
|
ctx.restore()
|
|
296
406
|
|
|
407
|
+
const native = opt.resolvedStyle === 'native'
|
|
297
408
|
const list = (opt.reactions || []).slice(0, p.xs.length)
|
|
298
|
-
for (let i = 0; i < list.length; i++)
|
|
409
|
+
for (let i = 0; i < list.length; i++) {
|
|
410
|
+
if (native) await P.emoji(list[i], 53 + i * 55.5, p.cy, 40)
|
|
411
|
+
else await P.emoji(list[i], p.xs[i], p.cy, p.size)
|
|
412
|
+
}
|
|
299
413
|
|
|
300
414
|
const { cx, cy, r } = p.plus
|
|
301
415
|
ctx.save()
|
|
@@ -397,15 +511,17 @@ async function drawBubble(P, L, by) {
|
|
|
397
511
|
ctx.fill()
|
|
398
512
|
ctx.restore()
|
|
399
513
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
514
|
+
if (t.bubble.tail !== false) {
|
|
515
|
+
ctx.save()
|
|
516
|
+
ctx.fillStyle = t.bubble.bg
|
|
517
|
+
ctx.beginPath()
|
|
518
|
+
ctx.moveTo(b.x + 12, by + L.h - 20)
|
|
519
|
+
ctx.quadraticCurveTo(b.x - 2, by + L.h - 4, b.x - 8, by + L.h)
|
|
520
|
+
ctx.quadraticCurveTo(b.x + 6, by + L.h, b.x + 22, by + L.h - 2)
|
|
521
|
+
ctx.closePath()
|
|
522
|
+
ctx.fill()
|
|
523
|
+
ctx.restore()
|
|
524
|
+
}
|
|
409
525
|
|
|
410
526
|
if (L.img) {
|
|
411
527
|
const { img, iw, ih } = L
|
|
@@ -566,6 +682,75 @@ function drawMenu(P, bg, labels) {
|
|
|
566
682
|
}
|
|
567
683
|
}
|
|
568
684
|
|
|
685
|
+
function drawNativeCard(P, bg, x, y, w, h, r) {
|
|
686
|
+
const { ctx, theme: t } = P
|
|
687
|
+
const c = t.menu
|
|
688
|
+
ctx.save()
|
|
689
|
+
ctx.shadowColor = c.shadow
|
|
690
|
+
ctx.shadowBlur = 30
|
|
691
|
+
ctx.shadowOffsetY = 8
|
|
692
|
+
ctx.fillStyle = c.card
|
|
693
|
+
roundRect(ctx, x, y, w, h, r)
|
|
694
|
+
ctx.fill()
|
|
695
|
+
ctx.restore()
|
|
696
|
+
ctx.save()
|
|
697
|
+
roundRect(ctx, x, y, w, h, r)
|
|
698
|
+
ctx.clip()
|
|
699
|
+
ctx.filter = 'blur(18px)'
|
|
700
|
+
ctx.drawImage(bg, 0, 0)
|
|
701
|
+
ctx.filter = 'none'
|
|
702
|
+
ctx.fillStyle = c.card
|
|
703
|
+
ctx.fillRect(x, y, w, h)
|
|
704
|
+
ctx.restore()
|
|
705
|
+
if (c.cardBorder) {
|
|
706
|
+
ctx.save()
|
|
707
|
+
ctx.strokeStyle = c.cardBorder
|
|
708
|
+
ctx.lineWidth = 1
|
|
709
|
+
roundRect(ctx, x + 0.5, y + 0.5, w - 1, h - 1, r)
|
|
710
|
+
ctx.stroke()
|
|
711
|
+
ctx.restore()
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
function drawNativeMenu(P, bg, labels, top) {
|
|
716
|
+
const { ctx, theme: t } = P
|
|
717
|
+
const n = LAYOUT.native.menu
|
|
718
|
+
const rows = n.rows
|
|
719
|
+
const mainH = rows.length * n.rowH
|
|
720
|
+
const y0 = top
|
|
721
|
+
|
|
722
|
+
drawNativeCard(P, bg, n.x, y0, n.w, mainH, n.r)
|
|
723
|
+
const moreY = y0 + mainH + n.gap
|
|
724
|
+
drawNativeCard(P, bg, n.x, moreY, n.w, n.rowH, n.r)
|
|
725
|
+
|
|
726
|
+
const items = rows.map((row, i) => ({ ...row, cy: y0 + i * n.rowH + n.rowH / 2 }))
|
|
727
|
+
items.push({ ...n.more, cy: moreY + n.rowH / 2 })
|
|
728
|
+
|
|
729
|
+
ctx.save()
|
|
730
|
+
ctx.strokeStyle = t.menu.separator
|
|
731
|
+
ctx.lineWidth = 1
|
|
732
|
+
for (let i = 1; i < rows.length; i++) {
|
|
733
|
+
const ly = Math.round(y0 + i * n.rowH) + 0.5
|
|
734
|
+
ctx.beginPath()
|
|
735
|
+
ctx.moveTo(n.x, ly)
|
|
736
|
+
ctx.lineTo(n.x + n.w, ly)
|
|
737
|
+
ctx.stroke()
|
|
738
|
+
}
|
|
739
|
+
ctx.restore()
|
|
740
|
+
|
|
741
|
+
for (const it of items) {
|
|
742
|
+
const color = it.danger ? t.menu.danger : t.menu.text
|
|
743
|
+
ctx.save()
|
|
744
|
+
ctx.fillStyle = color
|
|
745
|
+
ctx.textAlign = 'left'
|
|
746
|
+
ctx.textBaseline = 'middle'
|
|
747
|
+
const label = P.fit(String(labels[it.key] ?? ''), n.iconCx - n.labelX - 30, n.fontSize, n.weight)
|
|
748
|
+
P.text(label, n.labelX, it.cy + 1, n.fontSize, n.weight)
|
|
749
|
+
ctx.restore()
|
|
750
|
+
drawIcon(ctx, it.icon, n.iconCx, it.cy, it.danger ? t.menu.danger : t.menu.icon, 'native')
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
|
|
569
754
|
async function paint(opt) {
|
|
570
755
|
const { theme, families, emojiMap, labels, image, scale, timeout } = opt
|
|
571
756
|
const { W, H } = LAYOUT
|
|
@@ -576,6 +761,8 @@ async function paint(opt) {
|
|
|
576
761
|
ctx.scale(scale, scale)
|
|
577
762
|
const P = new Painter(ctx, { families, emojiMap, theme })
|
|
578
763
|
|
|
764
|
+
const style = opt.style || theme.style || 'glass'
|
|
765
|
+
opt.resolvedStyle = style
|
|
579
766
|
ctx.drawImage(bg, 0, 0)
|
|
580
767
|
if (opt.statusBar !== false) drawStatusBar(P, opt)
|
|
581
768
|
|
|
@@ -590,7 +777,10 @@ async function paint(opt) {
|
|
|
590
777
|
ctx.restore()
|
|
591
778
|
}
|
|
592
779
|
await drawBubble(P, L, by)
|
|
593
|
-
if (opt.menu !== false)
|
|
780
|
+
if (opt.menu !== false) {
|
|
781
|
+
if (style === 'native') drawNativeMenu(P, bg, labels, LAYOUT.bubble.anchor + LAYOUT.native.menu.top)
|
|
782
|
+
else drawMenu(P, bg, labels)
|
|
783
|
+
}
|
|
594
784
|
return canvas
|
|
595
785
|
}
|
|
596
786
|
|
package/src/themes.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { deepMerge, alpha, mix, lighten, darken, isObject } = require('./utils')
|
|
4
|
+
const { DEFAULT_THEME } = require('./constants')
|
|
4
5
|
|
|
5
6
|
function buildTheme(def = {}) {
|
|
6
7
|
const mode = def.mode === 'dark' ? 'dark' : 'light'
|
|
@@ -18,9 +19,11 @@ function buildTheme(def = {}) {
|
|
|
18
19
|
name: def.name || 'custom',
|
|
19
20
|
label: def.label || def.name || 'Custom',
|
|
20
21
|
mode,
|
|
22
|
+
style: def.style || 'glass',
|
|
21
23
|
category: def.category || 'custom',
|
|
22
|
-
background: { image: null, gradient, blobs },
|
|
24
|
+
background: { image: null, gradient, blobs, chat: def.chat || null },
|
|
23
25
|
statusBar: {
|
|
26
|
+
style: def.statusBarStyle || 'notch',
|
|
24
27
|
text: ink,
|
|
25
28
|
inactive: alpha(ink, 0.3),
|
|
26
29
|
battery: {
|
|
@@ -40,6 +43,7 @@ function buildTheme(def = {}) {
|
|
|
40
43
|
shadow: dark ? 'rgba(0,0,0,0.45)' : alpha(accent, 0.28),
|
|
41
44
|
plusBg: dark ? '#3a3a3c' : '#e7e7e9',
|
|
42
45
|
plusIcon: dark ? '#aeaeb2' : '#7b7b80',
|
|
46
|
+
border: null,
|
|
43
47
|
},
|
|
44
48
|
bubble: {
|
|
45
49
|
bg: surface,
|
|
@@ -48,6 +52,7 @@ function buildTheme(def = {}) {
|
|
|
48
52
|
shadow: dark ? 'rgba(0,0,0,0.35)' : 'rgba(0,0,0,0.08)',
|
|
49
53
|
mediaTimeBg: 'rgba(0,0,0,0.38)',
|
|
50
54
|
mediaTimeText: '#ffffff',
|
|
55
|
+
tail: true,
|
|
51
56
|
},
|
|
52
57
|
reply: {
|
|
53
58
|
bg: dark ? mix(surface, accent, 0.18) : mix(accent, '#ffffff', 0.9),
|
|
@@ -69,6 +74,9 @@ function buildTheme(def = {}) {
|
|
|
69
74
|
icon: ink,
|
|
70
75
|
danger: def.danger || (dark ? '#ff453a' : '#c10b27'),
|
|
71
76
|
divider: dark ? 'rgba(255,255,255,0.15)' : 'rgba(0,0,0,0.15)',
|
|
77
|
+
card: dark ? alpha(mix(surface, '#000000', 0.15), 0.9) : 'rgba(255,255,255,0.88)',
|
|
78
|
+
cardBorder: dark ? 'rgba(255,255,255,0.06)' : 'rgba(0,0,0,0.04)',
|
|
79
|
+
separator: dark ? 'rgba(255,255,255,0.09)' : 'rgba(60,60,67,0.16)',
|
|
72
80
|
},
|
|
73
81
|
}
|
|
74
82
|
return def.overrides ? deepMerge(base, def.overrides) : base
|
|
@@ -79,6 +87,50 @@ const L = (name, label, background, blobs, accent, extra = {}) =>
|
|
|
79
87
|
const D = (name, label, background, blobs, accent, extra = {}) =>
|
|
80
88
|
({ name, label, mode: 'dark', background, blobs, accent, ...extra })
|
|
81
89
|
|
|
90
|
+
const WHATSAPP = [
|
|
91
|
+
D('whatsapp', 'WhatsApp iOS Dark', ['#0b0b0d', '#0b0b0d', '#0b0b0d'], ['#0b0b0d', '#0b0b0d', '#0b0b0d', '#0b0b0d'], '#21c063', {
|
|
92
|
+
style: 'native',
|
|
93
|
+
statusBarStyle: 'classic',
|
|
94
|
+
highlight: 'rgba(0,0,0,0)',
|
|
95
|
+
surface: '#1f1f22',
|
|
96
|
+
danger: '#ff453a',
|
|
97
|
+
chat: {
|
|
98
|
+
header: '#151517', avatar: '#2c2c2e', accent: '#163a5c',
|
|
99
|
+
incoming: '#2a2a2d', outgoing: '#0d4a3e', blur: 16, overlay: 'rgba(0,0,0,0.38)',
|
|
100
|
+
},
|
|
101
|
+
overrides: {
|
|
102
|
+
statusBar: { battery: { fill: '#ffffff', charging: '#34c759', border: 'rgba(255,255,255,0.55)', cap: 'rgba(255,255,255,0.55)' } },
|
|
103
|
+
pill: { bg: '#1c1c1e', underlay: null, shadow: 'rgba(0,0,0,0.5)', plusBg: '#3a3a3c', plusIcon: '#c7c7cc', border: 'rgba(255,255,255,0.08)' },
|
|
104
|
+
bubble: { bg: '#1f1f22', text: '#ffffff', time: '#8d8d92', shadow: 'rgba(0,0,0,0.3)', tail: false },
|
|
105
|
+
reply: { bg: '#2a2a2e', bar: '#21c063', name: '#21c063', text: '#a8a8ad' },
|
|
106
|
+
menu: {
|
|
107
|
+
card: 'rgba(30,30,32,0.9)', cardBorder: 'rgba(255,255,255,0.06)', separator: 'rgba(255,255,255,0.09)',
|
|
108
|
+
text: '#ffffff', icon: '#ffffff', danger: '#ff453a', shadow: 'rgba(0,0,0,0.55)',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
}),
|
|
112
|
+
L('whatsapp-light', 'WhatsApp iOS Light', ['#f2ede6', '#f2ede6', '#f2ede6'], ['#f2ede6', '#f2ede6', '#f2ede6', '#f2ede6'], '#1fa855', {
|
|
113
|
+
style: 'native',
|
|
114
|
+
statusBarStyle: 'classic',
|
|
115
|
+
highlight: 'rgba(0,0,0,0)',
|
|
116
|
+
danger: '#ff3b30',
|
|
117
|
+
chat: {
|
|
118
|
+
header: '#f7f7f7', avatar: '#d1d1d6', accent: '#b9d7f5',
|
|
119
|
+
incoming: '#ffffff', outgoing: '#d6f5cc', blur: 16, overlay: 'rgba(255,255,255,0.2)',
|
|
120
|
+
},
|
|
121
|
+
overrides: {
|
|
122
|
+
statusBar: { battery: { fill: '#000000', charging: '#34c759' } },
|
|
123
|
+
pill: { bg: '#ffffff', underlay: null, shadow: 'rgba(0,0,0,0.12)', plusBg: '#ececee', plusIcon: '#6d6d72', border: 'rgba(0,0,0,0.05)' },
|
|
124
|
+
bubble: { bg: '#ffffff', text: '#000000', time: '#8a8a8e', shadow: 'rgba(0,0,0,0.08)', tail: false },
|
|
125
|
+
reply: { bg: '#f1f1f3', bar: '#1fa855', name: '#1fa855', text: '#6b6b70' },
|
|
126
|
+
menu: {
|
|
127
|
+
card: 'rgba(255,255,255,0.92)', cardBorder: 'rgba(0,0,0,0.04)', separator: 'rgba(60,60,67,0.16)',
|
|
128
|
+
text: '#000000', icon: '#000000', danger: '#ff3b30', shadow: 'rgba(0,0,0,0.12)',
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
}),
|
|
132
|
+
]
|
|
133
|
+
|
|
82
134
|
const COLORS = [
|
|
83
135
|
L('blue', 'Blue', ['#e8f4fa', '#d4ebf8', '#bfe0f6'], ['#5dade2', '#85c1e9', '#3498db', '#2e86c1'], '#3a8ee6', { underlay: '#b6dff4' }),
|
|
84
136
|
L('pink', 'Pink', ['#fdeef4', '#fadbe8', '#f7c8dc'], ['#f48fb1', '#f8bbd0', '#ec407a', '#d81b60'], '#e84a8a', { underlay: '#f8cfe0' }),
|
|
@@ -172,6 +224,7 @@ function darkVariant(def) {
|
|
|
172
224
|
}
|
|
173
225
|
|
|
174
226
|
const DEFINITIONS = [
|
|
227
|
+
...WHATSAPP.map(d => ({ ...d, category: 'whatsapp' })),
|
|
175
228
|
...COLORS.map(d => ({ ...d, category: 'colors' })),
|
|
176
229
|
...COLORS.filter(d => !['white', 'gray', 'silver'].includes(d.name)).map(darkVariant),
|
|
177
230
|
...MONO_DARK.map(d => ({ ...d, category: 'dark' })),
|
|
@@ -186,7 +239,9 @@ const ALIASES = new Map(Object.entries({
|
|
|
186
239
|
'merah-muda': 'pink', coklat: 'brown', cokelat: 'brown', abu: 'gray', 'abu-abu': 'gray', grey: 'gray', putih: 'white',
|
|
187
240
|
hitam: 'black', item: 'black', gelap: 'dark', emas: 'gold', perak: 'silver', laut: 'ocean', langit: 'sky', pantai: 'beach',
|
|
188
241
|
hutan: 'forest', gurun: 'desert', gunung: 'volcano', senja: 'sunset', fajar: 'sunrise', malam: 'midnight', galaksi: 'galaxy',
|
|
189
|
-
default: '
|
|
242
|
+
default: 'whatsapp', bawaan: 'whatsapp', wa: 'whatsapp', 'wa-dark': 'whatsapp', 'whatsapp-dark': 'whatsapp',
|
|
243
|
+
'wa-light': 'whatsapp-light', 'wa-terang': 'whatsapp-light', 'whatsapp-terang': 'whatsapp-light',
|
|
244
|
+
light: 'white', ios: 'dark', violet: 'purple', rose: 'rosegold',
|
|
190
245
|
}))
|
|
191
246
|
|
|
192
247
|
const normalize = name => String(name || '').trim().toLowerCase().replace(/[\s_]+/g, '-')
|
|
@@ -206,9 +261,9 @@ function resolveName(name) {
|
|
|
206
261
|
function getTheme(theme, overrides) {
|
|
207
262
|
let base
|
|
208
263
|
if (isObject(theme)) {
|
|
209
|
-
base = theme.background && Array.isArray(theme.background) ? buildTheme(theme) : deepMerge(THEMES.get(
|
|
264
|
+
base = theme.background && Array.isArray(theme.background) ? buildTheme(theme) : deepMerge(THEMES.get(DEFAULT_THEME), theme)
|
|
210
265
|
} else {
|
|
211
|
-
const key = resolveName(theme ||
|
|
266
|
+
const key = resolveName(theme || DEFAULT_THEME)
|
|
212
267
|
if (!key) throw new RangeError(`[iqc-maker] Tema "${theme}" tidak ditemukan. Lihat listThemes().`)
|
|
213
268
|
base = THEMES.get(key)
|
|
214
269
|
}
|
|
@@ -218,7 +273,7 @@ function getTheme(theme, overrides) {
|
|
|
218
273
|
function registerTheme(name, theme) {
|
|
219
274
|
const key = normalize(name)
|
|
220
275
|
if (!key) throw new TypeError('[iqc-maker] Nama tema wajib diisi')
|
|
221
|
-
const built = isObject(theme) && Array.isArray(theme.background) ? buildTheme({ ...theme, name: key }) : deepMerge(getTheme(theme
|
|
276
|
+
const built = isObject(theme) && Array.isArray(theme.background) ? buildTheme({ ...theme, name: key }) : deepMerge(getTheme(theme && theme.extends ? theme.extends : DEFAULT_THEME), theme, { name: key })
|
|
222
277
|
delete built.extends
|
|
223
278
|
THEMES.set(key, built)
|
|
224
279
|
return built
|