[web] Split initialization of the _flutter namespace and loader object. (flutter/engine#51294)
This makes it possible to more flexibly compose `{{flutter_js}}` and `{{flutter_build_options}}` in @eyebrowsoffire's [bootstrapping improvements PR](https://github.com/flutter/flutter/pull/144434).
[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
@@ -554,13 +554,21 @@ class BrowserPlatform extends PlatformPlugin {
|
||||
(CompileConfiguration config) => _makeBuildConfigString(scriptBase, config)
|
||||
).join(',\n');
|
||||
final String bootstrapScript = '''
|
||||
<script src="/flutter_js/flutter.js"></script>
|
||||
<script>
|
||||
// Define this before loading flutter.js to test PR flutter/engine#51294
|
||||
if (!window._flutter) {
|
||||
window._flutter = {};
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
_flutter.buildConfig = {
|
||||
builds: [
|
||||
$buildConfigsString
|
||||
]
|
||||
};
|
||||
</script>
|
||||
<script src="/flutter_js/flutter.js"></script>
|
||||
<script>
|
||||
_flutter.loader.load({
|
||||
config: {
|
||||
canvasKitBaseUrl: "/canvaskit/",
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
import { FlutterLoader } from './loader.js';
|
||||
|
||||
if (!window._flutter) {
|
||||
window._flutter = {
|
||||
loader: new FlutterLoader()
|
||||
};
|
||||
window._flutter = {};
|
||||
}
|
||||
|
||||
if (!window._flutter.loader) {
|
||||
window._flutter.loader = new FlutterLoader();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user