@@ -9,6 +9,8 @@ import 'package:mineral/container.dart';
99import 'package:mineral/contracts.dart' ;
1010import 'package:mineral/src/domains/services/packets/packet_dispatcher.dart' ;
1111import 'package:mineral/src/domains/services/wss/running_strategy.dart' ;
12+ import 'package:mineral/src/infrastructure/internals/packets/listeners/ready_packet.dart' ;
13+ import 'package:mineral/src/infrastructure/internals/packets/packet_type.dart' ;
1214import 'package:mineral/src/infrastructure/internals/wss/shard_message.dart' ;
1315import 'package:mineral/src/infrastructure/internals/wss/websocket_isolate_message_transfert.dart' ;
1416import 'package:mineral/src/infrastructure/services/wss/websocket_message.dart' ;
@@ -42,7 +44,8 @@ final class HmrRunningStrategy implements RunningStrategy {
4244 final dateTime = DateTime .now ();
4345
4446 Watcher (middlewares: [
45- IgnoreMiddleware (['~' , '.dart_tool' , '.git' , '.idea' , '.vscode' ]),
47+ IgnoreMiddleware (
48+ ['~' , '.dart_tool' , '.git' , '.idea' , '.vscode' , '.cursor' ]),
4649 IncludeMiddleware ([Glob ('**.dart' ), ..._watchedFiles]),
4750 DebounceMiddleware (Duration (milliseconds: 50 ), dateTime),
4851 ], onStart: handleStart, onFileChange: handleModify)
@@ -70,6 +73,12 @@ final class HmrRunningStrategy implements RunningStrategy {
7073 Future <void > dispatch (WebsocketMessage message) async {
7174 final strategy = _wss.config.encoding;
7275 final decoded = strategy.decode (message);
76+ final messageContent = decoded.content.serialize ();
77+
78+ if (messageContent case final Map <String , dynamic > json
79+ when json['t' ] == PacketType .ready.name) {
80+ ioc.bind (() => ReadyPacketMessage (decoded.content));
81+ }
7382
7483 await _runner.send (decoded.content.serialize ());
7584 }
@@ -123,8 +132,13 @@ final class HmrRunningStrategy implements RunningStrategy {
123132 }
124133
125134 sequences.add (AsciiControl .lineFeed);
126-
127135 stdout.writeAnsiAll (sequences);
136+
128137 await _runner.reload ();
138+
139+ if (ioc.resolveOrNull <ReadyPacketMessage >()
140+ case final ReadyPacketMessage packet) {
141+ await _runner.send (packet.message.serialize ());
142+ }
129143 }
130144}
0 commit comments