Skip to content

Commit

Permalink
merge to main
Browse files Browse the repository at this point in the history
  • Loading branch information
devoncarew committed Jun 13, 2024
2 parents a3dbff2 + 16d3e8b commit cdcdc54
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .cloud_build/firebase/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:lts-alpine3.14 AS app-env
FROM node:lts-slim AS app-env

RUN npm install -g firebase-tools

Expand Down
22 changes: 11 additions & 11 deletions pkgs/dart_services/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ description: The backend service for DartPad.
publish_to: none

environment:
sdk: ^3.3.0
sdk: ^3.4.0

dependencies:
analysis_server_lib: ^0.2.5
analyzer: ^6.4.1
analyzer: ^6.5.0
args: ^2.5.0
bazel_worker: ^1.1.1
dartpad_shared: any
dartpad_shared: ^0.0.0
encrypt: ^5.0.3
google_generative_ai: ^0.4.0
google_generative_ai: ^0.4.3
http: ^1.2.1
json_annotation: any
json_annotation: ^4.9.0
logging: ^1.2.0
meta: ^1.13.0
meta: ^1.15.0
path: ^1.9.0
resp_client: ^1.2.0
shelf: ^1.4.1
Expand All @@ -25,15 +25,15 @@ dependencies:
yaml: ^3.1.2

dev_dependencies:
build_runner: ^2.4.9
build_runner: ^2.4.11
collection: ^1.18.0
dart_flutter_team_lints: ^3.0.0
dart_flutter_team_lints: ^3.1.0
grinder: ^0.9.5
json_serializable: any
json_serializable: ^6.8.0
package_config: ^2.1.0
shelf_router_generator: ^1.1.0
synchronized: ^3.1.0
test: ^1.25.2
synchronized: ^3.1.0+1
test: ^1.25.7
test_descriptor: ^2.0.1

dependency_overrides:
Expand Down
6 changes: 1 addition & 5 deletions pkgs/dart_services/test/server_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,7 @@ void main() {

expect(
result.dartdoc!.toLowerCase(),
anyOf(
// Support both pre and post Dart 3.3.0.
contains('prints a string representation'),
contains('prints an object to the console'),
),
contains('prints an object to the console'),
);
expect(result.containingLibraryName, 'dart:core');
expect(result.elementDescription, isNotNull);
Expand Down
10 changes: 5 additions & 5 deletions pkgs/dart_services/tool/dependencies/pub_dependencies_beta.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
"flame_splash_screen": "0.3.0",
"flame_tiled": "1.20.2",
"flutter_adaptive_scaffold": "0.1.11",
"flutter_bloc": "8.1.5",
"flutter_bloc": "8.1.6",
"flutter_hooks": "0.20.5",
"flutter_map": "7.0.0",
"flutter_markdown": "0.7.1",
"flutter_map": "7.0.1",
"flutter_markdown": "0.7.2",
"flutter_riverpod": "2.5.1",
"flutter_svg": "2.0.10+1",
"forge2d": "0.13.0",
Expand Down Expand Up @@ -80,7 +80,7 @@
"path_provider_platform_interface": "2.1.2",
"path_provider_windows": "2.2.1",
"petitparser": "6.0.2",
"platform": "3.1.4",
"platform": "3.1.5",
"plugin_platform_interface": "2.1.8",
"polylabel": "1.0.1",
"pool": "1.5.1",
Expand Down Expand Up @@ -130,7 +130,7 @@
"vector_graphics_codec": "1.1.11+1",
"vector_graphics_compiler": "1.1.11+1",
"vector_math": "2.1.4",
"video_player": "2.8.6",
"video_player": "2.8.7",
"video_player_android": "2.5.0",
"video_player_avfoundation": "2.6.1",
"video_player_platform_interface": "6.2.2",
Expand Down
23 changes: 11 additions & 12 deletions pkgs/dart_services/tool/dependencies/pub_dependencies_main.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,18 @@
"flame_splash_screen": "0.3.0",
"flame_tiled": "1.20.2",
"flutter_adaptive_scaffold": "0.1.11",
"flutter_bloc": "8.1.5",
"flutter_bloc": "8.1.6",
"flutter_hooks": "0.20.5",
"flutter_map": "7.0.0",
"flutter_markdown": "0.7.1",
"flutter_plugin_android_lifecycle": "2.0.20",
"flutter_map": "7.0.1",
"flutter_markdown": "0.7.2",
"flutter_riverpod": "2.5.1",
"flutter_svg": "2.0.10+1",
"forge2d": "0.13.0",
"frontend_server_client": "4.0.0",
"glob": "2.1.2",
"go_router": "14.1.4",
"google_fonts": "6.2.1",
"google_generative_ai": "0.4.2",
"google_generative_ai": "0.4.3",
"hooks_riverpod": "2.5.1",
"html": "0.15.4",
"http": "1.2.1",
Expand Down Expand Up @@ -81,7 +80,7 @@
"path_provider_platform_interface": "2.1.2",
"path_provider_windows": "2.2.1",
"petitparser": "6.0.2",
"platform": "3.1.4",
"platform": "3.1.5",
"plugin_platform_interface": "2.1.8",
"polylabel": "1.0.1",
"pool": "1.5.1",
Expand Down Expand Up @@ -112,14 +111,14 @@
"stream_channel": "2.1.2",
"string_scanner": "1.2.0",
"term_glyph": "1.2.1",
"test": "1.25.5",
"test_api": "0.7.1",
"test_core": "0.6.2",
"test": "1.25.7",
"test_api": "0.7.2",
"test_core": "0.6.4",
"tiled": "0.10.2",
"timezone": "0.9.3",
"typed_data": "1.3.2",
"unicode": "0.3.1",
"url_launcher": "6.2.6",
"url_launcher": "6.3.0",
"url_launcher_android": "6.3.3",
"url_launcher_ios": "6.3.0",
"url_launcher_linux": "3.1.1",
Expand All @@ -131,8 +130,8 @@
"vector_graphics_codec": "1.1.11+1",
"vector_graphics_compiler": "1.1.11+1",
"vector_math": "2.1.4",
"video_player": "2.8.6",
"video_player_android": "2.4.16",
"video_player": "2.8.7",
"video_player_android": "2.5.0",
"video_player_avfoundation": "2.6.1",
"video_player_platform_interface": "6.2.2",
"video_player_web": "2.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,18 @@
"flame_splash_screen": "0.3.0",
"flame_tiled": "1.20.2",
"flutter_adaptive_scaffold": "0.1.11",
"flutter_bloc": "8.1.5",
"flutter_bloc": "8.1.6",
"flutter_hooks": "0.20.5",
"flutter_map": "7.0.0",
"flutter_markdown": "0.7.1",
"flutter_plugin_android_lifecycle": "2.0.20",
"flutter_map": "7.0.1",
"flutter_markdown": "0.7.2",
"flutter_riverpod": "2.5.1",
"flutter_svg": "2.0.10+1",
"forge2d": "0.13.0",
"frontend_server_client": "4.0.0",
"glob": "2.1.2",
"go_router": "14.1.4",
"google_fonts": "6.2.1",
"google_generative_ai": "0.4.2",
"google_generative_ai": "0.4.3",
"hooks_riverpod": "2.5.1",
"html": "0.15.4",
"http": "1.2.1",
Expand Down Expand Up @@ -80,7 +79,7 @@
"path_provider_platform_interface": "2.1.2",
"path_provider_windows": "2.2.1",
"petitparser": "6.0.2",
"platform": "3.1.4",
"platform": "3.1.5",
"plugin_platform_interface": "2.1.8",
"polylabel": "1.0.1",
"pool": "1.5.1",
Expand Down Expand Up @@ -118,7 +117,7 @@
"timezone": "0.9.3",
"typed_data": "1.3.2",
"unicode": "0.3.1",
"url_launcher": "6.2.6",
"url_launcher": "6.3.0",
"url_launcher_android": "6.3.3",
"url_launcher_ios": "6.3.0",
"url_launcher_linux": "3.1.1",
Expand All @@ -130,8 +129,8 @@
"vector_graphics_codec": "1.1.11+1",
"vector_graphics_compiler": "1.1.11+1",
"vector_math": "2.1.4",
"video_player": "2.8.6",
"video_player_android": "2.4.16",
"video_player": "2.8.7",
"video_player_android": "2.5.0",
"video_player_avfoundation": "2.6.1",
"video_player_platform_interface": "6.2.2",
"video_player_web": "2.3.1",
Expand Down
8 changes: 4 additions & 4 deletions pkgs/dartpad_shared/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ description: Shared code between the DartPad frontend and backend.
publish_to: none

environment:
sdk: ^3.3.0
sdk: ^3.4.0

dependencies:
http: ^1.2.1
json_annotation: ^4.9.0
meta: ^1.14.0
meta: ^1.15.0

dev_dependencies:
build_runner: ^2.4.9
dart_flutter_team_lints: ^3.0.0
build_runner: ^2.4.11
dart_flutter_team_lints: ^3.1.0
json_serializable: ^6.8.0
7 changes: 5 additions & 2 deletions pkgs/dartpad_ui/lib/embed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'model.dart';

/// Listen to frame messages if embedded as an iFrame
/// to accept injected snippets.
void handleEmbedMessage(AppModel model) {
void handleEmbedMessage(AppServices services, {bool runOnInject = false}) {
final parent = web.window.parent;
if (parent == null) return;

Expand All @@ -16,7 +16,10 @@ void handleEmbedMessage(AppModel model) {
if (event.data case _SourceCodeMessage(:final type?, :final sourceCode?)
when type == 'sourceCode') {
if (sourceCode.isNotEmpty) {
model.sourceCodeController.text = sourceCode;
services.appModel.sourceCodeController.text = sourceCode;
if (runOnInject) {
services.performCompileAndRun();
}
}
}
}.toJS,
Expand Down
45 changes: 9 additions & 36 deletions pkgs/dartpad_ui/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ class _DartPadMainPageState extends State<DartPadMainPage>
fallbackSnippet: Samples.getDefault(type: 'dart'))
.then((value) {
// Start listening for inject code messages.
handleEmbedMessage(appModel);
handleEmbedMessage(appServices, runOnInject: widget.runOnLoad);
if (widget.runOnLoad) {
_performCompileAndRun();
appServices.performCompileAndRun();
}
});

Expand Down Expand Up @@ -321,7 +321,7 @@ class _DartPadMainPageState extends State<DartPadMainPage>
appModel: appModel,
appServices: appServices,
onFormat: _handleFormatting,
onCompileAndRun: _performCompileAndRun,
onCompileAndRun: appServices.performCompileAndRun,
key: _editorKey,
);

Expand Down Expand Up @@ -473,10 +473,14 @@ class _DartPadMainPageState extends State<DartPadMainPage>
child: CallbackShortcuts(
bindings: <ShortcutActivator, VoidCallback>{
keys.runKeyActivator1: () {
if (!appModel.compilingBusy.value) _performCompileAndRun();
if (!appModel.compilingBusy.value) {
appServices.performCompileAndRun();
}
},
keys.runKeyActivator2: () {
if (!appModel.compilingBusy.value) _performCompileAndRun();
if (!appModel.compilingBusy.value) {
appServices.performCompileAndRun();
}
},
// keys.findKeyActivator: () {
// // TODO:
Expand Down Expand Up @@ -537,37 +541,6 @@ class _DartPadMainPageState extends State<DartPadMainPage>
}
}

Future<void> _performCompileAndRun() async {
final source = appModel.sourceCodeController.text;
final progress =
appModel.editorStatus.showMessage(initialText: 'Compiling…');

try {
final response =
await appServices.compileDDC(CompileRequest(source: source));
appModel.clearConsole();
appServices.executeJavaScript(
response.result,
modulesBaseUrl: response.modulesBaseUrl,
engineVersion: appModel.runtimeVersions.value?.engineVersion,
dartSource: source,
);
} catch (error) {
appModel.clearConsole();

appModel.editorStatus.showToast('Compilation failed');

if (error is ApiRequestError) {
appModel.appendLineToConsole(error.message);
appModel.appendLineToConsole(error.body);
} else {
appModel.appendLineToConsole('$error');
}
} finally {
progress.close();
}
}

void _handleRunStarted() {
setState(() {
// Switch to the application output tab.]
Expand Down
34 changes: 32 additions & 2 deletions pkgs/dartpad_ui/lib/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,36 @@ class AppServices {
appModel.appReady.value = true;
}

Future<void> performCompileAndRun() async {
final source = appModel.sourceCodeController.text;
final progress =
appModel.editorStatus.showMessage(initialText: 'Compiling…');

try {
final response = await _compileDDC(CompileRequest(source: source));
appModel.clearConsole();
_executeJavaScript(
response.result,
modulesBaseUrl: response.modulesBaseUrl,
engineVersion: appModel.runtimeVersions.value?.engineVersion,
dartSource: source,
);
} catch (error) {
appModel.clearConsole();

appModel.editorStatus.showToast('Compilation failed');

if (error is ApiRequestError) {
appModel.appendLineToConsole(error.message);
appModel.appendLineToConsole(error.body);
} else {
appModel.appendLineToConsole('$error');
}
} finally {
progress.close();
}
}

Future<FormatResponse> format(SourceRequest request) async {
try {
appModel.formattingBusy.value = true;
Expand All @@ -335,7 +365,7 @@ class AppServices {
}
}

Future<CompileDDCResponse> compileDDC(CompileRequest request) async {
Future<CompileDDCResponse> _compileDDC(CompileRequest request) async {
try {
appModel.compilingBusy.value = true;
return await services.compileDDC(request);
Expand Down Expand Up @@ -363,7 +393,7 @@ class AppServices {
_editorService = editorService;
}

void executeJavaScript(
void _executeJavaScript(
String javaScript, {
required String dartSource,
String? modulesBaseUrl,
Expand Down
Loading

0 comments on commit cdcdc54

Please sign in to comment.