iqc-maker 0.0.0-stage → 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/src/themes.js ADDED
@@ -0,0 +1,292 @@
1
+ 'use strict'
2
+
3
+ const { deepMerge, alpha, mix, lighten, darken, isObject } = require('./utils')
4
+ const { DEFAULT_THEME } = require('./constants')
5
+
6
+ function buildTheme(def = {}) {
7
+ const mode = def.mode === 'dark' ? 'dark' : 'light'
8
+ const dark = mode === 'dark'
9
+ const accent = def.accent || (dark ? '#0a84ff' : '#3a8ee6')
10
+ const gradient = def.background || (dark ? ['#000000', '#0b0b0c', '#141416'] : ['#f4f5f7', '#e9ebee', '#dfe2e6'])
11
+ const highlight = def.highlight || (dark ? 'rgba(255,255,255,0.05)' : 'rgba(255,255,255,0.9)')
12
+ const blobs = def.blobs ? [...def.blobs] : [lighten(accent, 0.3), lighten(accent, 0.5), accent, darken(accent, 0.15)]
13
+ if (blobs.length < 5) blobs.unshift(highlight)
14
+
15
+ const ink = dark ? '#ffffff' : '#000000'
16
+ const surface = def.surface || (dark ? '#262628' : '#ffffff')
17
+
18
+ const base = {
19
+ name: def.name || 'custom',
20
+ label: def.label || def.name || 'Custom',
21
+ mode,
22
+ style: def.style || 'glass',
23
+ category: def.category || 'custom',
24
+ background: { image: null, gradient, blobs, chat: def.chat || null },
25
+ statusBar: {
26
+ style: def.statusBarStyle || 'notch',
27
+ text: ink,
28
+ inactive: alpha(ink, 0.3),
29
+ battery: {
30
+ body: alpha(ink, 0.035),
31
+ border: alpha(ink, 0.5),
32
+ cap: alpha(ink, 0.45),
33
+ fill: ink,
34
+ low: dark ? '#ff453a' : '#ff3b30',
35
+ charging: dark ? '#30d158' : '#34c759',
36
+ bolt: '#ffffff',
37
+ boltStroke: 'rgba(0,0,0,0.55)',
38
+ },
39
+ },
40
+ pill: {
41
+ bg: dark ? '#2c2c2e' : '#ffffff',
42
+ underlay: def.underlay || (dark ? alpha(accent, 0.35) : mix(accent, '#ffffff', 0.68)),
43
+ shadow: dark ? 'rgba(0,0,0,0.45)' : alpha(accent, 0.28),
44
+ plusBg: dark ? '#3a3a3c' : '#e7e7e9',
45
+ plusIcon: dark ? '#aeaeb2' : '#7b7b80',
46
+ border: null,
47
+ },
48
+ bubble: {
49
+ bg: surface,
50
+ text: ink,
51
+ time: dark ? '#8e8e93' : '#7d7d82',
52
+ shadow: dark ? 'rgba(0,0,0,0.35)' : 'rgba(0,0,0,0.08)',
53
+ mediaTimeBg: 'rgba(0,0,0,0.38)',
54
+ mediaTimeText: '#ffffff',
55
+ tail: true,
56
+ },
57
+ reply: {
58
+ bg: dark ? mix(surface, accent, 0.18) : mix(accent, '#ffffff', 0.9),
59
+ bar: accent,
60
+ name: dark ? lighten(accent, 0.25) : darken(accent, 0.08),
61
+ text: dark ? '#b5b5ba' : '#5b5b60',
62
+ },
63
+ menu: {
64
+ shadow: dark ? 'rgba(0,0,0,0.45)' : alpha(darken(accent, 0.5), 0.08),
65
+ overlay: dark ? 'rgba(28,28,30,0.62)' : 'rgba(0,0,0,0)',
66
+ tintTop: alpha(accent, 0.02),
67
+ tintBottom: alpha(accent, dark ? 0.08 : 0.1),
68
+ sheen: dark ? 'rgba(255,255,255,0.05)' : 'rgba(255,255,255,0.30)',
69
+ glow: dark ? 'rgba(255,255,255,0.06)' : 'rgba(255,255,255,1)',
70
+ spec: dark ? 'rgba(255,255,255,0.06)' : 'rgba(255,255,255,0.22)',
71
+ rimTop: dark ? 'rgba(255,255,255,0.18)' : 'rgba(255,255,255,0.7)',
72
+ rimBottom: dark ? 'rgba(255,255,255,0.05)' : 'rgba(255,255,255,0.22)',
73
+ text: ink,
74
+ icon: ink,
75
+ danger: def.danger || (dark ? '#ff453a' : '#c10b27'),
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)',
80
+ },
81
+ }
82
+ return def.overrides ? deepMerge(base, def.overrides) : base
83
+ }
84
+
85
+ const L = (name, label, background, blobs, accent, extra = {}) =>
86
+ ({ name, label, mode: 'light', background, blobs, accent, ...extra })
87
+ const D = (name, label, background, blobs, accent, extra = {}) =>
88
+ ({ name, label, mode: 'dark', background, blobs, accent, ...extra })
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
+
134
+ const COLORS = [
135
+ L('blue', 'Blue', ['#e8f4fa', '#d4ebf8', '#bfe0f6'], ['#5dade2', '#85c1e9', '#3498db', '#2e86c1'], '#3a8ee6', { underlay: '#b6dff4' }),
136
+ L('pink', 'Pink', ['#fdeef4', '#fadbe8', '#f7c8dc'], ['#f48fb1', '#f8bbd0', '#ec407a', '#d81b60'], '#e84a8a', { underlay: '#f8cfe0' }),
137
+ L('red', 'Red', ['#fdecec', '#fad4d4', '#f6bcbc'], ['#ef5350', '#f28b82', '#e53935', '#c62828'], '#e53935'),
138
+ L('orange', 'Orange', ['#fff3e6', '#ffe2c4', '#ffd1a3'], ['#ffa726', '#ffcc80', '#fb8c00', '#ef6c00'], '#f57c00'),
139
+ L('yellow', 'Yellow', ['#fffbe6', '#fff3c2', '#ffe999'], ['#ffd54f', '#ffe082', '#fbc02d', '#f9a825'], '#d49b00'),
140
+ L('lime', 'Lime', ['#f7fce8', '#ecf8c8', '#e0f3a6'], ['#c0ca33', '#dce775', '#afb42b', '#9e9d24'], '#8fa31e'),
141
+ L('green', 'Green', ['#eaf7ee', '#d3efdc', '#bce6c9'], ['#66bb6a', '#a5d6a7', '#43a047', '#2e7d32'], '#2e9d4f'),
142
+ L('mint', 'Mint', ['#e9fbf5', '#d0f5e8', '#b6eedb'], ['#4dd0a8', '#99e6cd', '#26b88f', '#1a9c78'], '#1fae86'),
143
+ L('teal', 'Teal', ['#e6f6f6', '#ccecec', '#b2e2e2'], ['#26a69a', '#80cbc4', '#00897b', '#00695c'], '#00897b'),
144
+ L('cyan', 'Cyan', ['#e6fbfd', '#c9f3f9', '#abebf4'], ['#26c6da', '#80deea', '#00acc1', '#00838f'], '#00a5bb'),
145
+ L('navy', 'Navy', ['#e9edf6', '#d3dbed', '#bcc8e3'], ['#5c6bc0', '#9fa8da', '#3949ab', '#1a237e'], '#283593'),
146
+ L('indigo', 'Indigo', ['#eeedfb', '#dcdaf6', '#c9c6f1'], ['#7986cb', '#c5cae9', '#5c6bc0', '#3f51b5'], '#4f5bd5'),
147
+ L('purple', 'Purple', ['#f3ecfa', '#e6d6f5', '#d8c0ef'], ['#ab47bc', '#ce93d8', '#8e24aa', '#6a1b9a'], '#8e44ad'),
148
+ L('lavender', 'Lavender', ['#f5f2fd', '#e9e2fa', '#ddd2f7'], ['#9f8fe6', '#c5b8f2', '#7e6bd6', '#6552c4'], '#7461d1'),
149
+ L('magenta', 'Magenta', ['#fceaf8', '#f8d2f0', '#f3bae8'], ['#e040fb', '#ea80fc', '#d500f9', '#aa00ff'], '#c2185b'),
150
+ L('peach', 'Peach', ['#fff1ea', '#ffe0d1', '#ffcfb8'], ['#ffab91', '#ffccbc', '#ff8a65', '#f4511e'], '#f26b4a'),
151
+ L('brown', 'Brown', ['#f6efe9', '#ecdccf', '#e1c9b5'], ['#a1887f', '#bcaaa4', '#8d6e63', '#6d4c41'], '#795548'),
152
+ L('gray', 'Gray', ['#f4f5f7', '#e7e9ec', '#d9dce1'], ['#9aa0a6', '#c4c7cc', '#80868b', '#5f6368'], '#6b7280'),
153
+ L('white', 'White', ['#ffffff', '#f7f7f8', '#efeff1'], ['#e5e5ea', '#f2f2f7', '#d1d1d6', '#c7c7cc'], '#007aff', { underlay: '#e5e5ea' }),
154
+ L('gold', 'Gold', ['#fbf6e6', '#f4e8c1', '#ecd99a'], ['#d4af37', '#e6c866', '#c19b2e', '#a67c00'], '#b8860b'),
155
+ L('silver', 'Silver', ['#f6f7f9', '#e8ebef', '#dadee4'], ['#b0b8c1', '#d0d5db', '#909aa5', '#717c88'], '#7b8794'),
156
+ L('rosegold', 'Rose Gold', ['#fcefee', '#f6dcd8', '#efc8c1'], ['#e0a899', '#ecc4b9', '#c98b7a', '#b76e5d'], '#b76e79'),
157
+ ]
158
+
159
+ const MONO_DARK = [
160
+ D('black', 'Black', ['#000000', '#0a0a0a', '#121212'], ['#1c1c1e', '#2c2c2e', '#1c1c1e', '#2c2c2e'], '#a1a1a6', { surface: '#1f1f21' }),
161
+ D('dark', 'Dark (iOS)', ['#0b0b0c', '#111113', '#18181b'], ['#1d2a3a', '#232326', '#16324f', '#1c1c1e'], '#0a84ff'),
162
+ D('amoled', 'AMOLED', ['#000000', '#000000', '#000000'], ['#000000', '#000000', '#000000', '#000000'], '#8e8e93', {
163
+ highlight: 'rgba(0,0,0,0)', surface: '#161618', underlay: 'rgba(255,255,255,0.08)',
164
+ }),
165
+ D('graphite', 'Graphite', ['#1a1b1e', '#202125', '#26282c'], ['#3a3c42', '#2f3136', '#45484f', '#33363b'], '#9aa0a6'),
166
+ D('onyx', 'Onyx', ['#050505', '#0d0d0f', '#151518'], ['#2a2a2e', '#1e1e22', '#38383d', '#242428'], '#c7c7cc'),
167
+ ]
168
+
169
+ const EARTH = [
170
+ L('ocean', 'Ocean', ['#e3f4fb', '#c8e8f5', '#a9daf0'], ['#1e88e5', '#4fc3f7', '#0277bd', '#01579b'], '#0277bd', { category: 'earth' }),
171
+ L('sky', 'Sky', ['#f0f8ff', '#dcefff', '#c6e5ff'], ['#90caf9', '#bbdefb', '#64b5f6', '#42a5f5'], '#2196f3', { category: 'earth' }),
172
+ L('sunrise', 'Sunrise', ['#fff6e8', '#ffe6cc', '#ffd6e0'], ['#ffb74d', '#ffe0b2', '#f48fb1', '#ff8a65'], '#f57c4b', { category: 'earth' }),
173
+ L('sunset', 'Sunset', ['#fff0e6', '#ffd9cc', '#f3c6e0'], ['#ff7043', '#ffab91', '#ec407a', '#8e24aa'], '#e8505b', { category: 'earth' }),
174
+ L('beach', 'Beach', ['#fdf8ec', '#f5ecd2', '#d7f0f4'], ['#4dd0e1', '#f3e0a8', '#26c6da', '#e6c27a'], '#00a0b0', { category: 'earth' }),
175
+ L('coral', 'Coral Reef', ['#fff0ee', '#ffdcd6', '#d9f4f2'], ['#ff7f6e', '#ffb3a7', '#26a69a', '#ff5a47'], '#f2604e', { category: 'earth' }),
176
+ L('lagoon', 'Lagoon', ['#e6faf8', '#c7f2ee', '#a6e9e3'], ['#1de9b6', '#64ffda', '#00bfa5', '#00897b'], '#00a99d', { category: 'earth' }),
177
+ L('glacier', 'Glacier', ['#f2fbff', '#e1f5fe', '#cdeefd'], ['#b3e5fc', '#e1f5fe', '#81d4fa', '#4fc3f7'], '#2aa7d9', { category: 'earth' }),
178
+ L('arctic', 'Arctic', ['#f7fbfd', '#ebf3f8', '#dde9f1'], ['#cfd8dc', '#eceff1', '#b0bec5', '#90a4ae'], '#5d8aa8', { category: 'earth' }),
179
+ L('forest', 'Forest', ['#ecf5ec', '#d6e9d4', '#bfdcbc'], ['#558b2f', '#9ccc65', '#33691e', '#1b5e20'], '#2e7d32', { category: 'earth' }),
180
+ L('jungle', 'Jungle', ['#eef8e8', '#d8efcc', '#c0e6ae'], ['#7cb342', '#aed581', '#388e3c', '#00695c'], '#3b8c3a', { category: 'earth' }),
181
+ L('moss', 'Moss', ['#f2f5e9', '#e3eacf', '#d3dfb4'], ['#8a9a5b', '#b5c27f', '#6b7d3a', '#556b2f'], '#5f7a2f', { category: 'earth' }),
182
+ L('matcha', 'Matcha', ['#f3f8ea', '#e4efcf', '#d4e6b3'], ['#9bbf5a', '#c5dc94', '#7ea843', '#5e8a2a'], '#6c9a35', { category: 'earth' }),
183
+ L('meadow', 'Meadow', ['#f4fbe9', '#e5f5cd', '#fff3c2'], ['#9ccc65', '#fff176', '#7cb342', '#ffd54f'], '#689f38', { category: 'earth' }),
184
+ L('spring', 'Spring', ['#f6fcef', '#fce4ec', '#e8f5e9'], ['#a5d6a7', '#f8bbd0', '#81c784', '#f48fb1'], '#43a047', { category: 'earth' }),
185
+ L('sakura', 'Sakura', ['#fff4f7', '#ffe4ec', '#ffd3e0'], ['#f8a5c2', '#ffd1dc', '#f78fb3', '#e66a92'], '#e05a87', { category: 'earth' }),
186
+ L('lavenderfield', 'Lavender Field', ['#f6f2fc', '#e7ddf7', '#eef3e2'], ['#b39ddb', '#d1c4e9', '#9575cd', '#9ccc65'], '#7e57c2', { category: 'earth' }),
187
+ L('sunflower', 'Sunflower', ['#fffbe3', '#fff1b8', '#ffe68c'], ['#ffca28', '#ffe57f', '#ffb300', '#8d6e63'], '#e09b00', { category: 'earth' }),
188
+ L('autumn', 'Autumn', ['#fdf3e7', '#f8e0c4', '#f2cba0'], ['#e67e22', '#f0b27a', '#c0392b', '#a04000'], '#c4561b', { category: 'earth' }),
189
+ L('desert', 'Desert', ['#fbf4e8', '#f3e3c7', '#eacfa3'], ['#d7a86e', '#ecd2a6', '#c18f4f', '#a0703a'], '#b07a3b', { category: 'earth' }),
190
+ L('savanna', 'Savanna', ['#fbf6e3', '#f2e6bd', '#e8d597'], ['#d4b04a', '#e9d48a', '#b8913a', '#8d6e2f'], '#a8862b', { category: 'earth' }),
191
+ L('canyon', 'Canyon', ['#fbeee6', '#f3d6c3', '#eabd9f'], ['#d35400', '#e59866', '#a04000', '#7e3b1c'], '#b5501f', { category: 'earth' }),
192
+ L('earth', 'Earth', ['#f5f0e8', '#e6dccb', '#dde6d0'], ['#8d6e63', '#a5d6a7', '#6d4c41', '#558b2f'], '#6d5a3f', { category: 'earth' }),
193
+ L('clay', 'Clay', ['#f9efea', '#efdbd0', '#e4c6b6'], ['#c97b5a', '#e0ab92', '#b0613e', '#8f4a2c'], '#a65a3a', { category: 'earth' }),
194
+ L('stone', 'Stone', ['#f3f2ef', '#e4e2dd', '#d5d2cb'], ['#a8a29e', '#d6d3d1', '#8c8580', '#6f6964'], '#78716c', { category: 'earth' }),
195
+ L('mocha', 'Mocha', ['#f5eee8', '#e7d8cc', '#d9c2b0'], ['#a47551', '#c9a789', '#8b5e3c', '#6f4a2f'], '#7b5236', { category: 'earth' }),
196
+ L('cherry', 'Cherry', ['#fdebef', '#f9d0d9', '#f4b5c3'], ['#d81b60', '#f06292', '#ad1457', '#880e4f'], '#c2185b', { category: 'earth' }),
197
+ L('grape', 'Grape', ['#f4ebf7', '#e6d2ee', '#d8b9e5'], ['#8e44ad', '#bb8fce', '#6c3483', '#512e5f'], '#7d3c98', { category: 'earth' }),
198
+ L('lemon', 'Lemon', ['#fffde8', '#fff9c4', '#fff59d'], ['#fff176', '#fff9c4', '#ffee58', '#c0ca33'], '#b5a600', { category: 'earth' }),
199
+ L('rainbow', 'Rainbow', ['#fff0f0', '#f0f7ff', '#f3fff0'], ['#ff8a80', '#ffd180', '#80d8ff', '#b388ff'], '#7c4dff', { category: 'earth' }),
200
+ D('aurora', 'Aurora', ['#04121a', '#071d26', '#0b1830'], ['#00e5a0', '#2979ff', '#7c4dff', '#00bfa5'], '#1de9b6', { category: 'earth' }),
201
+ D('galaxy', 'Galaxy', ['#0a0614', '#120a24', '#1a0e33'], ['#7c4dff', '#e040fb', '#3d5afe', '#651fff'], '#b388ff', { category: 'earth' }),
202
+ D('midnight', 'Midnight', ['#050a18', '#0a1228', '#0e1a38'], ['#1a237e', '#283593', '#0d47a1', '#1a2a6c'], '#5c8dff', { category: 'earth' }),
203
+ D('twilight', 'Twilight', ['#120d24', '#1c1436', '#2a1b46'], ['#5e35b1', '#ec407a', '#3949ab', '#8e24aa'], '#b388ff', { category: 'earth' }),
204
+ D('volcano', 'Volcano', ['#120605', '#1c0a07', '#26100a'], ['#ff3d00', '#ff6e40', '#dd2c00', '#bf360c'], '#ff6e40', { category: 'earth' }),
205
+ D('deepsea', 'Deep Sea', ['#020d16', '#041a2a', '#06253b'], ['#006064', '#00838f', '#01579b', '#004d40'], '#26c6da', { category: 'earth' }),
206
+ D('nightforest', 'Night Forest', ['#06110a', '#0a1a10', '#0f2416'], ['#1b5e20', '#2e7d32', '#004d40', '#33691e'], '#66bb6a', { category: 'earth' }),
207
+ D('storm', 'Storm', ['#0d1014', '#141a20', '#1b232b'], ['#37474f', '#546e7a', '#263238', '#455a64'], '#90a4ae', { category: 'earth' }),
208
+ D('eclipse', 'Eclipse', ['#000000', '#0b0704', '#140c06'], ['#ff9100', '#3e2723', '#ff6d00', '#1a1a1a'], '#ffab40', { category: 'earth' }),
209
+ D('nebula', 'Nebula', ['#0d0718', '#170b26', '#200f34'], ['#ff4081', '#7c4dff', '#f50057', '#536dfe'], '#ff80ab', { category: 'earth' }),
210
+ ]
211
+
212
+ function darkVariant(def) {
213
+ const a = def.accent
214
+ return {
215
+ name: 'dark-' + def.name,
216
+ label: 'Dark ' + def.label,
217
+ mode: 'dark',
218
+ category: 'colors-dark',
219
+ accent: lighten(a, 0.12),
220
+ background: [mix(a, '#000000', 0.94), mix(a, '#000000', 0.9), mix(a, '#000000', 0.85)],
221
+ blobs: def.blobs.map(c => alpha(c, 0.32)),
222
+ surface: mix(a, '#1c1c1e', 0.9),
223
+ }
224
+ }
225
+
226
+ const DEFINITIONS = [
227
+ ...WHATSAPP.map(d => ({ ...d, category: 'whatsapp' })),
228
+ ...COLORS.map(d => ({ ...d, category: 'colors' })),
229
+ ...COLORS.filter(d => !['white', 'gray', 'silver'].includes(d.name)).map(darkVariant),
230
+ ...MONO_DARK.map(d => ({ ...d, category: 'dark' })),
231
+ ...EARTH,
232
+ ]
233
+
234
+ const THEMES = new Map(DEFINITIONS.map(d => [d.name, buildTheme(d)]))
235
+
236
+ const ALIASES = new Map(Object.entries({
237
+ biru: 'blue', 'biru-tua': 'navy', 'biru-muda': 'sky', merah: 'red', jingga: 'orange', oren: 'orange', oranye: 'orange',
238
+ kuning: 'yellow', hijau: 'green', 'hijau-muda': 'mint', tosca: 'teal', toska: 'teal', ungu: 'purple', lembayung: 'lavender',
239
+ 'merah-muda': 'pink', coklat: 'brown', cokelat: 'brown', abu: 'gray', 'abu-abu': 'gray', grey: 'gray', putih: 'white',
240
+ hitam: 'black', item: 'black', gelap: 'dark', emas: 'gold', perak: 'silver', laut: 'ocean', langit: 'sky', pantai: 'beach',
241
+ hutan: 'forest', gurun: 'desert', gunung: 'volcano', senja: 'sunset', fajar: 'sunrise', malam: 'midnight', galaksi: 'galaxy',
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',
245
+ }))
246
+
247
+ const normalize = name => String(name || '').trim().toLowerCase().replace(/[\s_]+/g, '-')
248
+
249
+ function resolveName(name) {
250
+ const n = normalize(name)
251
+ if (THEMES.has(n)) return n
252
+ if (ALIASES.has(n)) return ALIASES.get(n)
253
+ const m = n.match(/^(?:dark|gelap)-(.+)$/) || n.match(/^(.+)-(?:dark|gelap)$/)
254
+ if (m) {
255
+ const inner = ALIASES.get(m[1]) || m[1]
256
+ if (THEMES.has('dark-' + inner)) return 'dark-' + inner
257
+ }
258
+ return null
259
+ }
260
+
261
+ function getTheme(theme, overrides) {
262
+ let base
263
+ if (isObject(theme)) {
264
+ base = theme.background && Array.isArray(theme.background) ? buildTheme(theme) : deepMerge(THEMES.get(DEFAULT_THEME), theme)
265
+ } else {
266
+ const key = resolveName(theme || DEFAULT_THEME)
267
+ if (!key) throw new RangeError(`[iqc-maker] Tema "${theme}" tidak ditemukan. Lihat listThemes().`)
268
+ base = THEMES.get(key)
269
+ }
270
+ return overrides ? deepMerge(base, overrides) : deepMerge(base)
271
+ }
272
+
273
+ function registerTheme(name, theme) {
274
+ const key = normalize(name)
275
+ if (!key) throw new TypeError('[iqc-maker] Nama tema wajib diisi')
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 })
277
+ delete built.extends
278
+ THEMES.set(key, built)
279
+ return built
280
+ }
281
+
282
+ function createTheme(base, overrides) {
283
+ return getTheme(base, overrides)
284
+ }
285
+
286
+ function listThemes(filter) {
287
+ const all = [...THEMES.values()].map(t => ({ name: t.name, label: t.label, mode: t.mode, category: t.category }))
288
+ if (!filter) return all
289
+ return all.filter(t => t.category === filter || t.mode === filter)
290
+ }
291
+
292
+ module.exports = { buildTheme, getTheme, createTheme, registerTheme, listThemes, resolveName, THEMES, ALIASES }
package/src/utils.js ADDED
@@ -0,0 +1,60 @@
1
+ 'use strict'
2
+
3
+ const isObject = v => v !== null && typeof v === 'object' && !Array.isArray(v) && !Buffer.isBuffer(v)
4
+
5
+ function deepMerge(target, ...sources) {
6
+ const out = isObject(target) ? { ...target } : {}
7
+ for (const src of sources) {
8
+ if (!isObject(src)) continue
9
+ for (const [k, v] of Object.entries(src)) {
10
+ if (v === undefined) continue
11
+ out[k] = isObject(v) && isObject(out[k]) ? deepMerge(out[k], v) : Array.isArray(v) ? [...v] : v
12
+ }
13
+ }
14
+ return out
15
+ }
16
+
17
+ function parseColor(input) {
18
+ const s = String(input).trim().toLowerCase()
19
+ if (s.startsWith('#')) {
20
+ let h = s.slice(1)
21
+ if (h.length === 3 || h.length === 4) h = [...h].map(c => c + c).join('')
22
+ const n = parseInt(h.slice(0, 6), 16)
23
+ const a = h.length === 8 ? parseInt(h.slice(6, 8), 16) / 255 : 1
24
+ return { r: (n >> 16) & 255, g: (n >> 8) & 255, b: n & 255, a }
25
+ }
26
+ const m = s.match(/^rgba?\(([^)]+)\)$/)
27
+ if (m) {
28
+ const [r, g, b, a = 1] = m[1].split(/[\s,/]+/).filter(Boolean).map(Number)
29
+ return { r, g, b, a }
30
+ }
31
+ throw new TypeError(`[iqc-maker] Warna tidak valid: ${input}`)
32
+ }
33
+
34
+ const clamp = (v, min, max) => Math.min(max, Math.max(min, v))
35
+ const hex2 = v => Math.round(clamp(v, 0, 255)).toString(16).padStart(2, '0')
36
+
37
+ function toHex({ r, g, b }) {
38
+ return `#${hex2(r)}${hex2(g)}${hex2(b)}`
39
+ }
40
+
41
+ function alpha(color, a) {
42
+ const c = parseColor(color)
43
+ return `rgba(${c.r},${c.g},${c.b},${+(clamp(a, 0, 1) * c.a).toFixed(3)})`
44
+ }
45
+
46
+ function mix(a, b, t) {
47
+ const x = parseColor(a), y = parseColor(b)
48
+ return toHex({ r: x.r + (y.r - x.r) * t, g: x.g + (y.g - x.g) * t, b: x.b + (y.b - x.b) * t })
49
+ }
50
+
51
+ const lighten = (c, t) => mix(c, '#ffffff', t)
52
+ const darken = (c, t) => mix(c, '#000000', t)
53
+
54
+ function luminance(color) {
55
+ const { r, g, b } = parseColor(color)
56
+ const f = v => { v /= 255; return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4 }
57
+ return 0.2126 * f(r) + 0.7152 * f(g) + 0.0722 * f(b)
58
+ }
59
+
60
+ module.exports = { isObject, deepMerge, parseColor, toHex, alpha, mix, lighten, darken, luminance, clamp }