Documented tree replacement (the history has no git-subtree metadata): 3-way merge of the old subtree (570201a:engine/strata) against upstream 41cf05a06a25dd29103b7b27a2279a3f60c21876 (2026-10-25), merge base = the old pin d9ab8435 (tree-identical to upstream 5b734e42; d9ab8435 is not an ancestor of upstream main). Local patches re-applied by hand where they conflicted (15 files): STRATA_CUDA_STATIC profile, experimental KAR experts and KAR PLE arms, keyless V-only arm (now beside upstream's K8V4 hybrid KV and fused norm+rope). Details, conflict table and left-out files are in docs/upstream.md. Left out (weights, captures, logs, media): new bench/results (2022 files), binary media and app assets (61), docs/work/evidence (24), *.bin / *.gguf data files, and the 7 files the first import already left out. scripts/build-cpu.sh: build the 11 CPU tests upstream registered since the old pin (they ran as "Not Run"). Checked: build-cpu.sh 16/16 ctest in WSL; sm_86 CUDA objects of the patched files compile, also with the KAR macros on. No GPU run, no quality gate. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
88 lines
3.6 KiB
JavaScript
88 lines
3.6 KiB
JavaScript
/**
|
|
* Sync the Strata UI kit (../ui) into the app's public/ folder.
|
|
*
|
|
* node scripts/sync-design-kit.mjs
|
|
*
|
|
* Copies fonts, and rebuilds a single clean icon sprite at public/icons/sprite.svg.
|
|
* The kit's own SVG files carry C2PA manifest metadata (~12 KB each, base64);
|
|
* we strip <metadata> so the shipped sprite stays small.
|
|
*
|
|
* Also mirrors tokens.css / components.css into src/styles/kit/ so the app has a
|
|
* versioned copy that can be diffed against the kit.
|
|
*/
|
|
import { readFileSync, writeFileSync, mkdirSync, readdirSync, copyFileSync, existsSync } from 'node:fs';
|
|
import { join, dirname, basename } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
const root = join(here, '..');
|
|
const kit = join(root, '..', 'ui');
|
|
const pub = join(root, 'public');
|
|
const styles = join(root, 'src', 'styles', 'kit');
|
|
|
|
if (!existsSync(kit)) {
|
|
console.error(`Design kit not found at ${kit}`);
|
|
process.exit(1);
|
|
}
|
|
|
|
mkdirSync(join(pub, 'fonts'), { recursive: true });
|
|
mkdirSync(join(pub, 'icons'), { recursive: true });
|
|
mkdirSync(styles, { recursive: true });
|
|
|
|
// ---- fonts -----------------------------------------------------------------
|
|
let fonts = 0;
|
|
for (const f of readdirSync(join(kit, 'fonts'))) {
|
|
if (!f.endsWith('.woff2')) continue;
|
|
copyFileSync(join(kit, 'fonts', f), join(pub, 'fonts', f));
|
|
fonts++;
|
|
}
|
|
|
|
// ---- icon sprite -----------------------------------------------------------
|
|
const strip = (svg) =>
|
|
svg
|
|
.replace(/<metadata>[\s\S]*?<\/metadata>/g, '')
|
|
.replace(/<svg[^>]*>/, '')
|
|
.replace(/<\/svg>\s*$/, '')
|
|
.replace(/\s+xmlns(:\w+)?="[^"]*"/g, '')
|
|
.trim();
|
|
|
|
const iconDir = join(kit, 'icons');
|
|
const sources = new Map(readdirSync(iconDir)
|
|
.filter((f) => f.endsWith('.svg') && f !== 'sprite.svg')
|
|
.map((f) => [basename(f, '.svg'), join(iconDir, f)]));
|
|
const appIconDir = join(root, 'src', 'assets', 'icons');
|
|
if (existsSync(appIconDir)) {
|
|
for (const file of readdirSync(appIconDir).filter(f => f.endsWith('.svg'))) {
|
|
sources.set(basename(file, '.svg'), join(appIconDir, file));
|
|
}
|
|
}
|
|
const names = [...sources.keys()].sort();
|
|
|
|
const symbols = names.map((name) => {
|
|
const raw = readFileSync(sources.get(name), 'utf8');
|
|
const body = strip(raw);
|
|
const viewBox = /viewBox="([^"]+)"/.exec(raw)?.[1] ?? '0 0 24 24';
|
|
// The root <svg> carries fill="none"; without it every stroked path inherits
|
|
// the default black fill and the icons render as solid blobs.
|
|
const rootFill = /<svg[^>]*\sfill="([^"]+)"/.exec(raw)?.[1] ?? 'none';
|
|
return ` <symbol id="i-${name}" viewBox="${viewBox}" fill="${rootFill}">\n ${body}\n </symbol>`;
|
|
});
|
|
|
|
const sprite = `<svg xmlns="http://www.w3.org/2000/svg" style="display:none" aria-hidden="true">\n${symbols.join('\n')}\n</svg>\n`;
|
|
writeFileSync(join(pub, 'icons', 'sprite.svg'), sprite);
|
|
|
|
// ---- styles ----------------------------------------------------------------
|
|
// The kit references fonts relatively (fonts/x.woff2). In the app the fonts are
|
|
// served from public/fonts, so rewrite the URLs to be absolute — otherwise the
|
|
// browser resolves them against the CSS file and 404s in both dev and build.
|
|
for (const f of ['tokens.css', 'components.css']) {
|
|
const css = readFileSync(join(kit, f), 'utf8').replace(/url\((["']?)fonts\//g, 'url($1/fonts/');
|
|
writeFileSync(join(styles, f), css);
|
|
}
|
|
|
|
const kb = (n) => `${(n / 1024).toFixed(1)} KB`;
|
|
console.log(`synced ${fonts} fonts -> public/fonts/`);
|
|
console.log(`sprite: ${names.length} icons -> public/icons/sprite.svg (${kb(sprite.length)})`);
|
|
console.log(`styles: tokens.css, components.css -> src/styles/kit/`);
|
|
console.log(`icons: ${names.join(', ')}`);
|