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
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tokens reconstructed from the public cursor/canvas declarations.
|
|
3
|
+
* Text, fill, and stroke alphas follow the mix rules in canvas-tokens.d.ts
|
|
4
|
+
* (dark base #F0F0F0, light base #141414). Chart hexes are copied verbatim.
|
|
5
|
+
* Editor surfaces are not published; these constants are the canvas host fallback.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export type ThemeKind = "dark" | "light";
|
|
9
|
+
|
|
10
|
+
export type Color =
|
|
11
|
+
| "gray"
|
|
12
|
+
| "purple"
|
|
13
|
+
| "green"
|
|
14
|
+
| "yellow"
|
|
15
|
+
| "cyan"
|
|
16
|
+
| "pink"
|
|
17
|
+
| "blue"
|
|
18
|
+
| "orange"
|
|
19
|
+
| "red";
|
|
20
|
+
|
|
21
|
+
export type ChartTone = "success" | "danger" | "warning" | "info" | "neutral";
|
|
22
|
+
|
|
23
|
+
export type CanvasPalette = {
|
|
24
|
+
readonly foreground: string;
|
|
25
|
+
readonly foregroundSecondary: string;
|
|
26
|
+
readonly foregroundTertiary: string;
|
|
27
|
+
readonly foregroundQuaternary: string;
|
|
28
|
+
readonly editor: string;
|
|
29
|
+
readonly chrome: string;
|
|
30
|
+
readonly sidebar: string;
|
|
31
|
+
readonly elevated: string;
|
|
32
|
+
readonly fillPrimary: string;
|
|
33
|
+
readonly fillSecondary: string;
|
|
34
|
+
readonly fillTertiary: string;
|
|
35
|
+
readonly fillQuaternary: string;
|
|
36
|
+
readonly strokePrimary: string;
|
|
37
|
+
readonly strokeSecondary: string;
|
|
38
|
+
readonly strokeTertiary: string;
|
|
39
|
+
readonly strokeFocused: string;
|
|
40
|
+
readonly accent: string;
|
|
41
|
+
readonly buttonBackground: string;
|
|
42
|
+
readonly buttonForeground: string;
|
|
43
|
+
readonly buttonHoverBackground: string;
|
|
44
|
+
readonly link: string;
|
|
45
|
+
readonly diffInsertedLine: string;
|
|
46
|
+
readonly diffRemovedLine: string;
|
|
47
|
+
readonly diffStripAdded: string;
|
|
48
|
+
readonly diffStripRemoved: string;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type CanvasTokens = {
|
|
52
|
+
bg: { editor: string; chrome: string; elevated: string };
|
|
53
|
+
text: {
|
|
54
|
+
primary: string;
|
|
55
|
+
secondary: string;
|
|
56
|
+
tertiary: string;
|
|
57
|
+
quaternary: string;
|
|
58
|
+
link: string;
|
|
59
|
+
onAccent: string;
|
|
60
|
+
};
|
|
61
|
+
stroke: { primary: string; secondary: string; tertiary: string; focused: string };
|
|
62
|
+
fill: { primary: string; secondary: string; tertiary: string; quaternary: string };
|
|
63
|
+
accent: { primary: string; control: string; controlHover: string };
|
|
64
|
+
diff: {
|
|
65
|
+
insertedLine: string;
|
|
66
|
+
removedLine: string;
|
|
67
|
+
stripAdded: string;
|
|
68
|
+
stripRemoved: string;
|
|
69
|
+
};
|
|
70
|
+
category: Readonly<Record<Color, string>>;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const chartPalette = {
|
|
74
|
+
green: "#1F8A65E8",
|
|
75
|
+
darkGreen: "#0D855AE0",
|
|
76
|
+
lightGreen: "#52B896E0",
|
|
77
|
+
mintGreen: "#7DCAB0E0",
|
|
78
|
+
blue: "#2E79B5E0",
|
|
79
|
+
lightBlue: "#70B0D8E0",
|
|
80
|
+
indigo: "#5A6CC0F0",
|
|
81
|
+
lightIndigo: "#9AAADCE0",
|
|
82
|
+
purple: "#7B64B8F0",
|
|
83
|
+
lightPurple: "#AA98D8E0",
|
|
84
|
+
warmPink: "#C85898E0",
|
|
85
|
+
lightPink: "#E8A0C4E0",
|
|
86
|
+
brightOrange: "#F0A040E0",
|
|
87
|
+
deepOrange: "#C06028E0",
|
|
88
|
+
goldenYellow: "#E8C030E0",
|
|
89
|
+
darkAmber: "#C04848E0",
|
|
90
|
+
warmPeach: "#F0A088E0",
|
|
91
|
+
vibrantTeal: "#2A9A8AE0",
|
|
92
|
+
muted: "#8888A8E0",
|
|
93
|
+
neutralLine: "#888899D0",
|
|
94
|
+
} as const;
|
|
95
|
+
|
|
96
|
+
export const chartColorSequence: readonly string[] = [
|
|
97
|
+
chartPalette.green,
|
|
98
|
+
chartPalette.blue,
|
|
99
|
+
chartPalette.purple,
|
|
100
|
+
chartPalette.brightOrange,
|
|
101
|
+
chartPalette.lightBlue,
|
|
102
|
+
chartPalette.warmPink,
|
|
103
|
+
chartPalette.goldenYellow,
|
|
104
|
+
chartPalette.vibrantTeal,
|
|
105
|
+
chartPalette.indigo,
|
|
106
|
+
chartPalette.deepOrange,
|
|
107
|
+
];
|
|
108
|
+
|
|
109
|
+
export const toneColor: Record<ChartTone, string> = {
|
|
110
|
+
success: "#1F8A65",
|
|
111
|
+
danger: "#C04848",
|
|
112
|
+
warning: "#C06028",
|
|
113
|
+
info: "#2E79B5",
|
|
114
|
+
neutral: "#888899",
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const categoryDark: Record<Color, string> = {
|
|
118
|
+
gray: "#F0F0F099",
|
|
119
|
+
purple: "#7B64B8",
|
|
120
|
+
green: "#1F8A65",
|
|
121
|
+
yellow: "#E8C030",
|
|
122
|
+
cyan: "#2A9A8A",
|
|
123
|
+
pink: "#C85898",
|
|
124
|
+
blue: "#2E79B5",
|
|
125
|
+
orange: "#F0A040",
|
|
126
|
+
red: "#C04848",
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const categoryLight: Record<Color, string> = {
|
|
130
|
+
gray: "#14141499",
|
|
131
|
+
purple: "#6A54A8",
|
|
132
|
+
green: "#1A7A58",
|
|
133
|
+
yellow: "#8A6A10",
|
|
134
|
+
cyan: "#1E7A6C",
|
|
135
|
+
pink: "#A84880",
|
|
136
|
+
blue: "#2E79B5",
|
|
137
|
+
orange: "#C06028",
|
|
138
|
+
red: "#A83838",
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export const usageColorSequence: readonly Color[] = [
|
|
142
|
+
"purple",
|
|
143
|
+
"green",
|
|
144
|
+
"yellow",
|
|
145
|
+
"blue",
|
|
146
|
+
"orange",
|
|
147
|
+
"pink",
|
|
148
|
+
"cyan",
|
|
149
|
+
"red",
|
|
150
|
+
"gray",
|
|
151
|
+
];
|
|
152
|
+
|
|
153
|
+
function mix(base: string, percent: number): string {
|
|
154
|
+
const alpha = Math.round((percent / 100) * 255)
|
|
155
|
+
.toString(16)
|
|
156
|
+
.padStart(2, "0");
|
|
157
|
+
return `${base}${alpha}`;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function palette(kind: ThemeKind): CanvasPalette {
|
|
161
|
+
const dark = kind === "dark";
|
|
162
|
+
const ink = dark ? "#F0F0F0" : "#141414";
|
|
163
|
+
const editor = dark ? "#181818" : "#FCFCFC";
|
|
164
|
+
const chrome = dark ? "#141414" : "#F3F3F3";
|
|
165
|
+
const accent = dark ? "#70B0D8" : "#2E79B5";
|
|
166
|
+
return {
|
|
167
|
+
foreground: ink,
|
|
168
|
+
foregroundSecondary: mix(ink, 74),
|
|
169
|
+
foregroundTertiary: mix(ink, 60),
|
|
170
|
+
foregroundQuaternary: mix(ink, 36),
|
|
171
|
+
editor,
|
|
172
|
+
chrome,
|
|
173
|
+
sidebar: chrome,
|
|
174
|
+
elevated: editor,
|
|
175
|
+
fillPrimary: mix(ink, 20),
|
|
176
|
+
fillSecondary: mix(ink, 14),
|
|
177
|
+
fillTertiary: mix(ink, 8),
|
|
178
|
+
fillQuaternary: mix(ink, 6),
|
|
179
|
+
strokePrimary: mix(ink, 20),
|
|
180
|
+
strokeSecondary: mix(ink, 12),
|
|
181
|
+
strokeTertiary: mix(ink, 8),
|
|
182
|
+
strokeFocused: accent,
|
|
183
|
+
accent,
|
|
184
|
+
buttonBackground: accent,
|
|
185
|
+
buttonForeground: dark ? "#141414" : "#FCFCFC",
|
|
186
|
+
buttonHoverBackground: dark ? "#8EC0E4" : "#24689F",
|
|
187
|
+
link: accent,
|
|
188
|
+
diffInsertedLine: dark ? "#1F8A652E" : "#1F8A6524",
|
|
189
|
+
diffRemovedLine: dark ? "#C048482E" : "#C0484824",
|
|
190
|
+
diffStripAdded: "#1F8A65",
|
|
191
|
+
diffStripRemoved: "#C04848",
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export function buildTheme(kind: ThemeKind) {
|
|
196
|
+
const p = palette(kind);
|
|
197
|
+
const category = kind === "dark" ? categoryDark : categoryLight;
|
|
198
|
+
const tokens: CanvasTokens = {
|
|
199
|
+
bg: { editor: p.editor, chrome: p.chrome, elevated: p.elevated },
|
|
200
|
+
text: {
|
|
201
|
+
primary: p.foreground,
|
|
202
|
+
secondary: p.foregroundSecondary,
|
|
203
|
+
tertiary: p.foregroundTertiary,
|
|
204
|
+
quaternary: p.foregroundQuaternary,
|
|
205
|
+
link: p.link,
|
|
206
|
+
onAccent: p.buttonForeground,
|
|
207
|
+
},
|
|
208
|
+
stroke: {
|
|
209
|
+
primary: p.strokePrimary,
|
|
210
|
+
secondary: p.strokeSecondary,
|
|
211
|
+
tertiary: p.strokeTertiary,
|
|
212
|
+
focused: p.strokeFocused,
|
|
213
|
+
},
|
|
214
|
+
fill: {
|
|
215
|
+
primary: p.fillPrimary,
|
|
216
|
+
secondary: p.fillSecondary,
|
|
217
|
+
tertiary: p.fillTertiary,
|
|
218
|
+
quaternary: p.fillQuaternary,
|
|
219
|
+
},
|
|
220
|
+
accent: {
|
|
221
|
+
primary: p.accent,
|
|
222
|
+
control: p.buttonBackground,
|
|
223
|
+
controlHover: p.buttonHoverBackground,
|
|
224
|
+
},
|
|
225
|
+
diff: {
|
|
226
|
+
insertedLine: p.diffInsertedLine,
|
|
227
|
+
removedLine: p.diffRemovedLine,
|
|
228
|
+
stripAdded: p.diffStripAdded,
|
|
229
|
+
stripRemoved: p.diffStripRemoved,
|
|
230
|
+
},
|
|
231
|
+
category,
|
|
232
|
+
};
|
|
233
|
+
return {
|
|
234
|
+
kind,
|
|
235
|
+
...tokens,
|
|
236
|
+
tokens,
|
|
237
|
+
palette: p,
|
|
238
|
+
category,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export const canvasPaletteDark = palette("dark");
|
|
243
|
+
export const canvasPaletteLight = palette("light");
|
|
244
|
+
export const canvasTokens = buildTheme("dark").tokens;
|
|
245
|
+
export const canvasTokensLight = buildTheme("light").tokens;
|
|
246
|
+
export const categoryPaletteDark = categoryDark;
|
|
247
|
+
export const categoryPaletteLight = categoryLight;
|
|
248
|
+
export const colorPalette = categoryDark;
|
|
249
|
+
|
|
250
|
+
export const canvasTypography = {
|
|
251
|
+
h1: { fontSize: "24px", lineHeight: "30px", fontWeight: 590 },
|
|
252
|
+
h2: { fontSize: "18px", lineHeight: "24px", fontWeight: 590 },
|
|
253
|
+
h3: { fontSize: "16px", lineHeight: "22px", fontWeight: 590 },
|
|
254
|
+
body: { fontSize: "14px", lineHeight: "20px", fontWeight: 400 },
|
|
255
|
+
small: { fontSize: "12px", lineHeight: "16px", fontWeight: 400 },
|
|
256
|
+
} as const;
|
|
257
|
+
|
|
258
|
+
export const fontStack =
|
|
259
|
+
'"Segoe UI Variable", "Segoe UI", system-ui, sans-serif';
|
|
260
|
+
export const monoStack =
|
|
261
|
+
'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace';
|