@flesler/cursor-canvas-web 1.0.2 → 1.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/README.md +9 -8
- package/dist/cursor-canvas.cjs +1 -1
- package/dist/cursor-canvas.js +571 -764
- package/dist/host-tokens-Cjzmp0z_.cjs +1 -0
- package/dist/host-tokens-Dh2BFFjv.js +412 -0
- package/dist/runtime/index.d.ts +5 -7
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +101 -14
- package/package.json +21 -13
- package/src/vendor/canvas/SKILL.md +113 -0
- package/src/vendor/canvas-sdk/callout-tone-icons.d.ts +10 -0
- package/src/vendor/canvas-sdk/canvas-tokens.d.ts +259 -0
- package/src/vendor/canvas-sdk/chart-primitives.d.ts +272 -0
- package/src/vendor/canvas-sdk/collapsible-section.d.ts +66 -0
- package/src/vendor/canvas-sdk/dag-layout.d.ts +101 -0
- package/src/vendor/canvas-sdk/diff-view.d.ts +129 -0
- package/src/vendor/canvas-sdk/form-primitives.d.ts +194 -0
- package/src/vendor/canvas-sdk/hooks.d.ts +173 -0
- package/src/vendor/canvas-sdk/index.d.ts +65 -0
- package/src/vendor/canvas-sdk/internal/canvas-action-dispatch.d.ts +17 -0
- package/src/vendor/canvas-sdk/manifest.json +5 -0
- package/src/vendor/canvas-sdk/swatch.d.ts +39 -0
- package/src/vendor/canvas-sdk/theme.d.ts +107 -0
- package/src/vendor/canvas-sdk/todo-list.d.ts +48 -0
- package/src/vendor/canvas-sdk/ui-primitives.d.ts +569 -0
- package/src/vendor/canvas-sdk/usage-bar.d.ts +55 -0
- package/dist/shim/charts.d.ts +0 -66
- package/dist/shim/cursor-canvas.d.ts +0 -278
- package/dist/shim/dag.d.ts +0 -55
- package/dist/shim/diff.d.ts +0 -23
- package/dist/shim/theme.d.ts +0 -323
- package/dist/shim/todo.d.ts +0 -22
- package/dist/shim/use-tokens.d.ts +0 -6
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API for authoring `.canvas.tsx` files via `cursor/canvas`.
|
|
3
|
+
*
|
|
4
|
+
* Be creative with layout — use Grid, Row, cards, charts, tables, and raw SVG
|
|
5
|
+
* in whatever combination serves the content. Read
|
|
6
|
+
* `~/.cursor/skills-cursor/canvas/SKILL.md` for full design guidance. Key
|
|
7
|
+
* constraints:
|
|
8
|
+
*
|
|
9
|
+
* - Colors from `useHostTheme()` tokens (`theme.bg.editor`, not
|
|
10
|
+
* `theme.colors.bg.primary`). No hardcoded hex.
|
|
11
|
+
* - Literal props are component-specific: `Pill.tone` has no `"danger"`
|
|
12
|
+
* and is ignored; `Card.variant` is only `"default"` | `"borderless"`.
|
|
13
|
+
* - No gradients, no box-shadows, no emojis as decoration.
|
|
14
|
+
* - Don't wrap every section in Card — mix open sections with cards.
|
|
15
|
+
* - Run that skill's Pre-delivery self-check before returning code.
|
|
16
|
+
*/
|
|
17
|
+
/** React authoring utilities re-exported so canvases need one public import. */
|
|
18
|
+
export type { CSSProperties, RefObject } from "react";
|
|
19
|
+
export { useEffect, useMemo, useRef, useState } from "react";
|
|
20
|
+
/** Shared category color palette used by `Swatch`, `UsageBar`, etc. */
|
|
21
|
+
export type { CanvasHostThemeBrand, CategoryPalette, ChartPalette, Color, } from "./canvas-tokens.js";
|
|
22
|
+
export { categoryPaletteDark, categoryPaletteLight, colorPalette, usageColorSequence, } from "./canvas-tokens.js";
|
|
23
|
+
/** Charts. */
|
|
24
|
+
export type { BarChartProps, ChartDataPoint, ChartReferenceLine, ChartSeries, ChartTone, LineChartProps, PieChartProps, } from "./chart-primitives.js";
|
|
25
|
+
export { BarChart, LineChart, PieChart } from "./chart-primitives.js";
|
|
26
|
+
/** Borderless collapsible disclosure row with a structured header. */
|
|
27
|
+
export type { CollapsibleSectionProps } from "./collapsible-section.js";
|
|
28
|
+
export { CollapsibleSection } from "./collapsible-section.js";
|
|
29
|
+
/** DAG layout. */
|
|
30
|
+
export type { DAGLayoutEdge, DAGLayoutNode, DAGLayoutOptions, DAGLayoutRank, DAGLayoutResult, } from "./dag-layout.js";
|
|
31
|
+
export { computeDAGLayout } from "./dag-layout.js";
|
|
32
|
+
/**
|
|
33
|
+
* Diff rendering. Compose with the generic `Card` family for file-level
|
|
34
|
+
* chrome: use `DiffView` inside a `CardBody` (with `padding: 0`) and put
|
|
35
|
+
* `DiffStats` in the enclosing `CardHeader`'s `trailing` slot.
|
|
36
|
+
*/
|
|
37
|
+
export type { DiffLineData, DiffLineType, DiffStatsProps, DiffViewProps } from "./diff-view.js";
|
|
38
|
+
export { DiffStats, DiffView } from "./diff-view.js";
|
|
39
|
+
/** Form controls. */
|
|
40
|
+
export type { CheckboxProps, IconButtonProps, SelectOption, SelectProps, TextAreaProps, TextInputProps, ToggleProps, } from "./form-primitives.js";
|
|
41
|
+
export { Checkbox, IconButton, Select, TextArea, TextInput, Toggle } from "./form-primitives.js";
|
|
42
|
+
/** Host state hooks. */
|
|
43
|
+
export type { CanvasAction, CanvasHostTheme, SetCanvasState } from "./hooks.js";
|
|
44
|
+
export { useCanvasAction, useCanvasState, useHostTheme } from "./hooks.js";
|
|
45
|
+
/** Colored category swatch (uses the shared `Color` palette). */
|
|
46
|
+
export type { SwatchProps } from "./swatch.js";
|
|
47
|
+
export { Swatch } from "./swatch.js";
|
|
48
|
+
/** Semantic design tokens for custom styling. */
|
|
49
|
+
export type { CanvasPalette, CanvasTokens } from "./theme.js";
|
|
50
|
+
export { canvasPaletteDark, canvasPaletteGrokDark, canvasPaletteGrokLight, canvasPaletteLight, canvasTokens, canvasTokensLight, } from "./theme.js";
|
|
51
|
+
export type { TodoItem, TodoListCardProps, TodoListProps, TodoStatus } from "./todo-list.js";
|
|
52
|
+
export { TodoList, TodoListCard } from "./todo-list.js";
|
|
53
|
+
/** Component props types. */
|
|
54
|
+
export type { ButtonProps, CalloutProps, CalloutTone, CardBodyProps, CardHeaderProps, CardProps, CardSize, CardVariant, CodeProps, DividerProps, GridProps, H1Props, H2Props, H3Props, LinkProps, PillProps, PillSize, PillTone, RowProps, StackProps, StatProps, StatTone, TableColumnAlign, TableProps, TableRowTone, TextProps, TextWeight, } from "./ui-primitives.js";
|
|
55
|
+
/** Layout. */
|
|
56
|
+
/** Typography. */
|
|
57
|
+
/** Surfaces. */
|
|
58
|
+
/** Actions. */
|
|
59
|
+
/** Feedback. */
|
|
60
|
+
export { Button, Callout, Card, CardBody, CardHeader, Code, Divider, Grid, H1, H2, H3, Link,
|
|
61
|
+
/** Shallow-merge two style objects. Useful for combining tokens with overrides. */
|
|
62
|
+
mergeStyle, Pill, Row, Spacer, Stack, Stat, Table, Text, } from "./ui-primitives.js";
|
|
63
|
+
/** Usage bar — segmented progress meter with optional labels above. */
|
|
64
|
+
export type { UsageBarProps, UsageBarSegment } from "./usage-bar.js";
|
|
65
|
+
export { UsageBar } from "./usage-bar.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stub for IDE `hooks.d.ts` — the skills-cursor SDK snapshot omits `internal/`.
|
|
3
|
+
* Keep in sync with Cursor's dispatch action union when syncing the SDK.
|
|
4
|
+
*/
|
|
5
|
+
export type CanvasAction =
|
|
6
|
+
| { type: 'openAgent'; agentId: string }
|
|
7
|
+
| { type: 'newComposerChat'; userPrompt?: string }
|
|
8
|
+
| {
|
|
9
|
+
type: 'openFile';
|
|
10
|
+
path: string;
|
|
11
|
+
selection?: {
|
|
12
|
+
startLineNumber: number;
|
|
13
|
+
startColumn: number;
|
|
14
|
+
endLineNumber?: number;
|
|
15
|
+
endColumn?: number;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Colored category swatch — a small filled rounded box. Intended for inline
|
|
3
|
+
* list/row decoration (category badges, the leading slot of
|
|
4
|
+
* `CollapsibleSection`, etc.).
|
|
5
|
+
*
|
|
6
|
+
* Pulls colors from `useHostTheme().category` so a category's swatch and its
|
|
7
|
+
* `UsageBar` segment for the same `color` stay visually coherent.
|
|
8
|
+
*/
|
|
9
|
+
import type { CSSProperties, JSX } from "react";
|
|
10
|
+
import type { Color } from "./canvas-tokens.js";
|
|
11
|
+
export type SwatchProps = {
|
|
12
|
+
/** One of the shared category hues. Matches `UsageBar` segment colors. */
|
|
13
|
+
color: Color;
|
|
14
|
+
style?: CSSProperties;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Filled, rounded category swatch (24px). Use as the leading visual on
|
|
18
|
+
* category rows, list items, or as the `leading` slot of a
|
|
19
|
+
* `CollapsibleSection`.
|
|
20
|
+
*
|
|
21
|
+
* Colors come from the shared `Color` palette, so a category's swatch
|
|
22
|
+
* matches its `UsageBar` segment for the same `color`.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* // Standalone — purple "tools" swatch
|
|
27
|
+
* <Swatch color="purple" />
|
|
28
|
+
*
|
|
29
|
+
* // As the `leading` slot on a CollapsibleSection
|
|
30
|
+
* <CollapsibleSection
|
|
31
|
+
* title="Tools"
|
|
32
|
+
* count={4}
|
|
33
|
+
* leading={<Swatch color="purple" />}
|
|
34
|
+
* >
|
|
35
|
+
* <Text>Tool calls go here.</Text>
|
|
36
|
+
* </CollapsibleSection>
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function Swatch({ color, style }: SwatchProps): JSX.Element;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { CanvasHostThemeBrand } from "./canvas-tokens.js";
|
|
2
|
+
export type { CanvasHostThemeBrand, CanvasPalette, CanvasTokens, ChartPalette, } from "./canvas-tokens.js";
|
|
3
|
+
export { canvasPaletteDark, canvasPaletteGrokDark, canvasPaletteGrokLight, canvasPaletteLight, canvasTokens, canvasTokensLight, chartThemeForBrand, parseCanvasHostThemeBrand, } from "./canvas-tokens.js";
|
|
4
|
+
/** Typography presets used by the built-in `cursor/canvas` components. */
|
|
5
|
+
export declare const canvasTypography: {
|
|
6
|
+
readonly fontFamily: "inherit";
|
|
7
|
+
readonly h1: {
|
|
8
|
+
readonly fontSize: "24px";
|
|
9
|
+
readonly lineHeight: "30px";
|
|
10
|
+
readonly fontWeight: 590;
|
|
11
|
+
};
|
|
12
|
+
readonly h2: {
|
|
13
|
+
readonly fontSize: "18px";
|
|
14
|
+
readonly lineHeight: "24px";
|
|
15
|
+
readonly fontWeight: 590;
|
|
16
|
+
};
|
|
17
|
+
readonly h3: {
|
|
18
|
+
readonly fontSize: "16px";
|
|
19
|
+
readonly lineHeight: "22px";
|
|
20
|
+
readonly fontWeight: 590;
|
|
21
|
+
};
|
|
22
|
+
readonly body: {
|
|
23
|
+
readonly fontSize: "14px";
|
|
24
|
+
readonly lineHeight: "20px";
|
|
25
|
+
readonly fontWeight: 400;
|
|
26
|
+
};
|
|
27
|
+
readonly small: {
|
|
28
|
+
readonly fontSize: "12px";
|
|
29
|
+
readonly lineHeight: "16px";
|
|
30
|
+
readonly fontWeight: 400;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Cursor canvases inherit the host frame's face (Geist in IDE / Inter on
|
|
35
|
+
* portal). Do not force Geist into the SDK — hosts already load it.
|
|
36
|
+
*/
|
|
37
|
+
export declare const canvasFontFamilyCursor: "inherit";
|
|
38
|
+
/**
|
|
39
|
+
* Sand's current `--sand-font-sans` stack. Hosts apply this same stack on
|
|
40
|
+
* the frame document so `inherit` matches the token. System faces only.
|
|
41
|
+
*/
|
|
42
|
+
export declare const canvasFontFamilyGrok: string;
|
|
43
|
+
/** Spacing scale (px). */
|
|
44
|
+
export declare const canvasSpacing: {
|
|
45
|
+
readonly "0.5": 2;
|
|
46
|
+
readonly "1": 4;
|
|
47
|
+
readonly "1.5": 6;
|
|
48
|
+
readonly "2": 8;
|
|
49
|
+
readonly "2.5": 10;
|
|
50
|
+
readonly "3": 12;
|
|
51
|
+
readonly "3.5": 14;
|
|
52
|
+
readonly "4": 16;
|
|
53
|
+
readonly "4.5": 18;
|
|
54
|
+
readonly "5": 20;
|
|
55
|
+
readonly "6": 24;
|
|
56
|
+
readonly "7": 28;
|
|
57
|
+
readonly "8": 32;
|
|
58
|
+
readonly "9": 36;
|
|
59
|
+
readonly "10": 40;
|
|
60
|
+
};
|
|
61
|
+
export type CanvasSpacing = typeof canvasSpacing;
|
|
62
|
+
/** Border radius (px). */
|
|
63
|
+
export declare const canvasRadius: {
|
|
64
|
+
readonly none: 0;
|
|
65
|
+
readonly xs: 2;
|
|
66
|
+
readonly sm: 4;
|
|
67
|
+
readonly md: 6;
|
|
68
|
+
readonly lg: 8;
|
|
69
|
+
readonly xl: 12;
|
|
70
|
+
readonly full: 9999;
|
|
71
|
+
};
|
|
72
|
+
export type CanvasRadius = {
|
|
73
|
+
readonly [K in keyof typeof canvasRadius]: number;
|
|
74
|
+
};
|
|
75
|
+
export type CanvasTypography = {
|
|
76
|
+
readonly fontFamily: string;
|
|
77
|
+
readonly h1: {
|
|
78
|
+
readonly fontSize: string;
|
|
79
|
+
readonly lineHeight: string;
|
|
80
|
+
readonly fontWeight: number;
|
|
81
|
+
};
|
|
82
|
+
readonly h2: {
|
|
83
|
+
readonly fontSize: string;
|
|
84
|
+
readonly lineHeight: string;
|
|
85
|
+
readonly fontWeight: number;
|
|
86
|
+
};
|
|
87
|
+
readonly h3: {
|
|
88
|
+
readonly fontSize: string;
|
|
89
|
+
readonly lineHeight: string;
|
|
90
|
+
readonly fontWeight: number;
|
|
91
|
+
};
|
|
92
|
+
readonly body: {
|
|
93
|
+
readonly fontSize: string;
|
|
94
|
+
readonly lineHeight: string;
|
|
95
|
+
readonly fontWeight: number;
|
|
96
|
+
};
|
|
97
|
+
readonly small: {
|
|
98
|
+
readonly fontSize: string;
|
|
99
|
+
readonly lineHeight: string;
|
|
100
|
+
readonly fontWeight: number;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/** Sand-grounded radii: 8 / 10 / 14 on the md / lg / xl steps. */
|
|
104
|
+
export declare const canvasRadiusGrok: CanvasRadius;
|
|
105
|
+
export declare const canvasTypographyGrok: CanvasTypography;
|
|
106
|
+
export declare function canvasRadiusForBrand(brand: CanvasHostThemeBrand): CanvasRadius;
|
|
107
|
+
export declare function canvasTypographyForBrand(brand: CanvasHostThemeBrand): CanvasTypography;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { CSSProperties, JSX } from "react";
|
|
2
|
+
export type TodoStatus = "pending" | "in_progress" | "completed" | "cancelled";
|
|
3
|
+
export interface TodoItem {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly content: string;
|
|
6
|
+
readonly status: TodoStatus;
|
|
7
|
+
}
|
|
8
|
+
export type TodoListProps = {
|
|
9
|
+
todos: readonly TodoItem[];
|
|
10
|
+
dimmedTodoIds?: ReadonlySet<string>;
|
|
11
|
+
/** Called when a todo row is clicked (entire row is a button). */
|
|
12
|
+
onTodoClick?: (todo: TodoItem) => void;
|
|
13
|
+
style?: CSSProperties;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Task list with status icons and wrapping text. Each row is a **clickable**
|
|
17
|
+
* button; use `onTodoClick` to handle selection or navigation.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <TodoList
|
|
22
|
+
* todos={items}
|
|
23
|
+
* onTodoClick={(todo) => setActiveId(todo.id)}
|
|
24
|
+
* />
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function TodoList({ todos, dimmedTodoIds, onTodoClick, style, }: TodoListProps): JSX.Element | null;
|
|
28
|
+
export type TodoListCardProps = {
|
|
29
|
+
todos: readonly TodoItem[];
|
|
30
|
+
dimmedTodoIds?: ReadonlySet<string>;
|
|
31
|
+
defaultExpanded?: boolean;
|
|
32
|
+
onTodoClick?: (todo: TodoItem) => void;
|
|
33
|
+
style?: CSSProperties;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Bordered, collapsible todo list with summary header (N of M Done). Compose
|
|
37
|
+
* with `onTodoClick` for row actions.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* <TodoListCard
|
|
42
|
+
* todos={items}
|
|
43
|
+
* defaultExpanded
|
|
44
|
+
* onTodoClick={(todo) => console.log(todo.id)}
|
|
45
|
+
* />
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function TodoListCard({ todos, dimmedTodoIds, defaultExpanded, onTodoClick, style, }: TodoListCardProps): JSX.Element | null;
|