Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mono0926 committed May 12, 2022
1 parent bfd17ab commit d3d4e6f
Show file tree
Hide file tree
Showing 11 changed files with 60,904 additions and 57,760 deletions.
2 changes: 1 addition & 1 deletion docs/.last_build_id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e51b1c247d4fd590812daf78527401be
37464718919ae2fddf765b2be7c81a34
1,394 changes: 853 additions & 541 deletions docs/assets/NOTICES

Large diffs are not rendered by default.

Binary file modified docs/assets/fonts/MaterialIcons-Regular.otf
Binary file not shown.
281 changes: 281 additions & 0 deletions docs/canvaskit/canvaskit.js

Large diffs are not rendered by default.

Binary file added docs/canvaskit/canvaskit.wasm
Binary file not shown.
21 changes: 21 additions & 0 deletions docs/canvaskit/profiling/canvaskit.js

Large diffs are not rendered by default.

Binary file added docs/canvaskit/profiling/canvaskit.wasm
Binary file not shown.
144 changes: 144 additions & 0 deletions docs/flutter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/**
* This script installs service_worker.js to provide PWA functionality to
* application. For more information, see:
* https://developers.google.com/web/fundamentals/primers/service-workers
*/

if (!_flutter) {
var _flutter = {};
}
_flutter.loader = null;

(function() {
"use strict";
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.

// Watchdog to prevent injecting the main entrypoint multiple times.
_scriptLoaded = null;

// Resolver for the pending promise returned by loadEntrypoint.
_didCreateEngineInitializerResolve = null;

/**
* Initializes the main.dart.js with/without serviceWorker.
* @param {*} options
* @returns a Promise that will eventually resolve with an EngineInitializer,
* or will be rejected with the error caused by the loader.
*/
loadEntrypoint(options) {
const {
entrypointUrl = "main.dart.js",
serviceWorker,
} = (options || {});
return this._loadWithServiceWorker(entrypointUrl, serviceWorker);
}

/**
* Resolves the promise created by loadEntrypoint. Called by Flutter.
* Needs to be weirdly bound like it is, so "this" is preserved across
* the JS <-> Flutter jumps.
* @param {*} engineInitializer
*/
didCreateEngineInitializer = (function(engineInitializer) {
if (typeof this._didCreateEngineInitializerResolve != "function") {
console.warn("Do not call didCreateEngineInitializer by hand. Start with loadEntrypoint instead.");
}
this._didCreateEngineInitializerResolve(engineInitializer);
// Remove this method after it's done, so Flutter Web can hot restart.
delete this.didCreateEngineInitializer;
}).bind(this);

_loadEntrypoint(entrypointUrl) {
if (!this._scriptLoaded) {
this._scriptLoaded = new Promise((resolve, reject) => {
let scriptTag = document.createElement("script");
scriptTag.src = entrypointUrl;
scriptTag.type = "application/javascript";
this._didCreateEngineInitializerResolve = resolve; // Cache the resolve, so it can be called from Flutter.
scriptTag.addEventListener("error", reject);
document.body.append(scriptTag);
});
}

return this._scriptLoaded;
}

_waitForServiceWorkerActivation(serviceWorker, entrypointUrl) {
if (!serviceWorker || serviceWorker.state == "activated") {
if (!serviceWorker) {
console.warn("Cannot activate a null service worker. Falling back to plain <script> tag.");
} else {
console.debug("Service worker already active.");
}
return this._loadEntrypoint(entrypointUrl);
}
return new Promise((resolve, _) => {
serviceWorker.addEventListener("statechange", () => {
if (serviceWorker.state == "activated") {
console.debug("Installed new service worker.");
resolve(this._loadEntrypoint(entrypointUrl));
}
});
});
}

_loadWithServiceWorker(entrypointUrl, serviceWorkerOptions) {
if (!("serviceWorker" in navigator) || serviceWorkerOptions == null) {
console.warn("Service worker not supported (or configured). Falling back to plain <script> tag.", serviceWorkerOptions);
return this._loadEntrypoint(entrypointUrl);
}

const {
serviceWorkerVersion,
timeoutMillis = 4000,
} = serviceWorkerOptions;

let serviceWorkerUrl = "flutter_service_worker.js?v=" + serviceWorkerVersion;
let loader = navigator.serviceWorker.register(serviceWorkerUrl)
.then((reg) => {
if (!reg.active && (reg.installing || reg.waiting)) {
// No active web worker and we have installed or are installing
// one for the first time. Simply wait for it to activate.
let sw = reg.installing || reg.waiting;
return this._waitForServiceWorkerActivation(sw, entrypointUrl);
} else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
// When the app updates the serviceWorkerVersion changes, so we
// need to ask the service worker to update.
console.debug("New service worker available.");
return reg.update().then((reg) => {
console.debug("Service worker updated.");
let sw = reg.installing || reg.waiting || reg.active;
return this._waitForServiceWorkerActivation(sw, entrypointUrl);
});
} else {
// Existing service worker is still good.
console.debug("Loading app from service worker.");
return this._loadEntrypoint(entrypointUrl);
}
});

// Timeout race promise
let timeout;
if (timeoutMillis > 0) {
timeout = new Promise((resolve, _) => {
setTimeout(() => {
if (!this._scriptLoaded) {
console.warn("Failed to load app from service worker. Falling back to plain <script> tag.");
resolve(this._loadEntrypoint(entrypointUrl));
}
}, timeoutMillis);
});
}

return Promise.race([loader, timeout]);
}
}

_flutter.loader = new FlutterLoader();
}());
20 changes: 12 additions & 8 deletions docs/flutter_service_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,31 @@ const TEMP = 'flutter-temp-cache';
const CACHE_NAME = 'flutter-app-cache';
const RESOURCES = {
"version.json": "ff966ab969ba381b900e61629bfb9789",
"index.html": "161f80181f842bbaf31713d7b2bb212f",
"/": "161f80181f842bbaf31713d7b2bb212f",
"main.dart.js": "98b5a8a0669c923635fd8064153cfcc9",
"index.html": "b7917b2b70eeb3a907f36fc62fa423d9",
"/": "b7917b2b70eeb3a907f36fc62fa423d9",
"main.dart.js": "2e56aaaa053bb535ac3a1bad3a1a171a",
"flutter.js": "0816e65a103ba8ba51b174eeeeb2cb67",
"favicon.png": "5dcef449791fa27946b3d35ad8803796",
"icons/Icon-192.png": "ac9a721a12bbc803b44f645561ecb1e1",
"icons/Icon-maskable-192.png": "c457ef57daa1d16f64b27b786ec2ea3c",
"icons/Icon-maskable-512.png": "301a7604d45b3e739efc881eb04896ea",
"icons/Icon-512.png": "96e752610906ba2a93c65f8abe1645f1",
"manifest.json": "0867c3e13649ac4d06fe34b7b3ddce08",
"assets/AssetManifest.json": "a74cc0d763eb95d212056670ae0dda98",
"assets/NOTICES": "88396baa060d7189850a683cf3095105",
"assets/NOTICES": "131819b4d00b49c9620dbeb035061976",
"assets/FontManifest.json": "7b2a36307916a9721811788013e65289",
"assets/fonts/MaterialIcons-Regular.otf": "7e7a6cccddf6d7b20012a548461d5d81",
"assets/assets/images/love.png": "3091c01fc119a68bd7f1d20f9e1e92d8"
"assets/fonts/MaterialIcons-Regular.otf": "95db9098c58fd6db106f1116bae85a0b",
"assets/assets/images/love.png": "3091c01fc119a68bd7f1d20f9e1e92d8",
"canvaskit/canvaskit.js": "c2b4e5f3d7a3d82aed024e7249a78487",
"canvaskit/profiling/canvaskit.js": "ae2949af4efc61d28a4a80fffa1db900",
"canvaskit/profiling/canvaskit.wasm": "95e736ab31147d1b2c7b25f11d4c32cd",
"canvaskit/canvaskit.wasm": "4b83d89d9fecbea8ca46f2f760c5a9ba"
};

// The application shell files that are downloaded before a service worker can
// start.
const CORE = [
"/",
"main.dart.js",
"main.dart.js",
"index.html",
"assets/NOTICES",
"assets/AssetManifest.json",
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
application. For more information, see:
https://developers.google.com/web/fundamentals/primers/service-workers -->
<script>
var serviceWorkerVersion = '1328900260';
var serviceWorkerVersion = '3145785372';
var scriptLoaded = false;
function loadMainDartJs() {
if (scriptLoaded) {
Expand Down
Loading

0 comments on commit d3d4e6f

Please sign in to comment.