mirror of
https://github.com/olehomelchenko/astrolabe.git
synced 2026-08-08 02:02:33 +00:00
Eng-council sweep: export hygiene, dead code, helper dedup, declare vega-expression
This commit is contained in:
@@ -27,6 +27,7 @@ import {
|
||||
reassignCollidingSnippetIds,
|
||||
} from '@core/import-normalize';
|
||||
import { snippetSizeBytes } from '@core/snippet';
|
||||
import { humanizeBytes } from '@core/storage-estimate';
|
||||
import { downloadJson, readTextFile } from '../infrastructure/file-transfer';
|
||||
import { deleteSnippet, saveSnippet, StorageQuotaError } from '../infrastructure/snippet-store';
|
||||
import { notify } from '../stores/NotificationStore';
|
||||
@@ -36,13 +37,6 @@ import { useSnippetStore } from '../stores/SnippetStore';
|
||||
/** Practical snippet-storage budget (spec §02 storage monitor / §08). */
|
||||
const SNIPPET_BUDGET_BYTES = 5 * 1024 * 1024;
|
||||
|
||||
/** Round bytes to a short KB/MB string for the overage warning. */
|
||||
function formatBytes(bytes: number): string {
|
||||
const kb = bytes / 1024;
|
||||
if (kb < 1024) return `${Math.max(1, Math.round(kb))} KB`;
|
||||
return `${Math.round(kb / 1024)} MB`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the whole workspace to a downloaded JSON file (spec §08 → Export).
|
||||
* Flushes the live editor buffer first so in-progress draft edits are included.
|
||||
@@ -209,7 +203,7 @@ export async function importWorkspace(file: File): Promise<void> {
|
||||
}
|
||||
if (overage > 0) {
|
||||
clauses.push(
|
||||
`This puts snippet storage about ${formatBytes(overage)} over the ~5 MB budget; ` +
|
||||
`This puts snippet storage about ${humanizeBytes(overage)} over the ~5 MB budget; ` +
|
||||
`consider deleting some snippets.`,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user