mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
QA harnesses import some modules in the page by path, for example
import('/src/data/radio.js'). Those calls name exactly which bindings
they use, and every other export of these modules has no importer:
- src/data/radio.js: 20 aliases of radio layer methods and two
re-exported altitude constants. The radio layer keeps the methods.
- src/layers/transit/movement.js: tuning constants and course helpers
used only inside the module lose `export`; FIX_HISTORY_MAX,
DISPLAY_LAG_MIN_MS, DISPLAY_LAG_RESET_MS, FIX_NOISE_M, STOPPED_FIXES
and courseBetween, which nothing reads, are deleted.
- src/overlays/worldOverlay.js, src/splitFlap.js,
src/data/contactPlayback.js and src/voice/cloudVoiceAuth.js: helpers
and constants used only locally lose `export`.
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
const CLOUD_VOICE_AUTH_MODES = Object.freeze(['api-key', 'oauth']);
|
|
const DEFAULT_CLOUD_VOICE_AUTH_MODE = 'api-key';
|
|
export const CLOUD_VOICE_AUTH_STORAGE_KEY = 'godsEyeView.voice.cloudAuth';
|
|
|
|
function storageRef(storage) {
|
|
if (storage) return storage;
|
|
try {
|
|
return typeof localStorage === 'undefined' ? null : localStorage;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
function normalizeCloudVoiceAuthMode(mode) {
|
|
const normalized = String(mode || '')
|
|
.trim()
|
|
.toLowerCase();
|
|
return CLOUD_VOICE_AUTH_MODES.includes(normalized)
|
|
? normalized
|
|
: DEFAULT_CLOUD_VOICE_AUTH_MODE;
|
|
}
|
|
|
|
export function readStoredCloudVoiceAuthMode(storage) {
|
|
try {
|
|
return normalizeCloudVoiceAuthMode(
|
|
storageRef(storage)?.getItem(CLOUD_VOICE_AUTH_STORAGE_KEY),
|
|
);
|
|
} catch {
|
|
return DEFAULT_CLOUD_VOICE_AUTH_MODE;
|
|
}
|
|
}
|
|
|
|
export function writeStoredCloudVoiceAuthMode(mode, storage) {
|
|
const resolved = normalizeCloudVoiceAuthMode(mode);
|
|
try {
|
|
storageRef(storage)?.setItem(CLOUD_VOICE_AUTH_STORAGE_KEY, resolved);
|
|
} catch {
|
|
/* best effort */
|
|
}
|
|
return resolved;
|
|
}
|