@pixerate/editor 0.162.1 → 0.164.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 (75) hide show
  1. package/README.md +1 -1
  2. package/dist/agent/index.cjs +34 -34
  3. package/dist/agent/index.js +5 -5
  4. package/dist/canvas/displacement.d.cts +34 -2
  5. package/dist/canvas/displacement.d.ts +34 -2
  6. package/dist/canvas/explosion-tools.d.cts +43 -0
  7. package/dist/canvas/explosion-tools.d.ts +43 -0
  8. package/dist/canvas/explosionLayout.d.cts +50 -0
  9. package/dist/canvas/explosionLayout.d.ts +50 -0
  10. package/dist/canvas/explosionState.d.cts +52 -0
  11. package/dist/canvas/explosionState.d.ts +52 -0
  12. package/dist/canvas/index.cjs +430 -88
  13. package/dist/canvas/index.d.cts +3 -0
  14. package/dist/canvas/index.d.ts +3 -0
  15. package/dist/canvas/index.js +425 -83
  16. package/dist/canvas/types.d.cts +27 -2
  17. package/dist/canvas/types.d.ts +27 -2
  18. package/dist/chart/commands.d.cts +2 -1
  19. package/dist/chart/commands.d.ts +2 -1
  20. package/dist/chart/controller.d.cts +109 -1
  21. package/dist/chart/controller.d.ts +109 -1
  22. package/dist/chart/index.cjs +605 -130
  23. package/dist/chart/index.d.cts +1 -0
  24. package/dist/chart/index.d.ts +1 -0
  25. package/dist/chart/index.js +490 -15
  26. package/dist/chart/layout-annotations.d.cts +29 -0
  27. package/dist/chart/layout-annotations.d.ts +29 -0
  28. package/dist/chart/layout-families.d.cts +23 -0
  29. package/dist/chart/layout-families.d.ts +23 -0
  30. package/dist/chart/mermaid.d.cts +2 -1
  31. package/dist/chart/mermaid.d.ts +2 -1
  32. package/dist/chart/schemas.d.cts +13 -0
  33. package/dist/chart/schemas.d.ts +13 -0
  34. package/dist/chart/spec.d.cts +30 -5
  35. package/dist/chart/spec.d.ts +30 -5
  36. package/dist/chart/stats.d.cts +9 -1
  37. package/dist/chart/stats.d.ts +9 -1
  38. package/dist/chart/tools.d.cts +1 -1
  39. package/dist/chart/tools.d.ts +1 -1
  40. package/dist/chart/tree.d.cts +62 -0
  41. package/dist/chart/tree.d.ts +62 -0
  42. package/dist/chart/types.d.cts +77 -3
  43. package/dist/chart/types.d.ts +77 -3
  44. package/dist/{chunk-7YBDRJXT.cjs → chunk-22KLZZGH.cjs} +8 -8
  45. package/dist/{chunk-HLOKB7WW.js → chunk-3NEZJCBY.js} +366 -6
  46. package/dist/{chunk-EVPZ5IKN.js → chunk-5FNGLV2D.js} +65 -3
  47. package/dist/{chunk-EQ46F75O.cjs → chunk-D54JHQK2.cjs} +51 -51
  48. package/dist/{chunk-NO5QQDHZ.js → chunk-DAPQGA55.js} +2 -2
  49. package/dist/{chunk-3IHNXRUV.cjs → chunk-GKNEJ6EN.cjs} +399 -67
  50. package/dist/{chunk-4NGVHHJB.cjs → chunk-NZD2MZJC.cjs} +80 -18
  51. package/dist/{chunk-CX6JLDFC.js → chunk-OXERWBKE.js} +3 -3
  52. package/dist/{chunk-7CKPUUN4.js → chunk-POR54B55.js} +61 -10
  53. package/dist/{chunk-LL3H5XUH.cjs → chunk-R3P2M7HU.cjs} +367 -7
  54. package/dist/{chunk-HDGBM7EA.cjs → chunk-SBQVEBSU.cjs} +580 -53
  55. package/dist/{chunk-XDCFJEU7.js → chunk-SZA42R4N.js} +346 -14
  56. package/dist/{chunk-GLMP22FT.js → chunk-TALQONZ5.js} +3 -3
  57. package/dist/{chunk-NA4UVVJ4.cjs → chunk-YGG7WDWT.cjs} +76 -25
  58. package/dist/{chunk-EY22AY6R.cjs → chunk-YSAGBIRW.cjs} +16 -16
  59. package/dist/{chunk-DTSTNRPH.js → chunk-Z4P2RBMJ.js} +536 -9
  60. package/dist/export/index.cjs +4 -4
  61. package/dist/export/index.js +3 -3
  62. package/dist/extensions/index.cjs +7 -7
  63. package/dist/extensions/index.js +6 -6
  64. package/dist/index.cjs +13 -13
  65. package/dist/index.js +7 -7
  66. package/dist/paint-editor/index.cjs +0 -20
  67. package/dist/paint-editor/index.js +0 -20
  68. package/package.json +1 -1
  69. package/skills/README.md +12 -0
  70. package/skills/pixerate-agent-tools/SKILL.md +34 -1
  71. package/skills/pixerate-canvas/SKILL.md +16 -0
  72. package/skills/pixerate-chart/SKILL.md +41 -9
  73. package/skills/pixerate-image-editor/SKILL.md +2 -0
  74. package/skills/pixerate-paint-editor/SKILL.md +2 -0
  75. package/skills/pixerate-tokens/SKILL.md +5 -0
@@ -149,12 +149,38 @@ export type DisplacementDirection = 'right' | 'left' | 'down' | 'up' | 'vertical
149
149
  * Options for directional displacement calculation.
150
150
  */
151
151
  export interface DirectionalDisplacementOptions {
152
+ /** Which nodes move and where: `right` / `left` / `up` / `down` push one side; `vertical` opens the row up and down. Default `right`. */
152
153
  direction?: DisplacementDirection;
154
+ /** Clearance between the child cluster and displaced nodes, in canvas units. Default 40. */
153
155
  gap?: number;
156
+ /** With `right`, also push nodes in the origin's column that overlap the cluster up or down. Default false. */
154
157
  spreadSiblingLanes?: boolean;
158
+ /** Distance in canvas units within which a node counts as a sibling (same column for `right`, same row for `row-lane`). Default 50. */
155
159
  siblingTolerance?: number;
160
+ /**
161
+ * Floor for the top edge of nodes moved upward (e.g. below a pinned header). Rows pushed into it
162
+ * stack from `minY` down by `rowSpacing` so they never overlap, and never move below where they started.
163
+ */
156
164
  minY?: number;
165
+ /**
166
+ * Ceiling for the bottom edge of nodes moved downward. Rows pushed into it stack from `maxY` up by
167
+ * `rowSpacing`, and never move above where they started.
168
+ */
169
+ maxY?: number;
170
+ /**
171
+ * `freeform` (default) moves nodes by the exact clearance. `row-lane` treats the canvas as rows
172
+ * `rowSpacing` apart: nodes are bucketed into lanes relative to the origin row, the origin's lane
173
+ * stays put, and vertical deltas are rounded up to whole lanes so rows glide apart by exact lane heights.
174
+ */
175
+ layoutMode?: 'freeform' | 'row-lane';
176
+ /**
177
+ * Lane height in canvas units. Required for `row-lane` (default: the origin's height); also the
178
+ * spacing between rows stacked against `minY` / `maxY` (default: the tallest node in those rows).
179
+ */
180
+ rowSpacing?: number;
157
181
  }
182
+ /** How existing nodes make room when a node explodes. */
183
+ export type ExplosionDisplacementStrategy = 'directional' | 'dagre' | 'none';
158
184
  /**
159
185
  * Options for Dagre reflow displacement calculation.
160
186
  */
@@ -181,8 +207,7 @@ export interface ExplodeNodeOptions<TNode extends CanvasNode = CanvasNode, TEdge
181
207
  childNodes: TNode[];
182
208
  childEdges?: TEdge[];
183
209
  connectParentToChildren?: boolean | 'first' | 'all';
184
- connectChildrenToDownstream?: boolean;
185
- displacementStrategy?: 'directional' | 'dagre' | 'none';
210
+ displacementStrategy?: ExplosionDisplacementStrategy;
186
211
  directionalOptions?: DirectionalDisplacementOptions;
187
212
  reflowOptions?: Partial<ReflowDisplacementOptions>;
188
213
  trajectory?: TrajectoryFunction;
@@ -10,7 +10,8 @@ export interface ChartCommandOptions {
10
10
  }
11
11
  /**
12
12
  * Palette and agent commands for a chart: describe, update presentation, replace data, set
13
- * values, add / remove series, categories and trendlines, apply presets, switch rows and
13
+ * values, add / remove series, categories, trendlines and reference lines and bands, pin
14
+ * callouts, highlight, apply presets, switch rows and
14
15
  * columns, import CSV or Mermaid, export SVG, Mermaid or Office XML, recommend types and
15
16
  * check colours. Register them in a `CommandRegistry` and agents get them through
16
17
  * `createCommandToolProvider`; `createChartToolProvider` offers the same operations as
@@ -10,7 +10,8 @@ export interface ChartCommandOptions {
10
10
  }
11
11
  /**
12
12
  * Palette and agent commands for a chart: describe, update presentation, replace data, set
13
- * values, add / remove series, categories and trendlines, apply presets, switch rows and
13
+ * values, add / remove series, categories, trendlines and reference lines and bands, pin
14
+ * callouts, highlight, apply presets, switch rows and
14
15
  * columns, import CSV or Mermaid, export SVG, Mermaid or Office XML, recommend types and
15
16
  * check colours. Register them in a `CommandRegistry` and agents get them through
16
17
  * `createCommandToolProvider`; `createChartToolProvider` offers the same operations as
@@ -1,7 +1,8 @@
1
1
  import { HistoryManager } from '../history/HistoryManager.cjs';
2
2
  import { type ChartTrendFit } from './trend.cjs';
3
+ import { type ChartTreeRow } from './tree.cjs';
3
4
  import { type ChartTableOptions } from './spec.cjs';
4
- import type { ChartAxis, ChartIssue, ChartCurve, ChartErrorBars, ChartLegend, ChartMarker, ChartNumberFormat, ChartSelection, ChartSeries, ChartSeriesType, ChartSpec, ChartTrendline, ChartType } from './types.cjs';
5
+ import type { ChartAxis, ChartIssue, ChartCurve, ChartErrorBars, ChartLegend, ChartMarker, ChartNumberFormat, ChartReferenceBand, ChartReferenceLine, ChartSelection, ChartSeries, ChartSeriesType, ChartSpec, ChartTrendline, ChartType } from './types.cjs';
5
6
  export interface ChartControllerOptions {
6
7
  /** Starting chart (any partial or saved spec; problems are reported in `state.issues`). */
7
8
  spec?: Partial<ChartSpec> | unknown;
@@ -54,6 +55,7 @@ export interface ChartSeriesInput {
54
55
  x?: readonly unknown[];
55
56
  sizes?: readonly unknown[];
56
57
  pointColors?: readonly (string | null)[];
58
+ callouts?: readonly (string | null)[];
57
59
  marker?: ChartMarker;
58
60
  curve?: ChartCurve;
59
61
  dataLabels?: boolean;
@@ -74,6 +76,8 @@ export interface ChartSeriesPatch {
74
76
  x?: readonly unknown[] | null;
75
77
  sizes?: readonly unknown[] | null;
76
78
  pointColors?: readonly (string | null)[] | null;
79
+ /** One label per category (null: none); `null` removes them all. */
80
+ callouts?: readonly (string | null)[] | null;
77
81
  marker?: ChartMarker | null;
78
82
  curve?: ChartCurve | null;
79
83
  dataLabels?: boolean | null;
@@ -188,6 +192,9 @@ export declare class ChartController {
188
192
  }): {
189
193
  ok: true;
190
194
  index: number;
195
+ } | {
196
+ ok: false;
197
+ message: string;
191
198
  };
192
199
  removeCategory(index: number): ChartActionResult;
193
200
  renameCategory(index: number, label: string): ChartActionResult;
@@ -213,6 +220,107 @@ export declare class ChartController {
213
220
  }): ChartActionResult & {
214
221
  issues?: ChartIssue[];
215
222
  };
223
+ /** A refusal while the data is a tree (cell edits would be overwritten by its totals), else null. */
224
+ private treeLocked;
225
+ /** Replaces the grouped data (an empty list goes back to the table, keeping the totals as values). One undo step. */
226
+ setTree(tree: unknown, options?: ChartEditOptions): ChartActionResult;
227
+ /**
228
+ * Replaces the grouped data from rows of names and a value (group, …, item, value), as the
229
+ * data grid edits it; colours of nodes whose path is unchanged are kept. All-or-nothing.
230
+ */
231
+ setTreeRows(rows: readonly ChartTreeRow[] | readonly {
232
+ path: readonly unknown[];
233
+ value: unknown;
234
+ }[], options?: ChartEditOptions): ChartActionResult;
235
+ /** Replaces the data with a table of names and values (group, …, item, value); see `chartTreeFromTable`. */
236
+ importTreeTable(rows: ReadonlyArray<ReadonlyArray<unknown>>, options?: {
237
+ header?: boolean | 'auto';
238
+ }): ChartActionResult;
239
+ private nodeAt;
240
+ /** Adds a node under the group at `parent` ([] for the top level) at `at` (default: the end). Returns its path. */
241
+ addTreeNode(parent: readonly string[], input: {
242
+ name: string;
243
+ value?: number;
244
+ color?: string;
245
+ children?: unknown[];
246
+ }, options?: {
247
+ at?: number;
248
+ }): {
249
+ ok: true;
250
+ path: string[];
251
+ } | {
252
+ ok: false;
253
+ message: string;
254
+ issues?: ChartIssue[];
255
+ };
256
+ /** Renames, revalues (items only) or recolours a node; `color: null` goes back to the palette. Returns its path. */
257
+ updateTreeNode(path: readonly string[], patch: {
258
+ name?: string;
259
+ value?: number;
260
+ color?: string | null;
261
+ }): {
262
+ ok: true;
263
+ path: string[];
264
+ } | {
265
+ ok: false;
266
+ message: string;
267
+ issues?: ChartIssue[];
268
+ };
269
+ /** Removes a node (with everything under it). A group left empty becomes an item with value 0. */
270
+ removeTreeNode(path: readonly string[]): ChartActionResult;
271
+ /** Sets the note written under the chart ("" removes it). */
272
+ setNote(note: string): ChartActionResult;
273
+ /**
274
+ * Draws the named categories (labels) and series (names or ids) normally and mutes the
275
+ * rest; an empty list shows everything. Unknown names change nothing. Returns the category
276
+ * indexes and series ids that matched.
277
+ */
278
+ setHighlight(names: readonly string[]): {
279
+ ok: true;
280
+ categories: number[];
281
+ series: string[];
282
+ } | {
283
+ ok: false;
284
+ message: string;
285
+ issues?: ChartIssue[];
286
+ };
287
+ /** Why a reference on `axis` at `values` cannot be drawn on this chart, or null. */
288
+ private referenceProblem;
289
+ private editReferences;
290
+ /** Adds a reference line (a target, floor or average). Returns its index. */
291
+ addReferenceLine(input: ChartReferenceLine): {
292
+ ok: true;
293
+ index: number;
294
+ } | {
295
+ ok: false;
296
+ message: string;
297
+ issues?: ChartIssue[];
298
+ };
299
+ /** Changes a reference line (all-or-nothing); `null` removes its label, colour or axis. */
300
+ updateReferenceLine(index: number, patch: {
301
+ [K in keyof ChartReferenceLine]?: ChartReferenceLine[K] | null;
302
+ }): ChartActionResult;
303
+ removeReferenceLine(index: number): ChartActionResult;
304
+ /** Adds a reference band (a target range). Returns its index. */
305
+ addReferenceBand(input: ChartReferenceBand): {
306
+ ok: true;
307
+ index: number;
308
+ } | {
309
+ ok: false;
310
+ message: string;
311
+ issues?: ChartIssue[];
312
+ };
313
+ /** Changes a reference band (all-or-nothing); `null` removes its label, colour or axis. */
314
+ updateReferenceBand(index: number, patch: {
315
+ [K in keyof ChartReferenceBand]?: ChartReferenceBand[K] | null;
316
+ }): ChartActionResult;
317
+ removeReferenceBand(index: number): ChartActionResult;
318
+ private noReference;
319
+ /**
320
+ * Pins a label to one bar or point (`null` or "" removes it) and selects the point. The
321
+ * point must have a value, on a bar, line, area, scatter or bubble chart.
322
+ */
323
+ setCallout(seriesId: string, index: number, label: string | null): ChartActionResult;
216
324
  /** Adds a trendline to a series and selects it. Returns its index (and the fit, when it can be computed). */
217
325
  addTrendline(seriesId: string, input: ChartTrendline): {
218
326
  ok: true;
@@ -1,7 +1,8 @@
1
1
  import { HistoryManager } from '../history/HistoryManager.js';
2
2
  import { type ChartTrendFit } from './trend.js';
3
+ import { type ChartTreeRow } from './tree.js';
3
4
  import { type ChartTableOptions } from './spec.js';
4
- import type { ChartAxis, ChartIssue, ChartCurve, ChartErrorBars, ChartLegend, ChartMarker, ChartNumberFormat, ChartSelection, ChartSeries, ChartSeriesType, ChartSpec, ChartTrendline, ChartType } from './types.js';
5
+ import type { ChartAxis, ChartIssue, ChartCurve, ChartErrorBars, ChartLegend, ChartMarker, ChartNumberFormat, ChartReferenceBand, ChartReferenceLine, ChartSelection, ChartSeries, ChartSeriesType, ChartSpec, ChartTrendline, ChartType } from './types.js';
5
6
  export interface ChartControllerOptions {
6
7
  /** Starting chart (any partial or saved spec; problems are reported in `state.issues`). */
7
8
  spec?: Partial<ChartSpec> | unknown;
@@ -54,6 +55,7 @@ export interface ChartSeriesInput {
54
55
  x?: readonly unknown[];
55
56
  sizes?: readonly unknown[];
56
57
  pointColors?: readonly (string | null)[];
58
+ callouts?: readonly (string | null)[];
57
59
  marker?: ChartMarker;
58
60
  curve?: ChartCurve;
59
61
  dataLabels?: boolean;
@@ -74,6 +76,8 @@ export interface ChartSeriesPatch {
74
76
  x?: readonly unknown[] | null;
75
77
  sizes?: readonly unknown[] | null;
76
78
  pointColors?: readonly (string | null)[] | null;
79
+ /** One label per category (null: none); `null` removes them all. */
80
+ callouts?: readonly (string | null)[] | null;
77
81
  marker?: ChartMarker | null;
78
82
  curve?: ChartCurve | null;
79
83
  dataLabels?: boolean | null;
@@ -188,6 +192,9 @@ export declare class ChartController {
188
192
  }): {
189
193
  ok: true;
190
194
  index: number;
195
+ } | {
196
+ ok: false;
197
+ message: string;
191
198
  };
192
199
  removeCategory(index: number): ChartActionResult;
193
200
  renameCategory(index: number, label: string): ChartActionResult;
@@ -213,6 +220,107 @@ export declare class ChartController {
213
220
  }): ChartActionResult & {
214
221
  issues?: ChartIssue[];
215
222
  };
223
+ /** A refusal while the data is a tree (cell edits would be overwritten by its totals), else null. */
224
+ private treeLocked;
225
+ /** Replaces the grouped data (an empty list goes back to the table, keeping the totals as values). One undo step. */
226
+ setTree(tree: unknown, options?: ChartEditOptions): ChartActionResult;
227
+ /**
228
+ * Replaces the grouped data from rows of names and a value (group, …, item, value), as the
229
+ * data grid edits it; colours of nodes whose path is unchanged are kept. All-or-nothing.
230
+ */
231
+ setTreeRows(rows: readonly ChartTreeRow[] | readonly {
232
+ path: readonly unknown[];
233
+ value: unknown;
234
+ }[], options?: ChartEditOptions): ChartActionResult;
235
+ /** Replaces the data with a table of names and values (group, …, item, value); see `chartTreeFromTable`. */
236
+ importTreeTable(rows: ReadonlyArray<ReadonlyArray<unknown>>, options?: {
237
+ header?: boolean | 'auto';
238
+ }): ChartActionResult;
239
+ private nodeAt;
240
+ /** Adds a node under the group at `parent` ([] for the top level) at `at` (default: the end). Returns its path. */
241
+ addTreeNode(parent: readonly string[], input: {
242
+ name: string;
243
+ value?: number;
244
+ color?: string;
245
+ children?: unknown[];
246
+ }, options?: {
247
+ at?: number;
248
+ }): {
249
+ ok: true;
250
+ path: string[];
251
+ } | {
252
+ ok: false;
253
+ message: string;
254
+ issues?: ChartIssue[];
255
+ };
256
+ /** Renames, revalues (items only) or recolours a node; `color: null` goes back to the palette. Returns its path. */
257
+ updateTreeNode(path: readonly string[], patch: {
258
+ name?: string;
259
+ value?: number;
260
+ color?: string | null;
261
+ }): {
262
+ ok: true;
263
+ path: string[];
264
+ } | {
265
+ ok: false;
266
+ message: string;
267
+ issues?: ChartIssue[];
268
+ };
269
+ /** Removes a node (with everything under it). A group left empty becomes an item with value 0. */
270
+ removeTreeNode(path: readonly string[]): ChartActionResult;
271
+ /** Sets the note written under the chart ("" removes it). */
272
+ setNote(note: string): ChartActionResult;
273
+ /**
274
+ * Draws the named categories (labels) and series (names or ids) normally and mutes the
275
+ * rest; an empty list shows everything. Unknown names change nothing. Returns the category
276
+ * indexes and series ids that matched.
277
+ */
278
+ setHighlight(names: readonly string[]): {
279
+ ok: true;
280
+ categories: number[];
281
+ series: string[];
282
+ } | {
283
+ ok: false;
284
+ message: string;
285
+ issues?: ChartIssue[];
286
+ };
287
+ /** Why a reference on `axis` at `values` cannot be drawn on this chart, or null. */
288
+ private referenceProblem;
289
+ private editReferences;
290
+ /** Adds a reference line (a target, floor or average). Returns its index. */
291
+ addReferenceLine(input: ChartReferenceLine): {
292
+ ok: true;
293
+ index: number;
294
+ } | {
295
+ ok: false;
296
+ message: string;
297
+ issues?: ChartIssue[];
298
+ };
299
+ /** Changes a reference line (all-or-nothing); `null` removes its label, colour or axis. */
300
+ updateReferenceLine(index: number, patch: {
301
+ [K in keyof ChartReferenceLine]?: ChartReferenceLine[K] | null;
302
+ }): ChartActionResult;
303
+ removeReferenceLine(index: number): ChartActionResult;
304
+ /** Adds a reference band (a target range). Returns its index. */
305
+ addReferenceBand(input: ChartReferenceBand): {
306
+ ok: true;
307
+ index: number;
308
+ } | {
309
+ ok: false;
310
+ message: string;
311
+ issues?: ChartIssue[];
312
+ };
313
+ /** Changes a reference band (all-or-nothing); `null` removes its label, colour or axis. */
314
+ updateReferenceBand(index: number, patch: {
315
+ [K in keyof ChartReferenceBand]?: ChartReferenceBand[K] | null;
316
+ }): ChartActionResult;
317
+ removeReferenceBand(index: number): ChartActionResult;
318
+ private noReference;
319
+ /**
320
+ * Pins a label to one bar or point (`null` or "" removes it) and selects the point. The
321
+ * point must have a value, on a bar, line, area, scatter or bubble chart.
322
+ */
323
+ setCallout(seriesId: string, index: number, label: string | null): ChartActionResult;
216
324
  /** Adds a trendline to a series and selects it. Returns its index (and the fit, when it can be computed). */
217
325
  addTrendline(seriesId: string, input: ChartTrendline): {
218
326
  ok: true;