mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 12:19:41 +00:00
Update emoji-datasource to 16.0.0
This commit is contained in:
@@ -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),
|
||||
])
|
||||
);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user