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/index.d.ts ADDED
@@ -0,0 +1,222 @@
1
+ /// <reference types="node" />
2
+
3
+ import type { Canvas } from '@napi-rs/canvas'
4
+
5
+ export type ImageSource = Buffer | string
6
+ export type ThemeMode = 'light' | 'dark'
7
+ export type ThemeCategory = 'whatsapp' | 'colors' | 'colors-dark' | 'dark' | 'earth' | 'custom'
8
+ export type OutputFormat = 'png' | 'jpg' | 'jpeg' | 'webp' | 'avif'
9
+ export type MenuStyle = 'native' | 'glass'
10
+ export type StatusBarStyle = 'classic' | 'notch'
11
+ export type LocaleCode = 'id' | 'en' | 'ms' | 'jv' | 'su' | 'es' | 'pt' | 'ar' | 'ja'
12
+
13
+ export type BuiltinThemeName =
14
+ | 'whatsapp' | 'whatsapp-light'
15
+ | 'blue' | 'pink' | 'red' | 'orange' | 'yellow' | 'lime' | 'green' | 'mint' | 'teal' | 'cyan' | 'navy' | 'indigo'
16
+ | 'purple' | 'lavender' | 'magenta' | 'peach' | 'brown' | 'gray' | 'white' | 'gold' | 'silver' | 'rosegold'
17
+ | 'dark-blue' | 'dark-pink' | 'dark-red' | 'dark-orange' | 'dark-yellow' | 'dark-lime' | 'dark-green' | 'dark-mint'
18
+ | 'dark-teal' | 'dark-cyan' | 'dark-navy' | 'dark-indigo' | 'dark-purple' | 'dark-lavender' | 'dark-magenta'
19
+ | 'dark-peach' | 'dark-brown' | 'dark-gold' | 'dark-rosegold'
20
+ | 'black' | 'dark' | 'amoled' | 'graphite' | 'onyx'
21
+ | 'ocean' | 'sky' | 'sunrise' | 'sunset' | 'beach' | 'coral' | 'lagoon' | 'glacier' | 'arctic' | 'forest' | 'jungle'
22
+ | 'moss' | 'matcha' | 'meadow' | 'spring' | 'sakura' | 'lavenderfield' | 'sunflower' | 'autumn' | 'desert' | 'savanna'
23
+ | 'canyon' | 'earth' | 'clay' | 'stone' | 'mocha' | 'cherry' | 'grape' | 'lemon' | 'rainbow'
24
+ | 'aurora' | 'galaxy' | 'midnight' | 'twilight' | 'volcano' | 'deepsea' | 'nightforest' | 'storm' | 'eclipse' | 'nebula'
25
+
26
+ export type ThemeName = BuiltinThemeName | (string & {})
27
+
28
+ export interface Theme {
29
+ name: string
30
+ label: string
31
+ mode: ThemeMode
32
+ style: MenuStyle
33
+ category: ThemeCategory | string
34
+ background: {
35
+ image: ImageSource | null
36
+ gradient: string[]
37
+ blobs: string[]
38
+ solid?: string
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
49
+ }
50
+ statusBar: {
51
+ style: StatusBarStyle
52
+ text: string
53
+ inactive: string
54
+ battery: {
55
+ body: string
56
+ border: string
57
+ cap: string
58
+ fill: string
59
+ low: string
60
+ charging: string
61
+ bolt: string
62
+ boltStroke: string
63
+ }
64
+ }
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 }
67
+ reply: { bg: string; bar: string; name: string; text: string }
68
+ menu: {
69
+ shadow: string
70
+ overlay: string
71
+ tintTop: string
72
+ tintBottom: string
73
+ sheen: string
74
+ glow: string
75
+ spec: string
76
+ rimTop: string
77
+ rimBottom: string
78
+ text: string
79
+ icon: string
80
+ danger: string
81
+ divider: string
82
+ card: string
83
+ cardBorder: string | null
84
+ separator: string
85
+ }
86
+ }
87
+
88
+ export type DeepPartial<T> = { [K in keyof T]?: T[K] extends object ? (T[K] extends any[] ? T[K] : DeepPartial<T[K]>) : T[K] }
89
+
90
+ export interface ThemeDefinition {
91
+ name?: string
92
+ label?: string
93
+ mode?: ThemeMode
94
+ style?: MenuStyle
95
+ statusBarStyle?: StatusBarStyle
96
+ category?: string
97
+ background: string[]
98
+ blobs?: string[]
99
+ accent?: string
100
+ underlay?: string
101
+ highlight?: string
102
+ surface?: string
103
+ danger?: string
104
+ chat?: NonNullable<Theme['background']['chat']>
105
+ overrides?: DeepPartial<Theme>
106
+ }
107
+
108
+ export type ThemeInput = ThemeName | ThemeDefinition | DeepPartial<Theme>
109
+
110
+ export interface MenuLabels {
111
+ reply: string
112
+ forward: string
113
+ copy: string
114
+ star: string
115
+ delete: string
116
+ more: string
117
+ }
118
+
119
+ export interface ReplyInput {
120
+ name?: string
121
+ text?: string
122
+ color?: string
123
+ }
124
+
125
+ export interface AssetOptions {
126
+ cacheDir?: string
127
+ fonts?: { regular?: ImageSource; semibold?: ImageSource; bold?: ImageSource }
128
+ emoji?: string | Buffer | Record<string, string> | false
129
+ offline?: boolean
130
+ timeout?: number
131
+ logger?: ((message: string) => void) | false | null
132
+ }
133
+
134
+ export interface RenderOptions extends AssetOptions {
135
+ text?: string
136
+ image?: ImageSource | null
137
+ reply?: ReplyInput | null
138
+ theme?: ThemeInput
139
+ colors?: DeepPartial<Theme>
140
+ background?: ImageSource | DeepPartial<Theme['background']>
141
+ time?: string
142
+ bubbleTime?: string
143
+ timeZone?: string
144
+ network?: '4G' | '5G' | 'LTE' | '3G' | 'E' | 'wifi' | '' | (string & {})
145
+ signal?: 0 | 1 | 2 | 3 | 4
146
+ battery?: number
147
+ charging?: boolean
148
+ carrier?: string
149
+ wifi?: boolean
150
+ batteryPercent?: boolean
151
+ style?: MenuStyle
152
+ statusBarStyle?: StatusBarStyle
153
+ reactions?: string[]
154
+ locale?: LocaleCode | (string & {})
155
+ labels?: Partial<MenuLabels>
156
+ statusBar?: boolean
157
+ reactionBar?: boolean
158
+ menu?: boolean
159
+ format?: OutputFormat
160
+ quality?: number
161
+ scale?: number
162
+ output?: 'buffer' | 'canvas'
163
+ }
164
+
165
+ export interface PreloadResult {
166
+ fonts: { regular: boolean; semibold: boolean; bold: boolean; fallback: boolean }
167
+ emoji: number
168
+ cacheDir: string
169
+ }
170
+
171
+ export interface ThemeInfo {
172
+ name: string
173
+ label: string
174
+ mode: ThemeMode
175
+ category: string
176
+ }
177
+
178
+ export declare class IQC {
179
+ constructor(options?: RenderOptions)
180
+ options: RenderOptions
181
+ readonly version: string
182
+ preload(options?: AssetOptions): Promise<PreloadResult>
183
+ render(input: string | (RenderOptions & { output: 'canvas' })): Promise<Canvas>
184
+ render(input: string | RenderOptions): Promise<Buffer>
185
+ }
186
+
187
+ export declare function render(input: RenderOptions & { output: 'canvas' }): Promise<Canvas>
188
+ export declare function render(input: string | RenderOptions): Promise<Buffer>
189
+ export declare function preload(options?: AssetOptions): Promise<PreloadResult>
190
+ export declare function configure(options: RenderOptions): IQC
191
+ export declare function getTheme(theme?: ThemeInput, overrides?: DeepPartial<Theme>): Theme
192
+ export declare function createTheme(base: ThemeInput, overrides?: DeepPartial<Theme>): Theme
193
+ export declare function buildTheme(definition: ThemeDefinition): Theme
194
+ export declare function registerTheme(name: string, theme: ThemeDefinition | (DeepPartial<Theme> & { extends?: ThemeName })): Theme
195
+ export declare function listThemes(filter?: ThemeCategory | ThemeMode): ThemeInfo[]
196
+ export declare function resolveTheme(name: string): string | null
197
+ export declare function clearCache(cacheDir?: string): Promise<void>
198
+
199
+ export declare const locales: Readonly<Record<LocaleCode, MenuLabels>>
200
+ export declare const defaultReactions: readonly string[]
201
+ export declare const layout: Readonly<{ W: number; H: number; [key: string]: unknown }>
202
+ export declare const version: string
203
+
204
+ declare const iqc: {
205
+ IQC: typeof IQC
206
+ render: typeof render
207
+ preload: typeof preload
208
+ configure: typeof configure
209
+ getTheme: typeof getTheme
210
+ createTheme: typeof createTheme
211
+ buildTheme: typeof buildTheme
212
+ registerTheme: typeof registerTheme
213
+ listThemes: typeof listThemes
214
+ resolveTheme: typeof resolveTheme
215
+ clearCache: typeof clearCache
216
+ locales: typeof locales
217
+ defaultReactions: typeof defaultReactions
218
+ layout: typeof layout
219
+ version: string
220
+ }
221
+
222
+ export default iqc
package/index.mjs ADDED
@@ -0,0 +1,21 @@
1
+ import iqc from './src/index.js'
2
+
3
+ export const {
4
+ IQC,
5
+ render,
6
+ preload,
7
+ configure,
8
+ getTheme,
9
+ createTheme,
10
+ buildTheme,
11
+ registerTheme,
12
+ listThemes,
13
+ resolveTheme,
14
+ clearCache,
15
+ locales,
16
+ defaultReactions,
17
+ layout,
18
+ version,
19
+ } = iqc
20
+
21
+ export default iqc
package/package.json CHANGED
@@ -1,6 +1,70 @@
1
1
  {
2
2
  "name": "iqc-maker",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
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
+ "main": "./src/index.js",
6
+ "module": "./index.mjs",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./index.d.ts",
11
+ "import": "./index.mjs",
12
+ "require": "./src/index.js"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "files": [
17
+ "src",
18
+ "index.mjs",
19
+ "index.d.ts",
20
+ "README.md",
21
+ "CHANGELOG.md",
22
+ "LICENSE"
23
+ ],
24
+ "scripts": {
25
+ "test": "node test/run.js",
26
+ "preview": "node examples/all-themes.js"
27
+ },
28
+ "keywords": [
29
+ "iqc",
30
+ "iqc-maker",
31
+ "fake-chat",
32
+ "whatsapp",
33
+ "iphone",
34
+ "ios",
35
+ "quote",
36
+ "quoted-chat",
37
+ "canvas",
38
+ "baileys",
39
+ "bot",
40
+ "sticker",
41
+ "maker"
42
+ ],
43
+ "author": "Lynx Decode (https://github.com/Lynxcode-id)",
44
+ "contributors": [
45
+ {
46
+ "name": "Ditzzx",
47
+ "url": "https://github.com/Ditzzx-vibecoder"
48
+ },
49
+ {
50
+ "name": "Lynx Decode",
51
+ "url": "https://github.com/Lynxcode-id"
52
+ }
53
+ ],
54
+ "license": "MIT",
55
+ "repository": {
56
+ "type": "git",
57
+ "url": "git+https://github.com/Lynxcode-id/iqc-maker.git"
58
+ },
59
+ "bugs": {
60
+ "url": "https://github.com/Lynxcode-id/iqc-maker/issues"
61
+ },
62
+ "homepage": "https://github.com/Lynxcode-id/iqc-maker#readme",
63
+ "engines": {
64
+ "node": ">=18.0.0"
65
+ },
66
+ "dependencies": {
67
+ "@napi-rs/canvas": "^0.1.65"
68
+ },
69
+ "sideEffects": false
70
+ }
package/src/assets.js ADDED
@@ -0,0 +1,179 @@
1
+ 'use strict'
2
+
3
+ const os = require('os')
4
+ const { promises: fs, existsSync } = require('fs')
5
+ const { dirname, join, isAbsolute } = require('path')
6
+ const { GlobalFonts, loadImage } = require('@napi-rs/canvas')
7
+ const { SOURCES } = require('./constants')
8
+
9
+ const FAMILY = { regular: 'IQCMakerRegular', semibold: 'IQCMakerSemibold', bold: 'IQCMakerBold' }
10
+ const FALLBACK_FAMILY = 'IQCMakerFallback'
11
+
12
+ const registered = new Set()
13
+ const fontJobs = new Map()
14
+ const emojiJobs = new Map()
15
+ let emojiImages = new WeakMap()
16
+
17
+ const defaultCacheDir = () => process.env.IQC_MAKER_CACHE || join(os.homedir() || os.tmpdir(), '.cache', 'iqc-maker')
18
+ const rawUrl = u => u.replace(/^https?:\/\/github\.com\/([^/]+\/[^/]+)\/blob\//, 'https://raw.githubusercontent.com/$1/')
19
+ const isUrl = v => typeof v === 'string' && /^https?:\/\//i.test(v)
20
+
21
+ async function fetchBuffer(url, timeout = 60000) {
22
+ if (typeof fetch !== 'function') throw new Error('[iqc-maker] Butuh Node.js >= 18 (global fetch)')
23
+ const res = await fetch(rawUrl(url), {
24
+ headers: { 'User-Agent': 'Mozilla/5.0 iqc-maker' },
25
+ redirect: 'follow',
26
+ signal: AbortSignal.timeout(timeout),
27
+ })
28
+ if (!res.ok) throw new Error(`[iqc-maker] ${res.status} ${res.statusText} — ${url}`)
29
+ return Buffer.from(await res.arrayBuffer())
30
+ }
31
+
32
+ async function cachedDownload(url, dest, timeout) {
33
+ if (existsSync(dest)) return dest
34
+ const buf = await fetchBuffer(url, timeout)
35
+ await fs.mkdir(dirname(dest), { recursive: true })
36
+ const tmp = `${dest}.${process.pid}.${Date.now()}.part`
37
+ await fs.writeFile(tmp, buf)
38
+ await fs.rename(tmp, dest)
39
+ return dest
40
+ }
41
+
42
+ function registerFont(path, family) {
43
+ try {
44
+ const key = GlobalFonts.registerFromPath(path, family)
45
+ return Boolean(key) || GlobalFonts.has(family)
46
+ } catch {
47
+ return false
48
+ }
49
+ }
50
+
51
+ async function resolveLocal(src, cacheDir, name, timeout) {
52
+ if (Buffer.isBuffer(src)) {
53
+ const dest = join(cacheDir, 'custom', name)
54
+ await fs.mkdir(dirname(dest), { recursive: true })
55
+ await fs.writeFile(dest, src)
56
+ return dest
57
+ }
58
+ if (isUrl(src)) return cachedDownload(src, join(cacheDir, 'custom', name), timeout)
59
+ return isAbsolute(src) ? src : join(process.cwd(), src)
60
+ }
61
+
62
+ async function loadFonts(opts) {
63
+ const { cacheDir, fonts = {}, offline, timeout, logger } = opts
64
+ const families = {}
65
+
66
+ for (const weight of Object.keys(FAMILY)) {
67
+ const family = `${FAMILY[weight]}_${hashKey(fonts[weight] || 'default')}`
68
+ if (registered.has(family)) { families[weight] = family; continue }
69
+
70
+ if (fonts[weight]) {
71
+ try {
72
+ const p = await resolveLocal(fonts[weight], cacheDir, `${weight}-${hashKey(fonts[weight])}.font`, timeout)
73
+ if (registerFont(p, family)) { registered.add(family); families[weight] = family; continue }
74
+ } catch (e) { logger?.(`font custom ${weight} gagal: ${e.message}`) }
75
+ }
76
+
77
+ const file = SOURCES.fonts[weight]
78
+ const dest = join(cacheDir, 'fonts', file)
79
+ if (existsSync(dest) && registerFont(dest, family)) { registered.add(family); families[weight] = family; continue }
80
+ if (offline) continue
81
+
82
+ for (const base of SOURCES.fontBases) {
83
+ try {
84
+ await cachedDownload(base + file, dest, timeout)
85
+ if (registerFont(dest, family)) { registered.add(family); families[weight] = family; break }
86
+ } catch {}
87
+ await fs.unlink(dest).catch(() => {})
88
+ }
89
+ }
90
+
91
+ if (!families.regular && !registered.has(FALLBACK_FAMILY)) {
92
+ const dest = join(cacheDir, 'fonts', 'Inter-Regular.woff2')
93
+ try {
94
+ if (!existsSync(dest) && !offline) await cachedDownload(SOURCES.fontFallback, dest, timeout)
95
+ if (existsSync(dest) && registerFont(dest, FALLBACK_FAMILY)) registered.add(FALLBACK_FAMILY)
96
+ } catch (e) { logger?.(`font fallback gagal: ${e.message}`) }
97
+ }
98
+
99
+ families.fallback = registered.has(FALLBACK_FAMILY) ? FALLBACK_FAMILY : null
100
+ if (!families.semibold) families.semibold = null
101
+ if (!families.bold) families.bold = null
102
+ return families
103
+ }
104
+
105
+ function ensureFonts(opts) {
106
+ const key = JSON.stringify([opts.cacheDir, Object.entries(opts.fonts || {}).map(([k, v]) => [k, hashKey(v)])])
107
+ if (!fontJobs.has(key)) {
108
+ fontJobs.set(key, loadFonts(opts).catch(e => { fontJobs.delete(key); throw e }))
109
+ }
110
+ return fontJobs.get(key)
111
+ }
112
+
113
+ async function loadEmojiMap(opts) {
114
+ const { cacheDir, emoji, offline, timeout, logger } = opts
115
+ if (emoji === false) return {}
116
+ if (emoji && typeof emoji === 'object' && !Buffer.isBuffer(emoji)) return emoji
117
+ try {
118
+ let buf
119
+ if (Buffer.isBuffer(emoji)) buf = emoji
120
+ else if (typeof emoji === 'string' && !isUrl(emoji)) buf = await fs.readFile(isAbsolute(emoji) ? emoji : join(process.cwd(), emoji))
121
+ else {
122
+ const url = emoji || SOURCES.emoji
123
+ const dest = join(cacheDir, 'emoji', url === SOURCES.emoji ? 'emoji-apple.json' : `emoji-${hashKey(url)}.json`)
124
+ if (!existsSync(dest) && offline) return {}
125
+ buf = await fs.readFile(await cachedDownload(url, dest, Math.max(timeout, 120000)))
126
+ }
127
+ return JSON.parse(buf.toString('utf-8'))
128
+ } catch (e) {
129
+ logger?.(`emoji gagal dimuat, pakai emoji sistem: ${e.message}`)
130
+ return {}
131
+ }
132
+ }
133
+
134
+ function ensureEmoji(opts) {
135
+ const key = typeof opts.emoji === 'object' && opts.emoji ? opts.emoji : `${opts.cacheDir}|${opts.emoji ?? 'default'}`
136
+ if (!emojiJobs.has(key)) emojiJobs.set(key, loadEmojiMap(opts))
137
+ return emojiJobs.get(key)
138
+ }
139
+
140
+ const toCodepoints = e => [...e].map(c => c.codePointAt(0).toString(16).padStart(4, '0')).join('-')
141
+
142
+ async function getEmojiImage(map, emoji) {
143
+ let store = emojiImages.get(map)
144
+ if (!store) { store = new Map(); emojiImages.set(map, store) }
145
+ if (store.has(emoji)) return store.get(emoji)
146
+ const base = toCodepoints(emoji)
147
+ const noFe = base.replace(/-fe0f/gi, '')
148
+ const key = [base, noFe, `${noFe}-fe0f`, base.toUpperCase(), noFe.toUpperCase(), `${noFe.toUpperCase()}-FE0F`].find(k => map[k])
149
+ let img = null
150
+ if (key) {
151
+ try { img = await loadImage(Buffer.from(map[key], 'base64')) } catch { img = null }
152
+ }
153
+ store.set(emoji, img)
154
+ return img
155
+ }
156
+
157
+ async function loadInputImage(src, timeout) {
158
+ if (!src) return null
159
+ if (isUrl(src)) return loadImage(await fetchBuffer(src, timeout))
160
+ return loadImage(src)
161
+ }
162
+
163
+ function hashKey(v) {
164
+ const s = Buffer.isBuffer(v) ? v.subarray(0, 4096).toString('base64') + v.length : String(v)
165
+ let h = 2166136261
166
+ for (let i = 0; i < s.length; i++) { h ^= s.charCodeAt(i); h = Math.imul(h, 16777619) }
167
+ return (h >>> 0).toString(36)
168
+ }
169
+
170
+ async function clearCache(cacheDir = defaultCacheDir()) {
171
+ await fs.rm(cacheDir, { recursive: true, force: true })
172
+ fontJobs.clear()
173
+ emojiJobs.clear()
174
+ emojiImages = new WeakMap()
175
+ }
176
+
177
+ module.exports = {
178
+ defaultCacheDir, ensureFonts, ensureEmoji, getEmojiImage, loadInputImage, fetchBuffer, clearCache,
179
+ }
@@ -0,0 +1,109 @@
1
+ 'use strict'
2
+
3
+ const LAYOUT = Object.freeze({
4
+ W: 590,
5
+ H: 1280,
6
+ status: { x: 80, y: 40 },
7
+ pill: {
8
+ x: 22, y: 517, w: 461, h: 76, r: 38, cy: 555, size: 43, gap: 10,
9
+ xs: [57, 116, 175, 234, 293, 352, 407],
10
+ plus: { cx: 445, cy: 555, r: 24 },
11
+ },
12
+ bubble: {
13
+ x: 18, anchor: 673, r: 20, maxW: 468, maxH: 515, minW: 80,
14
+ padL: 16, padR: 12, padT: 9, padB: 8,
15
+ fontSize: 22.5, lineH: 29, base: 0.35,
16
+ tsSize: 15, tsGap: 12, tsRow: 16, tsLift: 2,
17
+ imgMinW: 240, imgMaxW: 360, imgMinH: 140,
18
+ reply: {
19
+ m: 5, padL: 16, padR: 12, padT: 8, padB: 9, gap: 1, r: 12, barW: 4.5,
20
+ nameSize: 18, nameH: 23, textSize: 17.5, lineH: 22, maxLines: 2,
21
+ },
22
+ },
23
+ menu: {
24
+ x: 22, y: 691, w: 342, h: 385, r: 40, iconCx: 71, labelX: 105, fontSize: 23,
25
+ rows: [
26
+ { y: 732, key: 'reply', icon: 'reply' },
27
+ { y: 787, key: 'forward', icon: 'forward' },
28
+ { y: 842, key: 'copy', icon: 'copy' },
29
+ { y: 898, key: 'star', icon: 'star' },
30
+ { y: 954, key: 'delete', icon: 'trash', danger: true },
31
+ { divider: 994, x1: 55, x2: 332 },
32
+ { y: 1035, key: 'more', icon: 'more' },
33
+ ],
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
+ },
58
+ blobs: [
59
+ { x: 0, y: 330, w: 350, h: 150, r: 40, blur: 50 },
60
+ { x: 175, y: 205, w: 385, h: 115, r: 30, blur: 44 },
61
+ { x: 410, y: 495, w: 180, h: 65, r: 28, blur: 40 },
62
+ { x: 395, y: 640, w: 185, h: 150, r: 40, blur: 44 },
63
+ { x: 405, y: 855, w: 170, h: 95, r: 34, blur: 40 },
64
+ ],
65
+ })
66
+
67
+ const LOCALES = Object.freeze({
68
+ id: { reply: 'Balas', forward: 'Teruskan', copy: 'Salin', star: 'Beri bintang', delete: 'Hapus', more: 'Lainnya...' },
69
+ en: { reply: 'Reply', forward: 'Forward', copy: 'Copy', star: 'Star', delete: 'Delete', more: 'More...' },
70
+ ms: { reply: 'Balas', forward: 'Majukan', copy: 'Salin', star: 'Bintangkan', delete: 'Padam', more: 'Lagi...' },
71
+ jv: { reply: 'Bales', forward: 'Terusna', copy: 'Salin', star: 'Wenehi lintang', delete: 'Busak', more: 'Liyane...' },
72
+ su: { reply: 'Bales', forward: 'Teraskeun', copy: 'Salin', star: 'Béntangan', delete: 'Pupus', more: 'Lianna...' },
73
+ es: { reply: 'Responder', forward: 'Reenviar', copy: 'Copiar', star: 'Destacar', delete: 'Eliminar', more: 'Más...' },
74
+ pt: { reply: 'Responder', forward: 'Encaminhar', copy: 'Copiar', star: 'Favoritar', delete: 'Apagar', more: 'Mais...' },
75
+ ar: { reply: 'رد', forward: 'إعادة توجيه', copy: 'نسخ', star: 'تمييز بنجمة', delete: 'حذف', more: 'المزيد...' },
76
+ ja: { reply: '返信', forward: '転送', copy: 'コピー', star: 'スター', delete: '削除', more: 'その他...' },
77
+ })
78
+
79
+ const DEFAULT_REACTIONS = Object.freeze(['😈', '🥱', '⚡', '🔥', '😒', '😹', '🤭'])
80
+
81
+ const DEFAULT_THEME = 'whatsapp'
82
+
83
+ const DEFAULTS = Object.freeze({
84
+ theme: 'whatsapp',
85
+ locale: 'id',
86
+ network: '4G',
87
+ signal: 4,
88
+ battery: 90,
89
+ charging: true,
90
+ timeZone: 'Asia/Jakarta',
91
+ format: 'png',
92
+ quality: 92,
93
+ scale: 1,
94
+ carrier: 'INDOSAT',
95
+ wifi: true,
96
+ batteryPercent: true,
97
+ })
98
+
99
+ const SOURCES = Object.freeze({
100
+ fontBases: [
101
+ 'https://cdn.jsdelivr.net/gh/sahibjotsaggu/San-Francisco-Pro-Fonts@master/',
102
+ 'https://raw.githubusercontent.com/sahibjotsaggu/San-Francisco-Pro-Fonts/master/',
103
+ ],
104
+ fonts: { regular: 'SF-Pro-Text-Regular.otf', semibold: 'SF-Pro-Text-Semibold.otf', bold: 'SF-Pro-Text-Bold.otf' },
105
+ fontFallback: 'https://fonts.gstatic.com/s/inter/v18/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZ9hiJ-Ek-_EeA.woff2',
106
+ emoji: 'https://media.githubusercontent.com/media/Ditzzx-vibecoder/entahlah/main/emoji-apple.json',
107
+ })
108
+
109
+ module.exports = { LAYOUT, LOCALES, DEFAULT_REACTIONS, DEFAULTS, DEFAULT_THEME, SOURCES }
package/src/icons.js ADDED
@@ -0,0 +1,79 @@
1
+ 'use strict'
2
+
3
+ const { Path2D } = require('@napi-rs/canvas')
4
+
5
+ const ICONS = {
6
+ reply: [{ d: 'M9.3356 5.47875L5.3633 9.00968C3.7947 10.404 3.0104 11.1012 3.0104 11.9993C3.0104 12.8975 3.7947 13.5946 5.3633 14.989L9.3356 18.5199C10.0516 19.1563 10.4097 19.4746 10.7048 19.342C11 19.2095 11 18.7305 11 17.7725V15.4279C14.6 15.4279 18.5 17.1422 20 19.9993C20 10.8565 14.6667 8.57075 11 8.57075V6.22616C11 5.26817 11 4.78917 10.7048 4.65662C10.4097 4.52407 10.0516 4.8423 9.3356 5.47875Z' }],
7
+ forward: [{ d: 'M14.6644 5.47875L18.6367 9.00968C20.2053 10.404 20.9896 11.1012 20.9896 11.9993C20.9896 12.8975 20.2053 13.5946 18.6367 14.989L14.6644 18.5199C13.9484 19.1563 13.5903 19.4746 13.2952 19.342C13 19.2095 13 18.7305 13 17.7725V15.4279C9.4 15.4279 5.5 17.1422 4 19.9993C4 10.8565 9.33333 8.57075 13 8.57075V6.22616C13 5.26817 13 4.78917 13.2952 4.65662C13.5903 4.52407 13.9484 4.8423 14.6644 5.47875Z' }],
8
+ copy: [
9
+ { d: 'M9.2 7.2V5.7C9.2 4.6 10 3.7 11.1 3.7H14.4L18.6 7.9V14.4C18.6 15.5 17.7 16.3 16.6 16.3H15.1' },
10
+ { d: 'M14.4 3.7V7.9H18.6' },
11
+ { d: 'M10 7.2H7.3C6.2 7.2 5.3 8.1 5.3 9.2V18.2C5.3 19.3 6.2 20.2 7.3 20.2H13.1C14.2 20.2 15.1 19.3 15.1 18.2V12.3L10 7.2Z' },
12
+ { d: 'M10 7.2V12.3H15.1' },
13
+ ],
14
+ star: [{ d: 'M12 2.5l2.92 6.13 6.72.88-4.92 4.65 1.24 6.64L12 17.55l-5.96 3.25 1.24-6.64-4.92-4.65 6.72-.88L12 2.5z' }],
15
+ trash: [
16
+ { d: 'M4.5 6.6H19.5' },
17
+ { d: 'M9 6.6V4.7C9 3.95 9.55 3.4 10.3 3.4H13.7C14.45 3.4 15 3.95 15 4.7V6.6' },
18
+ { d: 'M6.3 6.6L7.2 18.6C7.3 19.8 8.2 20.7 9.4 20.7H14.6C15.8 20.7 16.7 19.8 16.8 18.6L17.7 6.6' },
19
+ { d: 'M9.5 9.8V17.3M12 9.8V17.3M14.5 9.8V17.3' },
20
+ ],
21
+ more: [
22
+ { d: 'M2.5 12a9.5 9.5 0 1 0 19 0a9.5 9.5 0 1 0 -19 0z' },
23
+ { d: 'M6.7 12a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0 -2.4 0z', fill: true },
24
+ { d: 'M10.8 12a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0 -2.4 0z', fill: true },
25
+ { d: 'M14.9 12a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0 -2.4 0z', fill: true },
26
+ ],
27
+ }
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
+
51
+ const SIZE = { reply: 30, forward: 30, copy: 37, star: 32, trash: 36, more: 32 }
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
55
+ const cache = new Map()
56
+
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
61
+ const k = size / 24
62
+ ctx.save()
63
+ ctx.translate(cx - size / 2, cy - size / 2)
64
+ ctx.scale(k, k)
65
+ ctx.strokeStyle = color
66
+ ctx.fillStyle = color
67
+ ctx.lineWidth = (native ? NATIVE_STROKE : STROKE[name] || STROKE.default) / k
68
+ ctx.lineCap = 'round'
69
+ ctx.lineJoin = 'round'
70
+ for (const op of ops) {
71
+ let p = cache.get(op.d)
72
+ if (!p) { p = new Path2D(op.d); cache.set(op.d, p) }
73
+ if (op.fill) ctx.fill(p)
74
+ else ctx.stroke(p)
75
+ }
76
+ ctx.restore()
77
+ }
78
+
79
+ module.exports = { drawIcon, ICONS, NATIVE_ICONS }