diff --git a/src/client/build.ts b/src/client/build.ts index e17addc..6745406 100644 --- a/src/client/build.ts +++ b/src/client/build.ts @@ -8,17 +8,52 @@ const LAZY_CHUNK_BUDGET_BYTES = 20 * 1024; const clientDir = path.resolve('src/client'); const outDir = path.resolve('dist/public'); +function normalizeOutKey(rawPath: string): string { + const rel = path.relative(outDir, path.resolve(rawPath)); + return rel.replace(/\\/g, '/'); +} + +function collectSyncImports( + metaOutputs: Record, + entryKey: string, +): string[] { + const visited = new Set(); + const queue: string[] = [entryKey]; + + while (queue.length > 0) { + const cur = queue.shift()!; + if (visited.has(cur)) continue; + visited.add(cur); + + const matchEntry = Object.entries(metaOutputs).find( + ([outPath]) => normalizeOutKey(outPath) === cur, + ); + if (!matchEntry) continue; + + for (const imp of matchEntry[1].imports) { + if (imp.kind !== 'import-statement') continue; + const targetKey = normalizeOutKey(imp.path); + if (!visited.has(targetKey)) { + queue.push(targetKey); + } + } + } + + return [...visited]; +} + async function buildClient(): Promise { fs.rmSync(outDir, { recursive: true, force: true }); fs.mkdirSync(outDir, { recursive: true }); - await esbuild.build({ + const jsResult = await esbuild.build({ entryPoints: [path.join(clientDir, 'ts', 'main.ts')], bundle: true, format: 'esm', splitting: true, minify: true, sourcemap: false, + metafile: true, target: 'es2020', outdir: outDir, entryNames: '[name]', @@ -46,18 +81,22 @@ async function buildClient(): Promise { fs.copyFileSync(path.join(clientDir, asset), path.join(outDir, asset)); } - const coreAssets = ['index.html', 'themes.css', 'base.css', 'main.js']; + const syncJsChunks = jsResult.metafile + ? collectSyncImports(jsResult.metafile.outputs, 'main.js').filter((k) => k !== 'main.js') + : []; + + const coreAssets = ['index.html', 'themes.css', 'base.css', 'main.js', ...syncJsChunks]; let totalRaw = 0; let totalGzip = 0; for (const file of coreAssets) { - const buf = fs.readFileSync(path.join(outDir, file)); + const fullPath = path.join(outDir, file); + if (!fs.existsSync(fullPath)) continue; + const buf = fs.readFileSync(fullPath); const gz = zlib.gzipSync(buf, { level: 9 }); totalRaw += buf.length; totalGzip += gz.length; - console.log( - ` ${file.padEnd(14)} raw=${buf.length}B gzip=${gz.length}B`, - ); + console.log(` ${file.padEnd(24)} raw=${buf.length}B gzip=${gz.length}B`); } const chunksDir = path.join(outDir, 'chunks'); @@ -65,7 +104,8 @@ async function buildClient(): Promise { for (const chunk of fs.readdirSync(chunksDir).sort()) { const cBuf = fs.readFileSync(path.join(chunksDir, chunk)); const cGz = zlib.gzipSync(cBuf, { level: 9 }); - console.log(` chunks/${chunk.padEnd(28)} raw=${cBuf.length}B gzip=${cGz.length}B`); + const syncTag = syncJsChunks.includes(`chunks/${chunk}`) ? ' [sync-core]' : ''; + console.log(` chunks/${chunk.padEnd(28)} raw=${cBuf.length}B gzip=${cGz.length}B${syncTag}`); if (!chunk.startsWith('terminal-view-') && cGz.length >= LAZY_CHUNK_BUDGET_BYTES) { throw new Error( `Lazy chunk ${chunk} (${cGz.length}B gzipped) exceeded 20KB budget (${LAZY_CHUNK_BUDGET_BYTES}B)`, diff --git a/src/client/css/base.css b/src/client/css/base.css index 1077214..41699fb 100644 --- a/src/client/css/base.css +++ b/src/client/css/base.css @@ -699,3 +699,87 @@ dialog.ai-drawer[open] { padding: 6px 10px; } } + +.sr-only-focusable:focus { + position: static; + width: auto; + height: auto; + overflow: visible; + clip: auto; + white-space: normal; + display: inline-block; + margin-bottom: 6px; + padding: 6px 10px; + border: 1px solid var(--accent); + background: var(--bg-panel); + color: var(--accent); +} + +.toast-region { + position: fixed; + right: 12px; + bottom: 12px; + z-index: 40; + display: flex; + flex-direction: column; + gap: 6px; + max-width: min(380px, calc(100vw - 24px)); + pointer-events: none; +} + +.toast-item { + pointer-events: auto; + display: flex; + align-items: center; + justify-content: space-between; + gap: 8px; + padding: 8px 10px; + border: 1px solid var(--border); + background: var(--bg-panel); + color: var(--fg); + font-size: 0.85rem; +} + +.toast-ok { + border-color: var(--ok); +} + +.toast-warn { + border-color: var(--warn); +} + +.toast-err { + border-color: var(--err); +} + +.cmd-palette-list { + display: flex; + flex-direction: column; + gap: 4px; + max-height: 55vh; + overflow-y: auto; + margin-top: 8px; +} + +.cmd-palette-item { + display: flex; + align-items: center; + justify-content: space-between; + width: 100%; + text-align: left; +} + +.cmd-palette-item.active { + border-color: var(--accent); + background: var(--bg-elevated); + color: var(--accent); +} + +.diff-hunk-sep { + padding: 2px 6px; + margin: 4px 0; + border-top: 1px dashed var(--border); + border-bottom: 1px dashed var(--border); + color: var(--fg-muted); + font-size: 0.78rem; +} diff --git a/src/client/index.html b/src/client/index.html index 2484694..4342508 100644 --- a/src/client/index.html +++ b/src/client/index.html @@ -13,6 +13,7 @@
+ Skip to main content