Skip to content

Commit bf12efa

Browse files
authored
feat(mix_protocol): support contributed styler vocabularies (#1027)
1 parent f22a5ad commit bf12efa

43 files changed

Lines changed: 4850 additions & 665 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

melos.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ categories:
2828
flutter_projects:
2929
- packages/mix
3030
- packages/mix_protocol
31+
- packages/mix_chart_protocol
3132
- packages/mix_winds
3233
- packages/mix_winds/example
3334
- packages/mix_chart
@@ -46,8 +47,8 @@ scripts:
4647
description: Run all static analysis checks.
4748

4849
schema:inventory:
49-
run: melos exec --scope="mix_protocol" -- dart run tool/inventory_check.dart --check
50-
description: Verify mix_protocol inventory coverage decisions.
50+
run: melos exec --scope="mix_protocol" -- dart run tool/inventory_check.dart --check && melos exec --scope="mix_chart_protocol" -- dart run tool/inventory_check.dart
51+
description: Verify protocol vocabulary inventory coverage decisions.
5152

5253
analyze:dart:
5354
run: melos exec -c 4 -- dart analyze .
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## Unreleased
2+
3+
- Added the version-one `mix_chart` vocabulary with codecs and generated
4+
runtime and command-line inventory coverage for all 15 public chart stylers.
5+
- Added the ready-to-use `mixChartProtocol` composition and centralized styler
6+
metadata wiring without changing the chart v1 wire contract.
7+
8+
## 0.0.1-dev.0
9+
10+
- Initial unpublished sidecar package.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# mix_chart_protocol
2+
3+
`mix_chart_protocol` is the optional integration between the publishable
4+
`mix_chart` runtime and `mix_protocol`. It depends on both packages so
5+
`mix_chart` does not have to make serialization part of every chart app.
6+
7+
Use the ready-to-use protocol for the common core-plus-chart composition:
8+
9+
```dart
10+
import 'package:mix_chart_protocol/mix_chart_protocol.dart';
11+
12+
final encoded = mixChartProtocol.encodeStyle(chartStyle);
13+
```
14+
15+
Applications, servers, and tooling opt into this sidecar only when they cross a
16+
JSON boundary. `mix_chart` itself must not depend on it: Dart packages have no
17+
optional dependencies, and most chart rendering does not need the protocol.
18+
19+
Use the exported vocabulary directly only when combining charts with another
20+
package vocabulary:
21+
22+
```dart
23+
import 'package:mix_chart_protocol/mix_chart_protocol.dart';
24+
25+
final protocol = MixProtocol.compose([
26+
mixProtocolCoreVocabulary,
27+
mixChartVocabulary,
28+
anotherVocabulary,
29+
]);
30+
```
31+
32+
The sidecar re-exports the protocol API used by `mixChartProtocol`, so this
33+
integration needs only one protocol import.
34+
35+
The vocabulary uses the `mix_chart.v1.*` namespace and contains all 15 chart
36+
stylers, including shared nested stylers. Core stylers such as `TextStyler`
37+
inside chart labels recurse through the same composed union. Variants,
38+
modifiers, animation, property terms, tokens, and lenient decoding use the
39+
ordinary `mix_protocol` grammar.
40+
41+
This sidecar is unpublished while `mix_protocol` is unpublished. Keeping it
42+
separate preserves `mix_chart`'s existing publish contract and avoids exposing
43+
the private Ack implementation.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
include: ../../lints_with_dcm.yaml
2+
3+
dart_code_metrics:
4+
rules:
5+
avoid-inferrable-type-arguments:
6+
# Dart cannot infer the F-bounded Spec type from Styler alone.
7+
ignored-invocations:
8+
- MixProtocolStylerCodec.forStyler
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/// `mix_protocol` vocabulary for every public `mix_chart` styler.
2+
library;
3+
4+
import 'package:mix_protocol/mix_protocol.dart'
5+
show MixProtocol, mixProtocolCoreVocabulary;
6+
7+
import 'src/mix_chart_vocabulary.dart';
8+
9+
export 'package:mix_protocol/mix_protocol.dart';
10+
export 'src/mix_chart_vocabulary.dart' show mixChartVocabulary;
11+
12+
/// Ready-to-use protocol containing the core Mix and chart vocabularies.
13+
final MixProtocol mixChartProtocol = MixProtocol.compose([
14+
mixProtocolCoreVocabulary,
15+
mixChartVocabulary,
16+
]);

0 commit comments

Comments
 (0)