feat: import Chinese-localized Buzz source snapshot
Docker image / Build (linux/amd64) (push) Has been cancelled
Docker image / Build (linux/arm64) (push) Has been cancelled
Docker image / Merge release multi-arch manifest (push) Has been cancelled
Docker image / Merge debug multi-arch manifest (push) Has been cancelled
Docker image / Build public push gateway (linux/amd64) (push) Has been cancelled
Docker image / Build public push gateway (linux/arm64) (push) Has been cancelled
Docker image / Publish public push gateway image (push) Has been cancelled
Sprig image / Build (linux/amd64) (push) Has been cancelled
Sprig image / Build (linux/arm64) (push) Has been cancelled
Sprig image / Merge multi-arch manifest (push) Has been cancelled
Harbor Buzz Orchestra / Python tests and lint (push) Has been cancelled
CI / Detect Changed Paths (push) Has been cancelled
CI / Rust Lint (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Desktop Core (push) Has been cancelled
CI / Desktop Smoke E2E (1) (push) Has been cancelled
CI / Desktop Smoke E2E (2) (push) Has been cancelled
CI / Desktop Smoke E2E (3) (push) Has been cancelled
CI / Desktop Smoke E2E (4) (push) Has been cancelled
CI / Desktop (push) Has been cancelled
CI / Desktop E2E Relay (push) Has been cancelled
CI / Desktop E2E Integration (1/2) (push) Has been cancelled
CI / Desktop E2E Integration (2/2) (push) Has been cancelled
CI / Desktop E2E Integration (push) Has been cancelled
CI / Backend Integration (relay e2e) (push) Has been cancelled
CI / Relay E2E (push) Has been cancelled
CI / Web (push) Has been cancelled
CI / Mobile (push) Has been cancelled
CI / Security (push) Has been cancelled
CI / Dead Token Reference Guard (push) Has been cancelled
CI / Server Cross-Compile (aarch64-unknown-linux-musl) (push) Has been cancelled
CI / Server Cross-Compile (x86_64-unknown-linux-musl) (push) Has been cancelled
CI / Windows Rust (x86_64-pc-windows-msvc) (push) Has been cancelled
CI / Desktop Build (macOS) (push) Has been cancelled
helm chart / lint + unittest + render matrix (push) Has been cancelled
helm chart / install on kind (gated) (push) Has been cancelled
helm chart / publish chart to GHCR (push) Has been cancelled
Mesh Lifecycle / Relay-Driven Mesh Lifecycle Smoke (push) Has been cancelled
Sprig / Build (aarch64-unknown-linux-musl) (push) Has been cancelled
Sprig / Build (x86_64-unknown-linux-musl) (push) Has been cancelled
Sprig / Publish rolling release (push) Has been cancelled
Sprig / Publish tagged release (push) Has been cancelled

Signed-off-by: cls_宁波本机 <908705107@qq.com>
This commit is contained in:
2026-08-13 18:34:25 +08:00
parent 61c3fa1df9
commit 9dfa06ffee
3785 changed files with 1085458 additions and 2 deletions
+154
View File
@@ -0,0 +1,154 @@
import 'package:flutter/foundation.dart';
/// The standard (Unicode) emoji set, projected from the same emoji-mart dataset
/// desktop uses.
///
/// The asset at `assets/emoji/emoji-data.json` is generated by
/// `just mobile-emoji-data`; ids here are emoji-mart ids, which are exactly the
/// `:shortcode:` values desktop emits from its picker and resolves in
/// `emojiDisplayName`. Keeping both clients on one dataset is what stops a
/// shortcode from meaning different things on mobile and desktop.
@immutable
class EmojiEntry {
/// emoji-mart id, i.e. the shortcode without the surrounding colons.
final String id;
/// Human-readable name, e.g. `Index Pointing Up`.
final String name;
/// Search keywords from the dataset.
final List<String> keywords;
/// The default-skin glyph.
final String native;
/// Position within emoji-mart's skin list. The default skin is zero.
final int skinIndex;
/// Owning category id, e.g. `people`.
final String categoryId;
const EmojiEntry({
required this.id,
required this.name,
required this.keywords,
required this.native,
required this.categoryId,
this.skinIndex = 0,
});
/// Unique tile id while preserving the desktop-identical shortcode for the
/// default skin.
String get tileId => skinIndex == 0 ? id : '$id-$skinIndex';
}
/// One dataset category, in emoji-mart's own order.
@immutable
class EmojiCategory {
final String id;
final List<EmojiEntry> emoji;
const EmojiCategory({required this.id, required this.emoji});
/// Title-cased label for the category rail.
String get label => switch (id) {
'people' => 'Smileys & People',
'nature' => 'Animals & Nature',
'foods' => 'Food & Drink',
'activity' => 'Activity',
'places' => 'Travel & Places',
'objects' => 'Objects',
'symbols' => 'Symbols',
'flags' => 'Flags',
_ => id,
};
}
/// Parsed emoji dataset: ordered categories, a flat list for search, and a
/// reverse glyph index for resolving a reaction back to its shortcode.
@immutable
class EmojiDataset {
final List<EmojiCategory> categories;
/// Every entry, in category order. Search scans this.
final List<EmojiEntry> all;
/// Glyph to `:shortcode:`. Mirrors desktop's `emojiDisplayName`.
final Map<String, String> nativeToShortcode;
const EmojiDataset({
required this.categories,
required this.all,
required this.nativeToShortcode,
});
static const empty = EmojiDataset(
categories: [],
all: [],
nativeToShortcode: {},
);
bool get isEmpty => all.isEmpty;
/// Resolve a reaction value to something displayable as a name: a custom
/// emoji's `:shortcode:` passes through, a Unicode glyph maps to its
/// shortcode, and anything unknown falls back to itself.
String displayName(String emoji) {
final trimmed = emoji.trim();
if (trimmed.startsWith(':') && trimmed.endsWith(':')) return trimmed;
return nativeToShortcode[trimmed] ?? trimmed;
}
/// Parse the generated asset. Runs on a background isolate via `compute`, so
/// it must stay a top-level-callable pure function over plain JSON.
static EmojiDataset fromJson(Map<String, dynamic> json) {
final rawEmoji = (json['emoji'] as Map).cast<String, dynamic>();
final rawCategories = (json['categories'] as List).cast<dynamic>();
final categories = <EmojiCategory>[];
final all = <EmojiEntry>[];
final nativeToShortcode = <String, String>{};
for (final rawCategory in rawCategories) {
final category = (rawCategory as Map).cast<String, dynamic>();
final categoryId = category['id'] as String;
final entries = <EmojiEntry>[];
for (final rawId in (category['emoji'] as List).cast<dynamic>()) {
final id = rawId as String;
final record = (rawEmoji[id] as Map?)?.cast<String, dynamic>();
if (record == null) continue;
// Older committed assets used one string; accept that shape so the
// parser remains safe while generated assets move to all skin variants.
final natives = switch (record['u']) {
final List values => values.cast<String>(),
final String value => [value],
_ => const <String>[],
};
for (final (skinIndex, native) in natives.indexed) {
final entry = EmojiEntry(
id: id,
name: record['n'] as String,
keywords: (record['k'] as List).cast<String>(),
native: native,
categoryId: categoryId,
skinIndex: skinIndex,
);
entries.add(entry);
all.add(entry);
// First writer wins so the earliest category owns a shared glyph,
// matching desktop's map build order.
nativeToShortcode.putIfAbsent(entry.native, () => ':$id:');
}
}
categories.add(EmojiCategory(id: categoryId, emoji: entries));
}
return EmojiDataset(
categories: categories,
all: all,
nativeToShortcode: nativeToShortcode,
);
}
}