guanghu/tests/helpers/fixtureVaultDesktopBridge.ts
Guanghu Domestic Migration 9b41d51231
Some checks are pending
Auto-update PR branches / Update open PR branches (push) Waiting to run
CI / Frontend Static Quality Checks (push) Waiting to run
CI / Frontend Tests & Coverage (push) Waiting to run
CI / Rust Tests & Quality Checks (push) Waiting to run
CI / Linux build verification (push) Waiting to run
Deploy docs / Build VitePress site (push) Waiting to run
Deploy docs / Deploy to GitHub Pages (push) Blocked by required conditions
Release (Alpha) / Compute alpha version (push) Waiting to run
Release (Alpha) / Build release artifacts (push) Blocked by required conditions
Release (Alpha) / GitHub Release (alpha) (push) Blocked by required conditions
Release (Alpha) / Update docs and release pages (push) Blocked by required conditions
chore: import sanitized domestic snapshot for REPO-004
Source snapshot: 514ab1975951d94342ea38e64101d5a0f1c51c77
2026-07-17 15:55:28 +08:00

28 lines
919 B
TypeScript

export function installFixtureVaultDesktopBridgeInBrowser(): void {
const dispatchBrowserMenuCommand =
window.__laputaTest?.dispatchBrowserMenuCommand
?? (() => { throw new Error('Tolaria test bridge is missing dispatchBrowserMenuCommand') })
const specialHandlers: Record<string, (args?: Record<string, unknown>) => unknown> = {
trigger_menu_command: (args) => {
dispatchBrowserMenuCommand(String(args?.id ?? ''))
return null
},
}
const invoke = (command: string, args?: Record<string, unknown>) => {
const handler = specialHandlers[command] ?? window.__mockHandlers?.[command]
if (!handler) throw new Error(`Unhandled invoke: ${command}`)
return handler(args)
}
Object.defineProperty(window, '__TAURI__', {
configurable: true,
value: {},
})
Object.defineProperty(window, '__TAURI_INTERNALS__', {
configurable: true,
value: { invoke },
})
}