feat: support normalizing coordinate spaces

This commit is contained in:
Zoe
2026-09-19 18:23:51 -05:00
parent c49f228847
commit 5389d4541c
9 changed files with 85 additions and 15 deletions
+11
View File
@@ -1,7 +1,17 @@
export type CoordinateSpace = "pixels" | "normalized_1000";
export function readCoordinateSpace(value = "pixels"): CoordinateSpace {
if (value !== "pixels" && value !== "normalized_1000") {
throw new Error("DESKTOP_COORDINATE_SPACE must be pixels or normalized_1000.");
}
return value;
}
export interface Config {
llamaCppOrigin: string;
modelId: string;
databasePath: string;
coordinateSpace: CoordinateSpace;
}
export function readConfig(environment: NodeJS.ProcessEnv = process.env): Config {
@@ -16,6 +26,7 @@ export function readConfig(environment: NodeJS.ProcessEnv = process.env): Config
throw new Error("LLAMA_CPP_ORIGIN must be an HTTP(S) origin without credentials, path, query, or fragment.");
}
return {
coordinateSpace: readCoordinateSpace(environment.DESKTOP_COORDINATE_SPACE),
llamaCppOrigin: url.origin,
modelId,
databasePath: environment.DATABASE_PATH?.trim() || "./data/token.sqlite",