medias-fakerator 1.0.0-dra.4 → 1.0.0-dra.6
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/assets/database/emojilist_0.6.json +32409 -0
- package/assets/database/emojilist_0.7.json +6001 -0
- package/assets/database/emojilist_1.0.json +19919 -0
- package/assets/database/emojilist_11.0.json +6384 -0
- package/assets/database/emojilist_12.0.json +9610 -0
- package/assets/database/emojilist_12.1.json +6696 -0
- package/assets/database/emojilist_13.0.json +4609 -0
- package/assets/database/emojilist_13.1.json +10498 -0
- package/assets/database/emojilist_14.0.json +4200 -0
- package/assets/database/emojilist_15.0.json +1020 -0
- package/assets/database/emojilist_15.1.json +3903 -0
- package/assets/database/emojilist_16.0.json +227 -0
- package/assets/database/emojilist_2.0.json +11626 -0
- package/assets/database/emojilist_3.0.json +6419 -0
- package/assets/database/emojilist_4.0.json +25700 -0
- package/assets/database/emojilist_5.0.json +10362 -0
- package/assets/database/emojilist_esq.latest.json +610 -0
- package/assets/database/emojilist_nfq.latest.json +5010 -0
- package/assets/database/emojilist_xdd.latest.json +15126 -0
- package/lib/quote-generator.js +1 -1
- package/lib/utils/emoji-db.js +149 -0
- package/lib/utils/emoji-searcher.js +115 -0
- package/lib/utils.js +1 -1
- package/package.json +2 -3
- package/assets/test-assets/profile.jpg +0 -0
- package/assets/test-output/brat-animated.webp +0 -0
- package/assets/test-output/brat-animatedHd.webp +0 -0
- package/assets/test-output/brat-video-frame-1.png +0 -0
- package/assets/test-output/brat-video-frame-1Hd.png +0 -0
- package/assets/test-output/brat.png +0 -0
- package/assets/test-output/bratHd.png +0 -0
- package/assets/test-output/fake-call-android.png +0 -0
- package/assets/test-output/fake-call-iphone.png +0 -0
- package/assets/test-output/fake-chat-iphone.png +0 -0
- package/assets/test-output/fake-story.png +0 -0
- package/assets/test-output/fake-tweet.png +0 -0
- package/assets/test-output/google-lyrics.png +0 -0
- package/assets/test-output/google-search.png +0 -0
- package/assets/test-output/instagram-profile.png +0 -0
- package/assets/test-output/ktp-card.png +0 -0
- package/assets/test-output/meme.png +0 -0
- package/assets/test-output/quote.png +0 -0
- package/assets/test-output/tiktok-profile.png +0 -0
- package/assets/test-output/twitter-profile.png +0 -0
- package/assets/test-output/youtube-profile.png +0 -0
package/lib/quote-generator.js
CHANGED
|
@@ -2,7 +2,7 @@ const fs = require("fs");
|
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const runes = require("runes");
|
|
4
4
|
const sharp = require("sharp");
|
|
5
|
-
const EmojiDbLib = require("emoji-db");
|
|
5
|
+
const EmojiDbLib = require("./utils/emoji-db");
|
|
6
6
|
const { LRUCache } = require("lru-cache");
|
|
7
7
|
const emojiDb = new EmojiDbLib({ useDefaultDb: true });
|
|
8
8
|
const emojiImageByBrandPromise = require("emoji-cache");
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const EmojiSearcher = require("./emoji-searcher");
|
|
3
|
+
|
|
4
|
+
function initDb({ dbDir, ignoreUnqualified, logInit }) {
|
|
5
|
+
// default db filenames
|
|
6
|
+
const filePrefx = "emojilist_";
|
|
7
|
+
const fileSuffx = ".json";
|
|
8
|
+
// load files
|
|
9
|
+
let dbFiles = fs.readdirSync(dbDir);
|
|
10
|
+
// remove non db files
|
|
11
|
+
dbFiles = dbFiles.filter((dbFile) => {
|
|
12
|
+
if (!dbFile.endsWith(".json") || !dbFile.startsWith(filePrefx)) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return true;
|
|
16
|
+
});
|
|
17
|
+
// make emoji db nums
|
|
18
|
+
dbFiles = dbFiles.map((dbFile) => {
|
|
19
|
+
return dbFile
|
|
20
|
+
.replace(new RegExp("^" + filePrefx), "")
|
|
21
|
+
.replace(new RegExp(fileSuffx + "$"), "");
|
|
22
|
+
});
|
|
23
|
+
// sort dbs
|
|
24
|
+
dbFiles.sort((a, b) => {
|
|
25
|
+
a = !a.match(/nfq|esq|xdd/) ? parseFloat(a) : Infinity;
|
|
26
|
+
b = !b.match(/nfq|esq|xdd/) ? parseFloat(b) : Infinity;
|
|
27
|
+
return a - b;
|
|
28
|
+
});
|
|
29
|
+
// log
|
|
30
|
+
if (logInit) console.log("[LOG] Emoji versions:", dbFiles.join(", "));
|
|
31
|
+
// load dbs
|
|
32
|
+
let emojiDbData = {};
|
|
33
|
+
if (!/[\/\\]$/.test(dbDir)) {
|
|
34
|
+
dbDir += "/";
|
|
35
|
+
}
|
|
36
|
+
for (const dbFile of dbFiles) {
|
|
37
|
+
if (ignoreUnqualified && dbFile.match(/nfq/)) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
let loadEmojiDbData = require(dbDir + filePrefx + dbFile + fileSuffx);
|
|
41
|
+
for (let e of loadEmojiDbData) {
|
|
42
|
+
if (dbFile.match(/xdd/) && emojiDbData[e.code]) {
|
|
43
|
+
emojiDbData[e.code].description = e.description;
|
|
44
|
+
}
|
|
45
|
+
if (dbFile.match(/xdd/)) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (emojiDbData[e.code]) {
|
|
49
|
+
console.log("[WARN] DUBLICATE ENTRY IN DB:", dbFile, e.code);
|
|
50
|
+
}
|
|
51
|
+
emojiDbData[e.code] = e;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// return db
|
|
55
|
+
if (logInit)
|
|
56
|
+
console.log(
|
|
57
|
+
"[LOG] EmojiDB loaded %s entries.",
|
|
58
|
+
Object.keys(emojiDbData).length
|
|
59
|
+
);
|
|
60
|
+
return emojiDbData;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
class EmojiDb {
|
|
64
|
+
constructor(opts) {
|
|
65
|
+
// reset to object
|
|
66
|
+
if (typeof opts != "object") {
|
|
67
|
+
opts = {};
|
|
68
|
+
}
|
|
69
|
+
// set undefined
|
|
70
|
+
const useDefaultDb = opts.useDefaultDb || undefined;
|
|
71
|
+
const dbDir = opts.dbDir || undefined;
|
|
72
|
+
const ignoreUnqualified = opts.ignoreUnqualified || undefined;
|
|
73
|
+
const logInit = opts.logInit || undefined;
|
|
74
|
+
// set defaults
|
|
75
|
+
this.codePointSeparator = "-";
|
|
76
|
+
this.dbData = {};
|
|
77
|
+
// empty db
|
|
78
|
+
if (useDefaultDb && !dbDir) {
|
|
79
|
+
const dbDefDir = __dirname + "../assets/database/";
|
|
80
|
+
this.dbData = initDb({ dbDir: dbDefDir, ignoreUnqualified, logInit });
|
|
81
|
+
} else if (!useDefaultDb && dbDir) {
|
|
82
|
+
this.dbData = initDb({ dbDir, ignoreUnqualified, logInit });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
searchFromText({ input, fixCodePoints, showData }) {
|
|
86
|
+
let foundEmojis = new EmojiSearcher(this.dbData).getEmojis(input);
|
|
87
|
+
if (fixCodePoints || showData) {
|
|
88
|
+
let fixedFoundEmojis = [];
|
|
89
|
+
for (let e of foundEmojis) {
|
|
90
|
+
e.found = fixEmojiCodePoint(e.found, this.dbData);
|
|
91
|
+
e.emoji = this.dbData[e.found].emoji;
|
|
92
|
+
fixedFoundEmojis.push(e);
|
|
93
|
+
}
|
|
94
|
+
foundEmojis = fixedFoundEmojis;
|
|
95
|
+
}
|
|
96
|
+
if (showData) {
|
|
97
|
+
const emojisData = [];
|
|
98
|
+
for (let e of foundEmojis) {
|
|
99
|
+
emojisData.push(this.dbData[e.found]);
|
|
100
|
+
}
|
|
101
|
+
return { found: foundEmojis, data: [...new Set(emojisData)] };
|
|
102
|
+
} else {
|
|
103
|
+
return foundEmojis;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
toCodePoint(emoji, separator) {
|
|
107
|
+
let codePointArray = [];
|
|
108
|
+
for (const textContent of emoji) {
|
|
109
|
+
codePointArray.push(
|
|
110
|
+
textContent.codePointAt(0).toString(16).padStart(4, "0")
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
return codePointArray.join(separator || this.codePointSeparator);
|
|
114
|
+
}
|
|
115
|
+
fromCodePoint(codePoint, separator) {
|
|
116
|
+
separator = separator || this.codePointSeparator;
|
|
117
|
+
if (typeof codePoint === "string") {
|
|
118
|
+
let codePointArray = codePoint.split(separator);
|
|
119
|
+
for (let c in codePointArray) {
|
|
120
|
+
codePointArray[c] = String.fromCodePoint(
|
|
121
|
+
parseInt(codePointArray[c], 16)
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
return codePointArray.join("");
|
|
125
|
+
}
|
|
126
|
+
return String.fromCodePoint(codePoint);
|
|
127
|
+
}
|
|
128
|
+
toCodePointArray(emojiArray, separator) {
|
|
129
|
+
let codePointArray = [];
|
|
130
|
+
separator = separator || this.codePointSeparator;
|
|
131
|
+
for (let ix = 0; ix < emojiArray.length; ix++) {
|
|
132
|
+
codePointArray.push(this.toCodePoint(emojiArray[ix], separator));
|
|
133
|
+
}
|
|
134
|
+
return codePointArray;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function fixEmojiCodePoint(codePoint, dbData) {
|
|
139
|
+
if (
|
|
140
|
+
dbData[codePoint] &&
|
|
141
|
+
dbData[codePoint].qualified &&
|
|
142
|
+
dbData[dbData[codePoint].qualified]
|
|
143
|
+
) {
|
|
144
|
+
return dbData[codePoint].qualified;
|
|
145
|
+
}
|
|
146
|
+
return codePoint;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
module.exports = EmojiDb;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
class EmojiSearcher {
|
|
2
|
+
constructor(db) {
|
|
3
|
+
let smap = {};
|
|
4
|
+
for (const r in db) {
|
|
5
|
+
addSmapElement(smap, r);
|
|
6
|
+
}
|
|
7
|
+
this._smap = smap;
|
|
8
|
+
}
|
|
9
|
+
getEmojis(text) {
|
|
10
|
+
let sp = this._smap;
|
|
11
|
+
let lastCode = "";
|
|
12
|
+
let emojis = [];
|
|
13
|
+
let root = true;
|
|
14
|
+
let lastStart = -1;
|
|
15
|
+
let index = 0;
|
|
16
|
+
for (const rune of text) {
|
|
17
|
+
const cp = rune.codePointAt(0).toString(16).padStart(4, "0");
|
|
18
|
+
if (cp in sp) {
|
|
19
|
+
if (lastStart < 0) {
|
|
20
|
+
lastStart = index;
|
|
21
|
+
}
|
|
22
|
+
if ("code" in sp[cp]) {
|
|
23
|
+
lastCode = sp[cp].code;
|
|
24
|
+
}
|
|
25
|
+
if ("child" in sp[cp]) {
|
|
26
|
+
sp = sp[cp].child;
|
|
27
|
+
root = false;
|
|
28
|
+
} else {
|
|
29
|
+
if (lastCode != "") {
|
|
30
|
+
emojis.push({
|
|
31
|
+
found: lastCode,
|
|
32
|
+
offset: lastStart,
|
|
33
|
+
length: index - lastStart + rune.length,
|
|
34
|
+
});
|
|
35
|
+
lastCode = "";
|
|
36
|
+
}
|
|
37
|
+
lastStart = -1;
|
|
38
|
+
sp = this._smap;
|
|
39
|
+
root = true;
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
if (lastCode != "") {
|
|
43
|
+
emojis.push({
|
|
44
|
+
found: lastCode,
|
|
45
|
+
offset: lastStart,
|
|
46
|
+
length: index - lastStart,
|
|
47
|
+
});
|
|
48
|
+
lastCode = "";
|
|
49
|
+
}
|
|
50
|
+
lastStart = -1;
|
|
51
|
+
sp = this._smap;
|
|
52
|
+
if (!root) {
|
|
53
|
+
root = true;
|
|
54
|
+
// retry search in root
|
|
55
|
+
if (cp in sp) {
|
|
56
|
+
if (lastStart < 0) {
|
|
57
|
+
lastStart = index;
|
|
58
|
+
}
|
|
59
|
+
if ("code" in sp[cp]) {
|
|
60
|
+
lastCode = sp[cp].code;
|
|
61
|
+
}
|
|
62
|
+
if ("child" in sp[cp]) {
|
|
63
|
+
sp = sp[cp].child;
|
|
64
|
+
root = false;
|
|
65
|
+
} else {
|
|
66
|
+
if (lastCode != "") {
|
|
67
|
+
emojis.push({
|
|
68
|
+
found: lastCode,
|
|
69
|
+
offset: lastStart,
|
|
70
|
+
length: index - lastStart + rune.length,
|
|
71
|
+
});
|
|
72
|
+
lastCode = "";
|
|
73
|
+
}
|
|
74
|
+
lastStart = -1;
|
|
75
|
+
sp = this._smap;
|
|
76
|
+
root = true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
index += rune.length;
|
|
82
|
+
}
|
|
83
|
+
if (lastCode != "") {
|
|
84
|
+
emojis.push({
|
|
85
|
+
found: lastCode,
|
|
86
|
+
offset: lastStart,
|
|
87
|
+
length: index - lastStart,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
emojis.forEach((e) => (e.emoji = text.substr(e.offset, e.length)));
|
|
91
|
+
return emojis;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function addSmapElement(smap, code) {
|
|
96
|
+
let c = code.split("-");
|
|
97
|
+
let m = smap;
|
|
98
|
+
for (let i = 0; i < c.length - 1; i++) {
|
|
99
|
+
const p = c[i];
|
|
100
|
+
if (!(p in m)) {
|
|
101
|
+
m[p] = {};
|
|
102
|
+
}
|
|
103
|
+
if (!("child" in m[p])) {
|
|
104
|
+
m[p].child = {};
|
|
105
|
+
}
|
|
106
|
+
m = m[p].child;
|
|
107
|
+
}
|
|
108
|
+
let p = c[c.length - 1];
|
|
109
|
+
if (!(p in m)) {
|
|
110
|
+
m[p] = {};
|
|
111
|
+
}
|
|
112
|
+
m[p].code = code;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
module.exports = EmojiSearcher;
|
package/lib/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "medias-fakerator",
|
|
3
|
-
"version": "1.0.0-dra.
|
|
3
|
+
"version": "1.0.0-dra.6",
|
|
4
4
|
"description": "AIO Faker generator by Iruka Devs",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "Iruka Devs",
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@ffmpeg-installer/ffmpeg": "1.1.0",
|
|
12
12
|
"canvas": "^3.2.0",
|
|
13
|
-
"emoji-cache": "^2.0.
|
|
14
|
-
"emoji-db": "^16.0.1",
|
|
13
|
+
"emoji-cache": "^2.0.4",
|
|
15
14
|
"fluent-ffmpeg": "^2.1.3",
|
|
16
15
|
"fs-extra": "11.3.2",
|
|
17
16
|
"lru-cache": "^11.1.0",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|