( localStorageKey: string, )
| 119 | }; |
| 120 | |
| 121 | export const initializeInspectorConfig = ( |
| 122 | localStorageKey: string, |
| 123 | ): InspectorConfig => { |
| 124 | // Read persistent config from localStorage |
| 125 | const savedPersistentConfig = localStorage.getItem(localStorageKey); |
| 126 | // Read ephemeral config from sessionStorage |
| 127 | const savedEphemeralConfig = sessionStorage.getItem( |
| 128 | `${localStorageKey}_ephemeral`, |
| 129 | ); |
| 130 | |
| 131 | // Start with default config |
| 132 | let baseConfig = { ...DEFAULT_INSPECTOR_CONFIG }; |
| 133 | |
| 134 | // Apply saved persistent config |
| 135 | if (savedPersistentConfig) { |
| 136 | const parsedPersistentConfig = JSON.parse(savedPersistentConfig); |
| 137 | baseConfig = { ...baseConfig, ...parsedPersistentConfig }; |
| 138 | } |
| 139 | |
| 140 | // Apply saved ephemeral config |
| 141 | if (savedEphemeralConfig) { |
| 142 | const parsedEphemeralConfig = JSON.parse(savedEphemeralConfig); |
| 143 | baseConfig = { ...baseConfig, ...parsedEphemeralConfig }; |
| 144 | } |
| 145 | |
| 146 | // Ensure all config items have the latest labels/descriptions from defaults |
| 147 | for (const [key, value] of Object.entries(baseConfig)) { |
| 148 | baseConfig[key as keyof InspectorConfig] = { |
| 149 | ...value, |
| 150 | label: DEFAULT_INSPECTOR_CONFIG[key as keyof InspectorConfig].label, |
| 151 | description: |
| 152 | DEFAULT_INSPECTOR_CONFIG[key as keyof InspectorConfig].description, |
| 153 | is_session_item: |
| 154 | DEFAULT_INSPECTOR_CONFIG[key as keyof InspectorConfig].is_session_item, |
| 155 | }; |
| 156 | } |
| 157 | |
| 158 | // Apply query param overrides |
| 159 | const overrides = getConfigOverridesFromQueryParams(DEFAULT_INSPECTOR_CONFIG); |
| 160 | return { ...baseConfig, ...overrides }; |
| 161 | }; |
| 162 | |
| 163 | export const saveInspectorConfig = ( |
| 164 | localStorageKey: string, |
no test coverage detected