From 1d870fa78de0b7ddd97c69bfb392646ec12cc069 Mon Sep 17 00:00:00 2001 From: Kainoa Kanter Date: Mon, 4 Dec 2023 04:45:42 +0000 Subject: [PATCH] fix: :arrow_up: switch from twemoji-parser to @twemoji/parser --- packages/backend/package.json | 2 +- packages/backend/src/misc/emoji-regex.ts | 2 +- packages/client/src/scripts/emojilist.ts | 35 +++--------------------- pnpm-lock.yaml | 10 +++++-- 4 files changed, 13 insertions(+), 36 deletions(-) diff --git a/packages/backend/package.json b/packages/backend/package.json index c4f0236757..19386188f9 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -39,6 +39,7 @@ "@redocly/openapi-core": "1.4.1", "@sinonjs/fake-timers": "11.2.2", "@tensorflow/tfjs": "^4.13.0", + "@twemoji/parser": "^15.0.0", "adm-zip": "^0.5.10", "ajv": "8.12.0", "archiver": "6.0.1", @@ -128,7 +129,6 @@ "tinycolor2": "1.6.0", "tinyld": "^1.3.4", "tmp": "0.2.1", - "twemoji-parser": "14.0.0", "typeorm": "0.3.17", "ulid": "2.3.0", "uuid": "9.0.1", diff --git a/packages/backend/src/misc/emoji-regex.ts b/packages/backend/src/misc/emoji-regex.ts index 08b44788de..72d6a62d9a 100644 --- a/packages/backend/src/misc/emoji-regex.ts +++ b/packages/backend/src/misc/emoji-regex.ts @@ -1,4 +1,4 @@ -import twemoji from "twemoji-parser/dist/lib/regex.js"; +import twemoji from "@twemoji/parser/dist/lib/regex.js"; const twemojiRegex = twemoji.default; export const emojiRegex = new RegExp(`(${twemojiRegex.source})`); diff --git a/packages/client/src/scripts/emojilist.ts b/packages/client/src/scripts/emojilist.ts index 8a2ade12a4..09e6e97065 100644 --- a/packages/client/src/scripts/emojilist.ts +++ b/packages/client/src/scripts/emojilist.ts @@ -57,47 +57,20 @@ export function addSkinTone(emoji: string, skinTone?: number) { } } -const unicodeFifteenEmojis = [ - "🫨", - "🩷", - "🩵", - "🩶", - "🫷", - "🫸", - "🫎", - "🫏", - "🪽", - "🐦‍⬛", - "🪿", - "🪼", - "🪻", - "🫚", - "🫛", - "🪭", - "🪮", - "🪇", - "🪈", - "🪯", - "🛜", -]; - const newData = {}; -Object.keys(data).forEach((originalCategory) => { +for (const originalCategory of Object.keys(data)) { const newCategory = categoryMapping[originalCategory]; if (newCategory) { newData[newCategory] = newData[newCategory] || []; - Object.keys(data[originalCategory]).forEach((emojiIndex) => { + for (const emojiIndex of Object.keys(data[originalCategory])) { const emojiObj = { ...data[originalCategory][emojiIndex] }; - if (unicodeFifteenEmojis.includes(emojiObj.emoji)) { - return; - } emojiObj.category = newCategory; emojiObj.keywords = keywordSet[emojiObj.emoji]; newData[newCategory].push(emojiObj); - }); + } } -}); +} export const emojilist: UnicodeEmojiDef[] = Object.keys(newData).reduce( (acc, category) => { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fa0d8457cb..1dee1ae7cf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -135,6 +135,9 @@ importers: '@tensorflow/tfjs': specifier: ^4.13.0 version: 4.13.0(seedrandom@3.0.5) + '@twemoji/parser': + specifier: ^15.0.0 + version: 15.0.0 adm-zip: specifier: ^0.5.10 version: 0.5.10 @@ -402,9 +405,6 @@ importers: tmp: specifier: 0.2.1 version: 0.2.1 - twemoji-parser: - specifier: 14.0.0 - version: 14.0.0 typeorm: specifier: 0.3.17 version: 0.3.17(ioredis@5.3.2)(pg@8.11.3)(ts-node@10.9.1) @@ -3785,6 +3785,10 @@ packages: engines: {node: '>=14.17'} dev: true + /@twemoji/parser@15.0.0: + resolution: {integrity: sha512-lh9515BNsvKSNvyUqbj5yFu83iIDQ77SwVcsN/SnEGawczhsKU6qWuogewN1GweTi5Imo5ToQ9s+nNTf97IXvg==} + dev: false + /@types/accepts@1.3.5: resolution: {integrity: sha512-jOdnI/3qTpHABjM5cx1Hc0sKsPoYCp+DP/GJRGtDlPd7fiV9oXGGIcjW/ZOxLIvjGz8MA+uMZI9metHlgqbgwQ==} dependencies: