Skip to content

Commit fb5be50

Browse files
committed
refactor(react): source /ai-sdk server defs from the React-free core (drop the React re-export)
1 parent 035fba2 commit fb5be50

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

.changeset/tanstack-ai-adapter.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ Add a TanStack AI adapter (the `/tanstack-ai` subpath) for client-side tool call
88
- `@simplepdf/embed/tanstack-ai`: `simplePDFToolDefinitions()` (server, for `chat({ tools })`) and `createSimplePDFTools({ embed })` (browser `.client()` tools for `clientTools(...)` then `useChat({ tools })`).
99
- `@simplepdf/react-embed-pdf/tanstack-ai`: `useEmbedTools(embedRef)`, the editor-bound client tools. Server definitions stay in the React-free core `@simplepdf/embed/tanstack-ai`, so a server route never pulls React in.
1010
- `@tanstack/ai` is a new optional peer, pulled only by the `/tanstack-ai` subpath; the package roots stay free of it (and of `zod`).
11+
- `@simplepdf/react-embed-pdf` `/ai-sdk` no longer re-exports `simplePDFToolDefinitions`; import the server-side definitions from the React-free core `@simplepdf/embed/ai-sdk` (re-exporting them from the React package pulled React into server routes). The browser-side `createSimplePDFExecutor` is still re-exported, so both React adapters are consistent: server defs live only in the core. Released as a minor: the only consumer is copilot, updated in lockstep.

react/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ const CopilotEditor = () => {
223223
};
224224
```
225225

226-
For server-side tool definitions (execute-less, for `streamText`), import `simplePDFToolDefinitions` from the React-free core `@simplepdf/embed/ai-sdk` (importing it from this React subpath would pull React into your server). `embedRef.current` is the flat editor-actions handle, every camelCase operation, with the deprecated `selectTool` / `submit` overloads; subscribe to editor events via the `onEmbedEvent` prop. (The framework-free `@simplepdf/embed` core exposes the grouped `embed.actions` / `embed.events` / `embed.lifecycle` handle for non-React use.)
226+
For server-side tool definitions (execute-less, for `streamText`), import `simplePDFToolDefinitions` from the React-free core `@simplepdf/embed/ai-sdk` (it is intentionally not re-exported from this React subpath, which imports React). `embedRef.current` is the flat editor-actions handle, every camelCase operation, with the deprecated `selectTool` / `submit` overloads; subscribe to editor events via the `onEmbedEvent` prop. (The framework-free `@simplepdf/embed` core exposes the grouped `embed.actions` / `embed.events` / `embed.lifecycle` handle for non-React use.)
227227

228228
#### Agentic: `useEmbedTools` (TanStack AI)
229229

react/src/ai-sdk.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// The agentic surface for @simplepdf/react-embed-pdf the React mirror of
1+
// The agentic surface for @simplepdf/react-embed-pdf: the React mirror of
22
// @simplepdf/embed's /tools + /ai-sdk subpaths. Importing THIS module (not the package
33
// root) is what pulls in `zod`, so a <EmbedPDF>-only app never loads it — the same
44
// pay-for-use contract the core has. Pair it with useEmbed():
@@ -14,10 +14,11 @@ import { isSimplePDFToolName, routeToolCall, SIMPLEPDF_TOOLS, type SimplePDFTool
1414
import type { EmbedActions } from './embed-pdf';
1515
import { notMounted } from './not-mounted';
1616

17-
// Re-export the core agentic surface so React consumers get everything from one subpath:
18-
// server-side tool definitions (execute-less, for streamText), the browser executor, and
19-
// the tool-name guard — mirroring @simplepdf/embed/ai-sdk + /tools.
20-
export { createSimplePDFExecutor, simplePDFToolDefinitions } from '@simplepdf/embed/ai-sdk';
17+
// Re-export the browser-side executor + the tool-name guard for React consumers. The
18+
// server-side `simplePDFToolDefinitions` is deliberately NOT re-exported: this module
19+
// imports React (for the hook), so re-exporting the defs would pull React into a server
20+
// `streamText` route. Import those from the React-free core `@simplepdf/embed/ai-sdk`.
21+
export { createSimplePDFExecutor } from '@simplepdf/embed/ai-sdk';
2122
export { isSimplePDFToolName };
2223
export type { SimplePDFToolName };
2324

0 commit comments

Comments
 (0)