@shibam/sticker-maker 1.0.9 → 1.0.11

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.d.ts CHANGED
@@ -37,7 +37,7 @@ declare class Sticker {
37
37
  * @param newMetaInfo Partial metadata to update.
38
38
  * @returns Promise<Buffer> A Promise resolving to the Buffer with updated metadata.
39
39
  */
40
- changeMetaInfo(newMetaInfo?: Partial<MetaDataType>): Promise<Buffer>;
40
+ changeMetaInfo(): Promise<Buffer>;
41
41
  /**
42
42
  * Extracts metadata from the provided data.
43
43
  * @param data Buffer containing the data to extract metadata from.
package/dist/index.js CHANGED
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -180,9 +169,8 @@ var Sticker = /** @class */ (function () {
180
169
  * @returns Promise<Buffer> A Promise resolving to the Buffer with updated metadata.
181
170
  */
182
171
  Sticker.prototype.changeMetaInfo = function () {
183
- return __awaiter(this, arguments, void 0, function (newMetaInfo) {
172
+ return __awaiter(this, void 0, void 0, function () {
184
173
  var _a, error_4;
185
- if (newMetaInfo === void 0) { newMetaInfo = {}; }
186
174
  return __generator(this, function (_b) {
187
175
  switch (_b.label) {
188
176
  case 0:
@@ -190,7 +178,6 @@ var Sticker = /** @class */ (function () {
190
178
  return [4 /*yield*/, this.initialize()];
191
179
  case 1:
192
180
  _b.sent();
193
- this.metaInfo = __assign(__assign({}, this.metaInfo), newMetaInfo);
194
181
  _a = this;
195
182
  return [4 /*yield*/, new changeMetaInfo_js_1.default(this.metaInfo).add(this.buffer)];
196
183
  case 2:
@@ -96,7 +96,7 @@ var ToWebp = function (buffer, metaInfo, mimeExt, mimeType) { return __awaiter(v
96
96
  ? "-filter_complex \"color=".concat(metaInfo.background, " [c]; [c][0]scale2ref[cs][0s];[cs][0s]overlay=shortest=1, unsharp=3:3:0.5").concat(metaInfo.type === StickerTypes_js_1.StickerTypes.CIRCLE ||
97
97
  metaInfo.type === StickerTypes_js_1.StickerTypes.SQUARE ||
98
98
  metaInfo.type === StickerTypes_js_1.StickerTypes.FIT
99
- ? ", ".concat(metaInfo.type.replaceAll(/-vf/g, '').replaceAll(/"/g, '').replace('-filter_complex', '').trim())
99
+ ? ", ".concat(metaInfo.type.replace(/-vf/g, '').replace(/"/g, '').replace('-filter_complex', '').trim())
100
100
  : '', "\"")
101
101
  : '-pix_fmt yuva420p',
102
102
  (mimeExt === null || mimeExt === void 0 ? void 0 : mimeExt.includes('gif')) || (mimeType === null || mimeType === void 0 ? void 0 : mimeType.includes('video'))
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -51,6 +40,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
51
40
  };
52
41
  Object.defineProperty(exports, "__esModule", { value: true });
53
42
  var node_webpmux_1 = __importDefault(require("node-webpmux"));
43
+ var util_1 = require("util");
54
44
  /**
55
45
  * The Exif class is responsible for handling the metadata (Exif data)
56
46
  * for sticker images, particularly those used in messaging applications.
@@ -70,21 +60,14 @@ var Exif = /** @class */ (function () {
70
60
  */
71
61
  this.build = function () {
72
62
  var data = JSON.stringify(_this.data);
73
- var dataBuffer = Buffer.from(data, 'utf-8');
74
- // Construct the Exif header.
75
- var exifHeader = Buffer.alloc(22); // Allocate a new buffer of the correct size
76
- exifHeader.write('Exif\0\0', 0); // Exif header
77
- exifHeader.writeUInt16LE(0x4949, 6); // II for little-endian
78
- exifHeader.writeUInt16LE(0x002a, 8); // TIFF header
79
- exifHeader.writeUInt32LE(0x00000008, 10); // Offset to first IFD
80
- // Write the APP1 marker and size
81
- var app1Marker = Buffer.from([0xff, 0xe1]);
82
- var app1Size = Buffer.alloc(2);
83
- app1Size.writeUInt16BE(2 + exifHeader.length + dataBuffer.length);
84
- // Write the length of the data into the Exif header.
85
- exifHeader.writeUInt32LE(dataBuffer.length, 14);
86
- // Concatenate all parts
87
- var exif = Buffer.concat([app1Marker, app1Size, exifHeader, dataBuffer]);
63
+ var exif = Buffer.concat([
64
+ Buffer.from([
65
+ 0x49, 0x49, 0x2a, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00,
66
+ 0x00, 0x16, 0x00, 0x00, 0x00
67
+ ]),
68
+ Buffer.from(data, 'utf-8')
69
+ ]);
70
+ exif.writeUIntLE(new util_1.TextEncoder().encode(data).length, 14, 4);
88
71
  return exif;
89
72
  };
90
73
  /**
@@ -148,13 +131,10 @@ var Exif = /** @class */ (function () {
148
131
  }
149
132
  });
150
133
  }); };
151
- this.data['sticker-pack-id'] = options.id;
134
+ this.data['sticker-pack-id'] = options.id || '';
152
135
  this.data['sticker-pack-name'] = options.pack || '';
153
136
  this.data['sticker-pack-publisher'] = options.author || '';
154
- this.data['emojis'] = options.category || [];
155
- this.data['sticker-quality'] = options.quality || '30';
156
- this.data['sticker-background'] = options.background || '';
157
- this.data = __assign(__assign({}, this.data), options);
137
+ this.data['emojis'] = options.category || ['😹'];
158
138
  }
159
139
  return Exif;
160
140
  }());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shibam/sticker-maker",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "A package for creating stickers",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",