diff --git a/.gitignore b/.gitignore index 6270ae4b6..cc97ca946 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ build/ # Or the files created by dart2js. *.dart.js *.js.deps +*.js.map # Python generated files *.pyc diff --git a/pkgs/dart_services/lib/src/common.dart b/pkgs/dart_services/lib/src/common.dart index d2eda3bcd..fe9bc5c90 100644 --- a/pkgs/dart_services/lib/src/common.dart +++ b/pkgs/dart_services/lib/src/common.dart @@ -26,11 +26,8 @@ import 'main.dart' as entrypoint; Future main() async { registerPlugins(webPluginRegistrar); - await ui_web.bootstrapEngine( - runApp: () { - return entrypoint.main(); - }, - ); + await ui_web.bootstrapEngine(); + entrypoint.main(); } '''; diff --git a/pkgs/dartpad_ui/web/frame.html b/pkgs/dartpad_ui/web/frame.html index d7732e1aa..f115fdfa6 100644 --- a/pkgs/dartpad_ui/web/frame.html +++ b/pkgs/dartpad_ui/web/frame.html @@ -19,9 +19,9 @@ margin-top: 0; } - - + + diff --git a/pkgs/dartpad_ui/web/frame.js b/pkgs/dartpad_ui/web/frame.js index 95f034426..c4b007497 100644 --- a/pkgs/dartpad_ui/web/frame.js +++ b/pkgs/dartpad_ui/web/frame.js @@ -22,22 +22,16 @@ function messageHandler(e) { var obj = e.data; if (obj.command === 'execute') { - runFlutterApp(obj.js); + // TODO: Switch to using engineInitializer.initializeEngine(config). See + // https://docs.flutter.dev/development/platform-integration/web/initialization. + window.flutterConfiguration = { + canvasKitBaseUrl: obj.canvasKitBaseUrl + }; + + replaceJavaScript(obj.js); } }; -function runFlutterApp(compiledScript) { - var blob = new Blob([compiledScript], {type: 'text/javascript'}); - var url = URL.createObjectURL(blob); - _flutter.loader.loadEntrypoint({ - entrypointUrl: url, - onEntrypointLoaded: async function(engineInitializer) { - let appRunner = await engineInitializer.initializeEngine(); - appRunner.runApp(); - } - }); -} - window.addEventListener('load', function () { window.addEventListener('message', messageHandler, false); parent.postMessage({ 'sender': 'frame', 'type': 'ready' }, '*');