@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.
Files changed (33) hide show
  1. package/README.md +9 -8
  2. package/dist/cursor-canvas.cjs +1 -1
  3. package/dist/cursor-canvas.js +571 -764
  4. package/dist/host-tokens-Cjzmp0z_.cjs +1 -0
  5. package/dist/host-tokens-Dh2BFFjv.js +412 -0
  6. package/dist/runtime/index.d.ts +5 -7
  7. package/dist/runtime.cjs +1 -1
  8. package/dist/runtime.js +101 -14
  9. package/package.json +21 -13
  10. package/src/vendor/canvas/SKILL.md +113 -0
  11. package/src/vendor/canvas-sdk/callout-tone-icons.d.ts +10 -0
  12. package/src/vendor/canvas-sdk/canvas-tokens.d.ts +259 -0
  13. package/src/vendor/canvas-sdk/chart-primitives.d.ts +272 -0
  14. package/src/vendor/canvas-sdk/collapsible-section.d.ts +66 -0
  15. package/src/vendor/canvas-sdk/dag-layout.d.ts +101 -0
  16. package/src/vendor/canvas-sdk/diff-view.d.ts +129 -0
  17. package/src/vendor/canvas-sdk/form-primitives.d.ts +194 -0
  18. package/src/vendor/canvas-sdk/hooks.d.ts +173 -0
  19. package/src/vendor/canvas-sdk/index.d.ts +65 -0
  20. package/src/vendor/canvas-sdk/internal/canvas-action-dispatch.d.ts +17 -0
  21. package/src/vendor/canvas-sdk/manifest.json +5 -0
  22. package/src/vendor/canvas-sdk/swatch.d.ts +39 -0
  23. package/src/vendor/canvas-sdk/theme.d.ts +107 -0
  24. package/src/vendor/canvas-sdk/todo-list.d.ts +48 -0
  25. package/src/vendor/canvas-sdk/ui-primitives.d.ts +569 -0
  26. package/src/vendor/canvas-sdk/usage-bar.d.ts +55 -0
  27. package/dist/shim/charts.d.ts +0 -66
  28. package/dist/shim/cursor-canvas.d.ts +0 -278
  29. package/dist/shim/dag.d.ts +0 -55
  30. package/dist/shim/diff.d.ts +0 -23
  31. package/dist/shim/theme.d.ts +0 -323
  32. package/dist/shim/todo.d.ts +0 -22
  33. package/dist/shim/use-tokens.d.ts +0 -6
@@ -0,0 +1 @@
1
+ "use strict";const g={foreground:"#E4E4E4EB",foregroundSecondary:"#E4E4E48D",foregroundTertiary:"#E4E4E45E",foregroundQuaternary:"#E4E4E442",editor:"#181818",chrome:"#141414",sidebar:"#141414",elevated:"#181818",fillPrimary:"#E4E4E430",fillSecondary:"#E4E4E41E",fillTertiary:"#E4E4E411",fillQuaternary:"#E4E4E40A",strokePrimary:"#E4E4E433",strokeSecondary:"#E4E4E41F",strokeTertiary:"#E4E4E414",strokeFocused:"#599CE7",accent:"#599CE7",buttonBackground:"#599CE7",buttonForeground:"#191c22",buttonHoverBackground:"#6AABE9",link:"#87c3ff",diffInsertedLine:"#3FA26633",diffRemovedLine:"#B8004933",diffStripAdded:"#3FA2668F",diffStripRemoved:"#FC6B838F"},u={foreground:"#141414F0",foregroundSecondary:"#141414BD",foregroundTertiary:"#1414148A",foregroundQuaternary:"#1414145C",editor:"#FCFCFC",chrome:"#F8F8F8",sidebar:"#F3F3F3",elevated:"#FCFCFC",fillPrimary:"#14141433",fillSecondary:"#14141424",fillTertiary:"#14141414",fillQuaternary:"#1414140F",strokePrimary:"#14141433",strokeSecondary:"#1414141F",strokeTertiary:"#14141414",strokeFocused:"#3685BF",accent:"#3685BF",buttonBackground:"#3685BF",buttonForeground:"#FCFCFC",buttonHoverBackground:"#2E76AB",link:"#3685BF",diffInsertedLine:"#1F8A651F",diffRemovedLine:"#CF2D5614",diffStripAdded:"#1F8A65CC",diffStripRemoved:"#CF2D56CC"},A={accent:"#1084FE",buttonBackground:"#1084FE",buttonForeground:"#070707",buttonHoverBackground:"#459FFE",link:"#80BEFE",strokeFocused:"#1084FE"},b={accent:"#0C64C1",buttonBackground:"#0C64C1",buttonForeground:"#FAFAFA",buttonHoverBackground:"#1084FE",link:"#0C64C1",strokeFocused:"#0C64C1"},h={...g,...A},y={...u,...b},s={gray:"#8888A8E0",purple:"#7B64B8F0",green:"#1F8A65E8",yellow:"#E8C030E0",cyan:"#2A9A8AE0",pink:"#C85898E0",blue:"#2E79B5E0",orange:"#F0A040E0",red:"#C04848E0"},F={gray:"#8888A8E0",purple:"#7B64B8F0",green:"#1F8A65E8",yellow:"#E8C030E0",cyan:"#2A9A8AE0",pink:"#C85898E0",blue:"#2E79B5E0",orange:"#F0A088E0",red:"#CF2D56E0"},m={gray:"#777777E0",purple:"#9159FEF0",green:"#00C972E8",yellow:"#FF9800E0",cyan:"#00BCA6E0",pink:"#FF309BE0",blue:"#1084FEE0",orange:"#FF6700E0",red:"#FF263CE0"},v={...m},P=s,S=["blue","purple","green","yellow","cyan","pink","orange","red","gray"],i={green:"#1F8A65E8",darkGreen:"#0D855AE0",lightGreen:"#52B896E0",mintGreen:"#7DCAB0E0",blue:"#2E79B5E0",lightBlue:"#70B0D8E0",indigo:"#5A6CC0F0",lightIndigo:"#9AAADCE0",purple:"#7B64B8F0",lightPurple:"#AA98D8E0",warmPink:"#C85898E0",lightPink:"#E8A0C4E0",brightOrange:"#F0A040E0",deepOrange:"#C06028E0",goldenYellow:"#E8C030E0",darkAmber:"#C04848E0",warmPeach:"#F0A088E0",vibrantTeal:"#2A9A8AE0",muted:"#8888A8E0",neutralLine:"#888899D0"},a={green:"#00C972E8",darkGreen:"#009957E0",lightGreen:"#38D591E0",mintGreen:"#78E2B4E0",blue:"#1084FEE0",lightBlue:"#459FFEE0",indigo:"#0C64C1F0",lightIndigo:"#80BEFEE0",purple:"#9159FEF0",lightPurple:"#A97EFEE0",warmPink:"#FF309BE0",lightPink:"#FF5EB1E0",brightOrange:"#FF6700E0",deepOrange:"#C24E00E0",goldenYellow:"#FF9800E0",darkAmber:"#FF263CE0",warmPeach:"#FF8838E0",vibrantTeal:"#00BCA6E0",muted:"#777777E0",neutralLine:"#777777D0"},T=[i.green,i.lightBlue,i.indigo,i.brightOrange,i.deepOrange,i.goldenYellow,i.warmPink,i.warmPeach,i.purple,i.mintGreen,i.muted,i.vibrantTeal],L=[a.green,a.lightBlue,a.indigo,a.brightOrange,a.deepOrange,a.goldenYellow,a.warmPink,a.warmPeach,a.purple,a.mintGreen,a.muted,a.vibrantTeal],p={fontFamily:"inherit",h1:{fontSize:"24px",lineHeight:"30px",fontWeight:590},h2:{fontSize:"18px",lineHeight:"24px",fontWeight:590},h3:{fontSize:"16px",lineHeight:"22px",fontWeight:590},body:{fontSize:"14px",lineHeight:"20px",fontWeight:400},small:{fontSize:"12px",lineHeight:"16px",fontWeight:400}},x='ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',D={"0.5":2,1:4,"1.5":6,2:8,"2.5":10,3:12,"3.5":14,4:16,"4.5":18,5:20,6:24,7:28,8:32,9:36,10:40},C={none:0,xs:2,sm:4,md:6,lg:8,xl:12,full:9999},G={...C,md:8,lg:10,xl:14},H={...p,fontFamily:x};function f(e,n){return{bg:{editor:e.editor,chrome:e.chrome,elevated:e.elevated},text:{primary:e.foreground,secondary:e.foregroundSecondary,tertiary:e.foregroundTertiary,quaternary:e.foregroundQuaternary,link:e.link,onAccent:e.buttonForeground},stroke:{primary:e.strokePrimary,secondary:e.strokeSecondary,tertiary:e.strokeTertiary,focused:e.strokeFocused},fill:{primary:e.fillPrimary,secondary:e.fillSecondary,tertiary:e.fillTertiary,quaternary:e.fillQuaternary},accent:{primary:e.accent,control:e.buttonBackground,controlHover:e.buttonHoverBackground},diff:{insertedLine:e.diffInsertedLine,removedLine:e.diffRemovedLine,stripAdded:e.diffStripAdded,stripRemoved:e.diffStripRemoved},category:n}}const I=f(g,s),R=f(u,F);function E(e){const n=e.trim(),o=/^#([0-9a-f]{3,8})$/i.exec(n);if(!o)return;const r=o[1];if(r.length===3||r.length===4){const t=k=>k+k,c=parseInt(t(r[0]),16),d=parseInt(t(r[1]),16),l=parseInt(t(r[2]),16);return{r:c,g:d,b:l}}if(r.length===6||r.length===8){const t=parseInt(r.slice(0,2),16),c=parseInt(r.slice(2,4),16),d=parseInt(r.slice(4,6),16);return{r:t,g:c,b:d}}}function q(e){const n=o=>{const r=o/255;return r<=.03928?r/12.92:((r+.055)/1.055)**2.4};return .2126*n(e.r)+.7152*n(e.g)+.0722*n(e.b)}function M(e,n,o){const r=Math.min(1,Math.max(0,o));return{r:Math.round(e.r*(1-r)+n.r*r),g:Math.round(e.g*(1-r)+n.g*r),b:Math.round(e.b*(1-r)+n.b*r)}}function O(e){const n=o=>o.toString(16).padStart(2,"0");return`#${n(e.r)}${n(e.g)}${n(e.b)}`}function B(e){return e==="grok"?"grok":"cursor"}function Q(e,n){let o=e;if(typeof n.editorBackground=="string"&&E(n.editorBackground)){const r=n.editorBackground;o={...o,editor:r,chrome:r,sidebar:r,elevated:r}}if(typeof n.editorForeground=="string"&&E(n.editorForeground)){const r=n.editorForeground;o={...o,foreground:r,foregroundSecondary:r,foregroundTertiary:r,foregroundQuaternary:r}}return o}function W(e,n){const o=E(n);if(!o)return e;const r=M(o,{r:255,g:255,b:255},.12),t=q(o)>.45?"#141414":"#FAFAFA";return{...e,accent:n,buttonBackground:n,buttonHoverBackground:O(r),link:n,strokeFocused:n,buttonForeground:t}}const z=new Set(["light","hc-light"]);function Y(e){return z.has(e)}function $(e,n){const o=B(n==null?void 0:n.brand),r=Y(e);let t,c;return o==="grok"?(t=r?y:h,c=r?v:m):(t=r?u:g,c=r?F:s),t=Q(t,n??{}),o!=="grok"&&typeof(n==null?void 0:n.primary)=="string"&&(t=W(t,n.primary)),{tokens:f(t,c),palette:t,brand:o}}function _(e){return e==="grok"?{palette:a,sequence:L}:{palette:i,sequence:T}}function K(e){return e==="grok"?G:C}function N(e){return e==="grok"?H:p}function U(){var n;if(typeof window>"u")return;const e=window.__cursorCanvas;return(n=e==null?void 0:e.state)==null?void 0:n.theme}function j(e,n){let o=typeof(e==null?void 0:e.kind)=="string"&&e.kind.length>0?e.kind:void 0;o||(n?o=n:typeof window<"u"&&window.matchMedia?o=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":o="dark");const r={brand:B(e==null?void 0:e.brand),primary:typeof(e==null?void 0:e.primary)=="string"?e.primary:void 0,editorBackground:typeof(e==null?void 0:e.editorBackground)=="string"?e.editorBackground:void 0,editorForeground:typeof(e==null?void 0:e.editorForeground)=="string"?e.editorForeground:void 0},{tokens:t,palette:c,brand:d}=$(o,r),l=_(d);return{...t,kind:o,brand:d,tokens:t,palette:c,category:t.category,radius:K(d),typography:N(d),chart:l,spacing:D}}function w(e){const n=U();return j(n,e)}exports.canvasPaletteDark=g;exports.canvasPaletteGrokDark=h;exports.canvasPaletteGrokLight=y;exports.canvasPaletteLight=u;exports.canvasTokens=I;exports.canvasTokensLight=R;exports.categoryPaletteDark=s;exports.categoryPaletteLight=F;exports.colorPalette=P;exports.resolveThemeForColorScheme=w;exports.usageColorSequence=S;
@@ -0,0 +1,412 @@
1
+ const s = {
2
+ foreground: "#E4E4E4EB",
3
+ foregroundSecondary: "#E4E4E48D",
4
+ foregroundTertiary: "#E4E4E45E",
5
+ foregroundQuaternary: "#E4E4E442",
6
+ editor: "#181818",
7
+ chrome: "#141414",
8
+ sidebar: "#141414",
9
+ elevated: "#181818",
10
+ fillPrimary: "#E4E4E430",
11
+ fillSecondary: "#E4E4E41E",
12
+ fillTertiary: "#E4E4E411",
13
+ fillQuaternary: "#E4E4E40A",
14
+ strokePrimary: "#E4E4E433",
15
+ strokeSecondary: "#E4E4E41F",
16
+ strokeTertiary: "#E4E4E414",
17
+ strokeFocused: "#599CE7",
18
+ accent: "#599CE7",
19
+ buttonBackground: "#599CE7",
20
+ buttonForeground: "#191c22",
21
+ buttonHoverBackground: "#6AABE9",
22
+ link: "#87c3ff",
23
+ diffInsertedLine: "#3FA26633",
24
+ diffRemovedLine: "#B8004933",
25
+ diffStripAdded: "#3FA2668F",
26
+ diffStripRemoved: "#FC6B838F"
27
+ }, l = {
28
+ foreground: "#141414F0",
29
+ foregroundSecondary: "#141414BD",
30
+ foregroundTertiary: "#1414148A",
31
+ foregroundQuaternary: "#1414145C",
32
+ editor: "#FCFCFC",
33
+ chrome: "#F8F8F8",
34
+ sidebar: "#F3F3F3",
35
+ elevated: "#FCFCFC",
36
+ fillPrimary: "#14141433",
37
+ fillSecondary: "#14141424",
38
+ fillTertiary: "#14141414",
39
+ fillQuaternary: "#1414140F",
40
+ strokePrimary: "#14141433",
41
+ strokeSecondary: "#1414141F",
42
+ strokeTertiary: "#14141414",
43
+ strokeFocused: "#3685BF",
44
+ accent: "#3685BF",
45
+ buttonBackground: "#3685BF",
46
+ buttonForeground: "#FCFCFC",
47
+ buttonHoverBackground: "#2E76AB",
48
+ link: "#3685BF",
49
+ diffInsertedLine: "#1F8A651F",
50
+ diffRemovedLine: "#CF2D5614",
51
+ diffStripAdded: "#1F8A65CC",
52
+ diffStripRemoved: "#CF2D56CC"
53
+ }, C = {
54
+ accent: "#1084FE",
55
+ buttonBackground: "#1084FE",
56
+ buttonForeground: "#070707",
57
+ buttonHoverBackground: "#459FFE",
58
+ link: "#80BEFE",
59
+ strokeFocused: "#1084FE"
60
+ }, B = {
61
+ accent: "#0C64C1",
62
+ buttonBackground: "#0C64C1",
63
+ buttonForeground: "#FAFAFA",
64
+ buttonHoverBackground: "#1084FE",
65
+ link: "#0C64C1",
66
+ strokeFocused: "#0C64C1"
67
+ }, A = {
68
+ ...s,
69
+ ...C
70
+ }, b = {
71
+ ...l,
72
+ ...B
73
+ }, E = {
74
+ gray: "#8888A8E0",
75
+ purple: "#7B64B8F0",
76
+ green: "#1F8A65E8",
77
+ yellow: "#E8C030E0",
78
+ cyan: "#2A9A8AE0",
79
+ pink: "#C85898E0",
80
+ blue: "#2E79B5E0",
81
+ orange: "#F0A040E0",
82
+ red: "#C04848E0"
83
+ }, k = {
84
+ gray: "#8888A8E0",
85
+ purple: "#7B64B8F0",
86
+ green: "#1F8A65E8",
87
+ yellow: "#E8C030E0",
88
+ cyan: "#2A9A8AE0",
89
+ pink: "#C85898E0",
90
+ blue: "#2E79B5E0",
91
+ orange: "#F0A088E0",
92
+ red: "#CF2D56E0"
93
+ }, y = {
94
+ gray: "#777777E0",
95
+ purple: "#9159FEF0",
96
+ green: "#00C972E8",
97
+ yellow: "#FF9800E0",
98
+ cyan: "#00BCA6E0",
99
+ pink: "#FF309BE0",
100
+ blue: "#1084FEE0",
101
+ orange: "#FF6700E0",
102
+ red: "#FF263CE0"
103
+ }, v = {
104
+ ...y
105
+ }, K = E, N = [
106
+ "blue",
107
+ "purple",
108
+ "green",
109
+ "yellow",
110
+ "cyan",
111
+ "pink",
112
+ "orange",
113
+ "red",
114
+ "gray"
115
+ ], i = {
116
+ green: "#1F8A65E8",
117
+ darkGreen: "#0D855AE0",
118
+ lightGreen: "#52B896E0",
119
+ mintGreen: "#7DCAB0E0",
120
+ blue: "#2E79B5E0",
121
+ lightBlue: "#70B0D8E0",
122
+ indigo: "#5A6CC0F0",
123
+ lightIndigo: "#9AAADCE0",
124
+ purple: "#7B64B8F0",
125
+ lightPurple: "#AA98D8E0",
126
+ warmPink: "#C85898E0",
127
+ lightPink: "#E8A0C4E0",
128
+ brightOrange: "#F0A040E0",
129
+ deepOrange: "#C06028E0",
130
+ goldenYellow: "#E8C030E0",
131
+ darkAmber: "#C04848E0",
132
+ warmPeach: "#F0A088E0",
133
+ vibrantTeal: "#2A9A8AE0",
134
+ muted: "#8888A8E0",
135
+ neutralLine: "#888899D0"
136
+ }, a = {
137
+ green: "#00C972E8",
138
+ darkGreen: "#009957E0",
139
+ lightGreen: "#38D591E0",
140
+ mintGreen: "#78E2B4E0",
141
+ blue: "#1084FEE0",
142
+ lightBlue: "#459FFEE0",
143
+ indigo: "#0C64C1F0",
144
+ lightIndigo: "#80BEFEE0",
145
+ purple: "#9159FEF0",
146
+ lightPurple: "#A97EFEE0",
147
+ warmPink: "#FF309BE0",
148
+ lightPink: "#FF5EB1E0",
149
+ brightOrange: "#FF6700E0",
150
+ deepOrange: "#C24E00E0",
151
+ goldenYellow: "#FF9800E0",
152
+ darkAmber: "#FF263CE0",
153
+ warmPeach: "#FF8838E0",
154
+ vibrantTeal: "#00BCA6E0",
155
+ muted: "#777777E0",
156
+ neutralLine: "#777777D0"
157
+ }, S = [
158
+ i.green,
159
+ i.lightBlue,
160
+ i.indigo,
161
+ i.brightOrange,
162
+ i.deepOrange,
163
+ i.goldenYellow,
164
+ i.warmPink,
165
+ i.warmPeach,
166
+ i.purple,
167
+ i.mintGreen,
168
+ i.muted,
169
+ i.vibrantTeal
170
+ ], P = [
171
+ a.green,
172
+ a.lightBlue,
173
+ a.indigo,
174
+ a.brightOrange,
175
+ a.deepOrange,
176
+ a.goldenYellow,
177
+ a.warmPink,
178
+ a.warmPeach,
179
+ a.purple,
180
+ a.mintGreen,
181
+ a.muted,
182
+ a.vibrantTeal
183
+ ], h = {
184
+ fontFamily: "inherit",
185
+ h1: { fontSize: "24px", lineHeight: "30px", fontWeight: 590 },
186
+ h2: { fontSize: "18px", lineHeight: "24px", fontWeight: 590 },
187
+ h3: { fontSize: "16px", lineHeight: "22px", fontWeight: 590 },
188
+ body: { fontSize: "14px", lineHeight: "20px", fontWeight: 400 },
189
+ small: { fontSize: "12px", lineHeight: "16px", fontWeight: 400 }
190
+ }, T = 'ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif', x = {
191
+ "0.5": 2,
192
+ 1: 4,
193
+ "1.5": 6,
194
+ 2: 8,
195
+ "2.5": 10,
196
+ 3: 12,
197
+ "3.5": 14,
198
+ 4: 16,
199
+ "4.5": 18,
200
+ 5: 20,
201
+ 6: 24,
202
+ 7: 28,
203
+ 8: 32,
204
+ 9: 36,
205
+ 10: 40
206
+ }, m = {
207
+ none: 0,
208
+ xs: 2,
209
+ sm: 4,
210
+ md: 6,
211
+ lg: 8,
212
+ xl: 12,
213
+ full: 9999
214
+ }, D = {
215
+ ...m,
216
+ md: 8,
217
+ lg: 10,
218
+ xl: 14
219
+ }, L = {
220
+ ...h,
221
+ fontFamily: T
222
+ };
223
+ function F(e, n) {
224
+ return {
225
+ bg: {
226
+ editor: e.editor,
227
+ chrome: e.chrome,
228
+ elevated: e.elevated
229
+ },
230
+ text: {
231
+ primary: e.foreground,
232
+ secondary: e.foregroundSecondary,
233
+ tertiary: e.foregroundTertiary,
234
+ quaternary: e.foregroundQuaternary,
235
+ link: e.link,
236
+ onAccent: e.buttonForeground
237
+ },
238
+ stroke: {
239
+ primary: e.strokePrimary,
240
+ secondary: e.strokeSecondary,
241
+ tertiary: e.strokeTertiary,
242
+ focused: e.strokeFocused
243
+ },
244
+ fill: {
245
+ primary: e.fillPrimary,
246
+ secondary: e.fillSecondary,
247
+ tertiary: e.fillTertiary,
248
+ quaternary: e.fillQuaternary
249
+ },
250
+ accent: {
251
+ primary: e.accent,
252
+ control: e.buttonBackground,
253
+ controlHover: e.buttonHoverBackground
254
+ },
255
+ diff: {
256
+ insertedLine: e.diffInsertedLine,
257
+ removedLine: e.diffRemovedLine,
258
+ stripAdded: e.diffStripAdded,
259
+ stripRemoved: e.diffStripRemoved
260
+ },
261
+ category: n
262
+ };
263
+ }
264
+ const U = F(
265
+ s,
266
+ E
267
+ ), j = F(
268
+ l,
269
+ k
270
+ );
271
+ function u(e) {
272
+ const n = e.trim(), o = /^#([0-9a-f]{3,8})$/i.exec(n);
273
+ if (!o)
274
+ return;
275
+ const r = o[1];
276
+ if (r.length === 3 || r.length === 4) {
277
+ const t = (f) => f + f, c = parseInt(t(r[0]), 16), d = parseInt(t(r[1]), 16), g = parseInt(t(r[2]), 16);
278
+ return { r: c, g: d, b: g };
279
+ }
280
+ if (r.length === 6 || r.length === 8) {
281
+ const t = parseInt(r.slice(0, 2), 16), c = parseInt(r.slice(2, 4), 16), d = parseInt(r.slice(4, 6), 16);
282
+ return { r: t, g: c, b: d };
283
+ }
284
+ }
285
+ function G(e) {
286
+ const n = (o) => {
287
+ const r = o / 255;
288
+ return r <= 0.03928 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
289
+ };
290
+ return 0.2126 * n(e.r) + 0.7152 * n(e.g) + 0.0722 * n(e.b);
291
+ }
292
+ function H(e, n, o) {
293
+ const r = Math.min(1, Math.max(0, o));
294
+ return {
295
+ r: Math.round(e.r * (1 - r) + n.r * r),
296
+ g: Math.round(e.g * (1 - r) + n.g * r),
297
+ b: Math.round(e.b * (1 - r) + n.b * r)
298
+ };
299
+ }
300
+ function I(e) {
301
+ const n = (o) => o.toString(16).padStart(2, "0");
302
+ return `#${n(e.r)}${n(e.g)}${n(e.b)}`;
303
+ }
304
+ function p(e) {
305
+ return e === "grok" ? "grok" : "cursor";
306
+ }
307
+ function R(e, n) {
308
+ let o = e;
309
+ if (typeof n.editorBackground == "string" && u(n.editorBackground)) {
310
+ const r = n.editorBackground;
311
+ o = {
312
+ ...o,
313
+ editor: r,
314
+ chrome: r,
315
+ sidebar: r,
316
+ elevated: r
317
+ };
318
+ }
319
+ if (typeof n.editorForeground == "string" && u(n.editorForeground)) {
320
+ const r = n.editorForeground;
321
+ o = {
322
+ ...o,
323
+ foreground: r,
324
+ foregroundSecondary: r,
325
+ foregroundTertiary: r,
326
+ foregroundQuaternary: r
327
+ };
328
+ }
329
+ return o;
330
+ }
331
+ function M(e, n) {
332
+ const o = u(n);
333
+ if (!o)
334
+ return e;
335
+ const r = H(o, { r: 255, g: 255, b: 255 }, 0.12), t = G(o) > 0.45 ? "#141414" : "#FAFAFA";
336
+ return {
337
+ ...e,
338
+ accent: n,
339
+ buttonBackground: n,
340
+ buttonHoverBackground: I(r),
341
+ link: n,
342
+ strokeFocused: n,
343
+ buttonForeground: t
344
+ };
345
+ }
346
+ const O = /* @__PURE__ */ new Set(["light", "hc-light"]);
347
+ function q(e) {
348
+ return O.has(e);
349
+ }
350
+ function Q(e, n) {
351
+ const o = p(n == null ? void 0 : n.brand), r = q(e);
352
+ let t, c;
353
+ return o === "grok" ? (t = r ? b : A, c = r ? v : y) : (t = r ? l : s, c = r ? k : E), t = R(t, n ?? {}), o !== "grok" && typeof (n == null ? void 0 : n.primary) == "string" && (t = M(t, n.primary)), { tokens: F(t, c), palette: t, brand: o };
354
+ }
355
+ function W(e) {
356
+ return e === "grok" ? {
357
+ palette: a,
358
+ sequence: P
359
+ } : { palette: i, sequence: S };
360
+ }
361
+ function z(e) {
362
+ return e === "grok" ? D : m;
363
+ }
364
+ function Y(e) {
365
+ return e === "grok" ? L : h;
366
+ }
367
+ function $() {
368
+ var n;
369
+ if (typeof window > "u")
370
+ return;
371
+ const e = window.__cursorCanvas;
372
+ return (n = e == null ? void 0 : e.state) == null ? void 0 : n.theme;
373
+ }
374
+ function _(e, n) {
375
+ let o = typeof (e == null ? void 0 : e.kind) == "string" && e.kind.length > 0 ? e.kind : void 0;
376
+ o || (n ? o = n : typeof window < "u" && window.matchMedia ? o = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : o = "dark");
377
+ const r = {
378
+ brand: p(e == null ? void 0 : e.brand),
379
+ primary: typeof (e == null ? void 0 : e.primary) == "string" ? e.primary : void 0,
380
+ editorBackground: typeof (e == null ? void 0 : e.editorBackground) == "string" ? e.editorBackground : void 0,
381
+ editorForeground: typeof (e == null ? void 0 : e.editorForeground) == "string" ? e.editorForeground : void 0
382
+ }, { tokens: t, palette: c, brand: d } = Q(o, r), g = W(d);
383
+ return {
384
+ ...t,
385
+ kind: o,
386
+ brand: d,
387
+ tokens: t,
388
+ palette: c,
389
+ category: t.category,
390
+ radius: z(d),
391
+ typography: Y(d),
392
+ chart: g,
393
+ spacing: x
394
+ };
395
+ }
396
+ function w(e) {
397
+ const n = $();
398
+ return _(n, e);
399
+ }
400
+ export {
401
+ A as a,
402
+ b,
403
+ s as c,
404
+ l as d,
405
+ U as e,
406
+ j as f,
407
+ E as g,
408
+ k as h,
409
+ K as i,
410
+ w as r,
411
+ N as u
412
+ };
@@ -1,16 +1,14 @@
1
+ import { MantineColorScheme } from '@mantine/core';
1
2
  import { ReactNode } from 'react';
2
3
  import { Root } from 'react-dom/client';
3
- import { MantineColorScheme } from '@mantine/core';
4
+ import { CanvasMantineRoot } from '../shim/canvas-mantine-root';
4
5
  export interface CanvasRootProps {
5
6
  children: ReactNode;
6
7
  /** Initial color scheme; defaults to following the OS preference. */
7
8
  defaultColorScheme?: MantineColorScheme;
8
9
  }
9
- /**
10
- * Wraps a canvas in the `MantineProvider` the shim components require. Use this
11
- * when you manage your own React root (e.g. inside an existing app tree).
12
- */
13
- export declare function CanvasRoot({ children, defaultColorScheme, }: CanvasRootProps): import("react").JSX.Element;
10
+ /** @deprecated Use `CanvasMantineRoot` — same behavior. */
11
+ export declare const CanvasRoot: typeof CanvasMantineRoot;
14
12
  export interface MountCanvasOptions {
15
13
  defaultColorScheme?: MantineColorScheme;
16
14
  /** Skip `StrictMode` (e.g. for libraries that double-render badly). */
@@ -18,7 +16,7 @@ export interface MountCanvasOptions {
18
16
  }
19
17
  /**
20
18
  * One-call entry for a standalone page: resolves the container (element or id),
21
- * mounts the canvas inside `CanvasRoot`, and returns the React root so callers
19
+ * mounts the canvas inside `CanvasMantineRoot`, and returns the React root so callers
22
20
  * can `unmount()` later.
23
21
  */
24
22
  export declare function mountCanvas(container: HTMLElement | string, canvas: ReactNode, options?: MountCanvasOptions): Root;
package/dist/runtime.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),d=require("react"),l=require("react-dom/client"),m=require("@mantine/core");function u({children:t,defaultColorScheme:e="auto"}){return o.jsx(m.MantineProvider,{defaultColorScheme:e,children:t})}function f(t,e,c={}){const{defaultColorScheme:i="auto",strict:a=!0}=c,r=typeof t=="string"?document.getElementById(t):t;if(!r)throw new Error(`mountCanvas: container ${typeof t=="string"?`#${t}`:""} not found`);const n=l.createRoot(r),s=o.jsx(u,{defaultColorScheme:i,children:e});return n.render(a?o.jsx(d.StrictMode,{children:s}):s),n}exports.CanvasRoot=u;exports.mountCanvas=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),r=require("react"),g=require("react-dom/client"),l=require("@mantine/core"),u=require("./host-tokens-Cjzmp0z_.cjs");function f(t){return[t,t,t,t,t,t,t,t,t,t]}function d(t){const{typography:e,radius:n}=t;return l.createTheme({primaryColor:"accent",colors:{accent:f(t.palette.accent)},fontFamily:e.fontFamily,defaultRadius:`${n.md}`,radius:{xs:`${n.xs}px`,sm:`${n.sm}px`,md:`${n.md}px`,lg:`${n.lg}px`,xl:`${n.xl}px`},headings:{fontFamily:e.fontFamily,fontWeight:String(e.h1.fontWeight),sizes:{h1:{fontSize:e.h1.fontSize,lineHeight:e.h1.lineHeight,fontWeight:String(e.h1.fontWeight)},h2:{fontSize:e.h2.fontSize,lineHeight:e.h2.lineHeight,fontWeight:String(e.h2.fontWeight)},h3:{fontSize:e.h3.fontSize,lineHeight:e.h3.lineHeight,fontWeight:String(e.h3.fontWeight)},h4:{fontSize:e.body.fontSize,lineHeight:e.body.lineHeight,fontWeight:String(e.body.fontWeight)}}}})}function y(t){const e=window.matchMedia("(prefers-color-scheme: dark)");return e.addEventListener("change",t),()=>e.removeEventListener("change",t)}function S(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function p(t){const e=r.useSyncExternalStore(y,S,()=>"light");return t==="dark"?"dark":t==="light"?"light":e}function m({children:t,defaultColorScheme:e="auto"}){const n=p(e),o=r.useMemo(()=>u.resolveThemeForColorScheme(n),[n]),s=r.useMemo(()=>d(o),[o]);return i.jsx(l.MantineProvider,{theme:s,defaultColorScheme:e,forceColorScheme:n,children:i.jsx("div",{style:{minHeight:"inherit",background:o.bg.editor,color:o.text.primary,fontFamily:o.typography.fontFamily},children:t})})}const v=m;function H(t,e,n={}){const{defaultColorScheme:o="auto",strict:s=!0}=n,c=typeof t=="string"?document.getElementById(t):t;if(!c)throw new Error(`mountCanvas: container ${typeof t=="string"?`#${t}`:""} not found`);const a=g.createRoot(c),h=i.jsx(m,{defaultColorScheme:o,children:e});return a.render(s?i.jsx(r.StrictMode,{children:h}):h),a}exports.CanvasRoot=v;exports.mountCanvas=H;
package/dist/runtime.js CHANGED
@@ -1,23 +1,110 @@
1
- import { jsx as r } from "react/jsx-runtime";
2
- import { StrictMode as s } from "react";
3
- import { createRoot as c } from "react-dom/client";
4
- import { MantineProvider as d } from "@mantine/core";
5
- function a({
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { useMemo as m, useSyncExternalStore as f, StrictMode as l } from "react";
3
+ import { createRoot as g } from "react-dom/client";
4
+ import { MantineProvider as d, createTheme as u } from "@mantine/core";
5
+ import { r as y } from "./host-tokens-Dh2BFFjv.js";
6
+ function p(t) {
7
+ return [t, t, t, t, t, t, t, t, t, t];
8
+ }
9
+ function S(t) {
10
+ const { typography: e, radius: n } = t;
11
+ return u({
12
+ primaryColor: "accent",
13
+ colors: {
14
+ accent: p(t.palette.accent)
15
+ },
16
+ fontFamily: e.fontFamily,
17
+ defaultRadius: `${n.md}`,
18
+ radius: {
19
+ xs: `${n.xs}px`,
20
+ sm: `${n.sm}px`,
21
+ md: `${n.md}px`,
22
+ lg: `${n.lg}px`,
23
+ xl: `${n.xl}px`
24
+ },
25
+ headings: {
26
+ fontFamily: e.fontFamily,
27
+ fontWeight: String(e.h1.fontWeight),
28
+ sizes: {
29
+ h1: {
30
+ fontSize: e.h1.fontSize,
31
+ lineHeight: e.h1.lineHeight,
32
+ fontWeight: String(e.h1.fontWeight)
33
+ },
34
+ h2: {
35
+ fontSize: e.h2.fontSize,
36
+ lineHeight: e.h2.lineHeight,
37
+ fontWeight: String(e.h2.fontWeight)
38
+ },
39
+ h3: {
40
+ fontSize: e.h3.fontSize,
41
+ lineHeight: e.h3.lineHeight,
42
+ fontWeight: String(e.h3.fontWeight)
43
+ },
44
+ h4: {
45
+ fontSize: e.body.fontSize,
46
+ lineHeight: e.body.lineHeight,
47
+ fontWeight: String(e.body.fontWeight)
48
+ }
49
+ }
50
+ }
51
+ });
52
+ }
53
+ function v(t) {
54
+ const e = window.matchMedia("(prefers-color-scheme: dark)");
55
+ return e.addEventListener("change", t), () => e.removeEventListener("change", t);
56
+ }
57
+ function H() {
58
+ return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
59
+ }
60
+ function W(t) {
61
+ const e = f(
62
+ v,
63
+ H,
64
+ () => "light"
65
+ );
66
+ return t === "dark" ? "dark" : t === "light" ? "light" : e;
67
+ }
68
+ function c({
6
69
  children: t,
7
- defaultColorScheme: o = "auto"
70
+ defaultColorScheme: e = "auto"
8
71
  }) {
9
- return /* @__PURE__ */ r(d, { defaultColorScheme: o, children: t });
72
+ const n = W(e), o = m(
73
+ () => y(n),
74
+ [n]
75
+ ), r = m(() => S(o), [o]);
76
+ return /* @__PURE__ */ i(
77
+ d,
78
+ {
79
+ theme: r,
80
+ defaultColorScheme: e,
81
+ forceColorScheme: n,
82
+ children: /* @__PURE__ */ i(
83
+ "div",
84
+ {
85
+ style: {
86
+ minHeight: "inherit",
87
+ background: o.bg.editor,
88
+ color: o.text.primary,
89
+ fontFamily: o.typography.fontFamily
90
+ },
91
+ children: t
92
+ }
93
+ )
94
+ }
95
+ );
10
96
  }
11
- function C(t, o, i = {}) {
12
- const { defaultColorScheme: u = "auto", strict: f = !0 } = i, e = typeof t == "string" ? document.getElementById(t) : t;
13
- if (!e)
97
+ const k = c;
98
+ function w(t, e, n = {}) {
99
+ const { defaultColorScheme: o = "auto", strict: r = !0 } = n, s = typeof t == "string" ? document.getElementById(t) : t;
100
+ if (!s)
14
101
  throw new Error(
15
102
  `mountCanvas: container ${typeof t == "string" ? `#${t}` : ""} not found`
16
103
  );
17
- const n = c(e), m = /* @__PURE__ */ r(a, { defaultColorScheme: u, children: o });
18
- return n.render(f ? /* @__PURE__ */ r(s, { children: m }) : m), n;
104
+ const a = g(s), h = /* @__PURE__ */ i(c, { defaultColorScheme: o, children: e });
105
+ return a.render(r ? /* @__PURE__ */ i(l, { children: h }) : h), a;
19
106
  }
20
107
  export {
21
- a as CanvasRoot,
22
- C as mountCanvas
108
+ k as CanvasRoot,
109
+ w as mountCanvas
23
110
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@flesler/cursor-canvas-web",
3
3
  "private": false,
4
- "version": "1.0.2",
4
+ "version": "1.1.0",
5
5
  "repository": "github:flesler/cursor-canvas-web",
6
6
  "type": "module",
7
7
  "description": "Deploy your Cursor canvases to the web.",
@@ -19,17 +19,21 @@
19
19
  },
20
20
  "sideEffects": false,
21
21
  "files": [
22
- "dist"
22
+ "dist",
23
+ "src/vendor"
23
24
  ],
24
25
  "main": "./dist/cursor-canvas.cjs",
25
26
  "module": "./dist/cursor-canvas.js",
26
- "types": "./dist/shim/cursor-canvas.d.ts",
27
+ "types": "./src/vendor/canvas-sdk/index.d.ts",
27
28
  "exports": {
28
29
  ".": {
29
- "types": "./dist/shim/cursor-canvas.d.ts",
30
+ "types": "./src/vendor/canvas-sdk/index.d.ts",
30
31
  "import": "./dist/cursor-canvas.js",
31
32
  "require": "./dist/cursor-canvas.cjs"
32
33
  },
34
+ "./canvas-sdk": {
35
+ "types": "./src/vendor/canvas-sdk/index.d.ts"
36
+ },
33
37
  "./runtime": {
34
38
  "types": "./dist/runtime/index.d.ts",
35
39
  "import": "./dist/runtime.js",
@@ -48,16 +52,19 @@
48
52
  "test": "vitest run",
49
53
  "test:watch": "vitest",
50
54
  "sync:sdk": "bash scripts/sync-cursor-sdk-snapshot.sh",
51
- "check:sdk-exports": "node scripts/diff-sdk-exports.mjs",
52
- "test:contract": "pnpm run build:lib && pnpm run check:sdk-exports",
53
- "check:sdk-live": "node scripts/diff-sdk-exports.mjs \"${HOME}/.cursor/skills-cursor/canvas/sdk/index.d.ts\"",
54
- "test:contract:strict": "pnpm run build:lib && node scripts/generate-contract-consumer.mjs && pnpm exec tsc -p test/contract/tsconfig.json",
55
+ "check:sdk-exports": "tsx scripts/diff-sdk-exports.ts --strict",
56
+ "test:contract": "pnpm run check:sdk-exports && tsx scripts/generate-contract-consumer.ts && tsc --noEmit && pnpm run build:lib",
57
+ "check:sdk-live": "tsx scripts/diff-sdk-exports.ts --strict \"${HOME}/.cursor/skills-cursor/canvas/sdk/index.d.ts\"",
58
+ "test:contract:strict": "pnpm run test:contract",
55
59
  "test:contract:ci": "pnpm run test:contract",
56
60
  "sync:demo": "bash scripts/sync-demo-canvas.sh",
57
61
  "demo:screenshot": "bash scripts/readme-screenshot.sh",
62
+ "test:demo-screenshots": "bash scripts/test-demo-screenshots.sh",
63
+ "test:demo-screenshots:update": "bash scripts/test-demo-screenshots.sh --update",
64
+ "test:render-compat": "bash scripts/test-render-compat.sh",
58
65
  "ci:local": "pnpm typecheck && pnpm lint && pnpm test && pnpm test:contract:ci",
59
66
  "prepare": "[ \"$CI\" != \"true\" ] && [ -d node_modules/husky ] && husky || true",
60
- "prepublishOnly": "pnpm typecheck && pnpm test && pnpm build:lib"
67
+ "prepublishOnly": "pnpm typecheck && pnpm test && pnpm run check:sdk-exports && pnpm build:lib"
61
68
  },
62
69
  "peerDependencies": {
63
70
  "@mantine/charts": "^8.3.0",
@@ -71,9 +78,6 @@
71
78
  "@mantine/charts": "^8.3.18",
72
79
  "@mantine/core": "^8.3.18",
73
80
  "@mantine/hooks": "^8.3.18",
74
- "react": "^18.3.1",
75
- "react-dom": "^18.3.1",
76
- "recharts": "^3.10.1",
77
81
  "@testing-library/jest-dom": "^6.6.3",
78
82
  "@testing-library/react": "^16.2.0",
79
83
  "@types/node": "^22.13.1",
@@ -87,10 +91,14 @@
87
91
  "husky": "^9.1.7",
88
92
  "jsdom": "^26.0.0",
89
93
  "prettier": "^3.5.1",
94
+ "react": "^18.3.1",
95
+ "react-dom": "^18.3.1",
96
+ "recharts": "^3.10.1",
97
+ "tsx": "^4.21.0",
90
98
  "typescript": "^5.7.3",
91
99
  "typescript-eslint": "^8.24.0",
92
100
  "vite": "^6.1.0",
93
101
  "vite-plugin-dts": "^5.0.2",
94
- "vitest": "^3.0.5"
102
+ "vitest": "^4.1.11"
95
103
  }
96
104
  }