feat(ext): shared state host — decouple components from popup.ts
Introduce shared/state.ts as a service-locator so popup components (item-detail, item-form, trash, devices, settings, etc.) work in both the popup and vault tab bundles. Both entry points register themselves as the host; components import from shared/state instead of popup.ts. Vault.ts now delegates to the real popup components, removing ~300 lines of placeholder renderers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
vi.mock('../../popup', async () => {
|
||||
vi.mock('../../../shared/state', async () => {
|
||||
const navigate = vi.fn();
|
||||
const setState = vi.fn();
|
||||
const sendMessage = vi.fn();
|
||||
@@ -25,7 +25,7 @@ vi.mock('../../popup', async () => {
|
||||
const escapeHtml = (s: string) => s
|
||||
.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
||||
.replace(/"/g, '"').replace(/'/g, ''');
|
||||
return { navigate, setState, sendMessage, getState, escapeHtml };
|
||||
return { navigate, setState, sendMessage, getState, escapeHtml, popOutToTab: vi.fn(), isInTab: vi.fn(() => false), openVaultTab: vi.fn() };
|
||||
});
|
||||
|
||||
vi.mock('../generator-panel', () => ({
|
||||
@@ -34,7 +34,7 @@ vi.mock('../generator-panel', () => ({
|
||||
}));
|
||||
|
||||
import { renderVaultSettings } from '../settings-vault';
|
||||
import { sendMessage } from '../../popup';
|
||||
import { sendMessage } from '../../../shared/state';
|
||||
|
||||
describe('settings-vault', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
Reference in New Issue
Block a user