From 64a02ae1e73c80a6652e31ccaa51cfb95211e5c9 Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Thu, 6 Feb 2020 20:24:59 +0100 Subject: [PATCH] feat(electron): Remove injectCapacitor function (#2415) --- electron-template/index.js | 2 +- electron/index.js | 22 ++-------------------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/electron-template/index.js b/electron-template/index.js index e2ddd68c73..5034d7fe34 100644 --- a/electron-template/index.js +++ b/electron-template/index.js @@ -51,7 +51,7 @@ async function createWindow () { if(useSplashScreen) { splashScreen = new CapacitorSplashScreen(mainWindow); - splashScreen.init(false); + splashScreen.init(); } else { mainWindow.loadURL(`file://${__dirname}/app/index.html`); mainWindow.webContents.on('dom-ready', () => { diff --git a/electron/index.js b/electron/index.js index 9a1aec7754..27f0b3d746 100644 --- a/electron/index.js +++ b/electron/index.js @@ -14,19 +14,6 @@ function getURLFileContents(path) { }); } -const injectCapacitor = async function (url) { - console.warn('\nWARNING: injectCapacitor method is deprecated and will be removed in next major release. Check release notes for migration instructions\n') - try { - let urlFileContents = await getURLFileContents(url.substr(url.indexOf('://') + 3)); - let pathing = path.join(url.substr(url.indexOf('://') + 3), '../../node_modules/@capacitor/electron/dist/electron-bridge.js'); - urlFileContents = urlFileContents.replace('', ``); - return 'data:text/html;charset=UTF-8,' + urlFileContents; - } catch (e) { - console.error(e); - return url; - } -}; - const configCapacitor = async function(mainWindow) { let capConfigJson = JSON.parse(fs.readFileSync(`./capacitor.config.json`, 'utf-8')); const appendUserAgent = capConfigJson.electron && capConfigJson.electron.appendUserAgent ? capConfigJson.electron.appendUserAgent : capConfigJson.appendUserAgent; @@ -103,7 +90,7 @@ class CapacitorSplashScreen { }); } - init(inject = true) { + init() { let rootPath = app.getAppPath(); this.splashWindow = new BrowserWindow({ @@ -152,11 +139,7 @@ class CapacitorSplashScreen { this.splashWindow.webContents.on('dom-ready', async () => { this.splashWindow.show(); setTimeout(async () => { - if (inject) { - this.mainWindowRef.loadURL(await injectCapacitor(`file://${rootPath}/app/index.html`), { baseURLForDataURL: `file://${rootPath}/app/` }); - } else { - this.mainWindowRef.loadURL(`file://${rootPath}/app/index.html`); - } + this.mainWindowRef.loadURL(`file://${rootPath}/app/index.html`); }, 4500); }); @@ -181,7 +164,6 @@ class CapacitorSplashScreen { } module.exports = { - injectCapacitor, configCapacitor, CapacitorSplashScreen };