@markupai/sidebar-adapter 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -481,6 +481,10 @@ Optional (authentication):
481
481
 
482
482
  - `openAuthUrl?(url: string): Promise<void>` — Open the Auth0 `authorizeUrl` in whatever external-browser primitive the host provides. Implement this in sandboxed hosts where `globalThis.open` is blocked or unavailable (e.g. Office task panes should call `Office.context.ui.openBrowserWindow(url)`). Throw if the window cannot be opened so the mediation flow fails fast instead of polling to timeout. When omitted, the sidebar falls back to `globalThis.open(url, "_blank", "noopener,noreferrer")`.
483
483
 
484
+ Optional (clipboard):
485
+
486
+ - `copyToClipboard?(text: string): Promise<void>` — Write text to the system clipboard on the sidebar's behalf. Implement this in hosts where the sidebar iframe cannot use the async clipboard API itself — notably VS Code webviews, whose Electron permission handler denies `clipboard-write` to any frame that is not on the `vscode-webview://` origin (the VS Code extension calls `vscode.env.clipboard.writeText(text)` in the extension host). Reject to signal the write failed. When omitted, the sidebar detects the absence via the standard `"No receiver registered for: copyToClipboard"` IPC error and falls back to `navigator.clipboard.writeText`, then `document.execCommand("copy")`.
487
+
484
488
  #### Error control flows
485
489
 
486
490
  When implementing `selectContent` or `replaceContent`, throw `TextLookupError` from this package when text lookup (e.g. locating the selection or target range) fails. The sidebar will treat it as a selection failure and can invalidate the issue card with the error message.
@@ -776,3 +780,23 @@ npm run test:coverage
776
780
  npm run format:fix
777
781
  npm run format:check
778
782
  ```
783
+
784
+ ## IPC contract (AsyncAPI)
785
+
786
+ The sidebar↔host IPC protocol is published as a machine-readable **AsyncAPI 3.0**
787
+ document, generated from this package's TypeScript types. Other-language ports
788
+ (e.g. a C# host embedding the sidebar) use it for codegen and contract testing.
789
+
790
+ **Get it three ways:**
791
+
792
+ - **npm resource** — it ships in the tarball: `@markupai/sidebar-adapter/asyncapi.json`.
793
+ - **`require.resolve`** — `require.resolve("@markupai/sidebar-adapter/asyncapi.json")`.
794
+ - **Served URL** — per environment, e.g. `https://sidebar.dev.markup.ai/asyncapi.json`
795
+ (also `sidebar.stg.markup.ai`, `sidebar.markup.ai`), with permissive CORS.
796
+
797
+ `info.version` equals this package's version, so a consumer always knows which
798
+ contract revision it is testing against. The document is **generated — do not
799
+ hand-edit `asyncapi.json`.** Regenerate with `npm run build:contract`.
800
+
801
+ See [`docs/contract/consuming-the-ipc-contract.md`](../../docs/contract/consuming-the-ipc-contract.md)
802
+ for the consumer workflow.