cursor-canvas-export 0.0.0-stage → 0.1.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/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,95 @@
1
- # Temporary Holding Version
1
+ # cursor-canvas-export
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Export a Cursor canvas (`.canvas.tsx`) to a self-contained HTML file and a one-page PDF.
4
+
5
+ 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.
6
+
7
+ The same tool is published for agents as an MCP server.
8
+
9
+ ## Install
10
+
11
+ Node.js 20 or newer.
12
+
13
+ ```bash
14
+ npm install
15
+ npx playwright install chromium
16
+ ```
17
+
18
+ The first export downloads Chromium if it is not cached yet. Later runs reuse that copy on Windows, macOS, and Linux.
19
+
20
+ ## Command line
21
+
22
+ ```bash
23
+ npx tsx src/cli.ts path/to/report.canvas.tsx
24
+ ```
25
+
26
+ After `npm run build`, or once the package is installed:
27
+
28
+ ```bash
29
+ cursor-canvas-export path/to/report.canvas.tsx
30
+ canvas-to-html path/to/report.canvas.tsx
31
+ canvas-to-pdf path/to/report.canvas.tsx
32
+ ```
33
+
34
+ `canvas-to-html` and `canvas-to-pdf` are aliases. They default to one format. `--format` still overrides that.
35
+
36
+ Files are written next to the canvas: `report.html` and `report.pdf`.
37
+
38
+ ```bash
39
+ cursor-canvas-export report.canvas.tsx --out out/report --theme light --width 960 --format both
40
+ ```
41
+
42
+ | Flag | Default | |
43
+ | --- | --- | --- |
44
+ | `--out` | beside the source | Stem path. `.html` / `.pdf` are stripped. |
45
+ | `--theme` | `dark` | `dark` or `light` |
46
+ | `--width` | `800` | Page width in pixels |
47
+ | `--format` | `both` | `html`, `pdf`, or `both` |
48
+ | `--screenshot` | | Full-page PNG |
49
+
50
+ If `report.canvas.data.json` sits next to the canvas, `useCanvasState` reads it for the snapshot.
51
+
52
+ ## MCP
53
+
54
+ Add this to `~/.cursor/mcp.json`:
55
+
56
+ ```json
57
+ {
58
+ "mcpServers": {
59
+ "canvas-export": {
60
+ "command": "npx",
61
+ "args": ["-y", "cursor-canvas-export", "mcp"]
62
+ }
63
+ }
64
+ }
65
+ ```
66
+
67
+ [Add to Cursor](https://cursor.com/install-mcp?name=canvas-export&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImN1cnNvci1jYW52YXMtZXhwb3J0IiwibWNwIl19)
68
+
69
+ The server exposes three tools:
70
+
71
+ | Tool | Purpose |
72
+ | --- | --- |
73
+ | `list_canvases` | Find `.canvas.tsx` files under `~/.cursor/projects`, newest first. |
74
+ | `export_canvas` | Write HTML and PDF next to the canvas. Accepts a path or a name. |
75
+ | `preview_canvas` | Return a PNG of the page. Tall pages are clipped to the top. |
76
+
77
+ Ask the agent to export a canvas. It calls the tool and returns the file paths.
78
+
79
+ ## How it works
80
+
81
+ 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.
82
+
83
+ 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.
84
+
85
+ Very tall canvases can exceed Chromium’s page-size limit. The HTML file is still written.
86
+
87
+ ## Test
88
+
89
+ ```bash
90
+ npm test
91
+ ```
92
+
93
+ ## License
94
+
95
+ MIT
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ process.env.CANVAS_EXPORT_FORMAT ??= "html";
3
+ const { main } = await import("../dist/cli.js");
4
+ await main();
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ process.env.CANVAS_EXPORT_FORMAT ??= "pdf";
3
+ const { main } = await import("../dist/cli.js");
4
+ await main();