From c3c94b1ef842aeddf896f602d0957f7a03f99d75 Mon Sep 17 00:00:00 2001 From: dimstr <93518175+dimstr@users.noreply.github.com> Date: Thu, 5 May 2022 19:35:57 +0300 Subject: [PATCH] Delete all comments --- flutter.js | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/flutter.js b/flutter.js index 020f5e5..af9badb 100644 --- a/flutter.js +++ b/flutter.js @@ -2,11 +2,7 @@ // 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 - */ +// https://developers.google.com/web/fundamentals/primers/service-workers if (!_flutter) { var _flutter = {}; @@ -16,21 +12,10 @@ _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", @@ -39,18 +24,11 @@ _flutter.loader = null; 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); @@ -103,13 +81,9 @@ _flutter.loader = null; 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."); @@ -117,13 +91,11 @@ _flutter.loader = null; 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, _) => {