cursor-canvas-export 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +97 -2
- package/bin/canvas-to-html.js +4 -0
- package/bin/canvas-to-pdf.js +4 -0
- package/dist/cli.js +903 -0
- package/package.json +52 -4
- package/src/sdk/charts.tsx +411 -0
- package/src/sdk/extras.tsx +461 -0
- package/src/sdk/hooks.tsx +28 -0
- package/src/sdk/index.tsx +55 -0
- package/src/sdk/tokens.ts +261 -0
- package/src/sdk/ui.tsx +779 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 flockentanz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,98 @@
|
|
|
1
|
-
#
|
|
1
|
+
# cursor-canvas-export
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/cursor-canvas-export)
|
|
4
|
+
[](https://cursor.com/install-mcp?name=canvas-export&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImN1cnNvci1jYW52YXMtZXhwb3J0IiwibWNwIl19)
|
|
5
|
+
|
|
6
|
+
Command-line tool and MCP server. It exports a Cursor canvas (`.canvas.tsx`) to a self-contained HTML file and a one-page PDF.
|
|
7
|
+
|
|
8
|
+
HTML is the rendered page. The PDF is that page printed by headless Chromium, so colors, type, tables, and charts stay together. Nothing opens on screen. The page is one continuous sheet the width of the canvas panel.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
Node.js 20 or newer.
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install
|
|
16
|
+
npx playwright install chromium
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The first export downloads Chromium if it is not cached yet. On the command line that download happens inside the command. The MCP tools return immediately and ask for a short wait while the download continues in the background. Later runs reuse that copy on Windows, macOS, and Linux.
|
|
20
|
+
|
|
21
|
+
## Command line
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx tsx src/cli.ts path/to/report.canvas.tsx
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
After `npm run build`, or once the package is installed:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
cursor-canvas-export path/to/report.canvas.tsx
|
|
31
|
+
canvas-to-html path/to/report.canvas.tsx
|
|
32
|
+
canvas-to-pdf path/to/report.canvas.tsx
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`canvas-to-html` and `canvas-to-pdf` are aliases. They default to one format. `--format` still overrides that.
|
|
36
|
+
|
|
37
|
+
Files are written next to the canvas: `report.html` and `report.pdf`.
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
cursor-canvas-export report.canvas.tsx --out out/report --theme light --width 960 --format both
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
| Flag | Default | |
|
|
44
|
+
| --- | --- | --- |
|
|
45
|
+
| `--out` | beside the source | Stem path. `.html` / `.pdf` are stripped. |
|
|
46
|
+
| `--theme` | `dark` | `dark` or `light` |
|
|
47
|
+
| `--width` | `800` | Page width in pixels |
|
|
48
|
+
| `--format` | `both` | `html`, `pdf`, or `both` |
|
|
49
|
+
| `--screenshot` | | Full-page PNG |
|
|
50
|
+
|
|
51
|
+
If `report.canvas.data.json` sits next to the canvas, `useCanvasState` reads it for the snapshot.
|
|
52
|
+
|
|
53
|
+
## MCP
|
|
54
|
+
|
|
55
|
+
Add this to `~/.cursor/mcp.json`:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"mcpServers": {
|
|
60
|
+
"canvas-export": {
|
|
61
|
+
"command": "npx",
|
|
62
|
+
"args": ["-y", "cursor-canvas-export", "mcp"]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
<a href="https://cursor.com/install-mcp?name=canvas-export&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImN1cnNvci1jYW52YXMtZXhwb3J0IiwibWNwIl19"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/deeplink/mcp-install-dark.svg"><img alt="Add to Cursor" src="https://cursor.com/deeplink/mcp-install-light.svg"></picture></a>
|
|
69
|
+
|
|
70
|
+
The server exposes three tools:
|
|
71
|
+
|
|
72
|
+
| Tool | Purpose |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| `list_canvases` | Find `.canvas.tsx` files under `~/.cursor/projects`, newest first. |
|
|
75
|
+
| `export_canvas` | Write HTML and PDF next to the canvas. Accepts a path or a name. |
|
|
76
|
+
| `preview_canvas` | Return a PNG of the page. Tall pages are clipped to the top. |
|
|
77
|
+
|
|
78
|
+
Ask the agent to export a canvas. It calls the tool and returns the file paths.
|
|
79
|
+
|
|
80
|
+
The first time Chromium is not cached, `export_canvas` and `preview_canvas` return at once and tell the agent to wait about 30 seconds, then call the same tool again with the same arguments. That reply is not a failed export. The file appears when a later call returns the output paths.
|
|
81
|
+
|
|
82
|
+
## How it works
|
|
83
|
+
|
|
84
|
+
A canvas only imports `cursor/canvas`. This package bundles the file with esbuild against a local implementation of that SDK, mounts it in headless Chromium, and saves the DOM. Chart colors and the type scale come from the public canvas tokens.
|
|
85
|
+
|
|
86
|
+
The IDE font is private, so text uses Segoe UI on Windows and `system-ui` elsewhere. Glyphs can differ slightly from the panel in Cursor.
|
|
87
|
+
|
|
88
|
+
Very tall canvases can exceed Chromium’s page-size limit. The HTML file is still written.
|
|
89
|
+
|
|
90
|
+
## Test
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
npm test
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
MIT
|