# `fallback/fallback.ts` _(no submodules)_ ## Purpose Legacy clipboard fallback paths used when `navigator.clipboard` is unavailable or rejects. Provides a hidden-textarea + `execCommand("copy")` write path and a paste-event-based read path. Both return the same `ClipboardResult` shape as the API path so the manager's call sites do not branch on which mechanism actually ran. The paste-event fallback is purpose-built for environments — older Safari, embedded WebViews, and permission-denied contexts — where `navigator.clipboard.readText` rejects but the user can paste manually. ## Features - `copyTextFallback(text)` — synchronous textarea + `execCommand` copy. - `readTextFallback(timeoutMs)` — focus + paste-event capture with a configurable timeout. - `dispatchSyntheticPaste(text)` — test helper that fires a synthetic `paste` event on the most recent hidden host. - SSR-safe — both copy and read paths return `CLIPBOARD.DOCUMENT_UNAVAILABLE` when `document` is undefined. - Off-screen, non-interactive host element so users never see the textarea visibly steal focus. ## Usage: Basic ```ts import { copyTextFallback } from "@suaveplan/clipboard"; const result = copyTextFallback("hello"); if (!result.success) { console.warn("legacy copy failed:", result.code); } ``` ## Usage: Advanced ```ts import { readTextFallback, dispatchSyntheticPaste, } from "@suaveplan/clipboard"; async function readClipboardWithPasteFallback(): Promise { const result = await readTextFallback(2000); return result.success ? result.data : undefined; } // Inside a test harness: const promise = readTextFallback(500); queueMicrotask(() => dispatchSyntheticPaste("from-test")); const result = await promise; ``` ## API Reference ### `copyTextFallback(text: string): ClipboardResult` Stages a hidden `