Skip to content

Commit

Permalink
Switch to conditional import that works with wasm (#6526)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo authored Oct 13, 2023
1 parent 624ad87 commit f57b036
Show file tree
Hide file tree
Showing 21 changed files with 27 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import 'package:devtools_app_shared/utils.dart';
import 'package:devtools_extensions/api.dart';
import 'package:devtools_shared/devtools_extensions.dart';

import '_controller_desktop.dart' if (dart.library.html) '_controller_web.dart';
import '_controller_desktop.dart'
if (dart.library.js_interop) '_controller_web.dart';

EmbeddedExtensionControllerImpl createEmbeddedExtensionController(
DevToolsExtensionConfig config,
Expand Down
3 changes: 1 addition & 2 deletions packages/devtools_app/lib/src/extensions/embedded/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import 'package:flutter/material.dart';

import '../../shared/analytics/analytics.dart' as ga;
import '../../shared/analytics/constants.dart' as gac;

import '_view_desktop.dart' if (dart.library.html) '_view_web.dart';
import '_view_desktop.dart' if (dart.library.js_interop) '_view_web.dart';
import 'controller.dart';

/// A widget that displays a DevTools extension in an embedded iFrame.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import 'package:flutter/material.dart';

import '../../../../../shared/analytics/constants.dart' as gac;
import '../../../../../shared/common_widgets.dart';
import '_perfetto_desktop.dart' if (dart.library.html) '_perfetto_web.dart';
import '_perfetto_desktop.dart'
if (dart.library.js_interop) '_perfetto_web.dart';
import 'perfetto_controller.dart';

class EmbeddedPerfetto extends StatelessWidget {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import '../../../../../shared/primitives/utils.dart';
import '../../../performance_controller.dart';
import '../timeline_events_controller.dart';
import '_perfetto_controller_desktop.dart'
if (dart.library.html) '_perfetto_controller_web.dart';
if (dart.library.js_interop) '_perfetto_controller_web.dart';
import 'perfetto_event_processor.dart';

PerfettoControllerImpl createPerfettoController(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

export '_analytics_stub.dart' if (dart.library.html) '_analytics_web.dart';
export '_analytics_stub.dart'
if (dart.library.js_interop) '_analytics_web.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'dart:async';
import 'package:flutter/foundation.dart';

import '_analytics_controller_stub.dart'
if (dart.library.html) '_analytics_controller_web.dart';
if (dart.library.js_interop) '_analytics_controller_web.dart';

Future<AnalyticsController> get analyticsController async =>
await devToolsAnalyticsController;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:flutter/rendering.dart';

import '../../primitives/utils.dart';
import '_drag_and_drop_stub.dart'
if (dart.library.html) '_drag_and_drop_web.dart'
if (dart.library.js_interop) '_drag_and_drop_web.dart'
if (dart.library.io) '_drag_and_drop_desktop.dart';

abstract class DragAndDropManager {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// found in the LICENSE file.

import '_file_stub.dart'
if (dart.library.html) '_file_web.dart'
if (dart.library.js_interop) '_file_web.dart'
if (dart.library.io) '_file_desktop.dart';

abstract class FileIO {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import '../../../framework/framework_core.dart';
import '_framework_initialize_stub.dart'
if (dart.library.html) '_framework_initialize_web.dart'
if (dart.library.js_interop) '_framework_initialize_web.dart'
if (dart.library.io) '_framework_initialize_desktop.dart';

Future<void> initializeFramework() async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
// in the LICENSE file.

export 'host_platform_stub.dart'
if (dart.library.html) 'host_platform_web.dart'
if (dart.library.js_interop) 'host_platform_web.dart'
if (dart.library.io) 'host_platform_desktop.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import '../../primitives/simple_items.dart';
import '../../primitives/utils.dart';
import '../../screen.dart';
import '_export_stub.dart'
if (dart.library.html) '_export_web.dart'
if (dart.library.js_interop) '_export_web.dart'
if (dart.library.io) '_export_desktop.dart';

const nonDevToolsFileMessage = 'The imported file is not a Dart DevTools file.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:url_launcher/url_launcher.dart' as url_launcher;

import '../../globals.dart';
import '_launch_url_stub.dart'
if (dart.library.html) '_launch_url_web.dart'
if (dart.library.js_interop) '_launch_url_web.dart'
if (dart.library.io) '_launch_url_desktop.dart';

Future<void> launchUrl(String url) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
// found in the LICENSE file.

export 'allowed_error_default.dart'
if (dart.library.html) 'allowed_error_html.dart';
if (dart.library.js_interop) 'allowed_error_html.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// found in the LICENSE file.

export 'logger_default.dart'
if (dart.library.html) 'logger_html.dart'
if (dart.library.js_interop) 'logger_html.dart'
if (dart.library.io) 'logger_io.dart';

enum LogLevel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
// in the LICENSE file.

export 'notifications_stub.dart'
if (dart.library.html) 'notifications_web.dart'
if (dart.library.js_interop) 'notifications_web.dart'
if (dart.library.io) 'notifications_desktop.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file.

export 'post_message_stub.dart' if (dart.library.html) 'post_message_web.dart';
export 'post_message_stub.dart'
if (dart.library.js_interop) 'post_message_web.dart';

class PostMessageEvent {
PostMessageEvent({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file.

export '_server_stub.dart' if (dart.library.html) '_server_web.dart';
export '_server_stub.dart' if (dart.library.js_interop) '_server_web.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'dart:io' as io;
import 'package:devtools_app/src/shared/diagnostics/diagnostics_node.dart';
import 'package:flutter_test/flutter_test.dart';
import '_golden_matcher_io.dart'
if (dart.library.html) '_golden_matcher_web.dart' as golden_matcher;
if (dart.library.js_interop) '_golden_matcher_web.dart' as golden_matcher;

RemoteDiagnosticsNode? findNodeMatching(
RemoteDiagnosticsNode node,
Expand Down
3 changes: 2 additions & 1 deletion packages/devtools_app_shared/lib/src/ui/theme/ide_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import 'package:flutter/widgets.dart';

import 'theme.dart';

export '_ide_theme_desktop.dart' if (dart.library.html) '_ide_theme_web.dart';
export '_ide_theme_desktop.dart'
if (dart.library.js_interop) '_ide_theme_web.dart';

/// IDE-supplied theming.
final class IdeTheme {
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools_app_shared/lib/src/utils/url/url.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file.

export '_url_stub.dart' if (dart.library.html) '_url_web.dart';
export '_url_stub.dart' if (dart.library.js_interop) '_url_web.dart';
3 changes: 2 additions & 1 deletion packages/devtools_shared/lib/src/sse/sse_shim.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
// found in the LICENSE file.

export '_fake_sse.dart'
if (dart.library.html) 'package:sse/client/sse_client.dart' show SseClient;
if (dart.library.js_interop) 'package:sse/client/sse_client.dart'
show SseClient;

0 comments on commit f57b036

Please sign in to comment.