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

Revert "Use flutter.js bootstrapping" #2959

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ build/
# Or the files created by dart2js.
*.dart.js
*.js.deps
*.js.map

# Python generated files
*.pyc
Expand Down
7 changes: 2 additions & 5 deletions pkgs/dart_services/lib/src/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ import 'main.dart' as entrypoint;

Future<void> main() async {
registerPlugins(webPluginRegistrar);
await ui_web.bootstrapEngine(
runApp: () {
return entrypoint.main();
},
);
await ui_web.bootstrapEngine();
entrypoint.main();
}
''';

Expand Down
4 changes: 2 additions & 2 deletions pkgs/dartpad_ui/web/frame.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
margin-top: 0;
}
</style>
<script src="require.js"></script>
<script src="flutter.js"></script>
<script src="frame.js"></script>
<script src="require.js"></script>
<script id="compiled-script"></script>
</head>

<body>
Expand Down
20 changes: 7 additions & 13 deletions pkgs/dartpad_ui/web/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }, '*');
Expand Down
Loading