refactor(ext/shared): typed StateHost + sweep as-any casts (Plan C Phase 1)
Replaces the previously any-typed StateHost contract with a typed interface. Adds double-registration guard and __resetHostForTests for vitest. sendMessage wrapper is currently a pass-through; Phase 4 will fill its body with the vault_locked intercept lifted from vault.ts. Widens PopupState/View on shared/popup-state.ts to cover vault-tab-only views (history, backup, import) and vault-tab-only fields (unlocked, drawerOpen, typePanelOpen) so VaultState satisfies StateHost.getState() without a cast. The popup surface ignores the new optional fields. Drops the `any` annotations on vault.ts's registerHost callbacks now that the typed StateHost contract infers them from PopupState. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -229,11 +229,11 @@ const state: VaultState = {
|
||||
|
||||
registerHost({
|
||||
getState: () => state,
|
||||
setState: (partial: any) => {
|
||||
setState: (partial) => {
|
||||
Object.assign(state, partial);
|
||||
renderPane();
|
||||
},
|
||||
navigate: (view: string, extras?: any) => {
|
||||
navigate: (view, extras) => {
|
||||
Object.assign(state, { view, error: null, loading: false, ...extras });
|
||||
setHash(view as VaultView);
|
||||
applyShellViewClass();
|
||||
|
||||
Reference in New Issue
Block a user