@flesler/open-canvas

中文文档
1.14.0发布于 2026/11/16MITTypeScriptES Module近 30 天下载 2146

Agent-friendly canvas visuals (charts, tables, UI) from .canvas.tsx to HTML, PNG, PDF, JPG, or IDE-ready canvas

原始使用文档
文档目录5 节
  1. Install
  2. Agent skill
  3. Author a .canvas.tsx
  4. Generate
  5. License

open-canvas

Charts, tables, and structured visuals agents can one-shot — from a single .canvas.tsx file to HTML, PNG, PDF, JPG, or an IDE-ready canvas. Same cursor/canvas primitives as Cursor Canvas; no Cursor app required to build or export.

Web rendering uses the Mantine shim: cursor-canvas-web (@flesler/cursor-canvas-web on npm).

Live example: light · dark

Showcase (light) Showcase (dark)

Install

npm install -g @flesler/open-canvas

PNG, PDF, and JPG use headless Chromium (installed on first generate).

Agent skill

open-canvas skill ~/.cursor/skills/open-canvas   # SKILL.md only — read after open-canvas is on PATH

Installs agent guidance for authoring and exporting .canvas.tsx files with open-canvas.

Author a .canvas.tsx

One React file: charts, tables, callouts, forms — import only from cursor/canvas. Static data can live in sibling ./data/* files. Saved toggles and form state can live in <stem>.canvas.data.json beside the canvas (same keys as useCanvasState).

import { Stack, H1, BarChart } from "cursor/canvas";
import report from "./data/report.json";

Some components accept an extra prop with features beyond the Cursor SDK, such as <BarChart extra={{ valueAxis: { scale: "log" } }} />. Cursor ignores extra, so the canvas still renders there. See the shim's superset docs.

Generate

open-canvas generate path/to/report.canvas.tsx
open-canvas verify path/to/report.canvas.tsx
CommandPurpose
generate <canvas>HTML, PNG, PDF (default) into ./out
verify <canvas>Typecheck cursor/canvas and data imports
skill [dir]Print or install agent SKILL.md
vendor-pathPrint bundled cursor/canvas reference and SDK types
FlagDefault
-o, --out./out beside the canvas
-t, --themelight or dark
-f, --formatshtml,png,pdf — also jpg, cursor
-n, --nameOutput basename (default: canvas stem)
-w, --widthPlaywright viewport width (default 1280)
--min-heightOptional minimum page height in px
--selectorExport only matched sections
--inline-stateWith cursor: embed .canvas.data.json in the emitted file
-q, --quietNo stdout on success (outputs at {--out}/{--name or stem}.{ext})

Exports read .canvas.data.json when present. Run a separate generate for the IDE file: open-canvas generate path/to/x.canvas.tsx --formats cursor (optionally -o / -n for {dir}/{stem}.canvas.tsx). --formats cursor inlines ./data/*; add --inline-state to include saved UI state too.

Theme in canvas code: useHostTheme() — same hook and return value in Cursor and in export. Use generate --theme / --brand when you need a fixed light/dark or Cursor/Grok look in png/html/pdf.

License

MIT — LICENSE.

版本与发布记录

@flesler/open-canvas 共发布 27 个版本,首次发布于 2026/10/13;过去 12 个月发布了 27 个版本。

版本发布日期距今
1.14.0latest2026/11/16今天
1.13.12026/11/124 天前
1.13.02026/11/124 天前
1.12.02026/11/124 天前
1.11.22026/11/124 天前
1.11.12026/11/124 天前

关于 @flesler/open-canvas 的常见问题

@flesler/open-canvas 是什么?

Agent-friendly canvas visuals (charts, tables, UI) from .canvas.tsx to HTML, PNG, PDF, JPG, or IDE-ready canvas

如何安装 @flesler/open-canvas?

在项目目录运行 npm install @flesler/open-canvas,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 open-canvas,可以用 npx open-canvas 直接运行。

@flesler/open-canvas 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@flesler/open-canvas 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@flesler/open-canvas 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.12.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@flesler/open-canvas 可以商用吗?

@flesler/open-canvas 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@flesler/open-canvas 的下载量有多少?

根据 npm 官方下载统计,@flesler/open-canvas 在 2026/10/15 – 2026/11/13 这 30 天内被下载 2,146 次,日均约 72 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@flesler/open-canvas 还在维护吗?

最新版本 1.14.0 发布于 2026/11/16(今天);至今共发布 27 个版本,其中过去 12 个月发布了 27 个;首次发布于 2026/10/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。