ggaction 0.0.15 → 0.0.17

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 (270) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/README.md +23 -2
  3. package/knowledge/action-cards.json +1 -1
  4. package/knowledge/intent-taxonomy.json +1 -1
  5. package/knowledge/mcp-resources.json +1 -1
  6. package/knowledge/task-packet.schema.json +1 -1
  7. package/knowledge/task-resolver.js +1 -1
  8. package/package.json +40 -7
  9. package/src/BasicChartProgram.js +3 -1
  10. package/src/ChartProgram.js +2 -0
  11. package/src/accessibility.js +157 -0
  12. package/src/actions/boxPlots/components.js +6 -8
  13. package/src/actions/boxPlots/create.js +4 -5
  14. package/src/actions/boxPlots/edit.js +3 -4
  15. package/src/actions/boxPlots/materialize.js +1 -1
  16. package/src/actions/canvas/actions.js +3 -3
  17. package/src/actions/canvas/fitting.js +1 -1
  18. package/src/actions/categoryOrder/index.js +6 -8
  19. package/src/actions/charts/area.js +1 -1
  20. package/src/actions/charts/bar.js +1 -1
  21. package/src/actions/charts/beeswarm.js +1 -1
  22. package/src/actions/charts/density.js +1 -1
  23. package/src/actions/charts/ecdf.js +2 -2
  24. package/src/actions/charts/endpoints.js +4 -4
  25. package/src/actions/charts/heatmap.js +1 -1
  26. package/src/actions/charts/histogram.js +1 -1
  27. package/src/actions/charts/horizon.js +1 -1
  28. package/src/actions/charts/interval-regression.js +2 -2
  29. package/src/actions/charts/line.js +1 -1
  30. package/src/actions/charts/parallel.js +1 -1
  31. package/src/actions/charts/pie.js +1 -1
  32. package/src/actions/charts/polar.js +2 -2
  33. package/src/actions/charts/radar.js +1 -1
  34. package/src/actions/charts/radial.js +2 -2
  35. package/src/actions/charts/raincloud.js +2 -2
  36. package/src/actions/charts/rug-strip.js +2 -2
  37. package/src/actions/charts/scatter.js +1 -1
  38. package/src/actions/composition/actions.js +20 -24
  39. package/src/actions/coordinates/actions.js +1 -1
  40. package/src/actions/coordinates/edit.js +1 -1
  41. package/src/actions/data/basicBin2d.js +4 -5
  42. package/src/actions/data/bin.js +3 -3
  43. package/src/actions/data/bin2d.js +6 -8
  44. package/src/actions/data/bin2dMaterialize.js +4 -5
  45. package/src/actions/data/box.js +4 -4
  46. package/src/actions/data/complete.js +2 -2
  47. package/src/actions/data/computed.js +2 -2
  48. package/src/actions/data/create.js +23 -17
  49. package/src/actions/data/density.js +4 -4
  50. package/src/actions/data/derived.js +25 -15
  51. package/src/actions/data/ecdf.js +2 -2
  52. package/src/actions/data/edit.js +54 -29
  53. package/src/actions/data/filter.js +29 -24
  54. package/src/actions/data/fold.js +2 -2
  55. package/src/actions/data/gradientProfile.js +2 -2
  56. package/src/actions/data/horizon.js +2 -2
  57. package/src/actions/data/impute.js +2 -2
  58. package/src/actions/data/index.js +58 -54
  59. package/src/actions/data/interval.js +4 -2
  60. package/src/actions/data/intervalEdit.js +26 -18
  61. package/src/actions/data/normalize.js +2 -2
  62. package/src/actions/data/regression.js +9 -7
  63. package/src/actions/data/revise.js +80 -0
  64. package/src/actions/data/revisionBindings.js +13 -33
  65. package/src/actions/data/shared.js +30 -2
  66. package/src/actions/data/sort.js +21 -0
  67. package/src/actions/data/stack.js +2 -2
  68. package/src/actions/data/summary.js +3 -3
  69. package/src/actions/data/timeUnit.js +2 -2
  70. package/src/actions/data/window.js +2 -2
  71. package/src/actions/encodings/angle.js +5 -2
  72. package/src/actions/encodings/appearance.js +10 -6
  73. package/src/actions/encodings/barWidth.js +1 -1
  74. package/src/actions/encodings/channels.js +2 -2
  75. package/src/actions/encodings/color/continuous.js +4 -1
  76. package/src/actions/encodings/color/index.js +5 -2
  77. package/src/actions/encodings/density.js +2 -2
  78. package/src/actions/encodings/histogram.js +1 -1
  79. package/src/actions/encodings/horizon.js +6 -8
  80. package/src/actions/encodings/offset.js +6 -3
  81. package/src/actions/encodings/parallel.js +4 -5
  82. package/src/actions/encodings/pathOrder.js +6 -11
  83. package/src/actions/encodings/position/index.js +4 -4
  84. package/src/actions/encodings/position/resolve.js +6 -1
  85. package/src/actions/encodings/ranged.js +11 -6
  86. package/src/actions/encodings/remove.js +4 -5
  87. package/src/actions/encodings/ruleAppearance.js +5 -2
  88. package/src/actions/encodings/seriesLayout.js +1 -1
  89. package/src/actions/encodings/stroke.js +5 -2
  90. package/src/actions/encodings/strokeDash.js +8 -3
  91. package/src/actions/encodings/text.js +7 -2
  92. package/src/actions/errorBands/create.js +11 -17
  93. package/src/actions/errorBands/edit.js +13 -131
  94. package/src/actions/errorBars/create.js +8 -13
  95. package/src/actions/errorBars/edit.js +10 -121
  96. package/src/actions/facets/actions.js +30 -16
  97. package/src/actions/facets/derive.js +8 -2
  98. package/src/actions/facets/guides.js +4 -5
  99. package/src/actions/facets/replay.js +4 -5
  100. package/src/actions/gradientPlots/components.js +5 -6
  101. package/src/actions/gradientPlots/create.js +4 -5
  102. package/src/actions/gradientPlots/edit.js +4 -5
  103. package/src/actions/gradientPlots/materialize.js +2 -2
  104. package/src/actions/gradientPlots/rebind.js +4 -5
  105. package/src/actions/guides/axes/axes.js +23 -4
  106. package/src/actions/guides/axes/axis.js +2 -2
  107. package/src/actions/guides/axes/edit.js +2 -2
  108. package/src/actions/guides/axes/labels.js +9 -9
  109. package/src/actions/guides/axes/lines.js +9 -7
  110. package/src/actions/guides/axes/parallel/lifecycle.js +13 -13
  111. package/src/actions/guides/axes/parallel.js +5 -5
  112. package/src/actions/guides/axes/remove.js +4 -4
  113. package/src/actions/guides/axes/tickGroups.js +4 -4
  114. package/src/actions/guides/axes/ticks.js +13 -4
  115. package/src/actions/guides/axes/titles.js +10 -10
  116. package/src/actions/guides/grids/grid.js +18 -29
  117. package/src/actions/guides/guides.js +1 -1
  118. package/src/actions/guides/legends/blocks.js +1 -1
  119. package/src/actions/guides/legends/categorical/actions.js +4 -4
  120. package/src/actions/guides/legends/categorical/components.js +38 -33
  121. package/src/actions/guides/legends/categorical/layout.js +1 -1
  122. package/src/actions/guides/legends/categorical/symbols.js +27 -30
  123. package/src/actions/guides/legends/continuous/common.js +46 -8
  124. package/src/actions/guides/legends/continuous/gradient.js +89 -155
  125. package/src/actions/guides/legends/continuous/interval.js +13 -13
  126. package/src/actions/guides/legends/continuous/opacity.js +30 -79
  127. package/src/actions/guides/legends/continuous/stroke.js +22 -322
  128. package/src/actions/guides/legends/edit.js +1 -1
  129. package/src/actions/guides/legends/focused.js +5 -5
  130. package/src/actions/guides/legends/lane.js +6 -6
  131. package/src/actions/guides/legends/remove.js +4 -5
  132. package/src/actions/guides/legends/size.js +21 -82
  133. package/src/actions/guides/legends/strokeWidth.js +17 -77
  134. package/src/actions/guides/polar/axes/facade.js +4 -4
  135. package/src/actions/guides/polar/axes/labels.js +5 -5
  136. package/src/actions/guides/polar/axes/lines.js +9 -15
  137. package/src/actions/guides/polar/axes/ticks.js +9 -15
  138. package/src/actions/guides/polar/axes/titles.js +5 -5
  139. package/src/actions/guides/polar/grids.js +11 -13
  140. package/src/actions/index.js +2 -0
  141. package/src/actions/intervals/revision.js +126 -0
  142. package/src/actions/marks/arc/actions.js +3 -3
  143. package/src/actions/marks/area/actions.js +4 -4
  144. package/src/actions/marks/bar/create.js +9 -2
  145. package/src/actions/marks/bar/edit.js +13 -6
  146. package/src/actions/marks/bar/materialize.js +12 -38
  147. package/src/actions/marks/line/actions.js +3 -3
  148. package/src/actions/marks/point/create.js +9 -2
  149. package/src/actions/marks/point/edit.js +13 -6
  150. package/src/actions/marks/point/jitter.js +6 -8
  151. package/src/actions/marks/point/materialize.js +20 -26
  152. package/src/actions/marks/point/packing.js +6 -8
  153. package/src/actions/marks/rect/actions.js +26 -11
  154. package/src/actions/marks/references.js +8 -10
  155. package/src/actions/marks/remove.js +5 -49
  156. package/src/actions/marks/rule/actions.js +28 -12
  157. package/src/actions/marks/text/actions.js +30 -11
  158. package/src/actions/marks/text/layout.js +12 -20
  159. package/src/actions/marks/text/removal.js +1 -1
  160. package/src/actions/marks/text/selection.js +4 -5
  161. package/src/actions/marks/tick/actions.js +26 -11
  162. package/src/actions/primitives/createGraphics.js +5 -4
  163. package/src/actions/primitives/editGraphics.js +5 -4
  164. package/src/actions/primitives/graphicProperties.js +6 -0
  165. package/src/actions/primitives/semantic.js +10 -3
  166. package/src/actions/primitives/semanticAction.js +44 -7
  167. package/src/actions/primitives/semanticValidation/dataset.js +14 -4
  168. package/src/actions/primitives/semanticValidation/layer.js +22 -2
  169. package/src/actions/primitives/semanticValidation/scale.js +6 -0
  170. package/src/actions/regression/components.js +10 -14
  171. package/src/actions/regression/create.js +28 -8
  172. package/src/actions/regression/edit.js +50 -16
  173. package/src/actions/regression/follow.js +22 -0
  174. package/src/actions/resources/remove.js +12 -11
  175. package/src/actions/scales/channels.js +11 -11
  176. package/src/actions/scales/consumers/common.js +2 -1
  177. package/src/actions/scales/create.js +3 -2
  178. package/src/actions/scales/definitions.js +1 -1
  179. package/src/actions/scales/edit.js +2 -2
  180. package/src/actions/scales/materialize.js +1 -1
  181. package/src/actions/scales/offset.js +2 -2
  182. package/src/actions/scales/parallel.js +2 -2
  183. package/src/actions/scales/patch.js +1 -1
  184. package/src/actions/scales/preview.js +28 -1
  185. package/src/actions/scales/quantitativeColor.js +4 -5
  186. package/src/actions/selection/actions.js +25 -36
  187. package/src/actions/textMetrics/index.js +56 -0
  188. package/src/actions/theme/actions.js +2 -2
  189. package/src/actions/theme/reconcile.js +67 -121
  190. package/src/actions/titles/actions.js +8 -8
  191. package/src/actions/titles/resolve.js +3 -3
  192. package/src/actions/violinPlots/create.js +1 -1
  193. package/src/actions/violinPlots/edit.js +1 -1
  194. package/src/core/action.js +109 -36
  195. package/src/core/diagnostics.js +16 -0
  196. package/src/core/extensionRegistry.js +27 -0
  197. package/src/core/font.js +18 -0
  198. package/src/core/identifiers.js +5 -4
  199. package/src/core/immutable.js +10 -3
  200. package/src/core/optionRequirements.js +8 -0
  201. package/src/core/programState.js +6 -2
  202. package/src/core/resourceReferences.js +15 -6
  203. package/src/core/textMetricProfile.js +28 -0
  204. package/src/core/textMetrics.js +24 -3
  205. package/src/core/validation.js +22 -10
  206. package/src/diagnostics.js +1 -0
  207. package/src/grammar/bin.js +39 -10
  208. package/src/grammar/datasetSchema.js +386 -0
  209. package/src/grammar/density.js +53 -5
  210. package/src/grammar/filter.js +133 -39
  211. package/src/grammar/impute.js +3 -2
  212. package/src/grammar/interval.js +32 -1
  213. package/src/grammar/itemMissing.js +59 -0
  214. package/src/grammar/regression/derive.js +57 -16
  215. package/src/grammar/regression/index.js +1 -0
  216. package/src/grammar/regression/models.js +51 -22
  217. package/src/grammar/regression/parameters.js +56 -4
  218. package/src/grammar/scales/definition.js +7 -0
  219. package/src/grammar/scales/types.js +8 -0
  220. package/src/grammar/schemas/graphicBounds.js +11 -11
  221. package/src/grammar/schemas/semanticPath.js +3 -2
  222. package/src/grammar/sort.js +88 -0
  223. package/src/grammar/summary.js +117 -19
  224. package/src/grammar/transformTopology.js +1 -0
  225. package/src/grammar/transforms.js +21 -11
  226. package/src/inspection.js +495 -0
  227. package/src/inspectionDescriptors.js +3 -0
  228. package/src/layout/labels.js +11 -10
  229. package/src/layout/legend.js +4 -4
  230. package/src/layout/legendItems.js +6 -6
  231. package/src/layout/text.js +10 -9
  232. package/src/layout/title.js +9 -9
  233. package/src/materialization/bars/resolve.js +4 -2
  234. package/src/materialization/facetGuides/placement.js +1 -1
  235. package/src/materialization/facetGuides/preparation.js +1 -1
  236. package/src/materialization/facetHeaders.js +11 -10
  237. package/src/materialization/guides/layout.js +3 -3
  238. package/src/materialization/revisionIdentity.js +19 -0
  239. package/src/materialization/scaleGuideDependencies.js +10 -0
  240. package/src/materialization/scales/resolve.js +67 -4
  241. package/src/materialization/selection/items/common.js +1 -1
  242. package/src/materialization/text.js +6 -4
  243. package/src/materialization/typography.js +31 -0
  244. package/src/mcp/cli.js +5 -3
  245. package/src/persistence/codec.js +65 -0
  246. package/src/persistence/validation.js +185 -0
  247. package/src/persistence.js +147 -0
  248. package/src/renderers/canvas/index.js +5 -4
  249. package/src/renderers/nativeBackend.js +10 -0
  250. package/src/renderers/options.js +13 -0
  251. package/src/renderers/pdf.js +25 -54
  252. package/src/renderers/png.js +22 -17
  253. package/src/renderers/svg.js +10 -14
  254. package/src/renderers/text.js +1 -11
  255. package/src/selectors/coordinates.js +3 -1
  256. package/src/selectors/datasets.js +8 -6
  257. package/src/selectors/layers.js +6 -4
  258. package/src/selectors/markOwners.js +46 -0
  259. package/src/selectors/scales.js +6 -4
  260. package/src/theme/defaults.js +2 -1
  261. package/src/version.js +2 -0
  262. package/types/accessibility.d.ts +37 -0
  263. package/types/basic.d.ts +4 -2
  264. package/types/diagnostics.d.ts +15 -0
  265. package/types/index.d.ts +5 -0
  266. package/types/inspection.d.ts +17 -0
  267. package/types/pdf.d.ts +9 -0
  268. package/types/persistence.d.ts +7 -0
  269. package/types/png.d.ts +9 -0
  270. package/types/program.d.ts +181 -28
@@ -1,3 +1,5 @@
1
+ import { annotateError } from "../core/diagnostics.js";
2
+
1
3
  export function findDataset(program, id) {
2
4
  return program.semanticSpec.datasets.find(dataset => dataset.id === id);
3
5
  }
@@ -20,7 +22,7 @@ export function hasDatasetOwner(program, id) {
20
22
  export function resolveDatasetReference(program, id, label = "Dataset") {
21
23
  const matches = currentOwnerMatches(program, id);
22
24
  if (matches.length > 1) {
23
- throw new Error(`${label} logical owner "${id}" is ambiguous.`);
25
+ throw annotateError(new Error(`${label} logical owner "${id}" is ambiguous.`), { code: "ambiguous-resource", resourceId: id, candidates: matches.map(match => match.current) });
24
26
  }
25
27
  const resolved = matches.length === 1 ? matches[0].current : id;
26
28
  const dataset = findDataset(program, resolved);
@@ -28,7 +30,7 @@ export function resolveDatasetReference(program, id, label = "Dataset") {
28
30
  const kind = label.toLowerCase().includes("source")
29
31
  ? "source dataset"
30
32
  : "dataset";
31
- throw new Error(`Unknown ${kind} "${id}" does not exist.`);
33
+ throw annotateError(new Error(`Unknown ${kind} "${id}" does not exist.`), { code: "missing-resource", resourceId: id });
32
34
  }
33
35
  return dataset;
34
36
  }
@@ -43,19 +45,19 @@ export function findDatasetConsumer(program, source) {
43
45
 
44
46
  export function requireDataset(program, id, label = `Dataset "${id}"`) {
45
47
  const dataset = findDataset(program, id);
46
- if (dataset === undefined) throw new Error(`${label} does not exist.`);
48
+ if (dataset === undefined) throw annotateError(new Error(`${label} does not exist.`), { code: "missing-resource", resourceId: id });
47
49
  return dataset;
48
50
  }
49
51
 
50
52
  export function requireMaterializedDataset(program, id) {
51
53
  const dataset = resolveDatasetReference(program, id, "Dataset");
52
- if (dataset === undefined) throw new Error(`Unknown dataset "${id}".`);
54
+ if (dataset === undefined) throw annotateError(new Error(`Unknown dataset "${id}".`), { code: "missing-resource", resourceId: id });
53
55
  if (!Array.isArray(dataset.values)) {
54
- throw new Error(
56
+ throw annotateError(new Error(
55
57
  `Dataset "${id}" requires materialized values. ` +
56
58
  "createDerivedData stores a definition only; use the corresponding " +
57
59
  "value-producing data action before creating a chart or mark."
58
- );
60
+ ), { code: "incompatible-resource", resourceId: id });
59
61
  }
60
62
  return dataset;
61
63
  }
@@ -1,3 +1,5 @@
1
+ import { annotateError } from "../core/diagnostics.js";
2
+
1
3
  export function findLayer(program, id) {
2
4
  return program.semanticSpec.layers.find(layer => layer.id === id);
3
5
  }
@@ -12,7 +14,7 @@ export function hasLayer(program, id) {
12
14
 
13
15
  export function requireLayer(program, id, label = `Layer "${id}"`) {
14
16
  const layer = findLayer(program, id);
15
- if (layer === undefined) throw new Error(`${label} does not exist.`);
17
+ if (layer === undefined) throw annotateError(new Error(`${label} does not exist.`), { code: "missing-resource", resourceId: id });
16
18
  return layer;
17
19
  }
18
20
 
@@ -26,12 +28,12 @@ export function resolveEligibleLayer(program, {
26
28
  const candidates = program.semanticSpec.layers.filter(predicate);
27
29
  if (target !== undefined) {
28
30
  const selected = candidates.find(layer => layer.id === target);
29
- if (selected === undefined) throw new Error(`Unknown ${label} ${targetOption} "${target}".`);
31
+ if (selected === undefined) throw annotateError(new Error(`Unknown ${label} ${targetOption} "${target}".`), { code: findLayer(program, target) ? "incompatible-resource" : "missing-resource", resourceId: target, optionPath: targetOption });
30
32
  return selected;
31
33
  }
32
34
  const selected = candidates.find(layer => layer.id === current);
33
35
  if (selected !== undefined) return selected;
34
36
  if (candidates.length === 1) return candidates[0];
35
- if (candidates.length === 0) throw new Error(`${label} requires an eligible layer.`);
36
- throw new Error(`${label} ${targetOption} is ambiguous; provide ${targetOption}.`);
37
+ if (candidates.length === 0) throw annotateError(new Error(`${label} requires an eligible layer.`), { code: "missing-resource", optionPath: targetOption });
38
+ throw annotateError(new Error(`${label} ${targetOption} is ambiguous; provide ${targetOption}.`), { code: "ambiguous-resource", optionPath: targetOption, candidates: candidates.map(layer => layer.id) });
37
39
  }
@@ -0,0 +1,46 @@
1
+ import { findLayer } from "./layers.js";
2
+
3
+ export function ownedChildren(program, id) {
4
+ const config = program.markConfigs[id] ?? {};
5
+ return [
6
+ config.errorBar?.lowerCapId,
7
+ config.errorBar?.upperCapId,
8
+ config.errorBand?.lowerBoundaryId,
9
+ config.errorBand?.upperBoundaryId,
10
+ config.regression?.bandId,
11
+ config.regression?.lineId,
12
+ config.boxPlot?.whiskerId,
13
+ config.boxPlot?.medianId,
14
+ config.boxPlot?.outlierId,
15
+ config.gradientPlot?.centerId,
16
+ config.intervalPlot?.intervalId,
17
+ config.endpointPlot?.roles?.stemId,
18
+ config.endpointPlot?.roles?.startId,
19
+ config.endpointPlot?.roles?.connectorId,
20
+ ...(config.raincloudPlot?.ownedChildIds ?? [])
21
+ ].concat(
22
+ program.semanticSpec.layers
23
+ .filter(layer => layer.source === id)
24
+ .map(layer => layer.id)
25
+ ).concat(
26
+ program.semanticSpec.layers
27
+ .filter(layer =>
28
+ program.markConfigs[layer.id]?.statisticalReference?.source === id
29
+ )
30
+ .map(layer => layer.id)
31
+ ).filter(child => child !== undefined && child !== id && findLayer(program, child) !== undefined);
32
+ }
33
+
34
+ export function ownership(program) {
35
+ const ownerByChild = new Map();
36
+ for (const layer of program.semanticSpec.layers) {
37
+ for (const child of ownedChildren(program, layer.id)) {
38
+ if (program.markConfigs[child]?.statisticalReference !== undefined) {
39
+ continue;
40
+ }
41
+ ownerByChild.set(child, layer.id);
42
+ }
43
+ }
44
+ return ownerByChild;
45
+ }
46
+
@@ -1,21 +1,23 @@
1
+ import { annotateError } from "../core/diagnostics.js";
2
+
1
3
  export function findSemanticScale(program, id) {
2
4
  return program.semanticSpec.scales.find(scale => scale.id === id);
3
5
  }
4
6
 
5
7
  export function requireSemanticScale(program, id) {
6
8
  const scale = findSemanticScale(program, id);
7
- if (scale === undefined) throw new Error(`Unknown scale "${id}".`);
9
+ if (scale === undefined) throw annotateError(new Error(`Unknown scale "${id}".`), { code: "missing-resource", resourceId: id });
8
10
  return scale;
9
11
  }
10
12
 
11
13
  export function requireResolvedScale(program, id, type) {
12
- const scale = program.resolvedScales[id];
14
+ const scale = Object.hasOwn(program.resolvedScales, id) ? program.resolvedScales[id] : undefined;
13
15
  if (scale === undefined || (type !== undefined && scale.type !== type)) {
14
- throw new Error(
16
+ throw annotateError(new Error(
15
17
  type === undefined
16
18
  ? `Unknown resolved scale "${id}".`
17
19
  : `Expected resolved ${type} scale "${id}".`
18
- );
20
+ ), { code: scale === undefined ? "missing-resource" : "incompatible-resource", resourceId: id });
19
21
  }
20
22
  return scale;
21
23
  }
@@ -1,4 +1,5 @@
1
- export const DEFAULT_FONT_FAMILY = "sans-serif";
1
+ import { DEFAULT_FONT_FAMILY } from "../core/font.js";
2
+ export { DEFAULT_FONT_FAMILY };
2
3
 
3
4
  export const DEFAULT_POINT_RADIUS = 3;
4
5
 
package/src/version.js ADDED
@@ -0,0 +1,2 @@
1
+ // Must match package.json; enforced by the snapshot producer-version test.
2
+ export const packageVersion = "0.0.17";
@@ -0,0 +1,37 @@
1
+ import type { ChartProgram } from "./program.js";
2
+ import type { BasicChartProgram } from "./basic.js";
3
+
4
+ export interface AccessibleColumn {
5
+ readonly key: string;
6
+ readonly role: string;
7
+ readonly component: string;
8
+ readonly field?: string;
9
+ readonly aggregate?: string;
10
+ readonly unit?: "utc-milliseconds";
11
+ }
12
+ export interface AccessibleRow {
13
+ readonly component: string;
14
+ readonly series: Readonly<Record<string, unknown>>;
15
+ readonly values: Readonly<Record<string, unknown>>;
16
+ }
17
+ export interface AccessibleOwnerView {
18
+ readonly ownerId: string;
19
+ readonly markType: string;
20
+ readonly columns: readonly AccessibleColumn[];
21
+ readonly rows: readonly AccessibleRow[];
22
+ readonly units: Readonly<Record<string, "utc-milliseconds">>;
23
+ }
24
+ export interface AccessibleChildView {
25
+ readonly ownerId: string;
26
+ readonly kind: "composition-child";
27
+ readonly title: string | null;
28
+ readonly facet?: Readonly<Record<string, unknown>>;
29
+ readonly views: readonly AccessibleView[];
30
+ }
31
+ export type AccessibleView = AccessibleOwnerView | AccessibleChildView;
32
+ export interface AccessibleData {
33
+ readonly schemaVersion: 1;
34
+ readonly title: string | null;
35
+ readonly views: readonly AccessibleView[];
36
+ }
37
+ export function exportAccessibleData(program: ChartProgram | BasicChartProgram, options?: { readonly target?: string }): AccessibleData;
package/types/basic.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ChartProgram, BasicSeriesLayoutOptions } from "./program.js";
1
+ import type { ChartProgram, BasicSeriesLayoutOptions, CreateDataOptions } from "./program.js";
2
2
 
3
3
  export type {
4
4
  AxisLabelOptions,
@@ -17,6 +17,7 @@ export type {
17
17
  CompleteAxisOptions,
18
18
  CreateAxesOptions,
19
19
  CreateBarPlotOptions,
20
+ CreateDataOptions,
20
21
  CreateGridOptions,
21
22
  CreateGuidesOptions,
22
23
  CreateHeatmapOptions,
@@ -111,7 +112,8 @@ type RebindMethod<T> = T extends (...args: infer Args) => ChartProgram
111
112
 
112
113
  export type BasicChartProgram =
113
114
  Pick<ChartProgram, BasicStateKey> &
114
- { readonly [Key in BasicMethodKey]: RebindMethod<ChartProgram[Key]> } &
115
+ { readonly [Key in Exclude<BasicMethodKey, "createData">]: RebindMethod<ChartProgram[Key]> } &
116
+ { createData<Row extends object>(options: CreateDataOptions<Row>): BasicChartProgram } &
115
117
  { readonly layoutSeries: (options: BasicSeriesLayoutOptions) => BasicChartProgram };
116
118
 
117
119
  export function chart(): BasicChartProgram;
@@ -0,0 +1,15 @@
1
+ export type ErrorCode = "invalid-option" | "invalid-value" | "missing-resource" |
2
+ "ambiguous-resource" | "incompatible-resource" | "resource-in-use" |
3
+ "resource-limit" | "unsupported-format" | "action-failed";
4
+
5
+ export interface ErrorDetails {
6
+ readonly code: ErrorCode;
7
+ readonly operation?: string;
8
+ readonly optionPath?: string;
9
+ readonly resourceId?: string;
10
+ readonly candidates?: readonly string[];
11
+ readonly limit?: number;
12
+ readonly actual?: number;
13
+ }
14
+
15
+ export function getErrorDetails(error: unknown): ErrorDetails | undefined;
package/types/index.d.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  import type { ChartProgram, CompositionOptions } from "./program.js";
2
2
 
3
3
  export type {
4
+ TextMetricFontWeight,
5
+ TextMeasurement,
6
+ TextMetricsProfile,
7
+ ApplyTextMetricsOptions,
8
+ ReviseDataOptions,
4
9
  ActionOptions,
5
10
  AxisFormat,
6
11
  AxisFormatString,
@@ -0,0 +1,17 @@
1
+ import type { BasicChartProgram } from "./basic.js";
2
+ import type { ChartProgram, DatasetSchema } from "./program.js";
3
+ export type ProgramInput = ChartProgram | BasicChartProgram;
4
+ export interface ResourceRef { readonly kind: "data" | "mark" | "scale" | "coordinate" | "guide" | "canvas" | "composition"; readonly id: string; readonly childPath?: readonly string[]; }
5
+ export interface InspectionTarget { readonly kind: "data" | "mark" | "scale" | "coordinate" | "guide"; readonly id: string; readonly childPath?: readonly string[]; }
6
+ export interface Finding { readonly severity: "error" | "warning" | "info"; readonly code: string; readonly reason: string; readonly message: string; readonly resource?: ResourceRef; readonly optionPath?: string; }
7
+ export interface CheckResult { readonly name: string; readonly status: "not_run" | "passed" | "failed" | "not_applicable"; readonly evidencePaths: readonly string[]; readonly findings: readonly Finding[]; }
8
+ export interface ParameterDefinition { readonly path: string; readonly kind: "field" | "enum" | "number" | "string" | "boolean" | "range" | "array" | "object" | "resource"; readonly required: boolean; readonly active: boolean; readonly choices?: readonly (string | number | boolean | null)[]; readonly minimum?: number; readonly maximum?: number; readonly unit?: string; readonly fieldRole?: string; }
9
+ export interface ActionDescription { readonly version: 1; readonly action: string; readonly applicability: "supported" | "needs-input" | "incompatible" | "unsupported" | "unverified"; readonly parameterDefinitions: readonly ParameterDefinition[]; readonly requirements: readonly { readonly reason: string; readonly optionPath?: string }[]; readonly checks: readonly CheckResult[]; readonly findings: readonly Finding[]; }
10
+ export interface Change { readonly resource: ResourceRef; readonly operation: "add" | "remove" | "modify"; readonly effect: "data" | "binding" | "structure" | "scale" | "guide" | "style"; readonly roles: readonly string[]; }
11
+ export interface ProgramComparison { readonly version: 1; readonly equivalence: "equal" | "different" | "unknown"; readonly completeProgramComparison: boolean; readonly changes: readonly Change[]; readonly affected: readonly ResourceRef[]; readonly findings: readonly Finding[]; }
12
+ export interface OwnerInspection { readonly owner: ResourceRef; readonly grain: "item" | "series" | "composite" | "unknown"; readonly rawRows: number | null; readonly logicalDataItems: number | null; readonly drawablePrimitives: number | null; readonly visibleCandidates: number | null; readonly flags: readonly { readonly reason: "opacity-zero" | "zero-size" | "outside-clip" | "missing-skipped"; readonly count: number | null }[]; readonly bounds: Readonly<{x:number;y:number;width:number;height:number}> | null; readonly sourceRefs: readonly ResourceRef[]; readonly checks: readonly CheckResult[]; }
13
+ export interface ProgramInspection { readonly version: 1; readonly views: readonly OwnerInspection[]; readonly calculations: readonly unknown[]; readonly checks: readonly CheckResult[]; readonly findings: readonly Finding[]; readonly coverage: Readonly<{partial:boolean;unsupported:readonly ResourceRef[]}>; }
14
+ export function getDatasetSchema(program: ProgramInput, options: {readonly data:string;readonly childPath?:readonly string[]}): Readonly<{data:string;schema:DatasetSchema}>;
15
+ export function describeAction(program: ProgramInput, options: {readonly action:string;readonly target?:InspectionTarget;readonly options?:Readonly<Record<string,unknown>>}): ActionDescription;
16
+ export function comparePrograms(before: ProgramInput, after: ProgramInput, options?: {readonly target?:InspectionTarget}): ProgramComparison;
17
+ export function inspectProgram(program: ProgramInput, options?: {readonly target?:InspectionTarget}): ProgramInspection;
package/types/pdf.d.ts CHANGED
@@ -24,3 +24,12 @@ export function renderToPDF(
24
24
  program: Pick<ChartProgram, "graphicSpec">,
25
25
  options: PDFRenderOptions
26
26
  ): Promise<PDFRenderResult>;
27
+
28
+ export interface PDFBufferResult extends Omit<PDFRenderResult, "output"> {
29
+ readonly buffer: Uint8Array;
30
+ }
31
+
32
+ export function renderToPDFBuffer(
33
+ program: Pick<ChartProgram, "graphicSpec">,
34
+ options?: { metadata?: PDFMetadata }
35
+ ): Promise<PDFBufferResult>;
@@ -0,0 +1,7 @@
1
+ import type { ChartProgram } from "./program.js";
2
+ import type { BasicChartProgram } from "./basic.js";
3
+
4
+ export function serializeProgram(program: ChartProgram | BasicChartProgram): string;
5
+ export function deserializeProgram(text: string): ChartProgram;
6
+ export function serializeGraphic(program: Pick<ChartProgram, "graphicSpec">): string;
7
+ export function deserializeGraphic(text: string): Readonly<Pick<ChartProgram, "graphicSpec">>;
package/types/png.d.ts CHANGED
@@ -12,3 +12,12 @@ export function renderToPNG(
12
12
  program: Pick<ChartProgram, "graphicSpec">,
13
13
  options: { output: string; pixelRatio?: number }
14
14
  ): Promise<PNGRenderResult>;
15
+
16
+ export interface PNGBufferResult extends Omit<PNGRenderResult, "output"> {
17
+ readonly buffer: Uint8Array;
18
+ }
19
+
20
+ export function renderToPNGBuffer(
21
+ program: Pick<ChartProgram, "graphicSpec">,
22
+ options?: { pixelRatio?: number }
23
+ ): Promise<PNGBufferResult>;