@pixerate/editor 0.44.0 → 0.46.0
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 +29 -3
- package/dist/agent/index.cjs +548 -45
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +47 -17
- package/dist/agent/index.d.ts +47 -17
- package/dist/agent/index.js +536 -33
- package/dist/agent/index.js.map +1 -1
- package/dist/{builtins-BLud97fC.d.cts → builtins-CZW-aYKS.d.cts} +1 -1
- package/dist/{builtins-D0BDyAgw.d.ts → builtins-DghNQbT-.d.ts} +1 -1
- package/dist/chart/index.cjs +1984 -0
- package/dist/chart/index.cjs.map +1 -0
- package/dist/chart/index.d.cts +646 -0
- package/dist/chart/index.d.ts +646 -0
- package/dist/chart/index.js +1984 -0
- package/dist/chart/index.js.map +1 -0
- package/dist/{chunk-I6BZB5ZH.cjs → chunk-EFDCLENW.cjs} +73 -6
- package/dist/chunk-EFDCLENW.cjs.map +1 -0
- package/dist/chunk-HHQ4XJWT.js +826 -0
- package/dist/chunk-HHQ4XJWT.js.map +1 -0
- package/dist/chunk-J3R2OWOE.cjs +1465 -0
- package/dist/chunk-J3R2OWOE.cjs.map +1 -0
- package/dist/chunk-K2LVZ4FA.cjs +826 -0
- package/dist/chunk-K2LVZ4FA.cjs.map +1 -0
- package/dist/{chunk-6MDQKHRH.cjs → chunk-N4MLNJPO.cjs} +21 -899
- package/dist/chunk-N4MLNJPO.cjs.map +1 -0
- package/dist/chunk-PQM5W7ZN.js +168 -0
- package/dist/chunk-PQM5W7ZN.js.map +1 -0
- package/dist/{chunk-DDADOHJW.js → chunk-Q25ZS4F7.js} +5 -883
- package/dist/chunk-Q25ZS4F7.js.map +1 -0
- package/dist/chunk-TK2XZK6Z.js +1465 -0
- package/dist/chunk-TK2XZK6Z.js.map +1 -0
- package/dist/commands/index.cjs +3 -2
- package/dist/commands/index.cjs.map +1 -1
- package/dist/commands/index.d.cts +5 -5
- package/dist/commands/index.d.ts +5 -5
- package/dist/commands/index.js +2 -1
- package/dist/commands/index.js.map +1 -1
- package/dist/extensions/index.cjs +4 -4
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +3 -3
- package/dist/extensions/index.d.ts +3 -3
- package/dist/extensions/index.js +12 -12
- package/dist/generation/index.cjs +2 -2
- package/dist/generation/index.d.cts +4 -4
- package/dist/generation/index.d.ts +4 -4
- package/dist/generation/index.js +1 -1
- package/dist/image-editor/index.cjs +24 -24
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +2 -2
- package/dist/image-editor/index.d.ts +2 -2
- package/dist/image-editor/index.js +24 -24
- package/dist/image-editor/index.js.map +1 -1
- package/dist/{index-C6gaQRH0.d.cts → index-CfOQf70b.d.cts} +1 -1
- package/dist/{index-DXAv_R08.d.ts → index-jwJ_onWf.d.ts} +1 -1
- package/dist/index.cjs +9 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +12 -12
- package/dist/parameters/index.d.cts +2 -2
- package/dist/parameters/index.d.ts +2 -2
- package/dist/{registry-DnzpgY27.d.cts → registry-B4l-lYts.d.cts} +1 -1
- package/dist/{registry-DhVUZioj.d.ts → registry-BfVD-vVg.d.ts} +1 -1
- package/dist/{registry-BDe-vlv3.d.ts → registry-CSlH4iUn.d.ts} +1 -1
- package/dist/{registry-D0GADKc7.d.cts → registry-vz6HOiiy.d.cts} +1 -1
- package/dist/{schema-DYDGdYL9.d.cts → schema-Di0CS6Pe.d.cts} +26 -2
- package/dist/{schema-DYDGdYL9.d.ts → schema-Di0CS6Pe.d.ts} +26 -2
- package/dist/tools/index.cjs +37 -3
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.cts +871 -11
- package/dist/tools/index.d.ts +871 -11
- package/dist/tools/index.js +36 -2
- package/dist/vector/index.d.cts +2 -2
- package/dist/vector/index.d.ts +2 -2
- package/package.json +6 -1
- package/dist/chunk-36BLROHV.js +0 -438
- package/dist/chunk-36BLROHV.js.map +0 -1
- package/dist/chunk-5H2OPMXZ.js +0 -586
- package/dist/chunk-5H2OPMXZ.js.map +0 -1
- package/dist/chunk-6MDQKHRH.cjs.map +0 -1
- package/dist/chunk-D6S5M7HV.js +0 -101
- package/dist/chunk-D6S5M7HV.js.map +0 -1
- package/dist/chunk-DDADOHJW.js.map +0 -1
- package/dist/chunk-I6BZB5ZH.cjs.map +0 -1
- package/dist/chunk-MC2LQN5S.cjs +0 -586
- package/dist/chunk-MC2LQN5S.cjs.map +0 -1
- package/dist/chunk-V7CC7RZ6.cjs +0 -438
- package/dist/chunk-V7CC7RZ6.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -206,7 +206,32 @@ registry.onListChanged((tools) => server.sendToolListChanged());
|
|
|
206
206
|
await registry.callTool("insert_text", { text: "Hello" }); // { content: [...], structuredContent }
|
|
207
207
|
```
|
|
208
208
|
|
|
209
|
-
|
|
209
|
+
Built-in providers:
|
|
210
|
+
|
|
211
|
+
| Provider | Tools |
|
|
212
|
+
| :--- | :--- |
|
|
213
|
+
| `createRichTextToolProvider(editor, { id })` | `get_text` (`format`, `blocks: true` for every paragraph's positions), `find_text`, `insert_text`, `replace_text` (all matches or the n-th, one undo step), `replace_range`, `replace_selection`, `set_selection`, `edit_table` (when tables are on). Read-only editors get `get_text` and `find_text`. |
|
|
214
|
+
| `createSpreadsheetToolProvider(controller, { id })` | `get_range`, `set_cell`, `set_range` (2D block, one undo step, refuses read-only targets), `insert_rows`, `delete_rows`, `insert_columns`, `delete_columns` |
|
|
215
|
+
| `createEditorMcpToolProvider({ id, getSnapshot, applySteps })` | `get_editor_state`, `canvas_add_node`, `canvas_remove_nodes`, `canvas_connect`, `canvas_update_node`, `canvas_layout`, `canvas_select`, `canvas_highlight`, `prompt_insert_text`, `prompt_replace_range`, `prompt_set_variable`, `prompt_select`, `view_editor` (with `captureView`) |
|
|
216
|
+
| `createCanvasComponentToolProvider`, `createCommandToolProvider`, `createImageEditorToolProvider`, `createGenerationToolProvider` | See the canvas, commands, image editor and generation docs |
|
|
217
|
+
|
|
218
|
+
Text tools take ProseMirror document positions, not plain-text offsets: `find_text` and `get_text { blocks: true }` return them. The canvas tools check node ids against `getSnapshot()` (unknown ids, an id that already exists, self-edges and unordered ranges are tool errors the model can fix) and return what they created: `{ applied, steps, created: { nodes: [{ id, position }], edges: [{ id, source, target }] } }`. Pass `toolStyle: "combined"` for the older `edit_canvas` / `edit_prompt` tools with an `operation` argument, and `surfaces: { canvas: false }` to expose only the prompt tools. `planToolCall` turns any tool call into planner steps (`step:tool_call` for registry tools), and `validateAgentCommand` runs the same checks for hosts that drive the planner directly.
|
|
219
|
+
|
|
220
|
+
Tool `inputSchema`s are validated by `validateJsonSchema`, which supports `type`, `enum`, `const`, `properties`, `required`, `additionalProperties`, `items`, `minItems` / `maxItems`, `uniqueItems`, `minimum` / `maximum`, `exclusiveMinimum` / `exclusiveMaximum`, `multipleOf`, `minLength` / `maxLength`, `pattern`, `anyOf`, `oneOf`, `allOf`, `not` and local `$ref`s (`#/$defs/...`). Other keywords are ignored.
|
|
221
|
+
|
|
222
|
+
### Serving the registry over MCP
|
|
223
|
+
|
|
224
|
+
`createMcpServer(registry, { name, version, send })` (in `/tools`, no dependencies) answers MCP JSON-RPC messages from any transport: stdio lines, a WebSocket, `postMessage` or an HTTP handler. It handles `initialize` (protocol version negotiation), `ping`, `tools/list`, `tools/call` and `notifications/cancelled` (aborts the call's `signal`), and sends `notifications/tools/list_changed` through `send` once the client is initialized.
|
|
225
|
+
|
|
226
|
+
```ts
|
|
227
|
+
import { createMcpServer } from "@pixerate/editor/tools";
|
|
228
|
+
|
|
229
|
+
const server = createMcpServer(registry, { name: "my-app", version: "1.0.0", send: (msg) => socket.send(JSON.stringify(msg)) });
|
|
230
|
+
socket.onmessage = async (event) => {
|
|
231
|
+
const response = await server.handle(event.data);
|
|
232
|
+
if (response) socket.send(JSON.stringify(response));
|
|
233
|
+
};
|
|
234
|
+
```
|
|
210
235
|
|
|
211
236
|
### Without TipTap: `@pixerate/editor/tools`
|
|
212
237
|
|
|
@@ -223,7 +248,7 @@ const list = registry.listTools(); // MCP tools/list result
|
|
|
223
248
|
const result = await registry.callTool(name, args); // MCP tools/call result
|
|
224
249
|
```
|
|
225
250
|
|
|
226
|
-
It exports `ToolRegistry`, `createToolRegistry`, `ToolRegistryError`, the tool types (`AgentTool`, `AgentToolProvider`, `AgentToolHandler`, `ToolCallContext`, `McpToolDefinition`, `McpToolResult`, `McpListToolsResult`, `ToolCallError`), `validateJsonSchema` / `SchemaValidationError`,
|
|
251
|
+
It exports `ToolRegistry`, `createToolRegistry`, `ToolRegistryError`, the tool types (`AgentTool`, `AgentToolProvider`, `AgentToolHandler`, `ToolCallContext`, `McpToolDefinition`, `McpToolResult`, `McpListToolsResult`, `ToolCallError`), `validateJsonSchema` / `SchemaValidationError`, the static tool definitions (`EDITOR_MCP_TOOLS`, `EDITOR_CANVAS_TOOLS`, `EDITOR_PROMPT_TOOLS`) and `createMcpServer`. `/agent` re-exports all of it, so existing imports keep working. `createEditorMcpToolProvider` stays in `/agent` because its `layout` operation runs dagre.
|
|
227
252
|
|
|
228
253
|
## Commands, shortcuts and the command palette
|
|
229
254
|
|
|
@@ -427,9 +452,10 @@ Each module is also available as a subpath import:
|
|
|
427
452
|
| `@pixerate/editor/export` | Word export: `exportDocx`, `exportDocxBlob`, `createDocxParts`, `DocxExportController`, plus the zip writer and XML escapers it uses (no third-party imports; also re-exported from the root entry) |
|
|
428
453
|
| `@pixerate/editor/tokens` | Design tokens: collections, modes, aliases, `TokenStore`, `resolveToken`, W3C Design Tokens JSON and CSS custom-property export (no third-party imports) |
|
|
429
454
|
| `@pixerate/editor/vector` | Headless vector editor: `VectorDocument` (Bézier paths with corner / smooth / symmetric anchors, groups, gradients), `VectorEditorController` (select, direct select, pen, pencil and shape tools driven by pointer / key events; transforms, booleans, align, group, undo, viewport), scene and overlay render data, DOM-free `parseVectorSvg` / `vectorDocumentToSvg` and `createVectorCommands` for agents (no third-party imports; see [the vector editor guide](../../docs/vector-editor.md)) |
|
|
455
|
+
| `@pixerate/editor/chart` | Headless chart editor: `ChartSpec` (bar, line, area, scatter, pie, donut, combos, stacking) with `normalizeChartSpec`, the DOM-free `layoutChart` scene (drawing primitives with click targets), `ChartController` (data and presentation edits, selection, drag gestures, undo), `chartToSvg`, CSV / table import and `createChartCommands` for agents (no third-party imports; see [the chart editor guide](../../docs/chart-editor.md)) |
|
|
430
456
|
| `@pixerate/editor/parameters` | Schema-driven parameters editor for effects, shaders, generators and component props: `ParameterSchema` (number, int, boolean, choice, color, vector, image and text fields; groups; `showIf`), `ParametersController` (validation, undo with merged slider gestures, reset, randomize, presets, keyframe hooks), `createParameterCommands` for agents and `parameterSchemaFromShaderControls` (no third-party imports) |
|
|
431
457
|
|
|
432
|
-
The root entry (`@pixerate/editor`) re-exports everything except animation, canvas, agent, commands, persistence, generation, tokens, parameters, vector and image editor, including TipTap. Import from the narrowest subpath you need: `grammar`, `history`, `animation`, `spreadsheet`, `commands`, `persistence` and `image-editor` have no third-party imports, so a spreadsheet-only app bundles no TipTap, markdown or dagre code. The package is marked `sideEffects: false`, so unused root exports are also tree-shaken.
|
|
458
|
+
The root entry (`@pixerate/editor`) re-exports everything except animation, canvas, agent, commands, persistence, generation, tokens, parameters, vector, chart and image editor, including TipTap. Import from the narrowest subpath you need: `grammar`, `history`, `animation`, `spreadsheet`, `commands`, `persistence` and `image-editor` have no third-party imports, so a spreadsheet-only app bundles no TipTap, markdown or dagre code. The package is marked `sideEffects: false`, so unused root exports are also tree-shaken.
|
|
433
459
|
|
|
434
460
|
## Keyframe animation without the canvas
|
|
435
461
|
|