Skip to content

Commit 86626b3

Browse files
committed
release(flutter-inspector): 0.1.1
Improve pub.dev score: expand pubspec description and document the public API with dartdoc comments.
1 parent e851842 commit 86626b3

3 files changed

Lines changed: 75 additions & 2 deletions

File tree

packages/flutter-inspector/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.1.1
2+
3+
- Expand pubspec description for pub.dev.
4+
- Add dartdoc comments to public API (`startSimDeckFlutterInspector`, `stopSimDeckFlutterInspector`, `SimDeckFlutterInspector`, `SimDeckFlutterInspectorOptions`, `SimDeckFlutterInspectorFailure`).
5+
16
## 0.1.0
27

38
- Initial release of `simdeck_flutter_inspector`.

packages/flutter-inspector/lib/simdeck_flutter_inspector.dart

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/// Debug-only Flutter runtime inspector for SimDeck.
2+
///
3+
/// Connects to the SimDeck server over WebSocket and publishes the live
4+
/// Flutter widget hierarchy along with render bounds, diagnostics properties,
5+
/// semantics metadata, and source locations when widget creation tracking is
6+
/// enabled.
7+
///
8+
/// Call [startSimDeckFlutterInspector] during app startup in debug builds to
9+
/// begin publishing; call [stopSimDeckFlutterInspector] to tear it down.
10+
library;
11+
112
import 'dart:async';
213
import 'dart:convert';
314
import 'dart:io' as io;
@@ -16,6 +27,19 @@ const int _maxHierarchyDepth = 64;
1627

1728
SimDeckFlutterInspector? _sharedInspector;
1829

30+
/// Starts the shared [SimDeckFlutterInspector] and connects to the SimDeck
31+
/// server.
32+
///
33+
/// Safe to call once at app startup in debug builds. Subsequent calls return
34+
/// the existing inspector instance without reconnecting.
35+
///
36+
/// - [host] / [port] / [path] / [secure] configure the SimDeck WebSocket
37+
/// endpoint. Defaults target `ws://127.0.0.1:4310/api/inspector/connect`.
38+
/// - [reconnect] keeps trying to reconnect when the SimDeck server is not yet
39+
/// available or drops the connection.
40+
/// - [sourceRoot] is the absolute path to the Flutter app's source directory.
41+
/// When Flutter reports relative source locations, the inspector resolves
42+
/// them against this root so consumers see absolute file paths.
1943
SimDeckFlutterInspector startSimDeckFlutterInspector({
2044
String host = '127.0.0.1',
2145
String path = '/api/inspector/connect',
@@ -42,13 +66,17 @@ SimDeckFlutterInspector startSimDeckFlutterInspector({
4266
return inspector;
4367
}
4468

69+
/// Stops the shared inspector started by [startSimDeckFlutterInspector] and
70+
/// releases its WebSocket and semantics resources.
4571
void stopSimDeckFlutterInspector() {
4672
_sharedInspector?.stop();
4773
_sharedInspector = null;
4874
}
4975

76+
/// Configuration for a [SimDeckFlutterInspector] connection.
5077
@immutable
5178
class SimDeckFlutterInspectorOptions {
79+
/// Creates options for connecting the inspector to the SimDeck server.
5280
const SimDeckFlutterInspectorOptions({
5381
this.host = '127.0.0.1',
5482
this.path = '/api/inspector/connect',
@@ -58,18 +86,41 @@ class SimDeckFlutterInspectorOptions {
5886
this.sourceRoot = '',
5987
});
6088

89+
/// Host of the SimDeck server. Defaults to the loopback address.
6190
final String host;
91+
92+
/// WebSocket path the inspector connects to on the SimDeck server.
6293
final String path;
94+
95+
/// Port of the SimDeck server.
6396
final int port;
97+
98+
/// Whether the inspector should keep retrying the WebSocket connection
99+
/// after a failure or drop.
64100
final bool reconnect;
101+
102+
/// Whether to use a TLS WebSocket (`wss`) and HTTPS for polling.
65103
final bool secure;
104+
105+
/// Absolute path to the Flutter app's source root.
106+
///
107+
/// Used to turn relative source locations reported by Flutter's widget
108+
/// creation tracking into absolute paths.
66109
final String sourceRoot;
67110
}
68111

112+
/// Runtime inspector that publishes the live Flutter widget hierarchy to
113+
/// SimDeck over WebSocket and responds to inspector commands.
114+
///
115+
/// Most apps should use [startSimDeckFlutterInspector] / [stopSimDeckFlutterInspector]
116+
/// to manage a single shared instance rather than constructing this directly.
69117
class SimDeckFlutterInspector {
118+
/// Creates an inspector with the given [options]. Use [start] to begin
119+
/// publishing.
70120
SimDeckFlutterInspector([SimDeckFlutterInspectorOptions? options])
71121
: options = options ?? const SimDeckFlutterInspectorOptions();
72122

123+
/// Connection options the inspector was created with.
73124
final SimDeckFlutterInspectorOptions options;
74125
final Expando<String> _ids = Expando<String>('simdeckFlutterInspectorId');
75126
final Expando<Object> _sourceLocations = Expando<Object>(
@@ -86,6 +137,11 @@ class SimDeckFlutterInspector {
86137
Map<String, Object?>? _metadata;
87138
SemanticsHandle? _semanticsHandle;
88139

140+
/// Starts publishing to SimDeck.
141+
///
142+
/// Opens the WebSocket connection, begins polling for inspector commands,
143+
/// and ensures Flutter semantics are enabled while the inspector is active.
144+
/// Calling [start] on an already-running inspector restarts it.
89145
void start() {
90146
stop();
91147
_started = true;
@@ -94,6 +150,8 @@ class SimDeckFlutterInspector {
94150
_startPolling();
95151
}
96152

153+
/// Stops publishing and releases the WebSocket, polling timer, and
154+
/// semantics handle. Safe to call when the inspector is not running.
97155
void stop() {
98156
_reconnectTimer?.cancel();
99157
_reconnectTimer = null;
@@ -1078,10 +1136,20 @@ class SimDeckFlutterInspector {
10781136
}
10791137
}
10801138

1139+
/// JSON-RPC style error raised when an inspector request cannot be served.
1140+
///
1141+
/// The [code] follows the inspector protocol's negative numeric error space
1142+
/// (e.g. `-32601` unknown method, `-32004` unknown view id). The [message] is
1143+
/// suitable for surfacing to inspector clients.
10811144
class SimDeckFlutterInspectorFailure implements Exception {
1145+
/// Creates a failure with the given protocol [code] and human-readable
1146+
/// [message].
10821147
const SimDeckFlutterInspectorFailure(this.code, this.message);
10831148

1149+
/// Inspector protocol error code.
10841150
final int code;
1151+
1152+
/// Human-readable error message returned to the inspector client.
10851153
final String message;
10861154

10871155
@override

packages/flutter-inspector/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: simdeck_flutter_inspector
2-
description: Debug-only Flutter runtime inspector for SimDeck.
3-
version: 0.1.0
2+
description: Debug-only runtime inspector that publishes the live Flutter widget hierarchy, render bounds, diagnostics, and semantics to the SimDeck dashboard.
3+
version: 0.1.1
44
homepage: https://simdeck.sh/inspector/flutter
55
repository: https://github.com/NativeScript/SimDeck
66

0 commit comments

Comments
 (0)