manifest.js (1409B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 const { 8 l10n, 9 } = require("resource://devtools/client/application/src/modules/l10n.js"); 10 11 const { 12 services, 13 ManifestDevToolsError, 14 } = require("resource://devtools/client/application/src/modules/application-services.js"); 15 const { 16 FETCH_MANIFEST_FAILURE, 17 FETCH_MANIFEST_START, 18 FETCH_MANIFEST_SUCCESS, 19 RESET_MANIFEST, 20 } = require("resource://devtools/client/application/src/constants.js"); 21 22 function fetchManifest() { 23 return async ({ dispatch }) => { 24 dispatch({ type: FETCH_MANIFEST_START }); 25 try { 26 const manifest = await services.fetchManifest(); 27 dispatch({ type: FETCH_MANIFEST_SUCCESS, manifest }); 28 } catch (error) { 29 let errorMessage = error.message; 30 31 // since Firefox DevTools errors may not make sense for the user, swap 32 // their message for a generic one. 33 if (error instanceof ManifestDevToolsError) { 34 console.error(error); 35 errorMessage = l10n.getString("manifest-loaded-devtools-error"); 36 } 37 38 dispatch({ type: FETCH_MANIFEST_FAILURE, error: errorMessage }); 39 } 40 }; 41 } 42 43 function resetManifest() { 44 return { type: RESET_MANIFEST }; 45 } 46 47 module.exports = { 48 fetchManifest, 49 resetManifest, 50 };