Skip to content

Commit d3d4e6f

Browse files
committed
Update docs
1 parent bfd17ab commit d3d4e6f

File tree

11 files changed

+60904
-57760
lines changed

11 files changed

+60904
-57760
lines changed

docs/.last_build_id

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e51b1c247d4fd590812daf78527401be
1+
37464718919ae2fddf765b2be7c81a34

docs/assets/NOTICES

Lines changed: 853 additions & 541 deletions
Large diffs are not rendered by default.
67.7 KB
Binary file not shown.

docs/canvaskit/canvaskit.js

Lines changed: 281 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/canvaskit/canvaskit.wasm

6.63 MB
Binary file not shown.

docs/canvaskit/profiling/canvaskit.js

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
8.68 MB
Binary file not shown.

docs/flutter.js

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
/**
6+
* This script installs service_worker.js to provide PWA functionality to
7+
* application. For more information, see:
8+
* https://developers.google.com/web/fundamentals/primers/service-workers
9+
*/
10+
11+
if (!_flutter) {
12+
var _flutter = {};
13+
}
14+
_flutter.loader = null;
15+
16+
(function() {
17+
"use strict";
18+
class FlutterLoader {
19+
// TODO: Move the below methods to "#private" once supported by all the browsers
20+
// we support. In the meantime, we use the "revealing module" pattern.
21+
22+
// Watchdog to prevent injecting the main entrypoint multiple times.
23+
_scriptLoaded = null;
24+
25+
// Resolver for the pending promise returned by loadEntrypoint.
26+
_didCreateEngineInitializerResolve = null;
27+
28+
/**
29+
* Initializes the main.dart.js with/without serviceWorker.
30+
* @param {*} options
31+
* @returns a Promise that will eventually resolve with an EngineInitializer,
32+
* or will be rejected with the error caused by the loader.
33+
*/
34+
loadEntrypoint(options) {
35+
const {
36+
entrypointUrl = "main.dart.js",
37+
serviceWorker,
38+
} = (options || {});
39+
return this._loadWithServiceWorker(entrypointUrl, serviceWorker);
40+
}
41+
42+
/**
43+
* Resolves the promise created by loadEntrypoint. Called by Flutter.
44+
* Needs to be weirdly bound like it is, so "this" is preserved across
45+
* the JS <-> Flutter jumps.
46+
* @param {*} engineInitializer
47+
*/
48+
didCreateEngineInitializer = (function(engineInitializer) {
49+
if (typeof this._didCreateEngineInitializerResolve != "function") {
50+
console.warn("Do not call didCreateEngineInitializer by hand. Start with loadEntrypoint instead.");
51+
}
52+
this._didCreateEngineInitializerResolve(engineInitializer);
53+
// Remove this method after it's done, so Flutter Web can hot restart.
54+
delete this.didCreateEngineInitializer;
55+
}).bind(this);
56+
57+
_loadEntrypoint(entrypointUrl) {
58+
if (!this._scriptLoaded) {
59+
this._scriptLoaded = new Promise((resolve, reject) => {
60+
let scriptTag = document.createElement("script");
61+
scriptTag.src = entrypointUrl;
62+
scriptTag.type = "application/javascript";
63+
this._didCreateEngineInitializerResolve = resolve; // Cache the resolve, so it can be called from Flutter.
64+
scriptTag.addEventListener("error", reject);
65+
document.body.append(scriptTag);
66+
});
67+
}
68+
69+
return this._scriptLoaded;
70+
}
71+
72+
_waitForServiceWorkerActivation(serviceWorker, entrypointUrl) {
73+
if (!serviceWorker || serviceWorker.state == "activated") {
74+
if (!serviceWorker) {
75+
console.warn("Cannot activate a null service worker. Falling back to plain <script> tag.");
76+
} else {
77+
console.debug("Service worker already active.");
78+
}
79+
return this._loadEntrypoint(entrypointUrl);
80+
}
81+
return new Promise((resolve, _) => {
82+
serviceWorker.addEventListener("statechange", () => {
83+
if (serviceWorker.state == "activated") {
84+
console.debug("Installed new service worker.");
85+
resolve(this._loadEntrypoint(entrypointUrl));
86+
}
87+
});
88+
});
89+
}
90+
91+
_loadWithServiceWorker(entrypointUrl, serviceWorkerOptions) {
92+
if (!("serviceWorker" in navigator) || serviceWorkerOptions == null) {
93+
console.warn("Service worker not supported (or configured). Falling back to plain <script> tag.", serviceWorkerOptions);
94+
return this._loadEntrypoint(entrypointUrl);
95+
}
96+
97+
const {
98+
serviceWorkerVersion,
99+
timeoutMillis = 4000,
100+
} = serviceWorkerOptions;
101+
102+
let serviceWorkerUrl = "flutter_service_worker.js?v=" + serviceWorkerVersion;
103+
let loader = navigator.serviceWorker.register(serviceWorkerUrl)
104+
.then((reg) => {
105+
if (!reg.active && (reg.installing || reg.waiting)) {
106+
// No active web worker and we have installed or are installing
107+
// one for the first time. Simply wait for it to activate.
108+
let sw = reg.installing || reg.waiting;
109+
return this._waitForServiceWorkerActivation(sw, entrypointUrl);
110+
} else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
111+
// When the app updates the serviceWorkerVersion changes, so we
112+
// need to ask the service worker to update.
113+
console.debug("New service worker available.");
114+
return reg.update().then((reg) => {
115+
console.debug("Service worker updated.");
116+
let sw = reg.installing || reg.waiting || reg.active;
117+
return this._waitForServiceWorkerActivation(sw, entrypointUrl);
118+
});
119+
} else {
120+
// Existing service worker is still good.
121+
console.debug("Loading app from service worker.");
122+
return this._loadEntrypoint(entrypointUrl);
123+
}
124+
});
125+
126+
// Timeout race promise
127+
let timeout;
128+
if (timeoutMillis > 0) {
129+
timeout = new Promise((resolve, _) => {
130+
setTimeout(() => {
131+
if (!this._scriptLoaded) {
132+
console.warn("Failed to load app from service worker. Falling back to plain <script> tag.");
133+
resolve(this._loadEntrypoint(entrypointUrl));
134+
}
135+
}, timeoutMillis);
136+
});
137+
}
138+
139+
return Promise.race([loader, timeout]);
140+
}
141+
}
142+
143+
_flutter.loader = new FlutterLoader();
144+
}());

docs/flutter_service_worker.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,31 @@ const TEMP = 'flutter-temp-cache';
44
const CACHE_NAME = 'flutter-app-cache';
55
const RESOURCES = {
66
"version.json": "ff966ab969ba381b900e61629bfb9789",
7-
"index.html": "161f80181f842bbaf31713d7b2bb212f",
8-
"/": "161f80181f842bbaf31713d7b2bb212f",
9-
"main.dart.js": "98b5a8a0669c923635fd8064153cfcc9",
7+
"index.html": "b7917b2b70eeb3a907f36fc62fa423d9",
8+
"/": "b7917b2b70eeb3a907f36fc62fa423d9",
9+
"main.dart.js": "2e56aaaa053bb535ac3a1bad3a1a171a",
10+
"flutter.js": "0816e65a103ba8ba51b174eeeeb2cb67",
1011
"favicon.png": "5dcef449791fa27946b3d35ad8803796",
1112
"icons/Icon-192.png": "ac9a721a12bbc803b44f645561ecb1e1",
1213
"icons/Icon-maskable-192.png": "c457ef57daa1d16f64b27b786ec2ea3c",
1314
"icons/Icon-maskable-512.png": "301a7604d45b3e739efc881eb04896ea",
1415
"icons/Icon-512.png": "96e752610906ba2a93c65f8abe1645f1",
1516
"manifest.json": "0867c3e13649ac4d06fe34b7b3ddce08",
1617
"assets/AssetManifest.json": "a74cc0d763eb95d212056670ae0dda98",
17-
"assets/NOTICES": "88396baa060d7189850a683cf3095105",
18+
"assets/NOTICES": "131819b4d00b49c9620dbeb035061976",
1819
"assets/FontManifest.json": "7b2a36307916a9721811788013e65289",
19-
"assets/fonts/MaterialIcons-Regular.otf": "7e7a6cccddf6d7b20012a548461d5d81",
20-
"assets/assets/images/love.png": "3091c01fc119a68bd7f1d20f9e1e92d8"
20+
"assets/fonts/MaterialIcons-Regular.otf": "95db9098c58fd6db106f1116bae85a0b",
21+
"assets/assets/images/love.png": "3091c01fc119a68bd7f1d20f9e1e92d8",
22+
"canvaskit/canvaskit.js": "c2b4e5f3d7a3d82aed024e7249a78487",
23+
"canvaskit/profiling/canvaskit.js": "ae2949af4efc61d28a4a80fffa1db900",
24+
"canvaskit/profiling/canvaskit.wasm": "95e736ab31147d1b2c7b25f11d4c32cd",
25+
"canvaskit/canvaskit.wasm": "4b83d89d9fecbea8ca46f2f760c5a9ba"
2126
};
2227

2328
// The application shell files that are downloaded before a service worker can
2429
// start.
2530
const CORE = [
26-
"/",
27-
"main.dart.js",
31+
"main.dart.js",
2832
"index.html",
2933
"assets/NOTICES",
3034
"assets/AssetManifest.json",

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
application. For more information, see:
8686
https://developers.google.com/web/fundamentals/primers/service-workers -->
8787
<script>
88-
var serviceWorkerVersion = '1328900260';
88+
var serviceWorkerVersion = '3145785372';
8989
var scriptLoaded = false;
9090
function loadMainDartJs() {
9191
if (scriptLoaded) {

0 commit comments

Comments
 (0)