Skip to content

Commit b2f1639

Browse files
Update emoji-datasource to 16.0.0
1 parent 7bb8a35 commit b2f1639

File tree

14 files changed

+4113
-4083
lines changed

14 files changed

+4113
-4083
lines changed

app/EmojiService.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,12 @@ import { LRUCache } from 'lru-cache';
1010
import type { OptionalResourceService } from './OptionalResourceService.js';
1111
import { SignalService as Proto } from '../ts/protobuf/index.js';
1212
import { parseUnknown } from '../ts/util/schemas.js';
13+
import { utf16ToEmoji } from '../ts/util/utf16ToEmoji.js';
1314

1415
const MANIFEST_PATH = join(__dirname, '..', 'build', 'jumbomoji.json');
1516

1617
const manifestSchema = z.record(z.string(), z.string().array());
1718

18-
function utf16ToEmoji(utf16: string): string {
19-
const codePoints = new Array<number>();
20-
const buf = Buffer.from(utf16, 'hex');
21-
for (let i = 0; i < buf.length; i += 2) {
22-
codePoints.push(buf.readUint16BE(i));
23-
}
24-
return String.fromCodePoint(...codePoints);
25-
}
26-
2719
export type ManifestType = z.infer<typeof manifestSchema>;
2820

2921
type EmojiEntryType = Readonly<{
@@ -57,7 +49,7 @@ export class EmojiService {
5749

5850
for (const [sheet, emojiList] of Object.entries(manifest)) {
5951
for (const utf16 of emojiList) {
60-
this.#emojiMap.set(utf16ToEmoji(utf16), { sheet, utf16 });
52+
this.#emojiMap.set(utf16, { sheet, utf16 });
6153
}
6254
}
6355
}
@@ -92,7 +84,7 @@ export class EmojiService {
9284

9385
imageMap = new Map(
9486
pack.items.map(({ name, image }) => [
95-
name ?? '',
87+
name != null ? utf16ToEmoji(name) : '',
9688
image || new Uint8Array(0),
9789
])
9890
);

app/OptionalResourceService.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ export class OptionalResourceService {
6161
return undefined;
6262
}
6363

64-
const inMemory = this.#cache.get(name);
65-
if (inMemory) {
66-
return inMemory;
67-
}
68-
6964
const filePath = join(this.resourcesDir, name);
7065
return this.#queueFileWork(filePath, async () => {
66+
const inMemory = this.#cache.get(name);
67+
if (inMemory) {
68+
return inMemory;
69+
}
70+
7171
try {
7272
const onDisk = await readFile(filePath);
7373
const digest = createHash('sha512').update(onDisk).digest();

0 commit comments

Comments
 (0)