Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
b7eaad8b
Unverified
Commit
b7eaad8b
authored
May 27, 2022
by
David Iglesias
Committed by
GitHub
May 27, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[tool][web] Fix flutter.js in Safari 13 (#104761)
parent
812641b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
13 deletions
+26
-13
flutter_js.dart
...flutter_tools/lib/src/web/file_generators/flutter_js.dart
+26
-13
No files found.
packages/flutter_tools/lib/src/web/file_generators/flutter_js.dart
View file @
b7eaad8b
...
@@ -27,14 +27,23 @@ _flutter.loader = null;
...
@@ -27,14 +27,23 @@ _flutter.loader = null;
(function() {
(function() {
"use strict";
"use strict";
class FlutterLoader {
class FlutterLoader {
// TODO: Move the below methods to "#private" once supported by all the browsers
/**
// we support. In the meantime, we use the "revealing module" pattern.
* Creates a FlutterLoader, and initializes its instance methods.
*/
constructor() {
// TODO: Move the below methods to "#private" once supported by all the browsers
// we support. In the meantime, we use the "revealing module" pattern.
// Watchdog to prevent injecting the main entrypoint multiple times.
// Watchdog to prevent injecting the main entrypoint multiple times.
_scriptLoaded = null;
this.
_scriptLoaded = null;
// Resolver for the pending promise returned by loadEntrypoint.
// Resolver for the pending promise returned by loadEntrypoint.
_didCreateEngineInitializerResolve = null;
this._didCreateEngineInitializerResolve = null;
// Called by Flutter web.
// Bound to `this` now, so "this" is preserved across JS <-> Flutter jumps.
this.didCreateEngineInitializer = this._didCreateEngineInitializer.bind(this);
}
/**
/**
* Initializes the main.dart.js with/without serviceWorker.
* Initializes the main.dart.js with/without serviceWorker.
...
@@ -51,19 +60,19 @@ _flutter.loader = null;
...
@@ -51,19 +60,19 @@ _flutter.loader = null;
}
}
/**
/**
* Resolves the promise created by loadEntrypoint.
Called by Flutter.
* Resolves the promise created by loadEntrypoint.
*
Needs to be weirdly bound like it is, so "this" is preserved across
*
Called by Flutter through the public `didCreateEngineInitializer` method,
*
the JS <-> Flutter jumps
.
*
which is bound to the correct instance of the FlutterLoader on the page
.
* @param {*} engineInitializer
* @param {*} engineInitializer
*/
*/
didCreateEngineInitializer = (function
(engineInitializer) {
_didCreateEngineInitializer
(engineInitializer) {
if (typeof this._didCreateEngineInitializerResolve != "function") {
if (typeof this._didCreateEngineInitializerResolve != "function") {
console.warn("Do not call didCreateEngineInitializer by hand. Start with loadEntrypoint instead.");
console.warn("Do not call didCreateEngineInitializer by hand. Start with loadEntrypoint instead.");
}
}
this._didCreateEngineInitializerResolve(engineInitializer);
this._didCreateEngineInitializerResolve(engineInitializer);
// Remove th
is
method after it'
s
done
,
so
Flutter
Web
can
hot
restart
.
// Remove th
e public
method after it'
s
done
,
so
Flutter
Web
can
hot
restart
.
delete
this
.
didCreateEngineInitializer
;
delete
this
.
didCreateEngineInitializer
;
}
).
bind
(
this
);
}
_loadEntrypoint
(
entrypointUrl
)
{
_loadEntrypoint
(
entrypointUrl
)
{
if
(!
this
.
_scriptLoaded
)
{
if
(!
this
.
_scriptLoaded
)
{
...
@@ -71,7 +80,11 @@ _flutter.loader = null;
...
@@ -71,7 +80,11 @@ _flutter.loader = null;
let
scriptTag
=
document
.
createElement
(
"script"
);
let
scriptTag
=
document
.
createElement
(
"script"
);
scriptTag
.
src
=
entrypointUrl
;
scriptTag
.
src
=
entrypointUrl
;
scriptTag
.
type
=
"application/javascript"
;
scriptTag
.
type
=
"application/javascript"
;
this
.
_didCreateEngineInitializerResolve
=
resolve
;
// Cache the resolve, so it can be called from Flutter.
// Cache the resolve, so it can be called from Flutter.
// Note: Flutter hot restart doesn't re-create this promise, so this
// can only be called once. Instead, we need to model this as a stream
// of `engineCreated` events coming from Flutter that are handled by JS.
this
.
_didCreateEngineInitializerResolve
=
resolve
;
scriptTag
.
addEventListener
(
"error"
,
reject
);
scriptTag
.
addEventListener
(
"error"
,
reject
);
document
.
body
.
append
(
scriptTag
);
document
.
body
.
append
(
scriptTag
);
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment