Unverified Commit bc1c1b2f authored by Anna Gringauze's avatar Anna Gringauze Committed by GitHub

Add flag to enable expression evaluation for web (#55003)

* Add flag to enable expression evaluation for web

Added flag --web-enable-expression-evaluation to flutter run commmand
that enables expression evaluation from IDEs for web target. Disabled
by default.

Helps https://github.com/flutter/flutter/issues/54520

* Update packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart
Co-Authored-By: 's avatarJonah Williams <jonahwilliams@google.com>
Co-authored-by: 's avatarJonah Williams <jonahwilliams@google.com>
parent b69b2a8c
...@@ -418,6 +418,11 @@ class _ResidentWebRunner extends ResidentWebRunner { ...@@ -418,6 +418,11 @@ class _ResidentWebRunner extends ResidentWebRunner {
directory: globals.fs.path.join(Cache.flutterRoot, 'packages', 'flutter_tools') directory: globals.fs.path.join(Cache.flutterRoot, 'packages', 'flutter_tools')
); );
final ExpressionCompiler expressionCompiler =
debuggingOptions.webEnableExpressionEvaluation
? WebExpressionCompiler(device.generator)
: null;
device.devFS = WebDevFS( device.devFS = WebDevFS(
hostname: effectiveHostname, hostname: effectiveHostname,
port: hostPort, port: hostPort,
...@@ -427,7 +432,7 @@ class _ResidentWebRunner extends ResidentWebRunner { ...@@ -427,7 +432,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
buildMode: debuggingOptions.buildInfo.mode, buildMode: debuggingOptions.buildInfo.mode,
enableDwds: _enableDwds, enableDwds: _enableDwds,
entrypoint: globals.fs.file(target).uri, entrypoint: globals.fs.file(target).uri,
expressionCompiler: WebExpressionCompiler(device.generator), expressionCompiler: expressionCompiler,
); );
final Uri url = await device.devFS.create(); final Uri url = await device.devFS.create();
if (debuggingOptions.buildInfo.isDebug) { if (debuggingOptions.buildInfo.isDebug) {
......
...@@ -382,6 +382,7 @@ class RunCommand extends RunCommandBase { ...@@ -382,6 +382,7 @@ class RunCommand extends RunCommandBase {
webEnableExposeUrl: featureFlags.isWebEnabled && boolArg('web-allow-expose-url'), webEnableExposeUrl: featureFlags.isWebEnabled && boolArg('web-allow-expose-url'),
webRunHeadless: featureFlags.isWebEnabled && boolArg('web-run-headless'), webRunHeadless: featureFlags.isWebEnabled && boolArg('web-run-headless'),
webBrowserDebugPort: browserDebugPort, webBrowserDebugPort: browserDebugPort,
webEnableExpressionEvaluation: featureFlags.isWebEnabled && boolArg('web-enable-expression-evaluation'),
vmserviceOutFile: stringArg('vmservice-out-file'), vmserviceOutFile: stringArg('vmservice-out-file'),
// Allow forcing fast-start to off to prevent doing more work on devices that // Allow forcing fast-start to off to prevent doing more work on devices that
// don't support it. // don't support it.
......
...@@ -610,6 +610,7 @@ class DebuggingOptions { ...@@ -610,6 +610,7 @@ class DebuggingOptions {
this.webUseSseForDebugProxy = true, this.webUseSseForDebugProxy = true,
this.webRunHeadless = false, this.webRunHeadless = false,
this.webBrowserDebugPort, this.webBrowserDebugPort,
this.webEnableExpressionEvaluation = false,
this.vmserviceOutFile, this.vmserviceOutFile,
this.fastStart = false, this.fastStart = false,
}) : debuggingEnabled = true; }) : debuggingEnabled = true;
...@@ -639,7 +640,8 @@ class DebuggingOptions { ...@@ -639,7 +640,8 @@ class DebuggingOptions {
hostVmServicePort = null, hostVmServicePort = null,
deviceVmServicePort = null, deviceVmServicePort = null,
vmserviceOutFile = null, vmserviceOutFile = null,
fastStart = false; fastStart = false,
webEnableExpressionEvaluation = false;
final bool debuggingEnabled; final bool debuggingEnabled;
...@@ -676,6 +678,9 @@ class DebuggingOptions { ...@@ -676,6 +678,9 @@ class DebuggingOptions {
/// The port the browser should use for its debugging protocol. /// The port the browser should use for its debugging protocol.
final int webBrowserDebugPort; final int webBrowserDebugPort;
/// Enable expression evaluation for web target
final bool webEnableExpressionEvaluation;
/// A file where the vmservice URL should be written after the application is started. /// A file where the vmservice URL should be written after the application is started.
final String vmserviceOutFile; final String vmserviceOutFile;
final bool fastStart; final bool fastStart;
......
...@@ -199,6 +199,11 @@ abstract class FlutterCommand extends Command<void> { ...@@ -199,6 +199,11 @@ abstract class FlutterCommand extends Command<void> {
'(https://chromedevtools.github.io/devtools-protocol/).', '(https://chromedevtools.github.io/devtools-protocol/).',
hide: true, hide: true,
); );
argParser.addFlag('web-enable-expression-evaluation',
defaultsTo: false,
help: 'Enables expression evaluation in the debugger.',
hide: hide,
);
} }
void usesTargetOption() { void usesTargetOption() {
......
...@@ -448,7 +448,7 @@ class FlutterRunTestDriver extends FlutterTestDriver { ...@@ -448,7 +448,7 @@ class FlutterRunTestDriver extends FlutterTestDriver {
'--machine', '--machine',
'-d', '-d',
if (chrome) if (chrome)
...<String>['chrome', '--web-run-headless'] ...<String>['chrome', '--web-run-headless', '--web-enable-expression-evaluation']
else else
'flutter-tester', 'flutter-tester',
], ],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment