Update emoji-datasource to 16.0.0

This commit is contained in:
Fedor Indutny
2025-09-30 13:28:52 -07:00
committed by GitHub
parent 7bb8a35839
commit b2f1639146
14 changed files with 4113 additions and 4083 deletions

View File

@@ -10,20 +10,12 @@ import { LRUCache } from 'lru-cache';
import type { OptionalResourceService } from './OptionalResourceService.js';
import { SignalService as Proto } from '../ts/protobuf/index.js';
import { parseUnknown } from '../ts/util/schemas.js';
import { utf16ToEmoji } from '../ts/util/utf16ToEmoji.js';
const MANIFEST_PATH = join(__dirname, '..', 'build', 'jumbomoji.json');
const manifestSchema = z.record(z.string(), z.string().array());
function utf16ToEmoji(utf16: string): string {
const codePoints = new Array<number>();
const buf = Buffer.from(utf16, 'hex');
for (let i = 0; i < buf.length; i += 2) {
codePoints.push(buf.readUint16BE(i));
}
return String.fromCodePoint(...codePoints);
}
export type ManifestType = z.infer<typeof manifestSchema>;
type EmojiEntryType = Readonly<{
@@ -57,7 +49,7 @@ export class EmojiService {
for (const [sheet, emojiList] of Object.entries(manifest)) {
for (const utf16 of emojiList) {
this.#emojiMap.set(utf16ToEmoji(utf16), { sheet, utf16 });
this.#emojiMap.set(utf16, { sheet, utf16 });
}
}
}
@@ -92,7 +84,7 @@ export class EmojiService {
imageMap = new Map(
pack.items.map(({ name, image }) => [
name ?? '',
name != null ? utf16ToEmoji(name) : '',
image || new Uint8Array(0),
])
);

View File

@@ -61,13 +61,13 @@ export class OptionalResourceService {
return undefined;
}
const inMemory = this.#cache.get(name);
if (inMemory) {
return inMemory;
}
const filePath = join(this.resourcesDir, name);
return this.#queueFileWork(filePath, async () => {
const inMemory = this.#cache.get(name);
if (inMemory) {
return inMemory;
}
try {
const onDisk = await readFile(filePath);
const digest = createHash('sha512').update(onDisk).digest();