@shibam/sticker-maker 1.1.6 โ 1.1.8
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/dist/index.js +22 -19
- package/dist/lib/ToWebp.js +11 -39
- package/dist/lib/changeMetaInfo.js +41 -47
- package/dist/lib/extractMetaData.js +3 -8
- package/dist/lib/toGif.js +10 -15
- package/dist/lib/utils.js +6 -35
- package/dist/types/StickerTypes.js +2 -5
- package/dist/types/categoryType.js +1 -2
- package/dist/types/metaInfoType.js +1 -2
- package/package.json +2 -2
- package/dist/index.d.ts +0 -50
- package/dist/lib/ToWebp.d.ts +0 -12
- package/dist/lib/changeMetaInfo.d.ts +0 -25
- package/dist/lib/extractMetaData.d.ts +0 -6
- package/dist/lib/toGif.d.ts +0 -3
- package/dist/lib/utils.d.ts +0 -37
- package/dist/types/StickerTypes.d.ts +0 -5
- package/dist/types/categoryType.d.ts +0 -8
- package/dist/types/metaInfoType.d.ts +0 -10
package/dist/index.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const utils_js_1 = __importDefault(require("./lib/utils.js"));
|
|
8
|
-
const ToWebp_js_1 = __importDefault(require("./lib/ToWebp.js"));
|
|
9
|
-
const StickerTypes_js_1 = require("./types/StickerTypes.js");
|
|
10
|
-
const changeMetaInfo_js_1 = __importDefault(require("./lib/changeMetaInfo.js"));
|
|
11
|
-
const extractMetaData_js_1 = __importDefault(require("./lib/extractMetaData.js"));
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import Utils from './lib/utils.js';
|
|
3
|
+
import convert from './lib/ToWebp.js';
|
|
4
|
+
import { StickerTypes } from './types/StickerTypes.js';
|
|
5
|
+
import MetaInfoChanger from './lib/changeMetaInfo.js';
|
|
6
|
+
import extractMetaData from './lib/extractMetaData.js';
|
|
12
7
|
class Sticker {
|
|
8
|
+
data;
|
|
9
|
+
metaInfo;
|
|
10
|
+
buffer;
|
|
11
|
+
mimeType;
|
|
12
|
+
extType;
|
|
13
|
+
utils = new Utils();
|
|
14
|
+
outBuffer;
|
|
15
|
+
activeBuff;
|
|
16
|
+
activeMeta;
|
|
13
17
|
constructor(data, metaInfo = {}) {
|
|
14
18
|
this.data = data;
|
|
15
19
|
this.metaInfo = metaInfo;
|
|
16
|
-
this.utils = new utils_js_1.default();
|
|
17
20
|
this.buffer = Buffer.from([]);
|
|
18
21
|
this.outBuffer = Buffer.from([]);
|
|
19
22
|
this.activeBuff = false;
|
|
@@ -37,7 +40,7 @@ class Sticker {
|
|
|
37
40
|
this.metaInfo.author = this.metaInfo.author ?? '';
|
|
38
41
|
this.metaInfo.id = this.metaInfo.id ?? this.utils.getId();
|
|
39
42
|
this.metaInfo.category = this.metaInfo.category ?? [];
|
|
40
|
-
this.metaInfo.type = this.metaInfo.type ??
|
|
43
|
+
this.metaInfo.type = this.metaInfo.type ?? StickerTypes.DEFAULT;
|
|
41
44
|
this.metaInfo.quality = this.metaInfo?.quality ?? this.utils.getQuality(this.buffer);
|
|
42
45
|
}
|
|
43
46
|
catch (error) {
|
|
@@ -51,8 +54,8 @@ class Sticker {
|
|
|
51
54
|
async toBuffer() {
|
|
52
55
|
try {
|
|
53
56
|
await this.initialize();
|
|
54
|
-
const buffer = await (
|
|
55
|
-
this.outBuffer = await new
|
|
57
|
+
const buffer = await convert(this.buffer, this.metaInfo, this.extType, this.mimeType);
|
|
58
|
+
this.outBuffer = await new MetaInfoChanger(this.metaInfo).add(buffer);
|
|
56
59
|
this.activeBuff = true;
|
|
57
60
|
return this.outBuffer;
|
|
58
61
|
}
|
|
@@ -74,7 +77,7 @@ class Sticker {
|
|
|
74
77
|
else {
|
|
75
78
|
await this.toBuffer();
|
|
76
79
|
}
|
|
77
|
-
await
|
|
80
|
+
await fs.promises.writeFile(outputPath, this.outBuffer);
|
|
78
81
|
}
|
|
79
82
|
catch (error) {
|
|
80
83
|
throw new Error(`Conversion to file failed: ${error}`);
|
|
@@ -88,7 +91,7 @@ class Sticker {
|
|
|
88
91
|
async changeMetaInfo() {
|
|
89
92
|
try {
|
|
90
93
|
await this.initialize();
|
|
91
|
-
this.outBuffer = await new
|
|
94
|
+
this.outBuffer = await new MetaInfoChanger(this.metaInfo).add(this.buffer);
|
|
92
95
|
this.activeMeta = true;
|
|
93
96
|
return this.outBuffer;
|
|
94
97
|
}
|
|
@@ -105,11 +108,11 @@ class Sticker {
|
|
|
105
108
|
async extractMetaData(data) {
|
|
106
109
|
try {
|
|
107
110
|
await this.initialize();
|
|
108
|
-
return (
|
|
111
|
+
return extractMetaData(data);
|
|
109
112
|
}
|
|
110
113
|
catch (error) {
|
|
111
114
|
throw new Error(`Error extracting meta data: ${error}`);
|
|
112
115
|
}
|
|
113
116
|
}
|
|
114
117
|
}
|
|
115
|
-
|
|
118
|
+
export default { Sticker, StickerTypes };
|
package/dist/lib/ToWebp.js
CHANGED
|
@@ -1,34 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const sharp_1 = __importStar(require("sharp"));
|
|
30
|
-
const StickerTypes_js_1 = require("../types/StickerTypes.js");
|
|
31
|
-
const toGif_js_1 = __importDefault(require("./toGif.js"));
|
|
1
|
+
import sharp, { fit } from 'sharp';
|
|
2
|
+
import { StickerTypes } from '../types/StickerTypes.js';
|
|
3
|
+
import toGif from './toGif.js';
|
|
32
4
|
/**
|
|
33
5
|
* Converts a given buffer to WebP format with optional transformations.
|
|
34
6
|
*
|
|
@@ -43,13 +15,13 @@ const ToWebp = async (buffer, metaInfo, mimeExt, mimeType) => {
|
|
|
43
15
|
if (mimeExt === 'webp')
|
|
44
16
|
return buffer;
|
|
45
17
|
let data = mimeType?.includes('video')
|
|
46
|
-
? await (
|
|
18
|
+
? await toGif(buffer, mimeExt, metaInfo.type || StickerTypes.DEFAULT)
|
|
47
19
|
: buffer;
|
|
48
20
|
let isAnimated = mimeType?.includes('video') || mimeExt?.includes('gif');
|
|
49
|
-
const res = (
|
|
50
|
-
if (metaInfo.type ===
|
|
21
|
+
const res = sharp(data, { animated: isAnimated });
|
|
22
|
+
if (metaInfo.type === StickerTypes.CIRCLE) {
|
|
51
23
|
res.resize(512, 512, {
|
|
52
|
-
fit:
|
|
24
|
+
fit: fit.cover
|
|
53
25
|
}).composite([
|
|
54
26
|
{
|
|
55
27
|
input: Buffer.from(`<svg width="512" height="512"><circle cx="256" cy="256" r="256" fill=""/></svg>`),
|
|
@@ -59,14 +31,14 @@ const ToWebp = async (buffer, metaInfo, mimeExt, mimeType) => {
|
|
|
59
31
|
}
|
|
60
32
|
]);
|
|
61
33
|
}
|
|
62
|
-
else if (metaInfo.type ===
|
|
34
|
+
else if (metaInfo.type === StickerTypes.SQUARE && !mimeType?.includes('video')) {
|
|
63
35
|
res.resize(512, 512, {
|
|
64
|
-
fit:
|
|
36
|
+
fit: fit.fill
|
|
65
37
|
});
|
|
66
38
|
}
|
|
67
39
|
else {
|
|
68
40
|
res.resize(512, 512, {
|
|
69
|
-
fit:
|
|
41
|
+
fit: fit.contain,
|
|
70
42
|
background: { r: 0, g: 0, b: 0, alpha: 0 }
|
|
71
43
|
});
|
|
72
44
|
}
|
|
@@ -82,4 +54,4 @@ const ToWebp = async (buffer, metaInfo, mimeExt, mimeType) => {
|
|
|
82
54
|
throw new Error(`Conversion failed: ${error}`);
|
|
83
55
|
}
|
|
84
56
|
};
|
|
85
|
-
|
|
57
|
+
export default ToWebp;
|
|
@@ -1,62 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const node_webpmux_1 = __importDefault(require("node-webpmux"));
|
|
7
|
-
const util_1 = require("util");
|
|
1
|
+
import Image from 'node-webpmux';
|
|
2
|
+
import { TextEncoder } from 'util';
|
|
8
3
|
/**
|
|
9
4
|
* The Exif class is responsible for handling the metadata (Exif data)
|
|
10
5
|
* for sticker images, particularly those used in messaging applications.
|
|
11
6
|
*/
|
|
12
|
-
class Exif {
|
|
7
|
+
export default class Exif {
|
|
8
|
+
data = {};
|
|
9
|
+
exif = null;
|
|
13
10
|
/**
|
|
14
11
|
* Constructs an Exif instance with the given options.
|
|
15
12
|
* @param options - An object containing metadata for the sticker.
|
|
16
13
|
*/
|
|
17
14
|
constructor(options) {
|
|
18
|
-
this.data = {};
|
|
19
|
-
this.exif = null;
|
|
20
|
-
/**
|
|
21
|
-
* Builds the Exif metadata as a Buffer.
|
|
22
|
-
* @returns A Buffer containing the constructed Exif data.
|
|
23
|
-
*/
|
|
24
|
-
this.build = () => {
|
|
25
|
-
const data = JSON.stringify(this.data);
|
|
26
|
-
const exif = Buffer.concat([
|
|
27
|
-
Buffer.from([
|
|
28
|
-
0x49, 0x49, 0x2a, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00,
|
|
29
|
-
0x00, 0x16, 0x00, 0x00, 0x00
|
|
30
|
-
]),
|
|
31
|
-
Buffer.from(data, 'utf-8')
|
|
32
|
-
]);
|
|
33
|
-
exif.writeUIntLE(new util_1.TextEncoder().encode(data).length, 14, 4);
|
|
34
|
-
return exif;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Adds the Exif metadata to the given image.
|
|
38
|
-
* @param image - A Buffer or Image instance representing the image to which Exif data should be added.
|
|
39
|
-
* @returns A Promise that resolves to a Buffer containing the image with the added Exif data.
|
|
40
|
-
*/
|
|
41
|
-
this.add = async (image) => {
|
|
42
|
-
const exif = this.exif || this.build();
|
|
43
|
-
// Load the image if it is not already an instance of Image.Image.
|
|
44
|
-
image =
|
|
45
|
-
image instanceof node_webpmux_1.default.Image
|
|
46
|
-
? image
|
|
47
|
-
: await (async () => {
|
|
48
|
-
const img = new node_webpmux_1.default.Image();
|
|
49
|
-
await img.load(image);
|
|
50
|
-
return img;
|
|
51
|
-
})();
|
|
52
|
-
// Set the Exif data on the image and save it.
|
|
53
|
-
image.exif = exif;
|
|
54
|
-
return await image.save(null);
|
|
55
|
-
};
|
|
56
15
|
this.data['sticker-pack-id'] = options.id || '';
|
|
57
16
|
this.data['sticker-pack-name'] = options.pack || '';
|
|
58
17
|
this.data['sticker-pack-publisher'] = options.author || '';
|
|
59
18
|
this.data['emojis'] = options.category || ['๐น'];
|
|
60
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Builds the Exif metadata as a Buffer.
|
|
22
|
+
* @returns A Buffer containing the constructed Exif data.
|
|
23
|
+
*/
|
|
24
|
+
build = () => {
|
|
25
|
+
const data = JSON.stringify(this.data);
|
|
26
|
+
const exif = Buffer.concat([
|
|
27
|
+
Buffer.from([
|
|
28
|
+
0x49, 0x49, 0x2a, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00,
|
|
29
|
+
0x00, 0x16, 0x00, 0x00, 0x00
|
|
30
|
+
]),
|
|
31
|
+
Buffer.from(data, 'utf-8')
|
|
32
|
+
]);
|
|
33
|
+
exif.writeUIntLE(new TextEncoder().encode(data).length, 14, 4);
|
|
34
|
+
return exif;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Adds the Exif metadata to the given image.
|
|
38
|
+
* @param image - A Buffer or Image instance representing the image to which Exif data should be added.
|
|
39
|
+
* @returns A Promise that resolves to a Buffer containing the image with the added Exif data.
|
|
40
|
+
*/
|
|
41
|
+
add = async (image) => {
|
|
42
|
+
const exif = this.exif || this.build();
|
|
43
|
+
// Load the image if it is not already an instance of Image.Image.
|
|
44
|
+
image =
|
|
45
|
+
image instanceof Image.Image
|
|
46
|
+
? image
|
|
47
|
+
: await (async () => {
|
|
48
|
+
const img = new Image.Image();
|
|
49
|
+
await img.load(image);
|
|
50
|
+
return img;
|
|
51
|
+
})();
|
|
52
|
+
// Set the Exif data on the image and save it.
|
|
53
|
+
image.exif = exif;
|
|
54
|
+
return await image.save(null);
|
|
55
|
+
};
|
|
61
56
|
}
|
|
62
|
-
exports.default = Exif;
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const node_webpmux_1 = __importDefault(require("node-webpmux"));
|
|
1
|
+
import Image from 'node-webpmux';
|
|
7
2
|
/**
|
|
8
3
|
* Extracts metadata from a WebP image.
|
|
9
4
|
* @param {Buffer}image - The image buffer to extract metadata from
|
|
10
5
|
*/
|
|
11
6
|
const extractMetadata = async (image) => {
|
|
12
|
-
const img = new
|
|
7
|
+
const img = new Image.Image();
|
|
13
8
|
await img.load(image);
|
|
14
9
|
const exif = img.exif?.toString('utf-8') ?? '{}';
|
|
15
10
|
return JSON.parse(exif.substring(exif.indexOf('{'), exif.lastIndexOf('}') + 1) ?? '{}');
|
|
16
11
|
};
|
|
17
|
-
|
|
12
|
+
export default extractMetadata;
|
package/dist/lib/toGif.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
const fluent_ffmpeg_1 = __importDefault(require("fluent-ffmpeg"));
|
|
7
|
-
const ffmpeg_1 = __importDefault(require("@ffmpeg-installer/ffmpeg"));
|
|
8
|
-
const stream_1 = require("stream");
|
|
9
|
-
const StickerTypes_js_1 = require("../types/StickerTypes.js");
|
|
10
|
-
fluent_ffmpeg_1.default.setFfmpegPath(ffmpeg_1.default.path);
|
|
1
|
+
import ffmpeg from 'fluent-ffmpeg';
|
|
2
|
+
import ffmpegInstaller from '@ffmpeg-installer/ffmpeg';
|
|
3
|
+
import { PassThrough } from 'stream';
|
|
4
|
+
import { StickerTypes } from '../types/StickerTypes.js';
|
|
5
|
+
ffmpeg.setFfmpegPath(ffmpegInstaller.path);
|
|
11
6
|
const videoToGif = (buffer, extType, type) => {
|
|
12
7
|
return new Promise(async (resolve, reject) => {
|
|
13
8
|
try {
|
|
14
|
-
const outputStream = new
|
|
15
|
-
const inputStream = new
|
|
9
|
+
const outputStream = new PassThrough({ allowHalfOpen: false });
|
|
10
|
+
const inputStream = new PassThrough({ allowHalfOpen: false });
|
|
16
11
|
inputStream.write(buffer);
|
|
17
12
|
inputStream.end();
|
|
18
13
|
const chunks = [];
|
|
@@ -29,10 +24,10 @@ const videoToGif = (buffer, extType, type) => {
|
|
|
29
24
|
inputStream.destroy();
|
|
30
25
|
outputStream.destroy();
|
|
31
26
|
});
|
|
32
|
-
const shape = type ===
|
|
27
|
+
const shape = type === StickerTypes.SQUARE
|
|
33
28
|
? 'scale=320:-1:flags=lanczos,fps=10,crop=min(iw\\,ih):min(iw\\,ih)'
|
|
34
29
|
: 'scale=320:-1:flags=lanczos,fps=10';
|
|
35
|
-
(
|
|
30
|
+
ffmpeg(inputStream)
|
|
36
31
|
.inputFormat(extType)
|
|
37
32
|
.outputOptions(['-vf', shape, '-loop', '0', '-lossless', '0', '-t', '7', '-preset', 'ultrafast'])
|
|
38
33
|
.toFormat('gif')
|
|
@@ -48,4 +43,4 @@ const videoToGif = (buffer, extType, type) => {
|
|
|
48
43
|
}
|
|
49
44
|
});
|
|
50
45
|
};
|
|
51
|
-
|
|
46
|
+
export default videoToGif;
|
package/dist/lib/utils.js
CHANGED
|
@@ -1,34 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const stream_1 = require("stream");
|
|
30
|
-
const fs_1 = __importDefault(require("fs"));
|
|
31
|
-
class Utils {
|
|
1
|
+
import { Readable } from 'stream';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
export default class Utils {
|
|
32
4
|
constructor() { }
|
|
33
5
|
/**
|
|
34
6
|
* Converts various types of input data to a Buffer.
|
|
@@ -39,8 +11,8 @@ class Utils {
|
|
|
39
11
|
async buffer(data) {
|
|
40
12
|
try {
|
|
41
13
|
const buffer = typeof data === 'string'
|
|
42
|
-
? await
|
|
43
|
-
: data instanceof
|
|
14
|
+
? await fs.promises.readFile(data)
|
|
15
|
+
: data instanceof Readable
|
|
44
16
|
? await this.streamToBuffer(data)
|
|
45
17
|
: Buffer.from(data);
|
|
46
18
|
return buffer;
|
|
@@ -91,7 +63,7 @@ class Utils {
|
|
|
91
63
|
*/
|
|
92
64
|
async getMimeType(data) {
|
|
93
65
|
try {
|
|
94
|
-
const { fileTypeFromBuffer } = await
|
|
66
|
+
const { fileTypeFromBuffer } = await import('file-type');
|
|
95
67
|
const fileType = await fileTypeFromBuffer(data);
|
|
96
68
|
return fileType;
|
|
97
69
|
}
|
|
@@ -108,4 +80,3 @@ class Utils {
|
|
|
108
80
|
return [...Array(5)].map(() => Math.random().toString(36).substring(2, 15)).join('');
|
|
109
81
|
}
|
|
110
82
|
}
|
|
111
|
-
exports.default = Utils;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StickerTypes = void 0;
|
|
4
|
-
var StickerTypes;
|
|
1
|
+
export var StickerTypes;
|
|
5
2
|
(function (StickerTypes) {
|
|
6
3
|
StickerTypes[StickerTypes["DEFAULT"] = 0] = "DEFAULT";
|
|
7
4
|
StickerTypes[StickerTypes["SQUARE"] = 1] = "SQUARE";
|
|
8
5
|
StickerTypes[StickerTypes["CIRCLE"] = 2] = "CIRCLE";
|
|
9
|
-
})(StickerTypes || (
|
|
6
|
+
})(StickerTypes || (StickerTypes = {}));
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shibam/sticker-maker",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"description": "A package for creating stickers",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
24
|
-
"url": "https://github.com/
|
|
24
|
+
"url": "https://github.com/ShibamDey69/Sticker-Maker.git"
|
|
25
25
|
},
|
|
26
26
|
"keywords": [
|
|
27
27
|
"stickers",
|
package/dist/index.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Readable } from 'stream';
|
|
2
|
-
import { MetaDataType } from './types/metaInfoType.js';
|
|
3
|
-
import { StickerTypes } from './types/StickerTypes.js';
|
|
4
|
-
declare class Sticker {
|
|
5
|
-
private data;
|
|
6
|
-
metaInfo: Partial<MetaDataType>;
|
|
7
|
-
private buffer;
|
|
8
|
-
private mimeType;
|
|
9
|
-
private extType;
|
|
10
|
-
private utils;
|
|
11
|
-
private outBuffer;
|
|
12
|
-
private activeBuff;
|
|
13
|
-
private activeMeta;
|
|
14
|
-
constructor(data: Buffer | string | Readable, metaInfo?: Partial<MetaDataType>);
|
|
15
|
-
/**
|
|
16
|
-
* Initializes the Sticker instance.
|
|
17
|
-
* - Sets default values for metaInfo.
|
|
18
|
-
* - Reads and analyzes input data to determine MIME type and extension type.
|
|
19
|
-
* - Generates ID and quality metadata if not provided.
|
|
20
|
-
*/
|
|
21
|
-
private initialize;
|
|
22
|
-
/**
|
|
23
|
-
* Converts input data to a Buffer containing the converted content.
|
|
24
|
-
* @returns Promise<Buffer> A Promise resolving to the converted content as Buffer.
|
|
25
|
-
*/
|
|
26
|
-
toBuffer(): Promise<Buffer>;
|
|
27
|
-
/**
|
|
28
|
-
* Converts input data and writes it to a file at the specified outputPath.
|
|
29
|
-
* @param outputPath The path where the converted file will be saved.
|
|
30
|
-
* @returns Promise<void> A Promise resolving when the file is successfully written.
|
|
31
|
-
*/
|
|
32
|
-
toFile(outputPath: string): Promise<void>;
|
|
33
|
-
/**
|
|
34
|
-
* Changes the metadata of the sticker.
|
|
35
|
-
* @param newMetaInfo Partial metadata to update.
|
|
36
|
-
* @returns Promise<Buffer> A Promise resolving to the Buffer with updated metadata.
|
|
37
|
-
*/
|
|
38
|
-
changeMetaInfo(): Promise<Buffer>;
|
|
39
|
-
/**
|
|
40
|
-
* Extracts metadata from the provided data.
|
|
41
|
-
* @param data Buffer containing the data to extract metadata from.
|
|
42
|
-
* @returns Promise<Partial<MetaDataType>> A Promise resolving to the extracted metadata.
|
|
43
|
-
*/
|
|
44
|
-
extractMetaData(data: Buffer): Promise<Partial<MetaDataType>>;
|
|
45
|
-
}
|
|
46
|
-
declare const _default: {
|
|
47
|
-
Sticker: typeof Sticker;
|
|
48
|
-
StickerTypes: typeof StickerTypes;
|
|
49
|
-
};
|
|
50
|
-
export default _default;
|
package/dist/lib/ToWebp.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { MetaDataType } from '../types/metaInfoType.js';
|
|
2
|
-
/**
|
|
3
|
-
* Converts a given buffer to WebP format with optional transformations.
|
|
4
|
-
*
|
|
5
|
-
* @param {Buffer} buffer - The input buffer to be converted.
|
|
6
|
-
* @param {Partial<MetaDataType>} metaInfo - Metadata information for the conversion.
|
|
7
|
-
* @param {string} mimeExt - The MIME extension of the input buffer.
|
|
8
|
-
* @param {string} mimeType - The MIME type of the input buffer.
|
|
9
|
-
* @returns {Promise<Buffer>} - A promise that resolves to the converted WebP buffer.
|
|
10
|
-
*/
|
|
11
|
-
declare const ToWebp: (buffer: Buffer, metaInfo: Partial<MetaDataType>, mimeExt: string, mimeType: string) => Promise<Buffer>;
|
|
12
|
-
export default ToWebp;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import Image from 'node-webpmux';
|
|
2
|
-
/**
|
|
3
|
-
* The Exif class is responsible for handling the metadata (Exif data)
|
|
4
|
-
* for sticker images, particularly those used in messaging applications.
|
|
5
|
-
*/
|
|
6
|
-
export default class Exif {
|
|
7
|
-
private data;
|
|
8
|
-
private exif;
|
|
9
|
-
/**
|
|
10
|
-
* Constructs an Exif instance with the given options.
|
|
11
|
-
* @param options - An object containing metadata for the sticker.
|
|
12
|
-
*/
|
|
13
|
-
constructor(options: any);
|
|
14
|
-
/**
|
|
15
|
-
* Builds the Exif metadata as a Buffer.
|
|
16
|
-
* @returns A Buffer containing the constructed Exif data.
|
|
17
|
-
*/
|
|
18
|
-
build: () => Buffer;
|
|
19
|
-
/**
|
|
20
|
-
* Adds the Exif metadata to the given image.
|
|
21
|
-
* @param image - A Buffer or Image instance representing the image to which Exif data should be added.
|
|
22
|
-
* @returns A Promise that resolves to a Buffer containing the image with the added Exif data.
|
|
23
|
-
*/
|
|
24
|
-
add: (image: Buffer | Image.Image) => Promise<Buffer>;
|
|
25
|
-
}
|
package/dist/lib/toGif.d.ts
DELETED
package/dist/lib/utils.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Readable } from 'stream';
|
|
2
|
-
export default class Utils {
|
|
3
|
-
constructor();
|
|
4
|
-
/**
|
|
5
|
-
* Converts various types of input data to a Buffer.
|
|
6
|
-
* @param data Input data as Buffer, string (file path), or Readable stream.
|
|
7
|
-
* @returns Promise<Buffer> A Promise resolving to the converted Buffer.
|
|
8
|
-
* @throws Error if conversion fails.
|
|
9
|
-
*/
|
|
10
|
-
buffer(data: Buffer | string | Readable): Promise<Buffer>;
|
|
11
|
-
/**
|
|
12
|
-
* Converts a Readable stream to a Buffer.
|
|
13
|
-
* @param stream Readable stream to convert.
|
|
14
|
-
* @returns Promise<Buffer> A Promise resolving to the converted Buffer.
|
|
15
|
-
*/
|
|
16
|
-
streamToBuffer(stream: Readable): Promise<Buffer>;
|
|
17
|
-
/**
|
|
18
|
-
* Determines the quality of the data based on its size.
|
|
19
|
-
* @param data Buffer containing the data.
|
|
20
|
-
* @returns number Quality value based on data size.
|
|
21
|
-
*/
|
|
22
|
-
getQuality(data: Buffer): number;
|
|
23
|
-
/**
|
|
24
|
-
* Determines the MIME type of the data buffer.
|
|
25
|
-
* @param data Buffer containing the data.
|
|
26
|
-
* @returns Promise<{ mime: string; ext: string }> A Promise resolving to an object with MIME type and extension.
|
|
27
|
-
*/
|
|
28
|
-
getMimeType(data: Buffer): Promise<{
|
|
29
|
-
mime: string;
|
|
30
|
-
ext: string;
|
|
31
|
-
} | undefined>;
|
|
32
|
-
/**
|
|
33
|
-
* Generates a random ID.
|
|
34
|
-
* @returns string A random alphanumeric ID.
|
|
35
|
-
*/
|
|
36
|
-
getId(): string;
|
|
37
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
type LoveEmojis = 'โค' | '๐' | '๐' | '๐' | '๐ป' | '๐' | '๐ฉโโคโ๐ฉ' | '๐จโโคโ๐จ' | '๐' | '๐ฉโโคโ๐โ๐ฉ' | '๐จโโคโ๐โ๐จ' | '๐งก' | '๐' | '๐' | '๐' | '๐' | '๐ค' | '๐' | 'โฃ' | '๐' | '๐' | '๐' | '๐' | '๐' | '๐' | '๐' | 'โฅ' | '๐' | '๐' | '๐ฉโโค๏ธโ๐โ๐ฉ' | '๐จโโค๏ธโ๐โ๐จ' | '๐ฉโโค๏ธโ๐จ' | '๐ฉโโค๏ธโ๐ฉ' | '๐จโโค๏ธโ๐จ' | '๐ฉโโค๏ธโ๐โ๐จ' | '๐ฌ' | '๐ญ' | '๐ซ' | '๐ฅฐ' | '๐' | '๐' | '๐' | '๐น' | '๐ฝ' | 'โฃ๏ธ' | 'โค๏ธ';
|
|
2
|
-
type HappyEmojis = '๐' | '๐' | '๐' | '๐' | '๐' | '๐
' | '๐' | '๐คฃ' | '๐' | '๐' | '๐' | '๐' | '๐คช' | '๐ค' | '๐บ' | '๐ธ' | '๐น' | 'โบ' | '๐' | '๐' | '๐ค' | '๐';
|
|
3
|
-
type SadEmojis = 'โน' | '๐ฃ' | '๐' | '๐ซ' | '๐ฉ' | '๐ข' | '๐ญ' | '๐' | '๐' | '๐' | '๐' | '๐ค' | '๐ ' | '๐ฅ' | '๐ฐ' | '๐จ' | '๐ฟ' | '๐พ' | '๐' | '๐โโ๏ธ' | '๐โโ๏ธ' | '๐' | '๐' | '๐ฅบ' | '๐ค' | 'โ๏ธ' | 'โ' | '๐ฉ' | '๐ง';
|
|
4
|
-
type AngryEmojis = '๐ฏ' | '๐ฆ' | '๐ง' | '๐ฎ' | '๐ฒ' | '๐' | '๐ฑ' | '๐คฏ' | '๐ณ' | 'โ' | 'โ' | '๐คฌ' | '๐ก' | '๐ ' | '๐' | '๐ฟ' | '๐พ' | '๐ค' | '๐ข' | '๐บ' | '๐ฏ๏ธ' | '๐' | '๐ฅต';
|
|
5
|
-
type GreetEmojis = '๐';
|
|
6
|
-
type CelebrateEmojis = '๐' | '๐' | '๐' | '๐' | '๐ฏโโ๏ธ' | '๐ฏ' | '๐ฏโโ๏ธ' | '๐' | '๐บ' | '๐ฅ' | 'โญ๏ธ' | 'โจ' | '๐ซ' | '๐' | '๐' | '๐ป' | '๐ฅ' | '๐พ' | '๐' | '๐ฐ';
|
|
7
|
-
export type category = LoveEmojis | HappyEmojis | SadEmojis | AngryEmojis | GreetEmojis | CelebrateEmojis;
|
|
8
|
-
export {};
|