@boruto_vk7/stickengine 0.0.6 → 1.0.1

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.
@@ -0,0 +1,137 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import { type AxiosRequestConfig } from 'axios';
3
+ export interface StickerMetadata {
4
+ pack?: string;
5
+ author?: string;
6
+ emojis?: string[];
7
+ id?: string;
8
+ }
9
+ export interface JimpOptions {
10
+ greyscale?: boolean;
11
+ invert?: boolean;
12
+ sepia?: boolean;
13
+ blur?: number;
14
+ /** -1 .. 1 */
15
+ brightness?: number;
16
+ /** -1 .. 1 */
17
+ contrast?: number;
18
+ circle?: boolean;
19
+ resize?: {
20
+ width: number;
21
+ height: number;
22
+ };
23
+ text?: {
24
+ content: string;
25
+ alignmentX?: number;
26
+ alignmentY?: number;
27
+ color?: 'WHITE' | 'BLACK';
28
+ stroke?: boolean;
29
+ };
30
+ }
31
+ export interface StickEngineOptions {
32
+ /** Convert output to WebP sticker (default true). */
33
+ webp?: boolean;
34
+ /** Static-image edits via Jimp. */
35
+ edit?: JimpOptions | boolean;
36
+ /** remove.bg API key (string or list). Static images only. */
37
+ transparent?: string | string[] | false;
38
+ metadata?: StickerMetadata;
39
+ /**
40
+ * Delete temp files when you call `clean()`.
41
+ * Default false so you can read the sticker path first.
42
+ */
43
+ autoClean?: boolean;
44
+ /** Animated sticker FPS (default 15). */
45
+ fps?: number;
46
+ /** WebP quality 1–100 for animated (default 75). */
47
+ quality?: number;
48
+ /** Max animated duration in seconds (default 6). */
49
+ maxDuration?: number;
50
+ /** Temp directory (default ./tmp_stickengine). */
51
+ tempDir?: string;
52
+ }
53
+ export type StickInput = string | Buffer;
54
+ export interface StickResult {
55
+ /** Absolute path to the final .webp */
56
+ path: string;
57
+ /** File as Buffer */
58
+ buffer: Buffer;
59
+ /** Base64 (no data: prefix) */
60
+ base64: string;
61
+ animated: boolean;
62
+ width: number;
63
+ height: number;
64
+ size: number;
65
+ }
66
+ export interface MediaInfo {
67
+ width: number;
68
+ height: number;
69
+ duration: number;
70
+ }
71
+ export declare function getBuffer(url: string, options?: AxiosRequestConfig): Promise<Buffer>;
72
+ /**
73
+ * WhatsApp sticker engine (static + animated WebP + EXIF pack metadata).
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * import StickEngine from '@boruto_vk7/stickengine';
78
+ *
79
+ * const sticker = await StickEngine.create('./cat.gif', {
80
+ * metadata: { pack: 'My Pack', author: 'Me' },
81
+ * });
82
+ * // sticker.buffer → send to WhatsApp
83
+ * // sticker.path → temp file path
84
+ * ```
85
+ */
86
+ export declare class StickEngine extends EventEmitter {
87
+ options: Required<Pick<StickEngineOptions, 'webp' | 'autoClean' | 'fps' | 'quality' | 'maxDuration'>> & StickEngineOptions;
88
+ private tempDir;
89
+ private queue;
90
+ private createdFiles;
91
+ constructor(options?: StickEngineOptions);
92
+ /**
93
+ * Create a sticker in one call. Returns path + buffer + base64.
94
+ */
95
+ static create(input: StickInput, options?: StickEngineOptions): Promise<StickResult>;
96
+ /**
97
+ * Create sticker and return only the Buffer (handy for bots).
98
+ */
99
+ static toBuffer(input: StickInput, options?: StickEngineOptions): Promise<Buffer>;
100
+ /**
101
+ * Create sticker and return base64 string.
102
+ */
103
+ static toBase64String(input: StickInput, options?: StickEngineOptions): Promise<string>;
104
+ /** Instance one-shot (uses constructor options). */
105
+ build(input: StickInput): Promise<StickResult>;
106
+ addFile(file: StickInput): this;
107
+ add(...files: StickInput[]): this;
108
+ /**
109
+ * Process the queue. Returns settled results with `value` = absolute path.
110
+ * Prefer `build()` / `StickEngine.create()` for a simpler API.
111
+ */
112
+ start(): Promise<PromiseSettledResult<string>[]>;
113
+ /** Delete tracked temp files. */
114
+ clean(): void;
115
+ private track;
116
+ private processFile;
117
+ private materializeInput;
118
+ /**
119
+ * Write WhatsApp sticker pack EXIF.
120
+ * Animated WebP MUST use muxAnim — save() throws on animations.
121
+ */
122
+ private addExif;
123
+ private detectAnimatedWebp;
124
+ private convertToWebp;
125
+ private applyJimpEdits;
126
+ private getMediaInfo;
127
+ static fileToBase64(filePath: string): string;
128
+ /** 96×96 tray icon WebP for sticker packs. */
129
+ createTrayIcon(input: StickInput): Promise<string>;
130
+ /** Text-only sticker (transparent 512×512). */
131
+ createTextSticker(text: string, options?: {
132
+ color?: 'WHITE' | 'BLACK';
133
+ background?: number | string;
134
+ }): Promise<StickResult>;
135
+ }
136
+ export default StickEngine;
137
+ //# sourceMappingURL=StickEngine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StickEngine.d.ts","sourceRoot":"","sources":["../../src/StickEngine.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAuBvD,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,IAAI,CAAC,EAAE;QACL,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAA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AAM,EACZ,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAO,GACxE,OAAO,CAAC,WAAW,CAAC;CAsBxB;AAED,eAAe,WAAW,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { StickEngine, getBuffer, type StickEngineOptions, type StickerMetadata, type JimpOptions, type StickInput, type StickResult, type MediaInfo, } from './StickEngine.js';
2
+ export { StickEngine as default } from './StickEngine.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,SAAS,EACT,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,SAAS,GACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,WAAW,IAAI,OAAO,EAAE,MAAM,kBAAkB,CAAC"}
package/package.json CHANGED
@@ -1,50 +1,73 @@
1
1
  {
2
2
  "name": "@boruto_vk7/stickengine",
3
- "version": "0.0.6",
4
- "description": "StickEngine module for creating WhatsApp stickers",
3
+ "version": "1.0.1",
4
+ "description": "Simple WhatsApp sticker engine static & animated WebP, EXIF pack metadata, ESM + CommonJS.",
5
+ "author": "Borutovk7",
6
+ "contributors": [
7
+ "Eduh Dev"
8
+ ],
9
+ "license": "MIT",
10
+ "keywords": [
11
+ "whatsapp",
12
+ "sticker",
13
+ "webp",
14
+ "animated",
15
+ "stickengine",
16
+ "baileys",
17
+ "wbot"
18
+ ],
5
19
  "type": "module",
6
- "main": "dist/StickEngine.js",
7
- "module": "dist/StickEngine.js",
8
- "types": "dist/StickEngine.d.ts",
20
+ "main": "./dist/cjs/index.js",
21
+ "module": "./dist/esm/index.js",
22
+ "types": "./dist/types/index.d.ts",
9
23
  "exports": {
10
24
  ".": {
11
- "require": "./dist/StickEngine.js",
12
- "import": "./dist/StickEngine.js",
13
- "types": "./dist/StickEngine.d.ts"
14
- }
25
+ "types": "./dist/types/index.d.ts",
26
+ "import": "./dist/esm/index.js",
27
+ "require": "./dist/cjs/index.js",
28
+ "default": "./dist/esm/index.js"
29
+ },
30
+ "./package.json": "./package.json"
15
31
  },
32
+ "files": [
33
+ "dist",
34
+ "README.md",
35
+ "LICENSE"
36
+ ],
16
37
  "scripts": {
17
- "build": "tsc",
18
- "test": "echo \"Error: no test specified\" && exit 1"
38
+ "clean": "node ./scripts/clean.mjs",
39
+ "build:esm": "tsc -p tsconfig.esm.json && node ./scripts/fix-esm-dirname.mjs && node ./scripts/copy-assets.mjs esm",
40
+ "build:cjs": "tsc -p tsconfig.cjs.json && node ./scripts/copy-assets.mjs cjs && node ./scripts/write-cjs-package.mjs",
41
+ "build:types": "tsc -p tsconfig.types.json",
42
+ "build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:types",
43
+ "prepublishOnly": "npm run build",
44
+ "typecheck": "tsc -p tsconfig.json --noEmit"
45
+ },
46
+ "engines": {
47
+ "node": ">=18"
48
+ },
49
+ "publishConfig": {
50
+ "access": "public"
19
51
  },
20
- "keywords": [
21
- "sticker",
22
- "whatsapp",
23
- "stickengine"
24
- ],
25
- "author": "Borutovk7 <https://github.com/Borutovk7>",
26
- "contributors": [
27
- "Eduh Dev",
28
- "Manus AI"
29
- ],
30
- "license": "ISC",
31
52
  "repository": {
32
53
  "type": "git",
33
- "url": "https://github.com/Borutovk7/StickEngine.git"
54
+ "url": "git+https://github.com/Borutovk7/StickEngine.git"
55
+ },
56
+ "bugs": {
57
+ "url": "https://github.com/Borutovk7/StickEngine/issues"
34
58
  },
59
+ "homepage": "https://github.com/Borutovk7/StickEngine#readme",
35
60
  "dependencies": {
36
61
  "axios": "^1.6.0",
37
- "file-type": "^16.5.3",
38
- "fluent-ffmpeg": "^2.1.2",
39
- "jimp": "^0.22.10",
40
- "node-fetch": "^2.6.1",
41
- "node-webpmux": "^1.0.7",
62
+ "file-type": "^16.5.4",
63
+ "fluent-ffmpeg": "^2.1.3",
64
+ "jimp": "^0.22.12",
65
+ "node-webpmux": "^3.1.7",
42
66
  "remove.bg": "^1.3.0"
43
67
  },
44
68
  "devDependencies": {
45
- "@types/fluent-ffmpeg": "^2.1.28",
46
- "@types/node": "^25.9.2",
47
- "@types/node-fetch": "2.6.1",
48
- "typescript": "^6.0.3"
69
+ "@types/fluent-ffmpeg": "^2.1.27",
70
+ "@types/node": "^20.14.0",
71
+ "typescript": "^5.5.4"
49
72
  }
50
73
  }
Binary file
Binary file
@@ -1,72 +0,0 @@
1
- import { AxiosRequestConfig } from 'axios';
2
- import { EventEmitter } from 'events';
3
- export interface StickerMetadata {
4
- pack?: string;
5
- author?: string;
6
- emojis?: string[];
7
- }
8
- export interface JimpOptions {
9
- greyscale?: boolean;
10
- invert?: boolean;
11
- sepia?: boolean;
12
- blur?: number;
13
- brightness?: number;
14
- contrast?: number;
15
- circle?: boolean;
16
- resize?: {
17
- width: number;
18
- height: number;
19
- };
20
- text?: {
21
- content: string;
22
- alignmentX?: number;
23
- alignmentY?: number;
24
- color?: 'WHITE' | 'BLACK';
25
- stroke?: boolean;
26
- };
27
- }
28
- export interface StickEngineOptions {
29
- webp?: boolean;
30
- edit?: JimpOptions | boolean;
31
- convert?: boolean;
32
- transparent?: string | string[] | false;
33
- metadata?: StickerMetadata;
34
- autoClean?: boolean;
35
- fps?: number;
36
- quality?: number;
37
- }
38
- /**
39
- * Faz GET em uma URL e retorna o corpo como Buffer.
40
- */
41
- export declare const getBuffer: (url: string, options?: AxiosRequestConfig) => Promise<Buffer>;
42
- export declare class StickEngine extends EventEmitter {
43
- options: StickEngineOptions;
44
- private tempDir;
45
- private queue;
46
- private createdFiles;
47
- constructor(options?: StickEngineOptions);
48
- addFile(file: string | Buffer): this;
49
- clean(): void;
50
- private processFile;
51
- private applyJimpEdits;
52
- private getMediaInfo;
53
- private convertToWebp;
54
- private addExif;
55
- start(): Promise<PromiseSettledResult<string>[]>;
56
- /**
57
- * Converte um arquivo em Base64.
58
- */
59
- static toBase64(filePath: string): string;
60
- /**
61
- * Gera um ícone de bandeja (Tray Icon) 96x96 para o pacote de figurinhas.
62
- */
63
- createTrayIcon(input: string | Buffer): Promise<string>;
64
- /**
65
- * Cria uma figurinha de texto do zero (TP).
66
- */
67
- createTextSticker(text: string, options?: {
68
- color?: 'WHITE' | 'BLACK';
69
- background?: string;
70
- }): Promise<string>;
71
- }
72
- export default StickEngine;