iqc-maker 0.0.0-stage → 1.0.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/index.d.ts ADDED
@@ -0,0 +1,197 @@
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 = 'colors' | 'colors-dark' | 'dark' | 'earth' | 'custom'
8
+ export type OutputFormat = 'png' | 'jpg' | 'jpeg' | 'webp' | 'avif'
9
+ export type LocaleCode = 'id' | 'en' | 'ms' | 'jv' | 'su' | 'es' | 'pt' | 'ar' | 'ja'
10
+
11
+ export type BuiltinThemeName =
12
+ | 'blue' | 'pink' | 'red' | 'orange' | 'yellow' | 'lime' | 'green' | 'mint' | 'teal' | 'cyan' | 'navy' | 'indigo'
13
+ | 'purple' | 'lavender' | 'magenta' | 'peach' | 'brown' | 'gray' | 'white' | 'gold' | 'silver' | 'rosegold'
14
+ | 'dark-blue' | 'dark-pink' | 'dark-red' | 'dark-orange' | 'dark-yellow' | 'dark-lime' | 'dark-green' | 'dark-mint'
15
+ | 'dark-teal' | 'dark-cyan' | 'dark-navy' | 'dark-indigo' | 'dark-purple' | 'dark-lavender' | 'dark-magenta'
16
+ | 'dark-peach' | 'dark-brown' | 'dark-gold' | 'dark-rosegold'
17
+ | 'black' | 'dark' | 'amoled' | 'graphite' | 'onyx'
18
+ | 'ocean' | 'sky' | 'sunrise' | 'sunset' | 'beach' | 'coral' | 'lagoon' | 'glacier' | 'arctic' | 'forest' | 'jungle'
19
+ | 'moss' | 'matcha' | 'meadow' | 'spring' | 'sakura' | 'lavenderfield' | 'sunflower' | 'autumn' | 'desert' | 'savanna'
20
+ | 'canyon' | 'earth' | 'clay' | 'stone' | 'mocha' | 'cherry' | 'grape' | 'lemon' | 'rainbow'
21
+ | 'aurora' | 'galaxy' | 'midnight' | 'twilight' | 'volcano' | 'deepsea' | 'nightforest' | 'storm' | 'eclipse' | 'nebula'
22
+
23
+ export type ThemeName = BuiltinThemeName | (string & {})
24
+
25
+ export interface Theme {
26
+ name: string
27
+ label: string
28
+ mode: ThemeMode
29
+ category: ThemeCategory | string
30
+ background: {
31
+ image: ImageSource | null
32
+ gradient: string[]
33
+ blobs: string[]
34
+ solid?: string
35
+ dim?: number | string
36
+ }
37
+ statusBar: {
38
+ text: string
39
+ inactive: string
40
+ battery: {
41
+ body: string
42
+ border: string
43
+ cap: string
44
+ fill: string
45
+ low: string
46
+ charging: string
47
+ bolt: string
48
+ boltStroke: string
49
+ }
50
+ }
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 }
53
+ reply: { bg: string; bar: string; name: string; text: string }
54
+ menu: {
55
+ shadow: string
56
+ overlay: string
57
+ tintTop: string
58
+ tintBottom: string
59
+ sheen: string
60
+ glow: string
61
+ spec: string
62
+ rimTop: string
63
+ rimBottom: string
64
+ text: string
65
+ icon: string
66
+ danger: string
67
+ divider: string
68
+ }
69
+ }
70
+
71
+ export type DeepPartial<T> = { [K in keyof T]?: T[K] extends object ? (T[K] extends any[] ? T[K] : DeepPartial<T[K]>) : T[K] }
72
+
73
+ export interface ThemeDefinition {
74
+ name?: string
75
+ label?: string
76
+ mode?: ThemeMode
77
+ category?: string
78
+ background: string[]
79
+ blobs?: string[]
80
+ accent?: string
81
+ underlay?: string
82
+ highlight?: string
83
+ surface?: string
84
+ danger?: string
85
+ overrides?: DeepPartial<Theme>
86
+ }
87
+
88
+ export type ThemeInput = ThemeName | ThemeDefinition | DeepPartial<Theme>
89
+
90
+ export interface MenuLabels {
91
+ reply: string
92
+ forward: string
93
+ copy: string
94
+ star: string
95
+ delete: string
96
+ more: string
97
+ }
98
+
99
+ export interface ReplyInput {
100
+ name?: string
101
+ text?: string
102
+ color?: string
103
+ }
104
+
105
+ export interface AssetOptions {
106
+ cacheDir?: string
107
+ fonts?: { regular?: ImageSource; semibold?: ImageSource; bold?: ImageSource }
108
+ emoji?: string | Buffer | Record<string, string> | false
109
+ offline?: boolean
110
+ timeout?: number
111
+ logger?: ((message: string) => void) | false | null
112
+ }
113
+
114
+ export interface RenderOptions extends AssetOptions {
115
+ text?: string
116
+ image?: ImageSource | null
117
+ reply?: ReplyInput | null
118
+ theme?: ThemeInput
119
+ colors?: DeepPartial<Theme>
120
+ background?: ImageSource | DeepPartial<Theme['background']>
121
+ time?: string
122
+ bubbleTime?: string
123
+ timeZone?: string
124
+ network?: '4G' | '5G' | 'LTE' | '3G' | 'E' | 'wifi' | '' | (string & {})
125
+ signal?: 0 | 1 | 2 | 3 | 4
126
+ battery?: number
127
+ charging?: boolean
128
+ reactions?: string[]
129
+ locale?: LocaleCode | (string & {})
130
+ labels?: Partial<MenuLabels>
131
+ statusBar?: boolean
132
+ reactionBar?: boolean
133
+ menu?: boolean
134
+ format?: OutputFormat
135
+ quality?: number
136
+ scale?: number
137
+ output?: 'buffer' | 'canvas'
138
+ }
139
+
140
+ export interface PreloadResult {
141
+ fonts: { regular: boolean; semibold: boolean; bold: boolean; fallback: boolean }
142
+ emoji: number
143
+ cacheDir: string
144
+ }
145
+
146
+ export interface ThemeInfo {
147
+ name: string
148
+ label: string
149
+ mode: ThemeMode
150
+ category: string
151
+ }
152
+
153
+ export declare class IQC {
154
+ constructor(options?: RenderOptions)
155
+ options: RenderOptions
156
+ readonly version: string
157
+ preload(options?: AssetOptions): Promise<PreloadResult>
158
+ render(input: string | (RenderOptions & { output: 'canvas' })): Promise<Canvas>
159
+ render(input: string | RenderOptions): Promise<Buffer>
160
+ }
161
+
162
+ export declare function render(input: RenderOptions & { output: 'canvas' }): Promise<Canvas>
163
+ export declare function render(input: string | RenderOptions): Promise<Buffer>
164
+ export declare function preload(options?: AssetOptions): Promise<PreloadResult>
165
+ export declare function configure(options: RenderOptions): IQC
166
+ export declare function getTheme(theme?: ThemeInput, overrides?: DeepPartial<Theme>): Theme
167
+ export declare function createTheme(base: ThemeInput, overrides?: DeepPartial<Theme>): Theme
168
+ export declare function buildTheme(definition: ThemeDefinition): Theme
169
+ export declare function registerTheme(name: string, theme: ThemeDefinition | (DeepPartial<Theme> & { extends?: ThemeName })): Theme
170
+ export declare function listThemes(filter?: ThemeCategory | ThemeMode): ThemeInfo[]
171
+ export declare function resolveTheme(name: string): string | null
172
+ export declare function clearCache(cacheDir?: string): Promise<void>
173
+
174
+ export declare const locales: Readonly<Record<LocaleCode, MenuLabels>>
175
+ export declare const defaultReactions: readonly string[]
176
+ export declare const layout: Readonly<{ W: number; H: number; [key: string]: unknown }>
177
+ export declare const version: string
178
+
179
+ declare const iqc: {
180
+ IQC: typeof IQC
181
+ render: typeof render
182
+ preload: typeof preload
183
+ configure: typeof configure
184
+ getTheme: typeof getTheme
185
+ createTheme: typeof createTheme
186
+ buildTheme: typeof buildTheme
187
+ registerTheme: typeof registerTheme
188
+ listThemes: typeof listThemes
189
+ resolveTheme: typeof resolveTheme
190
+ clearCache: typeof clearCache
191
+ locales: typeof locales
192
+ defaultReactions: typeof defaultReactions
193
+ layout: typeof layout
194
+ version: string
195
+ }
196
+
197
+ 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.0",
4
+ "description": "Generator fake chat WhatsApp gaya iPhone (iQC) dengan reply chat, font SF Pro, emoji Apple, dan 80+ 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,81 @@
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
+ blobs: [
36
+ { x: 0, y: 330, w: 350, h: 150, r: 40, blur: 50 },
37
+ { x: 175, y: 205, w: 385, h: 115, r: 30, blur: 44 },
38
+ { x: 410, y: 495, w: 180, h: 65, r: 28, blur: 40 },
39
+ { x: 395, y: 640, w: 185, h: 150, r: 40, blur: 44 },
40
+ { x: 405, y: 855, w: 170, h: 95, r: 34, blur: 40 },
41
+ ],
42
+ })
43
+
44
+ const LOCALES = Object.freeze({
45
+ id: { reply: 'Balas', forward: 'Teruskan', copy: 'Salin', star: 'Beri bintang', delete: 'Hapus', more: 'Lainnya...' },
46
+ en: { reply: 'Reply', forward: 'Forward', copy: 'Copy', star: 'Star', delete: 'Delete', more: 'More...' },
47
+ ms: { reply: 'Balas', forward: 'Majukan', copy: 'Salin', star: 'Bintangkan', delete: 'Padam', more: 'Lagi...' },
48
+ jv: { reply: 'Bales', forward: 'Terusna', copy: 'Salin', star: 'Wenehi lintang', delete: 'Busak', more: 'Liyane...' },
49
+ su: { reply: 'Bales', forward: 'Teraskeun', copy: 'Salin', star: 'Béntangan', delete: 'Pupus', more: 'Lianna...' },
50
+ es: { reply: 'Responder', forward: 'Reenviar', copy: 'Copiar', star: 'Destacar', delete: 'Eliminar', more: 'Más...' },
51
+ pt: { reply: 'Responder', forward: 'Encaminhar', copy: 'Copiar', star: 'Favoritar', delete: 'Apagar', more: 'Mais...' },
52
+ ar: { reply: 'رد', forward: 'إعادة توجيه', copy: 'نسخ', star: 'تمييز بنجمة', delete: 'حذف', more: 'المزيد...' },
53
+ ja: { reply: '返信', forward: '転送', copy: 'コピー', star: 'スター', delete: '削除', more: 'その他...' },
54
+ })
55
+
56
+ const DEFAULT_REACTIONS = Object.freeze(['😈', '🥱', '⚡', '🔥', '😒', '😹', '🤭'])
57
+
58
+ const DEFAULTS = Object.freeze({
59
+ theme: 'blue',
60
+ locale: 'id',
61
+ network: '4G',
62
+ signal: 4,
63
+ battery: 90,
64
+ charging: true,
65
+ timeZone: 'Asia/Jakarta',
66
+ format: 'png',
67
+ quality: 92,
68
+ scale: 1,
69
+ })
70
+
71
+ const SOURCES = Object.freeze({
72
+ fontBases: [
73
+ 'https://cdn.jsdelivr.net/gh/sahibjotsaggu/San-Francisco-Pro-Fonts@master/',
74
+ 'https://raw.githubusercontent.com/sahibjotsaggu/San-Francisco-Pro-Fonts/master/',
75
+ ],
76
+ fonts: { regular: 'SF-Pro-Text-Regular.otf', semibold: 'SF-Pro-Text-Semibold.otf', bold: 'SF-Pro-Text-Bold.otf' },
77
+ fontFallback: 'https://fonts.gstatic.com/s/inter/v18/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZ9hiJ-Ek-_EeA.woff2',
78
+ emoji: 'https://media.githubusercontent.com/media/Ditzzx-vibecoder/entahlah/main/emoji-apple.json',
79
+ })
80
+
81
+ module.exports = { LAYOUT, LOCALES, DEFAULT_REACTIONS, DEFAULTS, SOURCES }
package/src/icons.js ADDED
@@ -0,0 +1,53 @@
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 SIZE = { reply: 30, forward: 30, copy: 37, star: 32, trash: 36, more: 32 }
30
+ const STROKE = { default: 2.6, trash: 2.3 }
31
+ const cache = new Map()
32
+
33
+ function drawIcon(ctx, name, cx, cy, color) {
34
+ const size = SIZE[name] || 30
35
+ const k = size / 24
36
+ ctx.save()
37
+ ctx.translate(cx - size / 2, cy - size / 2)
38
+ ctx.scale(k, k)
39
+ ctx.strokeStyle = color
40
+ ctx.fillStyle = color
41
+ ctx.lineWidth = (STROKE[name] || STROKE.default) / k
42
+ ctx.lineCap = 'round'
43
+ ctx.lineJoin = 'round'
44
+ for (const op of ICONS[name]) {
45
+ let p = cache.get(op.d)
46
+ if (!p) { p = new Path2D(op.d); cache.set(op.d, p) }
47
+ if (op.fill) ctx.fill(p)
48
+ else ctx.stroke(p)
49
+ }
50
+ ctx.restore()
51
+ }
52
+
53
+ module.exports = { drawIcon, ICONS }