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
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:
@@ -0,0 +1,22 @@
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { runFileSizeCheck } from "../../scripts/check-file-sizes-core.mjs";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const projectRoot = path.resolve(__dirname, "..");
|
||||
|
||||
const MAX_LINES = 1000;
|
||||
|
||||
const rules = [
|
||||
{
|
||||
root: "lib",
|
||||
extensions: new Set([".dart"]),
|
||||
maxLines: MAX_LINES,
|
||||
},
|
||||
];
|
||||
|
||||
await runFileSizeCheck({
|
||||
projectRoot,
|
||||
rules,
|
||||
label: "Mobile",
|
||||
});
|
||||
@@ -0,0 +1,94 @@
|
||||
import { readFileSync, readdirSync, statSync } from "node:fs";
|
||||
import { dirname, join, relative } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const mobileDir = dirname(dirname(fileURLToPath(import.meta.url)));
|
||||
const sourceDir = join(mobileDir, "lib");
|
||||
const arbFiles = ["app_en.arb", "app_zh_CN.arb"];
|
||||
const catalogs = arbFiles.map((file) => ({
|
||||
file,
|
||||
data: JSON.parse(readFileSync(join(sourceDir, "l10n", file), "utf8")),
|
||||
}));
|
||||
|
||||
const messageKeys = (catalog) =>
|
||||
Object.keys(catalog.data).filter((key) => !key.startsWith("@"));
|
||||
const referenceKeys = messageKeys(catalogs[0]);
|
||||
|
||||
for (const catalog of catalogs.slice(1)) {
|
||||
const keys = new Set(messageKeys(catalog));
|
||||
const missing = referenceKeys.filter((key) => !keys.has(key));
|
||||
const extra = [...keys].filter((key) => !(key in catalogs[0].data));
|
||||
if (missing.length || extra.length) {
|
||||
throw new Error(
|
||||
`${catalog.file} ARB mismatch\nmissing: ${missing.join(", ")}\nextra: ${extra.join(", ")}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (const key of referenceKeys) {
|
||||
const metadataKey = `@${key}`;
|
||||
const expected = Object.keys(
|
||||
catalogs[0].data[metadataKey]?.placeholders ?? {},
|
||||
).sort();
|
||||
for (const catalog of catalogs.slice(1)) {
|
||||
const actual = Object.keys(
|
||||
catalog.data[metadataKey]?.placeholders ?? {},
|
||||
).sort();
|
||||
if (JSON.stringify(actual) !== JSON.stringify(expected)) {
|
||||
throw new Error(`${catalog.file} placeholder mismatch for ${key}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const references = new Map();
|
||||
const directUiLiterals = [];
|
||||
const directUiPatterns = [
|
||||
/\bText\(\s*(?:const\s+)?(["'])[A-Za-z][^\r\n]*?\1/g,
|
||||
/\bTextSpan\(\s*text\s*:\s*(["'])[A-Za-z][^\r\n]*?\1/g,
|
||||
/\b(?:tooltip|hintText|labelText|helperText|errorText|semanticLabel)\s*:\s*(["'])[A-Za-z][^\r\n]*?\1/g,
|
||||
];
|
||||
function scanDirectory(directory) {
|
||||
for (const name of readdirSync(directory)) {
|
||||
const path = join(directory, name);
|
||||
if (statSync(path).isDirectory()) {
|
||||
scanDirectory(path);
|
||||
continue;
|
||||
}
|
||||
if (!name.endsWith(".dart")) continue;
|
||||
const source = readFileSync(path, "utf8");
|
||||
for (const match of source.matchAll(/(?:context\.)?l10n\.([A-Za-z_]\w*)/g)) {
|
||||
const key = match[1];
|
||||
if (["dart", "localeName"].includes(key)) continue;
|
||||
if (!references.has(key)) references.set(key, relative(mobileDir, path));
|
||||
}
|
||||
for (const pattern of directUiPatterns) {
|
||||
for (const match of source.matchAll(pattern)) {
|
||||
if (/^Text\(\s*(["'])v\$/.test(match[0])) continue;
|
||||
const line = source.slice(0, match.index).split(/\r?\n/).length;
|
||||
directUiLiterals.push(`${relative(mobileDir, path)}:${line}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
scanDirectory(sourceDir);
|
||||
|
||||
const missingReferences = [...references].filter(
|
||||
([key]) => !(key in catalogs[0].data),
|
||||
);
|
||||
if (missingReferences.length) {
|
||||
throw new Error(
|
||||
`Missing ARB messages:\n${missingReferences
|
||||
.map(([key, file]) => `${key} (${file})`)
|
||||
.join("\n")}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (directUiLiterals.length) {
|
||||
throw new Error(
|
||||
`Direct English UI literals found:\n${directUiLiterals.join("\n")}`,
|
||||
);
|
||||
}
|
||||
|
||||
console.log(
|
||||
`l10n check passed: ${referenceKeys.length} messages, ${references.size} Dart references`,
|
||||
);
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* Generate the mobile emoji dataset from emoji-mart.
|
||||
*
|
||||
* Desktop's emoji picker, autocomplete, and reaction display names all read
|
||||
* `@emoji-mart/data/sets/15/native.json` (see
|
||||
* `desktop/src/features/custom-emoji/ui/EmojiPicker.tsx` and
|
||||
* `desktop/src/shared/lib/emojiName.ts`). Mobile can't consume the npm package,
|
||||
* so this script projects the same source into a trimmed JSON asset that ships
|
||||
* with the Flutter app. Same ids, same names, same keywords, same category
|
||||
* order — so a `:shortcode:` means the same thing on both clients.
|
||||
*
|
||||
* The output is committed. Regenerate with `just mobile-emoji-data` after
|
||||
* bumping the emoji-mart dependency.
|
||||
*/
|
||||
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const mobileRoot = path.resolve(__dirname, "..");
|
||||
const repoRoot = path.resolve(mobileRoot, "..");
|
||||
|
||||
const DATA_SUBPATH = "@emoji-mart/data/sets/15/native.json";
|
||||
// `EMOJI_MART_DATA` lets a git worktree (which has no desktop/node_modules of
|
||||
// its own) point at the main checkout's install instead of paying for a full
|
||||
// `pnpm install` just to regenerate a committed asset.
|
||||
const SOURCE =
|
||||
process.env.EMOJI_MART_DATA ??
|
||||
path.join(repoRoot, "desktop/node_modules", DATA_SUBPATH);
|
||||
const OUTPUT = path.join(mobileRoot, "assets/emoji/emoji-data.json");
|
||||
|
||||
let raw;
|
||||
try {
|
||||
raw = readFileSync(SOURCE, "utf8");
|
||||
} catch {
|
||||
console.error(
|
||||
`Missing emoji-mart data at ${SOURCE}.\n` +
|
||||
"Run `pnpm install` in desktop/ first — this script projects the same\n" +
|
||||
"dataset the desktop picker uses so the two clients cannot drift.\n" +
|
||||
"From a worktree, point EMOJI_MART_DATA at the main checkout's copy:\n" +
|
||||
` EMOJI_MART_DATA=<main-checkout>/desktop/node_modules/${DATA_SUBPATH}`,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const data = JSON.parse(raw);
|
||||
|
||||
// Category order is emoji-mart's own, which is the order desktop's picker
|
||||
// renders. Preserve it verbatim rather than re-sorting.
|
||||
const categories = data.categories.map((category) => ({
|
||||
id: category.id,
|
||||
emoji: category.emojis.filter((id) => {
|
||||
const entry = data.emojis[id];
|
||||
return Boolean(entry?.skins?.some((skin) => skin.native));
|
||||
}),
|
||||
}));
|
||||
|
||||
// Keys are deliberately short (`n`/`u`/`k`) — the map is ~1.9k entries and the
|
||||
// asset ships in the app bundle.
|
||||
const emoji = {};
|
||||
for (const category of categories) {
|
||||
for (const id of category.emoji) {
|
||||
const entry = data.emojis[id];
|
||||
emoji[id] = {
|
||||
n: entry.name,
|
||||
// Keep every skin variation. The app flattens these into selectable
|
||||
// tiles and maps every glyph back to this desktop-identical shortcode.
|
||||
u: entry.skins.map((skin) => skin.native).filter(Boolean),
|
||||
k: entry.keywords ?? [],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const payload = { categories, emoji };
|
||||
|
||||
mkdirSync(path.dirname(OUTPUT), { recursive: true });
|
||||
// Trailing newline keeps the file diff-friendly; no indentation because the
|
||||
// asset is machine-read only and indentation would roughly double its size.
|
||||
writeFileSync(OUTPUT, `${JSON.stringify(payload)}\n`, "utf8");
|
||||
|
||||
console.log(
|
||||
`Wrote ${path.relative(repoRoot, OUTPUT)} — ` +
|
||||
`${categories.length} categories, ${Object.keys(emoji).length} emoji.`,
|
||||
);
|
||||
Reference in New Issue
Block a user