Improve JSDoc comments with cross-references and clarifications (#254)
Key improvements:
- Add `{@link}` cross-references throughout the codebase to make API
documentation navigable and help AI models understand relationships
- Use `{@link module!Export}` syntax for cross-module references
- Add backticks for inline code formatting (`ResizeObserver`, `App`, etc)
- Fix `PostMessageTransport` examples to show required two-argument form
- Clarify `onteardown` callback return type requirement
- Document React hooks cleanup behavior and Strict Mode considerations
- Add tool visibility example for `registerAppTool`
- Add CSP example for `registerAppResource`
- Fix notification direction documentation in `spec.types.ts`
TypeDoc config migrated from `typedoc.json` to `typedoc.config.mjs` to:
- Support custom `@description` block tag
- Add `intentionallyNotExported` for internal types
- Include `src/server/index.ts` entry point
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
978d8e6fff
commit
d48e35d88a
1 changed files with 359 additions and 231 deletions
|
|
@ -5,27 +5,29 @@ import { App, McpUiAppCapabilities, PostMessageTransport } from "../app";
|
|||
export * from "../app";
|
||||
|
||||
/**
|
||||
* Options for configuring the useApp hook.
|
||||
* Options for configuring the {@link useApp} hook.
|
||||
*
|
||||
* Note: This interface does NOT expose App options like `autoResize`.
|
||||
* The hook creates the App with default options (autoResize: true). If you need
|
||||
* custom App options, create the App manually instead of using this hook.
|
||||
* Note: This interface does NOT expose {@link App} options like `autoResize`.
|
||||
* The hook creates the `App` with default options (`autoResize: true`). If you
|
||||
* need custom `App` options, create the `App` manually instead of using this hook.
|
||||
*
|
||||
* @see {@link useApp} for the hook that uses these options
|
||||
* @see {@link useAutoResize} for manual auto-resize control with custom App options
|
||||
* @see {@link useAutoResize} for manual auto-resize control with custom `App` options
|
||||
*/
|
||||
export interface UseAppOptions {
|
||||
/** App identification (name and version) */
|
||||
appInfo: Implementation;
|
||||
/** Features and capabilities this app provides */
|
||||
/**
|
||||
* Declares what features this app supports.
|
||||
*/
|
||||
capabilities: McpUiAppCapabilities;
|
||||
/**
|
||||
* Called after App is created but before connection.
|
||||
* Called after {@link App} is created but before connection.
|
||||
*
|
||||
* Use this to register request/notification handlers that need to be in place
|
||||
* before the initialization handshake completes.
|
||||
*
|
||||
* @param app - The newly created App instance
|
||||
* @param app - The newly created `App` instance
|
||||
*
|
||||
* @example Register a notification handler
|
||||
* ```typescript
|
||||
|
|
@ -45,10 +47,10 @@ export interface UseAppOptions {
|
|||
}
|
||||
|
||||
/**
|
||||
* State returned by the useApp hook.
|
||||
* State returned by the {@link useApp} hook.
|
||||
*/
|
||||
export interface AppState {
|
||||
/** The connected App instance, null during initialization */
|
||||
/** The connected {@link App} instance, null during initialization */
|
||||
app: App | null;
|
||||
/** Whether initialization completed successfully */
|
||||
isConnected: boolean;
|
||||
|
|
@ -59,16 +61,19 @@ export interface AppState {
|
|||
/**
|
||||
* React hook to create and connect an MCP App.
|
||||
*
|
||||
* This hook manages the complete lifecycle of an {@link App}: creation, connection,
|
||||
* and cleanup. It automatically creates a {@link PostMessageTransport} to window.parent
|
||||
* and handles initialization.
|
||||
* This hook manages {@link App} creation and connection. It automatically
|
||||
* creates a {@link PostMessageTransport} to window.parent and handles
|
||||
* initialization.
|
||||
*
|
||||
* This hook is part of the optional React integration. The core SDK (`App`,
|
||||
* `PostMessageTransport`) is framework-agnostic and can be used with any UI
|
||||
* framework or vanilla JavaScript.
|
||||
*
|
||||
* **Important**: The hook intentionally does NOT re-run when options change
|
||||
* to avoid reconnection loops. Options are only used during the initial mount.
|
||||
*
|
||||
* **Note**: This is part of the optional React integration. The core SDK
|
||||
* (App, PostMessageTransport) is framework-agnostic and can be
|
||||
* used with any UI framework or vanilla JavaScript.
|
||||
* Furthermore, the `App` instance is NOT closed on unmount. This avoids cleanup
|
||||
* issues during React Strict Mode's double-mount cycle. If you need to
|
||||
* explicitly close the `App`, call {@link App.close} manually.
|
||||
*
|
||||
* @param options - Configuration for the app
|
||||
* @returns Current connection state and app instance. If connection fails during
|
||||
|
|
|
|||
Loading…
Reference in a new issue