mirror of
https://github.com/Matysh/houseplan-card
synced 2026-09-30 19:58:50 +00:00
Add Deutsch across all card surfaces and backend flows, backed by the language registry introduced in #62. German loads as a fingerprint-checked page-shared locale chunk so EN/RU remain synchronous and the initial View budget stays intact. Root render gates prevent mixed-language flashes, retry once, and fail open to English. Extend parity, runtime, bundle, browser and visual coverage, plus contributor and user documentation. Issue: #348 User-Visible: yes
52 lines
2.0 KiB
JavaScript
52 lines
2.0 KiB
JavaScript
#!/usr/bin/env node
|
|
import { readFileSync } from 'node:fs';
|
|
import { resolve } from 'node:path';
|
|
import { pathToFileURL } from 'node:url';
|
|
|
|
export const INITIAL_VIEW_GZIP_BUDGET = 256_000;
|
|
|
|
export function assertBundleBudget(manifest, budget = INITIAL_VIEW_GZIP_BUDGET) {
|
|
if (manifest?.schema !== 1 || !Array.isArray(manifest.files)) {
|
|
throw new Error('invalid houseplan-assets.json');
|
|
}
|
|
if (!manifest.lazyEditorFiles?.length) {
|
|
throw new Error('bundle has no lazy editor graph');
|
|
}
|
|
if (!manifest.lazyLocaleFiles?.length) {
|
|
throw new Error('bundle has no lazy locale graph');
|
|
}
|
|
if (manifest.initialViewFiles.some((path) => manifest.lazyEditorFiles.includes(path))) {
|
|
throw new Error('initial View graph overlaps lazy editor graph');
|
|
}
|
|
if (manifest.initialViewFiles.some((path) => manifest.lazyLocaleFiles.includes(path))) {
|
|
throw new Error('initial View graph overlaps lazy locale graph');
|
|
}
|
|
if (manifest.lazyLocaleFiles.some((path) => manifest.lazyEditorFiles.includes(path)
|
|
|| manifest.lazyOnboardingFiles?.includes(path))) {
|
|
throw new Error('lazy locale graph overlaps an editor graph');
|
|
}
|
|
if (manifest.initialViewGzipBytes > budget) {
|
|
throw new Error(
|
|
`initial View graph ${manifest.initialViewGzipBytes} B gzip exceeds ${budget} B budget`,
|
|
);
|
|
}
|
|
return {
|
|
initialViewGzipBytes: manifest.initialViewGzipBytes,
|
|
lazyEditorGzipBytes: manifest.lazyEditorGzipBytes,
|
|
lazyLocaleGzipBytes: manifest.lazyLocaleGzipBytes,
|
|
};
|
|
}
|
|
|
|
if (import.meta.url === pathToFileURL(process.argv[1] || '').href) {
|
|
try {
|
|
const manifest = JSON.parse(readFileSync(resolve('dist/houseplan-assets.json'), 'utf8'));
|
|
const result = assertBundleBudget(manifest);
|
|
console.log(`initial View: ${result.initialViewGzipBytes} B gzip`);
|
|
console.log(`lazy editor: ${result.lazyEditorGzipBytes} B gzip`);
|
|
console.log(`lazy locale: ${result.lazyLocaleGzipBytes} B gzip`);
|
|
} catch (error) {
|
|
console.error(error instanceof Error ? error.message : String(error));
|
|
process.exit(1);
|
|
}
|
|
}
|