forked from getsentry/XcodeBuildMCP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsession-store.ts
More file actions
47 lines (40 loc) · 1.24 KB
/
session-store.ts
File metadata and controls
47 lines (40 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { log } from './logger.ts';
export type SessionDefaults = {
projectPath?: string;
workspacePath?: string;
scheme?: string;
configuration?: string;
simulatorName?: string;
simulatorId?: string;
deviceId?: string;
useLatestOS?: boolean;
arch?: 'arm64' | 'x86_64';
};
class SessionStore {
private defaults: SessionDefaults = {};
setDefaults(partial: Partial<SessionDefaults>): void {
this.defaults = { ...this.defaults, ...partial };
log('info', `[Session] Defaults updated: ${Object.keys(partial).join(', ')}`);
}
clear(keys?: (keyof SessionDefaults)[]): void {
if (keys == null) {
this.defaults = {};
log('info', '[Session] All defaults cleared');
return;
}
if (keys.length === 0) {
// No-op when an empty array is provided (e.g., empty UI selection)
log('info', '[Session] No keys provided to clear; no changes made');
return;
}
for (const k of keys) delete this.defaults[k];
log('info', `[Session] Defaults cleared: ${keys.join(', ')}`);
}
get<K extends keyof SessionDefaults>(key: K): SessionDefaults[K] {
return this.defaults[key];
}
getAll(): SessionDefaults {
return { ...this.defaults };
}
}
export const sessionStore = new SessionStore();