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
3bf79607
Unverified
Commit
3bf79607
authored
Jan 23, 2023
by
Mouad Debbar
Committed by
GitHub
Jan 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[web] Fix paths fetched by flutter.js (#118684)
parent
bd7bee0f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
3 deletions
+29
-3
flutter_js.dart
...flutter_tools/lib/src/web/file_generators/flutter_js.dart
+17
-3
web_test.dart
...ols/test/general.shard/build_system/targets/web_test.dart
+12
-0
No files found.
packages/flutter_tools/lib/src/web/file_generators/flutter_js.dart
View file @
3bf79607
...
...
@@ -20,6 +20,21 @@ _flutter.loader = null;
(function () {
"use strict";
const baseUri = ensureTrailingSlash(getBaseURI());
function getBaseURI() {
const base = document.querySelector("base");
return (base && base.getAttribute("href")) || "";
}
function ensureTrailingSlash(uri) {
if (uri == "") {
return uri;
}
return uri.endsWith("/") ? uri : `
${uri}
/`;
}
/**
* Wraps `promise` in a timeout of the given `duration` in ms.
*
...
...
@@ -120,8 +135,7 @@ _flutter.loader = null;
}
const
{
serviceWorkerVersion
,
serviceWorkerUrl
=
"flutter_service_worker.js?v="
+
serviceWorkerVersion
,
serviceWorkerUrl
=
`$
{
baseUri
}
flutter_service_worker
.
js
?
v
=
$
{
serviceWorkerVersion
}
`
,
timeoutMillis
=
4000
,
}
=
settings
;
...
...
@@ -239,7 +253,7 @@ _flutter.loader = null;
* Returns undefined when an `onEntrypointLoaded` callback is supplied in `options`.
*/
async
loadEntrypoint
(
options
)
{
const
{
entrypointUrl
=
"main.dart.js"
,
onEntrypointLoaded
}
=
const
{
entrypointUrl
=
`$
{
baseUri
}
main
.
dart
.
js
`
,
onEntrypointLoaded
}
=
options
||
{};
return
this
.
_loadEntrypoint
(
entrypointUrl
,
onEntrypointLoaded
);
...
...
packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart
View file @
3bf79607
...
...
@@ -852,6 +852,18 @@ void main() {
contains
(
'"main.dart.js"'
));
}));
test
(
'flutter.js sanity checks'
,
()
{
final
String
flutterJsContents
=
flutter_js
.
generateFlutterJsFile
();
expect
(
flutterJsContents
,
contains
(
'"use strict";'
));
expect
(
flutterJsContents
,
contains
(
'main.dart.js'
));
expect
(
flutterJsContents
,
contains
(
'flutter_service_worker.js?v='
));
expect
(
flutterJsContents
,
contains
(
'document.createElement("script")'
));
expect
(
flutterJsContents
,
contains
(
'"application/javascript"'
));
expect
(
flutterJsContents
,
contains
(
'const baseUri = '
));
expect
(
flutterJsContents
,
contains
(
'document.querySelector("base")'
));
expect
(
flutterJsContents
,
contains
(
'.getAttribute("href")'
));
});
test
(
'flutter.js is not dynamically generated'
,
()
=>
testbed
.
run
(()
async
{
globals
.
fs
.
file
(
'bin/cache/flutter_web_sdk/canvaskit/foo'
)
..
createSync
(
recursive:
true
)
...
...
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