@blueprint-chart/lib 0.1.29 → 0.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/dsl/index.d.ts +1 -1
- package/dist/dsl/types.d.ts +6 -2
- package/dist/dsl/validate.d.ts +36 -0
- package/dist/enums.d.ts +7 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +3492 -3168
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ The simplest way to render a chart is the IIFE runtime, which auto-scans the doc
|
|
|
23
23
|
</script>
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
For programmatic use in an ES module project, the lib exposes the underlying primitives: `parse` (DSL → AST), `buildChartOptions` (AST → render options), `createFrame`/`createCanvas`, and the chart registry (`registerChart`, `getChart`). See [src/index.ts](https://github.com/blueprint-chart/blueprint-chart/blob/main/packages/lib/src/index.ts) for the full public API.
|
|
26
|
+
For programmatic use in an ES module project, the lib exposes the underlying primitives: `parse` (DSL → AST), `validateChart` (AST → `ValidationResult` with typed errors and warnings), `buildChartOptions` (AST → render options), `createFrame`/`createCanvas`, and the chart registry (`registerChart`, `getChart`). See [src/index.ts](https://github.com/blueprint-chart/blueprint-chart/blob/main/packages/lib/src/index.ts) for the full public API.
|
|
27
27
|
|
|
28
28
|
## DSL Grammar
|
|
29
29
|
|
|
@@ -37,7 +37,7 @@ ChartMember = DataBlock | Colorize | AreaFill | Annotation | Series | Scene | Pr
|
|
|
37
37
|
|
|
38
38
|
DataBlock = "data" "{" Property* "}"
|
|
39
39
|
Colorize = "colorize" String "{" Property* "}"
|
|
40
|
-
AreaFill = "
|
|
40
|
+
AreaFill = "area-fill" String String "{" Property* "}"
|
|
41
41
|
Annotation = "annotation" String "{" Property* "}"
|
|
42
42
|
Series = "series" String "{" Property* "}"
|
|
43
43
|
Scene = "scene" String "{" SceneMember* "}"
|
package/dist/dsl/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { parse } from './parser';
|
|
2
2
|
export { serialize } from './serializer';
|
|
3
|
-
export type { AnnotationNode, AreaFillNode, ChartNode, DataNode, ColorizeNode, HighlightNode, PropertyNode, SceneNode, SeriesNode,
|
|
3
|
+
export type { AnnotationNode, AreaFillNode, ChartNode, DataNode, ColorizeNode, HighlightNode, PropertyNode, SceneNode, SeriesNode, TransformNode } from './types';
|
package/dist/dsl/types.d.ts
CHANGED
|
@@ -5,6 +5,12 @@ export interface PropertyNode {
|
|
|
5
5
|
value: string | number;
|
|
6
6
|
isPercentage: boolean;
|
|
7
7
|
values?: (string | number)[];
|
|
8
|
+
/**
|
|
9
|
+
* Set when a data row's key was written as a quoted string and collides
|
|
10
|
+
* with the reserved `series` meta-row key. A quoted `"series"` row is a
|
|
11
|
+
* real data category; only the unquoted `series = ...` row names columns.
|
|
12
|
+
*/
|
|
13
|
+
quotedKey?: boolean;
|
|
8
14
|
}
|
|
9
15
|
export interface DataNode {
|
|
10
16
|
type: DslNodeType.Data;
|
|
@@ -68,8 +74,6 @@ export interface SceneNode {
|
|
|
68
74
|
series: SeriesNode[];
|
|
69
75
|
transforms: TransformNode[];
|
|
70
76
|
}
|
|
71
|
-
/** @deprecated Use SceneNode instead */
|
|
72
|
-
export type StepNode = SceneNode;
|
|
73
77
|
export interface TransformNode {
|
|
74
78
|
type: DslNodeType.Transform;
|
|
75
79
|
transformType: string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ChartNode } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* A single validation finding. `code` is a stable machine-readable identifier,
|
|
4
|
+
* `path` locates the offending node (dotted, scene-prefixed where relevant),
|
|
5
|
+
* `message` is human-readable, and `suggestion` is an optional nearest-match
|
|
6
|
+
* hint ("did you mean …").
|
|
7
|
+
*/
|
|
8
|
+
export interface ValidationIssue {
|
|
9
|
+
code: string;
|
|
10
|
+
path: string;
|
|
11
|
+
message: string;
|
|
12
|
+
suggestion?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ValidationResult {
|
|
15
|
+
valid: boolean;
|
|
16
|
+
errors: ValidationIssue[];
|
|
17
|
+
warnings: ValidationIssue[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Per-kind allowlists for annotation body property keys, derived from the keys
|
|
21
|
+
* convertAnnotations() in converter.ts actually reads for each kind. Anything
|
|
22
|
+
* not listed is silently ignored by the converter, so we flag it. This is what
|
|
23
|
+
* catches the `fromX`/`toX`-on-a-range bug.
|
|
24
|
+
*/
|
|
25
|
+
export declare const POINT_ANNOTATION_KEYS: Set<string>;
|
|
26
|
+
export declare const RANGE_ANNOTATION_KEYS: Set<string>;
|
|
27
|
+
export declare const FREE_ANNOTATION_KEYS: Set<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Validate a chart AST for value-level semantic problems that the renderer
|
|
30
|
+
* would otherwise swallow with silent fallbacks (devex-review finding 6).
|
|
31
|
+
*
|
|
32
|
+
* Returns errors (things that change or drop the user's intent) and warnings
|
|
33
|
+
* (currently none; reserved for softer signals). `valid` is true iff there are
|
|
34
|
+
* no errors.
|
|
35
|
+
*/
|
|
36
|
+
export declare function validateChart(ast: ChartNode): ValidationResult;
|
package/dist/enums.d.ts
CHANGED
|
@@ -76,6 +76,12 @@ export declare enum AnnotationKind {
|
|
|
76
76
|
Range = "range",
|
|
77
77
|
Free = "free"
|
|
78
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Maps an annotation kind to its DSL block keyword. Used by the serializer,
|
|
81
|
+
* the editor's DSL output, and the validator so the three never drift apart
|
|
82
|
+
* (e.g. `point` -> `annotation`, not the enum's raw value).
|
|
83
|
+
*/
|
|
84
|
+
export declare const ANNOTATION_KIND_KEYWORD: Record<AnnotationKind, string>;
|
|
79
85
|
export declare enum AnnotationAction {
|
|
80
86
|
Hide = "hide",
|
|
81
87
|
Show = "show"
|
|
@@ -183,7 +189,7 @@ export declare enum DslNodeType {
|
|
|
183
189
|
Data = "data",
|
|
184
190
|
Colorize = "colorize",
|
|
185
191
|
Highlight = "highlight",
|
|
186
|
-
AreaFill = "
|
|
192
|
+
AreaFill = "area-fill",
|
|
187
193
|
Annotation = "annotation",
|
|
188
194
|
Series = "series",
|
|
189
195
|
AnnotationVisibility = "annotation-visibility",
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { ChartType, AxisDirection, ScaleType, GridStyle, LabelPosition, LabelRotation, TickPosition, FrameSizing, CompassDirection, AnnotationLineStyle, StrokeStyle, AnnotationKind, AnnotationAction, RangeAnchor, Orientation, SymbolShape, SymbolShowOn, SymbolStyle, SortDirection, SortMode, LegendPosition, Anchor, ValueLabelPosition, CrosshairDirection, CrosshairStyle, StackMode, LineStyle, ChartOptionType, DirectLabelMode, Interpolation, DslNodeType, } from './enums';
|
|
2
|
+
export { ANNOTATION_KIND_KEYWORD } from './enums';
|
|
2
3
|
export type { ChartData, ChartOptions, ChartRenderer, ChartOptionDef, ChartTypeOptions, ChartTypeOptionKey, ColorizeConfig, HighlightConfig, AxisOptions, FrameOptions, AreaFillConfig, AnnotationConfig, PointAnnotationConfig, RangeAnnotationConfig, FreeAnnotationConfig, AnnotationLineConfig, LineSymbolConfig, SeriesOverride, Margin, } from './charts/types';
|
|
3
4
|
export { createFrame } from './charts/frame/frame';
|
|
4
5
|
export type { FrameElements } from './charts/frame/frame';
|
|
@@ -26,7 +27,9 @@ export type { CvdType, CvdIssue } from './charts/colorblind';
|
|
|
26
27
|
export { parse } from './dsl/parser';
|
|
27
28
|
export { serialize, compactSerialize } from './dsl/serializer';
|
|
28
29
|
export { propertyMap, extractChartTypeOptions, dataEntriesToString, extractSceneOverrides, convertColorizes, convertHighlights, convertAreaFills, convertAnnotations, convertSeriesOverrides } from './dsl/converter';
|
|
29
|
-
export type { AnnotationNode, AnnotationVisibilityNode, PointAnnotationNode, RangeAnnotationNode, FreeAnnotationNode, AreaFillNode, ChartNode, DataNode, ColorizeNode, HighlightNode, PropertyNode, SceneNode, SeriesNode,
|
|
30
|
+
export type { AnnotationNode, AnnotationVisibilityNode, PointAnnotationNode, RangeAnnotationNode, FreeAnnotationNode, AreaFillNode, ChartNode, DataNode, ColorizeNode, HighlightNode, PropertyNode, SceneNode, SeriesNode, TransformNode } from './dsl/types';
|
|
31
|
+
export { validateChart } from './dsl/validate';
|
|
32
|
+
export type { ValidationIssue, ValidationResult } from './dsl/validate';
|
|
30
33
|
export { samples } from './samples';
|
|
31
34
|
export type { ChartSample } from './samples';
|
|
32
35
|
export { renderBpc, renderChart, astToDefinition, resolveScene } from './render';
|