Skip to content

Commit fac7b75

Browse files
authored
refactor: slim machine API and remove built-in devtools (#33)
* refactor: remove built-in devtools layer * refactor(machine): simplify to command-only runtime API * refactor(api): tighten machine dispatch and public surface
1 parent 15d1092 commit fac7b75

46 files changed

Lines changed: 456 additions & 11678 deletions

Some content is hidden

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

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
## Unreleased
22

3+
### Changed
4+
5+
- Removed `package:unrouter/devtools.dart` and all built-in inspector/replay
6+
implementations to keep the package focused on core routing and machine APIs.
7+
- Simplified docs, tests, and example app to match the slimmer public surface.
8+
- Simplified machine API to command-first dispatch by removing declarative
9+
action/envelope layers and related schema contracts.
10+
- Tightened machine/controller public surface: merged dispatch entrypoint into
11+
`machine.dispatch<T>()`, removed `typedTimeline`, removed public
12+
`routeRequest` command, and stopped exporting controller lifecycle/composer
13+
APIs from `package:unrouter/unrouter.dart`.
14+
315
## 0.8.0
416

517
### Added

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A URL-first typed router for Flutter.
77
- Typed route objects via `RouteData`
88
- Route matching powered by `roux`
99
- Browser history integration via `unstory`
10-
- Core API by default, optional machine and devtools layers
10+
- Core API by default with an optional machine layer
1111

1212
## Install
1313

@@ -18,8 +18,7 @@ flutter pub add unrouter
1818
## Entrypoints
1919

2020
- `package:unrouter/unrouter.dart`: core routing API
21-
- `package:unrouter/machine.dart`: machine commands/actions
22-
- `package:unrouter/devtools.dart`: inspector/panel/replay tooling
21+
- `package:unrouter/machine.dart`: machine commands
2322

2423
Import `unrouter.dart` explicitly. Other entrypoints do not re-export core APIs.
2524

@@ -85,14 +84,11 @@ flutter pub get
8584
flutter run -d chrome
8685
```
8786

88-
Open `/debug` (or tap the bug icon) for inspector/panel/replay diagnostics.
89-
9087
## Docs
9188

9289
- Overview: `doc/README.md`
9390
- Getting started: `doc/getting_started.md`
9491
- Core routing: `doc/core_routing.md`
9592
- Machine API: `doc/machine_api.md`
96-
- Devtools: `doc/devtools.md`
97-
- Contracts: `doc/state_envelope.md`, `doc/machine_action_envelope_schema.md`
93+
- Contracts: `doc/state_envelope.md`
9894
- Benchmark guide: `doc/router_benchmarking.md`

doc/README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,11 @@ This folder contains user-facing guides and reference notes for `unrouter`.
88
and wire `MaterialApp.router`.
99
- [Core routing guide](core_routing.md): route definitions, guards, redirects,
1010
loaders, and shell branches.
11-
- [Machine API guide](machine_api.md): typed command/action dispatch and action
12-
envelope flows.
13-
- [Devtools guide](devtools.md): inspector widget, bridge, panel, replay, and
14-
`/debug` integration.
11+
- [Machine API guide](machine_api.md): typed command dispatch and machine
12+
timeline usage.
1513
- [Router benchmarking](router_benchmarking.md): behavior parity and performance
1614
comparison workflow.
1715

1816
## Reference contracts
1917

2018
- [State envelope](state_envelope.md): `history.state` format and compatibility.
21-
- [Machine action envelope schema](machine_action_envelope_schema.md): schema
22-
and event version contract for machine action envelopes.
23-
- [Replay persistence examples](replay_persistence_examples.md): storage adapter
24-
patterns for replay persistence.

doc/devtools.md

Lines changed: 0 additions & 79 deletions
This file was deleted.

doc/getting_started.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import 'package:unrouter/unrouter.dart';
1414

1515
Use additional entrypoints only when needed:
1616

17-
- `package:unrouter/machine.dart`: machine command/action APIs.
18-
- `package:unrouter/devtools.dart`: inspector, panel, and replay tooling.
17+
- `package:unrouter/machine.dart`: machine command APIs.
1918

2019
## Minimal typed router
2120

@@ -79,5 +78,4 @@ context.unrouter.pop(7);
7978
## Next reads
8079

8180
- Core behavior and advanced route features: `doc/core_routing.md`
82-
- Debug and diagnostics tooling: `doc/devtools.md`
83-
- Command/action machine API: `doc/machine_api.md`
81+
- Command machine API: `doc/machine_api.md`

doc/machine_action_envelope_schema.md

Lines changed: 0 additions & 101 deletions
This file was deleted.

doc/machine_api.md

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -13,66 +13,29 @@ import 'package:unrouter/unrouter.dart';
1313
final machine = context.unrouterMachineAs<AppRoute>();
1414
```
1515

16-
## Dispatch typed commands
16+
## Dispatch commands
1717

1818
```dart
19-
machine.dispatchTyped<void>(UnrouterMachineCommand.goUri(Uri(path: '/')));
20-
final pushed = machine.dispatchTyped<Future<Object?>>(
19+
machine.dispatch<void>(UnrouterMachineCommand.goUri(Uri(path: '/')));
20+
final pushed = machine.dispatch<Future<Object?>>(
2121
UnrouterMachineCommand.pushUri(Uri(path: '/users/42')),
2222
);
23-
final canBack = machine.dispatchTyped<bool>(UnrouterMachineCommand.back());
24-
```
25-
26-
## Dispatch declarative actions
27-
28-
```dart
29-
machine.dispatchAction<void>(
30-
UnrouterMachineAction.navigateRoute(
31-
const UserRoute(id: 7),
32-
mode: UnrouterMachineNavigateMode.replace,
33-
),
34-
);
35-
```
36-
37-
## Use action envelopes
38-
39-
Action envelopes expose explicit state for command outcomes:
40-
41-
- `accepted`
42-
- `rejected`
43-
- `deferred`
44-
- `completed`
45-
46-
```dart
47-
final envelope = machine.dispatchActionEnvelope<Future<int?>>(
48-
UnrouterMachineAction.pushRoute<UserRoute, int>(const UserRoute(id: 8)),
49-
);
50-
51-
if (envelope.isDeferred) {
52-
final value = await envelope.value;
53-
debugPrint('deferred value: $value');
54-
}
55-
56-
if (envelope.isRejected) {
57-
debugPrint('reject code: ${envelope.rejectCode}');
58-
debugPrint('reject failure: ${envelope.failure?.toJson()}');
59-
}
23+
final canBack = machine.dispatch<bool>(UnrouterMachineCommand.back());
6024
```
6125

6226
## Inspect machine state and transitions
6327

6428
```dart
6529
final machineState = machine.state;
6630
final rawTimeline = machine.timeline;
67-
final typedTimeline = machine.typedTimeline;
31+
final typedTimeline = machine.timeline
32+
.map((entry) => entry.typed)
33+
.toList(growable: false);
6834
```
6935

7036
Typed transitions classify payload shape by kind:
7137

72-
- `actionEnvelope`
7338
- `navigation`
7439
- `route`
7540
- `controller`
7641
- `generic`
77-
78-
See `doc/machine_action_envelope_schema.md` for schema compatibility details.

0 commit comments

Comments
 (0)