@mapcairn/react
Generic React hooks for MapCairn applications.
Checked against version 0.2.0. Install it with npm install @mapcairn/react; import from @mapcairn/react.
Hooks
useLatestRef: Keeps a ref synced to the latest committed value of something an effect or event listener needs to read at the moment it actually fires, rather than at the…useModelContextTool: Registers a WebMCP tool for the lifetime of the calling component, so an in-browser AI agent can discover and call it via document.modelContext.useReadingDirection: The reading direction of the page, from dir on <html>, for the few components that hand a direction to a library (a slider's thumb, a group's arrow keys)…
Functions
isModelContextSupported: Whether the current document exposes the WebMCP document.modelContext API.
Types
ModelContextProvider: WebMCP's tool-registration entry point, the value of document.modelContext (Chrome origin trial, see https://webmachinelearning.github.io/webmcp/).ModelContextToolContentBlock: A single content block in a WebMCP tool's result, as consumed by the calling agent.ModelContextToolDefinition: A WebMCP tool definition, as registered via document.modelContext.registerTool().ModelContextToolResult: The value a WebMCP tool's execute function resolves to.ReadingDirection: The reading direction of a page: left to right or right to left.