Skip to content

Commit 5c805f1

Browse files
authored
Updated DWDS to include a boolean flag that enables debugging support when set to true (#2601)
* updated Dwds with bool that only enableDebuggingSupport when set to true * updated Changelog * formatted file * updated dwds version in pubspec to 24.3.8 * updated version.dart to 24.3.8 * updated docstring for DWDSInjector class * updated docstring for DWDSInjector class * modified docstring
1 parent 302b6db commit 5c805f1

File tree

5 files changed

+40
-13
lines changed

5 files changed

+40
-13
lines changed

Diff for: dwds/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 24.3.8
2+
3+
- Updated DWDS to include a boolean flag that enables debugging support only when set to true. [#60289](https://github.com/dart-lang/sdk/issues/60289)
4+
15
## 24.3.7
26

37
- The registered extension `reassemble` is now no longer called when calling

Diff for: dwds/lib/dart_web_debug_service.dart

+5-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class Dwds {
6666
required Stream<BuildResult> buildResults,
6767
required ConnectionProvider chromeConnection,
6868
required ToolConfiguration toolConfiguration,
69+
bool enableDebuggingSupport = true,
6970
}) async {
7071
globalToolConfiguration = toolConfiguration;
7172
final debugSettings = toolConfiguration.debugSettings;
@@ -117,7 +118,10 @@ class Dwds {
117118
_logger.info('Serving DevTools at $uri\n');
118119
}
119120

120-
final injected = DwdsInjector(extensionUri: extensionUri);
121+
final injected = DwdsInjector(
122+
extensionUri: extensionUri,
123+
enableDebuggingSupport: enableDebuggingSupport,
124+
);
121125

122126
final devHandler = DevHandler(
123127
chromeConnection,

Diff for: dwds/lib/src/handlers/injector.dart

+29-10
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,29 @@ const mainExtensionMarker = '/* MAIN_EXTENSION_MARKER */';
2626

2727
const _clientScript = 'dwds/src/injected/client';
2828

29-
/// Handles injecting the DWDS client and embedding debugging related
30-
/// information.
29+
/// This class is responsible for modifying the served JavaScript files
30+
/// to include the injected DWDS client, enabling debugging capabilities
31+
/// and source mapping when running in a browser environment.
32+
///
33+
/// The `_enableDebuggingSupport` flag determines whether debugging-related
34+
/// functionality should be included:
35+
/// - When `true`, the DWDS client is injected, enabling debugging features.
36+
/// - When `false`, debugging support is disabled, meaning the application will
37+
/// run without debugging.
38+
///
39+
/// This separation allows for scenarios where debugging is not needed or
40+
/// should be explicitly avoided.
3141
class DwdsInjector {
3242
final Future<String>? _extensionUri;
3343
final _devHandlerPaths = StreamController<String>();
3444
final _logger = Logger('DwdsInjector');
45+
final bool _enableDebuggingSupport;
3546

36-
DwdsInjector({Future<String>? extensionUri}) : _extensionUri = extensionUri;
47+
DwdsInjector({
48+
Future<String>? extensionUri,
49+
bool enableDebuggingSupport = true,
50+
}) : _extensionUri = extensionUri,
51+
_enableDebuggingSupport = enableDebuggingSupport;
3752

3853
/// Returns the embedded dev handler paths.
3954
///
@@ -95,13 +110,17 @@ class DwdsInjector {
95110
await globalToolConfiguration.loadStrategy.trackEntrypoint(
96111
entrypoint,
97112
);
98-
body = await _injectClientAndHoistMain(
99-
body,
100-
appId,
101-
devHandlerPath,
102-
entrypoint,
103-
await _extensionUri,
104-
);
113+
// If true, inject the debugging client and hoist the main function
114+
// to enable debugging support.
115+
if (_enableDebuggingSupport) {
116+
body = await _injectClientAndHoistMain(
117+
body,
118+
appId,
119+
devHandlerPath,
120+
entrypoint,
121+
await _extensionUri,
122+
);
123+
}
105124
body += await globalToolConfiguration.loadStrategy.bootstrapFor(
106125
entrypoint,
107126
);

Diff for: dwds/lib/src/version.dart

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dwds/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: dwds
22
# Every time this changes you need to run `dart run build_runner build`.
3-
version: 24.3.7
3+
version: 24.3.8
44
description: >-
55
A service that proxies between the Chrome debug protocol and the Dart VM
66
service protocol.

0 commit comments

Comments
 (0)