@flesler/cursor-canvas-web 0.0.0-stage → 1.0.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.
@@ -0,0 +1,24 @@
1
+ import { ReactNode } from 'react';
2
+ import { Root } from 'react-dom/client';
3
+ import { MantineColorScheme } from '@mantine/core';
4
+ export interface CanvasRootProps {
5
+ children: ReactNode;
6
+ /** Initial color scheme; defaults to following the OS preference. */
7
+ defaultColorScheme?: MantineColorScheme;
8
+ }
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;
14
+ export interface MountCanvasOptions {
15
+ defaultColorScheme?: MantineColorScheme;
16
+ /** Skip `StrictMode` (e.g. for libraries that double-render badly). */
17
+ strict?: boolean;
18
+ }
19
+ /**
20
+ * 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
22
+ * can `unmount()` later.
23
+ */
24
+ export declare function mountCanvas(container: HTMLElement | string, canvas: ReactNode, options?: MountCanvasOptions): Root;
@@ -0,0 +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;
@@ -0,0 +1,23 @@
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({
6
+ children: t,
7
+ defaultColorScheme: o = "auto"
8
+ }) {
9
+ return /* @__PURE__ */ r(d, { defaultColorScheme: o, children: t });
10
+ }
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)
14
+ throw new Error(
15
+ `mountCanvas: container ${typeof t == "string" ? `#${t}` : ""} not found`
16
+ );
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;
19
+ }
20
+ export {
21
+ a as CanvasRoot,
22
+ C as mountCanvas
23
+ };
@@ -0,0 +1,62 @@
1
+ import { CSSProperties } from 'react';
2
+ export type ChartTone = 'success' | 'danger' | 'warning' | 'info' | 'neutral';
3
+ export type ChartDataPoint = {
4
+ label: string;
5
+ value: number;
6
+ };
7
+ export type ChartSeries = {
8
+ name: string;
9
+ data: number[];
10
+ tone?: ChartTone;
11
+ };
12
+ export type ChartReferenceLine = {
13
+ value: number;
14
+ label?: string;
15
+ tone?: ChartTone;
16
+ };
17
+ type ValueAxisProps = {
18
+ beginAtZero?: boolean;
19
+ yMin?: number;
20
+ yMax?: number;
21
+ referenceLines?: ChartReferenceLine[];
22
+ };
23
+ export type BarChartProps = ValueAxisProps & {
24
+ categories: string[];
25
+ series: ChartSeries[];
26
+ height?: number;
27
+ stacked?: boolean;
28
+ horizontal?: boolean;
29
+ normalized?: boolean;
30
+ valueSuffix?: string;
31
+ valuePrefix?: string;
32
+ showValues?: boolean;
33
+ style?: CSSProperties;
34
+ };
35
+ export type LineChartProps = ValueAxisProps & {
36
+ categories: string[];
37
+ series: ChartSeries[];
38
+ height?: number;
39
+ fill?: boolean;
40
+ valueSuffix?: string;
41
+ valuePrefix?: string;
42
+ showValues?: boolean;
43
+ showHoverGuide?: boolean;
44
+ style?: CSSProperties;
45
+ };
46
+ export type PieChartProps = {
47
+ data: Array<ChartDataPoint & {
48
+ tone?: ChartTone;
49
+ }>;
50
+ size?: number;
51
+ donut?: boolean;
52
+ style?: CSSProperties;
53
+ };
54
+ /**
55
+ * Fork-only export (not in IDE `index.d.ts`); keeps chart data shaping stable for
56
+ * Mantine — listed under “fork-only” in `pnpm run check:sdk-exports`.
57
+ */
58
+ export declare function reshapeLineChartData(categories: string[], series: ChartSeries[]): Record<string, string | number>[];
59
+ export declare function LineChart({ categories, series, height, fill, valueSuffix, valuePrefix, showValues, showHoverGuide, beginAtZero, yMin, yMax, referenceLines, style, }: LineChartProps): import("react").JSX.Element;
60
+ export declare function BarChart({ categories, series, height, stacked, horizontal, normalized, valueSuffix, valuePrefix, showValues, beginAtZero, yMin, yMax, referenceLines, style, }: BarChartProps): import("react").JSX.Element;
61
+ export declare function PieChart({ data, size, donut, style }: PieChartProps): import("react").JSX.Element;
62
+ export {};
@@ -0,0 +1,278 @@
1
+ import { CSSProperties, ReactNode } from 'react';
2
+ import { Color } from './theme';
3
+ export { useEffect, useMemo, useRef, useState } from 'react';
4
+ export type { CSSProperties, RefObject } from 'react';
5
+ export { BarChart, LineChart, PieChart, reshapeLineChartData } from './charts';
6
+ export type { BarChartProps, ChartDataPoint, ChartReferenceLine, ChartSeries, ChartTone, LineChartProps, PieChartProps } from './charts';
7
+ export { computeDAGLayout } from './dag';
8
+ export type { DAGLayoutEdge, DAGLayoutNode, DAGLayoutOptions, DAGLayoutRank, DAGLayoutResult } from './dag';
9
+ export { DiffStats, DiffView } from './diff';
10
+ export type { DiffLineData, DiffLineType, DiffStatsProps, DiffViewProps } from './diff';
11
+ export { canvasPaletteDark, canvasPaletteLight, canvasTokens, canvasTokensLight, categoryPaletteDark, categoryPaletteLight, colorPalette, usageColorSequence } from './theme';
12
+ export type { CanvasHostTheme, CanvasPalette, CanvasTokens, CategoryPalette, Color } from './theme';
13
+ export { TodoList, TodoListCard } from './todo';
14
+ export type { TodoItem, TodoListCardProps, TodoListProps, TodoStatus } from './todo';
15
+ export { useHostTheme } from './use-tokens';
16
+ export type SetCanvasState<T> = (action: T | ((prev: T) => T)) => void;
17
+ /**
18
+ * Persistent state hook. The real SDK stores values in a `.canvas.data.json`
19
+ * sidecar; on the web we persist to `localStorage` under `canvas:<key>`.
20
+ */
21
+ export declare function useCanvasState<T>(key: string, defaultValue: T): [T, SetCanvasState<T>];
22
+ export type CanvasAction = {
23
+ type: 'openAgent';
24
+ agentId: string;
25
+ } | {
26
+ type: 'newComposerChat';
27
+ userPrompt?: string;
28
+ } | {
29
+ type: 'openFile';
30
+ path: string;
31
+ selection?: {
32
+ startLineNumber: number;
33
+ startColumn: number;
34
+ endLineNumber?: number;
35
+ endColumn?: number;
36
+ };
37
+ };
38
+ /**
39
+ * IDE actions are not available on the web host, so the returned dispatch is a
40
+ * no-op (it logs in dev). Exists for API parity with the real SDK.
41
+ */
42
+ export declare function useCanvasAction(): (action: CanvasAction) => void;
43
+ /** Shallow-merge two style objects, `override` winning. */
44
+ export declare function mergeStyle(base: CSSProperties, override?: CSSProperties): CSSProperties;
45
+ export interface H1Props {
46
+ children?: ReactNode;
47
+ style?: CSSProperties;
48
+ }
49
+ export declare function H1({ children, style }: H1Props): import("react").JSX.Element;
50
+ export interface H2Props {
51
+ children?: ReactNode;
52
+ style?: CSSProperties;
53
+ }
54
+ export declare function H2({ children, style }: H2Props): import("react").JSX.Element;
55
+ export interface H3Props {
56
+ children?: ReactNode;
57
+ style?: CSSProperties;
58
+ }
59
+ export declare function H3({ children, style }: H3Props): import("react").JSX.Element;
60
+ export type TextWeight = 'normal' | 'medium' | 'semibold' | 'bold';
61
+ export type TextTone = 'primary' | 'secondary' | 'tertiary' | 'quaternary';
62
+ export interface TextProps {
63
+ children?: ReactNode;
64
+ tone?: TextTone;
65
+ size?: 'body' | 'small';
66
+ as?: 'p' | 'span';
67
+ weight?: TextWeight;
68
+ italic?: boolean;
69
+ truncate?: boolean | 'start' | 'end';
70
+ style?: CSSProperties;
71
+ }
72
+ export declare function Text({ children, tone, size, as, weight, italic, truncate, style, }: TextProps): import("react").JSX.Element;
73
+ export interface CodeProps {
74
+ children?: ReactNode;
75
+ style?: CSSProperties;
76
+ }
77
+ export declare function Code({ children, style }: CodeProps): import("react").JSX.Element;
78
+ export interface LinkProps {
79
+ children?: ReactNode;
80
+ href: string;
81
+ style?: CSSProperties;
82
+ }
83
+ export declare function Link({ children, href, style }: LinkProps): import("react").JSX.Element;
84
+ export interface StackProps {
85
+ children?: ReactNode;
86
+ gap?: number;
87
+ style?: CSSProperties;
88
+ }
89
+ export declare function Stack({ children, gap, style }: StackProps): import("react").JSX.Element;
90
+ export interface RowProps {
91
+ children?: ReactNode;
92
+ gap?: number;
93
+ align?: 'start' | 'center' | 'end' | 'stretch';
94
+ justify?: 'start' | 'center' | 'end' | 'space-between';
95
+ wrap?: boolean;
96
+ style?: CSSProperties;
97
+ }
98
+ export declare function Row({ children, gap, align, justify, wrap, style, }: RowProps): import("react").JSX.Element;
99
+ /** Flexible filler that pushes siblings apart inside a `Row`. */
100
+ export declare function Spacer(): import("react").JSX.Element;
101
+ export interface GridProps {
102
+ children?: ReactNode;
103
+ columns: number | string;
104
+ gap?: number;
105
+ align?: 'start' | 'center' | 'end' | 'stretch';
106
+ style?: CSSProperties;
107
+ }
108
+ export declare function Grid({ children, columns, gap, align, style }: GridProps): import("react").JSX.Element;
109
+ export interface DividerProps {
110
+ style?: CSSProperties;
111
+ }
112
+ export declare function Divider({ style }: DividerProps): import("react").JSX.Element;
113
+ export type CardVariant = 'default' | 'borderless';
114
+ export type CardSize = 'base' | 'lg';
115
+ export interface CardProps {
116
+ children?: ReactNode;
117
+ variant?: CardVariant;
118
+ size?: CardSize;
119
+ stickyHeader?: boolean;
120
+ collapsible?: boolean;
121
+ defaultOpen?: boolean;
122
+ open?: boolean;
123
+ onOpenChange?: (open: boolean) => void;
124
+ style?: CSSProperties;
125
+ }
126
+ export declare function Card({ children, variant, collapsible, defaultOpen, open: openProp, onOpenChange, style, }: CardProps): import("react").JSX.Element;
127
+ export interface CardHeaderProps {
128
+ children?: ReactNode;
129
+ trailing?: ReactNode;
130
+ style?: CSSProperties;
131
+ }
132
+ export declare function CardHeader({ children, trailing, style }: CardHeaderProps): import("react").JSX.Element;
133
+ export interface CardBodyProps {
134
+ children?: ReactNode;
135
+ style?: CSSProperties;
136
+ }
137
+ export declare function CardBody({ children, style }: CardBodyProps): import("react").JSX.Element | null;
138
+ export type StatTone = 'success' | 'danger' | 'warning' | 'info';
139
+ export interface StatProps {
140
+ value: ReactNode;
141
+ label: string;
142
+ tone?: StatTone;
143
+ style?: CSSProperties;
144
+ }
145
+ export declare function Stat({ value, label, tone, style }: StatProps): import("react").JSX.Element;
146
+ export type PillTone = 'neutral' | 'added' | 'deleted' | 'renamed' | 'success' | 'warning' | 'info';
147
+ export type PillSize = 'sm' | 'md';
148
+ export interface PillProps {
149
+ children?: ReactNode;
150
+ active?: boolean;
151
+ tone?: PillTone;
152
+ size?: PillSize;
153
+ leadingContent?: ReactNode;
154
+ keyboardHint?: string;
155
+ disabled?: boolean;
156
+ title?: string;
157
+ style?: CSSProperties;
158
+ onClick?: () => void;
159
+ }
160
+ export declare function Pill({ children, active, tone, size, leadingContent, keyboardHint, title, style, onClick, }: PillProps): import("react").JSX.Element;
161
+ export type CalloutTone = 'info' | 'success' | 'warning' | 'danger' | 'neutral';
162
+ export interface CalloutProps {
163
+ children?: ReactNode;
164
+ tone?: CalloutTone;
165
+ title?: ReactNode;
166
+ icon?: ReactNode;
167
+ style?: CSSProperties;
168
+ }
169
+ export declare function Callout({ children, tone, title, icon, style, }: CalloutProps): import("react").JSX.Element;
170
+ export type TableColumnAlign = 'left' | 'center' | 'right';
171
+ export type TableRowTone = 'success' | 'danger' | 'warning' | 'info' | 'neutral';
172
+ export interface TableProps {
173
+ headers: readonly ReactNode[];
174
+ rows: readonly (readonly ReactNode[])[];
175
+ columnAlign?: readonly (TableColumnAlign | undefined)[];
176
+ rowTone?: readonly (TableRowTone | undefined)[];
177
+ framed?: boolean;
178
+ striped?: boolean;
179
+ stickyHeader?: boolean;
180
+ style?: CSSProperties;
181
+ emptyMessage?: ReactNode;
182
+ }
183
+ export declare function Table({ headers, rows, columnAlign, rowTone, framed, striped, stickyHeader, style, emptyMessage, }: TableProps): import("react").JSX.Element;
184
+ export interface ButtonProps {
185
+ children?: ReactNode;
186
+ variant?: 'primary' | 'secondary' | 'ghost';
187
+ disabled?: boolean;
188
+ type?: 'button' | 'submit' | 'reset';
189
+ style?: CSSProperties;
190
+ onClick?: () => void;
191
+ }
192
+ export declare function Button({ children, variant, disabled, type, style, onClick, }: ButtonProps): import("react").JSX.Element;
193
+ export interface IconButtonProps {
194
+ children: ReactNode;
195
+ onClick?: () => void;
196
+ disabled?: boolean;
197
+ title?: string;
198
+ variant?: 'default' | 'circle';
199
+ size?: 'sm' | 'md';
200
+ style?: CSSProperties;
201
+ }
202
+ export declare function IconButton({ children, onClick, disabled, title, variant, size, style, }: IconButtonProps): import("react").JSX.Element;
203
+ export interface SelectOption {
204
+ value: string;
205
+ label: string;
206
+ disabled?: boolean;
207
+ }
208
+ export interface SelectProps {
209
+ value?: string;
210
+ onChange?: (value: string) => void;
211
+ options: SelectOption[];
212
+ placeholder?: string;
213
+ disabled?: boolean;
214
+ style?: CSSProperties;
215
+ }
216
+ export declare function Select({ value, onChange, options, placeholder, disabled, style, }: SelectProps): import("react").JSX.Element;
217
+ export interface CheckboxProps {
218
+ checked?: boolean;
219
+ onChange?: (checked: boolean) => void;
220
+ disabled?: boolean;
221
+ label?: ReactNode;
222
+ style?: CSSProperties;
223
+ }
224
+ export declare function Checkbox({ checked, onChange, disabled, label, style, }: CheckboxProps): import("react").JSX.Element;
225
+ export interface ToggleProps {
226
+ checked?: boolean;
227
+ onChange?: (checked: boolean) => void;
228
+ disabled?: boolean;
229
+ size?: 'sm' | 'md';
230
+ style?: CSSProperties;
231
+ }
232
+ export declare function Toggle({ checked, onChange, disabled, size, style, }: ToggleProps): import("react").JSX.Element;
233
+ export interface TextInputProps {
234
+ value?: string;
235
+ onChange?: (value: string) => void;
236
+ placeholder?: string;
237
+ disabled?: boolean;
238
+ type?: 'text' | 'email' | 'password' | 'number' | 'url' | 'search';
239
+ style?: CSSProperties;
240
+ }
241
+ export declare function TextInput({ value, onChange, placeholder, disabled, type, style, }: TextInputProps): import("react").JSX.Element;
242
+ export interface TextAreaProps {
243
+ value?: string;
244
+ onChange?: (value: string) => void;
245
+ placeholder?: string;
246
+ disabled?: boolean;
247
+ rows?: number;
248
+ style?: CSSProperties;
249
+ }
250
+ export declare function TextArea({ value, onChange, placeholder, disabled, rows, style, }: TextAreaProps): import("react").JSX.Element;
251
+ export interface SwatchProps {
252
+ color: Color;
253
+ style?: CSSProperties;
254
+ }
255
+ export declare function Swatch({ color, style }: SwatchProps): import("react").JSX.Element;
256
+ export interface UsageBarSegment {
257
+ readonly id: string;
258
+ readonly value: number;
259
+ readonly color?: Color;
260
+ }
261
+ export interface UsageBarProps {
262
+ readonly segments: readonly UsageBarSegment[];
263
+ readonly total: number;
264
+ readonly topLeftLabel?: ReactNode;
265
+ readonly topRightLabel?: ReactNode;
266
+ readonly style?: CSSProperties;
267
+ }
268
+ export declare function UsageBar({ segments, total, topLeftLabel, topRightLabel, style, }: UsageBarProps): import("react").JSX.Element;
269
+ export interface CollapsibleSectionProps {
270
+ title: string;
271
+ leading?: ReactNode;
272
+ count?: number;
273
+ trailing?: ReactNode;
274
+ children?: ReactNode;
275
+ defaultOpen?: boolean;
276
+ style?: CSSProperties;
277
+ }
278
+ export declare function CollapsibleSection({ title, leading, count, trailing, children, defaultOpen, style, }: CollapsibleSectionProps): import("react").JSX.Element;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Pure layered DAG layout, matching the SDK's `computeDAGLayout` contract.
3
+ *
4
+ * Back-edges (cycles) are detected via DFS, excluded from ranking, and flagged
5
+ * in the output so callers can render them differently. Rendering is the
6
+ * caller's responsibility — this returns only coordinates and anchor points.
7
+ */
8
+ export type DAGLayoutOptions = {
9
+ nodes: Array<{
10
+ id: string;
11
+ }>;
12
+ edges: Array<{
13
+ from: string;
14
+ to: string;
15
+ }>;
16
+ direction?: 'vertical' | 'horizontal';
17
+ nodeWidth?: number;
18
+ nodeHeight?: number;
19
+ rankGap?: number;
20
+ nodeGap?: number;
21
+ padding?: number;
22
+ };
23
+ export type DAGLayoutNode = {
24
+ id: string;
25
+ x: number;
26
+ y: number;
27
+ rank: number;
28
+ order: number;
29
+ };
30
+ export type DAGLayoutEdge = {
31
+ from: string;
32
+ to: string;
33
+ sourceX: number;
34
+ sourceY: number;
35
+ targetX: number;
36
+ targetY: number;
37
+ isBackEdge: boolean;
38
+ };
39
+ export type DAGLayoutRank = {
40
+ rank: number;
41
+ x: number;
42
+ y: number;
43
+ width: number;
44
+ height: number;
45
+ nodeIds: string[];
46
+ };
47
+ export type DAGLayoutResult = {
48
+ nodes: DAGLayoutNode[];
49
+ edges: DAGLayoutEdge[];
50
+ ranks: DAGLayoutRank[];
51
+ direction: 'vertical' | 'horizontal';
52
+ width: number;
53
+ height: number;
54
+ };
55
+ export declare function computeDAGLayout(options: DAGLayoutOptions): DAGLayoutResult;
@@ -0,0 +1,23 @@
1
+ import { CSSProperties } from 'react';
2
+ export type DiffStatsProps = {
3
+ additions?: number;
4
+ deletions?: number;
5
+ style?: CSSProperties;
6
+ };
7
+ export declare function DiffStats({ additions, deletions, style, }: DiffStatsProps): import("react").JSX.Element | null;
8
+ export type DiffLineType = 'added' | 'removed' | 'unchanged';
9
+ export type DiffLineData = {
10
+ type: DiffLineType;
11
+ content: string;
12
+ lineNumber?: number;
13
+ };
14
+ export type DiffViewProps = {
15
+ lines: DiffLineData[];
16
+ path?: string;
17
+ language?: string;
18
+ showLineNumbers?: boolean;
19
+ coloredLineNumbers?: boolean;
20
+ showAccentStrip?: boolean;
21
+ style?: CSSProperties;
22
+ };
23
+ export declare function DiffView({ lines, showLineNumbers, coloredLineNumbers, showAccentStrip, style, }: DiffViewProps): import("react").JSX.Element;