-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7aae1df
commit f831be0
Showing
14 changed files
with
235 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
abstract interface class HmrContract { | ||
void send(Map payload); | ||
Future<void> spawn(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:mineral/container.dart'; | ||
|
||
abstract interface class ScaffoldContract { | ||
File get entrypoint; | ||
Directory get rootDir; | ||
Directory get libDir; | ||
Directory? get binDir; | ||
Directory? get configDir; | ||
IocContainer get container; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:mineral/src/infrastructure/services/wss/websocket_message.dart'; | ||
|
||
abstract interface class RunningStrategy { | ||
FutureOr<void> init(); | ||
FutureOr<void> dispatch(WebsocketMessage message); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
lib/src/infrastructure/internals/wss/dispatchers/shard_data.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
lib/src/infrastructure/internals/wss/running_strategies/default_running_strategy.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'dart:async'; | ||
import 'dart:io'; | ||
import 'dart:isolate'; | ||
|
||
import 'package:mansion/mansion.dart'; | ||
import 'package:mineral/services.dart' as services; | ||
import 'package:mineral/src/domains/commons/kernel.dart'; | ||
import 'package:mineral/src/domains/commons/utils/file.dart'; | ||
import 'package:mineral/src/domains/contracts/wss/running_strategy.dart'; | ||
import 'package:mineral/src/infrastructure/services/wss/websocket_message.dart'; | ||
import 'package:path/path.dart' as path; | ||
|
||
final class DefaultRunningStrategy implements RunningStrategy { | ||
final KernelContract kernel; | ||
final FutureOr<void> Function() onStartup; | ||
|
||
DefaultRunningStrategy(this.kernel, this.onStartup) { | ||
kernel.logger.trace('Default strategy initialized'); | ||
} | ||
|
||
@override | ||
Future<void> init() async { | ||
if (Isolate.current.debugName == 'main') { | ||
final packageFile = File(path.join(Directory.current.path, 'pubspec.yaml')); | ||
final package = await packageFile.readAsYaml(); | ||
|
||
final coreVersion = package['dependencies']['mineral']; | ||
|
||
stdout.writeAnsiAll([ | ||
CursorPosition.reset, | ||
Clear.all, | ||
AsciiControl.lineFeed, | ||
SetStyles(Style.foreground(services.Logger.primaryColor), Style.bold), | ||
Print('Mineral v$coreVersion'), | ||
SetStyles.reset, | ||
AsciiControl.lineFeed, | ||
]); | ||
} | ||
|
||
onStartup(); | ||
} | ||
|
||
@override | ||
void dispatch(WebsocketMessage payload) { | ||
kernel.packetListener.dispatcher.dispatch(payload.content); | ||
} | ||
} |
Oops, something went wrong.