Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate DTDConnectionInfo and replace with a class that can handle separate private/exposed URIs #8291

Merged
merged 7 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/devtools_shared/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Deprecate `surveyActionTakenPropertyName`.
* Deprecate `apiGetSurveyShownCount` in favor of `SurveyApi.getSurveyShownCount`.
* Deprecate `apiIncrementSurveyShownCount` in favor of `SurveyApi.incrementSurveyShownCount`.
* Deprecate `DTDConnectionInfo` in favor of `DTDInfo` which supports tracking to URIs for DTD to better support web/remote environments.
* Deprecate `DTDConnectionInfo` in favor of `DTDInfo` which supports tracking two URIs for DTD to better support web/remote environments.
kenzieschmoll marked this conversation as resolved.
Show resolved Hide resolved

# 10.0.2
* Update dependency `web_socket_channel: '>=2.4.0 <4.0.0'`.
Expand Down
11 changes: 6 additions & 5 deletions packages/devtools_shared/lib/src/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
// found in the LICENSE file.

/// Describes an instance of the Dart Tooling Daemon.
@Deprecated('Use DTDInfo instead')
@Deprecated('Use DtdInfo instead')
typedef DTDConnectionInfo = ({String? uri, String? secret});

/// Information about a Dart Tooling Daemon instance.
class DTDInfo {
DTDInfo(
class DtdInfo {
DtdInfo(
this.localUri, {
Uri? exposedUri,
this.secret,
Expand All @@ -18,8 +18,9 @@ class DTDInfo {
///
/// This is usually a `http://localhost/` address that is accessible to tools
/// running in the same location as the DTD process. It may NOT be accessible
/// to frontends that may run in another location - for example the DevTools
/// frontend running in a browser (or VS Code UI) in a remote/web IDE session.
/// to frontends that run in another location - for example the DevTools
/// frontend running in a browser (or embedded in an IDE) in a remote/web IDE
/// session.
final Uri localUri;

/// The exposed URI for connecting to DTD from the frontend.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ExtensionsManager {
Future<void> serveAvailableExtensions(
String? rootFileUriString,
List<String> logs,
DTDInfo? dtd,
DtdInfo? dtd,
) async {
logs.add(
'ExtensionsManager.serveAvailableExtensions for '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ abstract class _ExtensionsApiHandler {
ServerApi api,
Map<String, String> queryParams,
ExtensionsManager extensionsManager,
DTDInfo? dtd,
DtdInfo? dtd,
) async {
final missingRequiredParams = ServerApi._checkRequiredParameters(
[ExtensionsApi.packageRootUriPropertyName],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ part of '../server_api.dart';
abstract class _DtdApiHandler {
static shelf.Response handleGetDtdUri(
ServerApi api,
DTDInfo? dtd,
DtdInfo? dtd,
) {
return ServerApi._encodeResponse(
{
// Always provide the exposed URI to callers of the web API.
// TODO(dantup): Should we add properties for both URIs and deprecate
// "uri"? Would anyone on the backend ever call this API?
DtdApi.uriPropertyName: dtd?.exposedUri,
},
api: api,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class Handler {
static Future<shelf.Response> handleNotifyForVmServiceConnection(
ServerApi api,
Map<String, String> queryParams,
DTDInfo? dtd,
DtdInfo? dtd,
) async {
final missingRequiredParams = ServerApi._checkRequiredParameters(
const [apiParameterValueKey, apiParameterVmServiceConnected],
Expand Down Expand Up @@ -152,7 +152,7 @@ abstract class Handler {
@visibleForTesting
static Future<shelf.Response> updateDtdWorkspaceRoots(
DartToolingDaemon dtd, {
required DTDInfo dtdConnectionInfo,
required DtdInfo dtdConnectionInfo,
required Uri rootFromVmService,
required bool connected,
required ServerApi api,
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools_shared/lib/src/server/server_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ServerApi {
required ExtensionsManager extensionsManager,
required DeeplinkManager deeplinkManager,
ServerApi? api,
DTDInfo? dtd,
DtdInfo? dtd,
}) {
api ??= ServerApi();
final queryParams = request.requestedUri.queryParameters;
Expand Down
4 changes: 2 additions & 2 deletions packages/devtools_shared/test/helpers/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:devtools_shared/devtools_shared.dart';
import 'package:path/path.dart' as path;

typedef TestDtdConnectionInfo = ({
DTDInfo? info,
DtdInfo? info,
Process? process,
});

Expand Down Expand Up @@ -43,7 +43,7 @@ Future<TestDtdConnectionInfo> startDtd() async {
}) {
completer.complete(
(
info: DTDInfo(Uri.parse(uri), secret: secret),
info: DtdInfo(Uri.parse(uri), secret: secret),
process: dtdProcess
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class _TestExtensionsManager extends ExtensionsManager {
Future<void> serveAvailableExtensions(
String? rootFileUriString,
List<String> logs,
DTDInfo? dtd,
DtdInfo? dtd,
) async {
await super.serveAvailableExtensions(rootFileUriString, logs, dtd);
throw Exception('Fake exception for test');
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools_shared/test/server/dtd_api_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void main() {
request,
extensionsManager: ExtensionsManager(),
deeplinkManager: FakeDeeplinkManager(),
dtd: DTDInfo(dtdUri),
dtd: DtdInfo(dtdUri),
);
expect(response.statusCode, HttpStatus.ok);
expect(
Expand Down
6 changes: 3 additions & 3 deletions packages/devtools_shared/test/server/general_api_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void main() {
group('General DevTools server API', () {
group(apiNotifyForVmServiceConnection, () {
Future<Response> sendNotifyRequest({
required DTDInfo? dtd,
required DtdInfo? dtd,
Map<String, Object?>? queryParameters,
// ignore: avoid-redundant-async, returning FutureOr.
}) async {
Expand Down Expand Up @@ -60,7 +60,7 @@ void main() {
'returns badRequest for invalid VM service argument',
() async {
final response = await sendNotifyRequest(
dtd: DTDInfo(Uri.parse('ws://dtd:uri'), secret: 'fake_secret'),
dtd: DtdInfo(Uri.parse('ws://dtd:uri'), secret: 'fake_secret'),
queryParameters: {
apiParameterValueKey: 'fake_uri',
apiParameterVmServiceConnected: 'true',
Expand All @@ -77,7 +77,7 @@ void main() {
'returns badRequest for invalid $apiParameterVmServiceConnected argument',
() async {
final response = await sendNotifyRequest(
dtd: DTDInfo(Uri.parse('ws://dtd:uri'), secret: 'fake_secret'),
dtd: DtdInfo(Uri.parse('ws://dtd:uri'), secret: 'fake_secret'),
queryParameters: {
apiParameterValueKey: 'ws://127.0.0.1:8181/LEpVqqD7E_Y=/ws',
apiParameterVmServiceConnected: 'bad_arg',
Expand Down
Loading