Initial commit: Clean DSS implementation
Migrated from design-system-swarm with fresh git history.
Old project history preserved in /home/overbits/apps/design-system-swarm
Core components:
- MCP Server (Python FastAPI with mcp 1.23.1)
- Claude Plugin (agents, commands, skills, strategies, hooks, core)
- DSS Backend (dss-mvp1 - token translation, Figma sync)
- Admin UI (Node.js/React)
- Server (Node.js/Express)
- Storybook integration (dss-mvp1/.storybook)
Self-contained configuration:
- All paths relative or use DSS_BASE_PATH=/home/overbits/dss
- PYTHONPATH configured for dss-mvp1 and dss-claude-plugin
- .env file with all configuration
- Claude plugin uses ${CLAUDE_PLUGIN_ROOT} for portability
Migration completed: $(date)
🤖 Clean migration with full functionality preserved
This commit is contained in:
118
admin-ui/js/utils/incognito-detector.js
Normal file
118
admin-ui/js/utils/incognito-detector.js
Normal file
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* incognito-detector.js
|
||||
* Detects if the browser is running in incognito/private mode
|
||||
* Uses LAZY initialization to avoid cascading failures at module load time
|
||||
*/
|
||||
|
||||
let isIncognitoResult = null;
|
||||
let storageTypeResult = null;
|
||||
|
||||
/**
|
||||
* Detect if browser is in incognito/private mode
|
||||
* Works by trying to write to localStorage and catching the silent failure
|
||||
* Result is memoized after first call
|
||||
*/
|
||||
function detectIncognito() {
|
||||
try {
|
||||
const testKey = '__incognito_test__';
|
||||
const testValue = Date.now().toString();
|
||||
|
||||
// Try to write to localStorage
|
||||
localStorage.setItem(testKey, testValue);
|
||||
|
||||
// Try to read it back
|
||||
const retrieved = localStorage.getItem(testKey);
|
||||
|
||||
// Clean up
|
||||
localStorage.removeItem(testKey);
|
||||
|
||||
// If we can write and read, we're not in incognito
|
||||
isIncognitoResult = retrieved !== testValue;
|
||||
storageTypeResult = isIncognitoResult ? 'sessionStorage' : 'localStorage';
|
||||
|
||||
if (isIncognitoResult) {
|
||||
console.log('[IncognitoDetector] Incognito mode detected - using sessionStorage');
|
||||
}
|
||||
return isIncognitoResult;
|
||||
|
||||
} catch (e) {
|
||||
// If localStorage access throws an error, we're definitely in incognito
|
||||
console.warn('[IncognitoDetector] Storage access failed, assuming incognito mode:', e);
|
||||
isIncognitoResult = true;
|
||||
storageTypeResult = 'sessionStorage';
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the appropriate storage object for this browser context
|
||||
* Triggers incognito detection if not yet done
|
||||
*/
|
||||
export function getStorage() {
|
||||
if (isIncognitoResult === null) {
|
||||
detectIncognito();
|
||||
}
|
||||
return isIncognitoResult ? sessionStorage : localStorage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we're in incognito mode
|
||||
* Triggers detection if not yet done
|
||||
*/
|
||||
export function checkIncognito() {
|
||||
if (isIncognitoResult === null) {
|
||||
detectIncognito();
|
||||
}
|
||||
return isIncognitoResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an item in the appropriate storage
|
||||
*/
|
||||
export function setItem(key, value) {
|
||||
try {
|
||||
getStorage().setItem(key, value);
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.error('[IncognitoDetector] Failed to store item:', key, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an item from the appropriate storage
|
||||
*/
|
||||
export function getItem(key) {
|
||||
try {
|
||||
return getStorage().getItem(key);
|
||||
} catch (e) {
|
||||
console.error('[IncognitoDetector] Failed to retrieve item:', key, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an item from the appropriate storage
|
||||
*/
|
||||
export function removeItem(key) {
|
||||
try {
|
||||
getStorage().removeItem(key);
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.error('[IncognitoDetector] Failed to remove item:', key, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all items from the appropriate storage
|
||||
*/
|
||||
export function clear() {
|
||||
try {
|
||||
getStorage().clear();
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.error('[IncognitoDetector] Failed to clear storage:', e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user