Skip to content

Commit 5dbb30e

Browse files
authored
Support hot reload over websocket (#2616)
* renamed DWDS injector parameter * updated chromeProxyService to perform hotreload with websockets * updated changelog * applied dart format * remove newline in changelog * updated error message * implemented _performWebSocketFetchLibrariesForHotReload * applied dart format * reverted code to remove fetchLibrariesForHotReload websocket logic * applied dart format
1 parent 1ea8462 commit 5dbb30e

13 files changed

+1640
-615
lines changed

dwds/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## 24.3.11-wip
22

3+
- Added WebSocket-based hot reload support: `reloadSources` in `ChromeProxyService` and `DevHandler` now handle hot reload requests and responses over WebSockets.
4+
- Refactored the injected client to use a reusable function for handling hot reload requests and responses over WebSockets.
5+
36
## 24.3.10
47

58
- Disabled breakpoints on changed files in a hot reload. They currently do not

dwds/lib/data/hot_reload_request.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
library hot_reload_request;
6+
7+
import 'package:built_value/built_value.dart';
8+
import 'package:built_value/serializer.dart';
9+
10+
part 'hot_reload_request.g.dart';
11+
12+
/// A request to hot reload the application.
13+
abstract class HotReloadRequest
14+
implements Built<HotReloadRequest, HotReloadRequestBuilder> {
15+
static Serializer<HotReloadRequest> get serializer =>
16+
_$hotReloadRequestSerializer;
17+
18+
/// A unique identifier for this request.
19+
String get id;
20+
21+
HotReloadRequest._();
22+
factory HotReloadRequest([void Function(HotReloadRequestBuilder) updates]) =
23+
_$HotReloadRequest;
24+
}

dwds/lib/data/hot_reload_request.g.dart

Lines changed: 151 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
library hot_reload_response;
6+
7+
import 'package:built_value/built_value.dart';
8+
import 'package:built_value/serializer.dart';
9+
10+
part 'hot_reload_response.g.dart';
11+
12+
/// A response to a hot reload request.
13+
abstract class HotReloadResponse
14+
implements Built<HotReloadResponse, HotReloadResponseBuilder> {
15+
static Serializer<HotReloadResponse> get serializer =>
16+
_$hotReloadResponseSerializer;
17+
18+
/// The unique identifier matching the request.
19+
String get id;
20+
21+
/// Whether the hot reload succeeded on the client.
22+
bool get success;
23+
24+
/// An optional error message if success is false.
25+
@BuiltValueField(wireName: 'error')
26+
String? get errorMessage;
27+
28+
HotReloadResponse._();
29+
factory HotReloadResponse([void Function(HotReloadResponseBuilder) updates]) =
30+
_$HotReloadResponse;
31+
}

0 commit comments

Comments
 (0)