feat: support normalizing coordinate spaces
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user