getstation / electron-chrome-extension

Implementation of Chrome extension APIs for Electron
139 stars 26 forks source link

Fix APIs in frames #46

Closed alexstrat closed 5 years ago

alexstrat commented 5 years ago

IPC messages were not sent to all frames in the original implementation of electron-simple-ipc. As a result some APIs relying on electron-simple-rpc (like storage) were not working in iframes.

Fixed with https://github.com/alexstrat/electron-simple-ipc/commit/b77d28dde40cda76c3da00d26cf42c78a0d2d015 and bumping version.

Esp. fix Apollo DevTools

alexstrat commented 5 years ago
diff --git a/package.json b/package.json
index aba67a5..a75d647 100644
--- a/package.json
+++ b/package.json
@@ -21,11 +21,14 @@
     "electron": ">=4.0.0"
   },
   "devDependencies": {
-    "@types/mime-types": "^2.1.0",
     "@types/fs-extra": "^5.0.4",
     "@types/glob": "^7.1.1",
+    "@types/mime-types": "^2.1.0",
     "@types/mocha": "^5.2.5",
     "@types/tmp": "0.0.33",
+    "apollo-cache-inmemory": "^1.4.3",
+    "apollo-client": "^2.4.13",
+    "apollo-link-http": "^1.5.11",
     "concurrently": "^4.1.0",
     "electron": "^4.0.4",
     "electron-mocha": "^6.0.4",
diff --git a/playground/app.html b/playground/app.html
index e94e944..d51705d 100644
--- a/playground/app.html
+++ b/playground/app.html
@@ -19,19 +19,25 @@
     }
   </style>

-  <div class="container">
-    <webview allowPopups webpreferences="nativeWindowOpen=yes" preload='../lib/src/renderer/init.js'
-      src="https://mail.google.com/">
-    </webview>
-
-    <webview allowPopups webpreferences="nativeWindowOpen=yes" preload='../lib/src/renderer/init.js'
-      src="https://notion.so/">
-    </webview>
-
-    <webview allowPopups webpreferences="nativeWindowOpen=yes" preload='../lib/src/renderer/init.js'
-      src="https://calendar.google.com/calendar/r">
-    </webview>
+  <div class="container">Stashed changes
   </div>
 </body>
+<script>
+  const { ApolloClient } = require('apollo-client');
+  const { HttpLink } = require('apollo-link-http');
+  const { InMemoryCache } = require('apollo-cache-inmemory');

+
+  const cache = new InMemoryCache();
+
+  const httpLink = new HttpLink({
+    uri: "https://48p1r2roz4.sse.codesandbox.io",
+  });
+
+  window.client = new ApolloClient({
+    connectToDevTools: true,
+    link: httpLink,
+    cache,
+  });
+</script>
 </html>
diff --git a/playground/main.js b/playground/main.js
index cb50ba2..a738951 100644
--- a/playground/main.js
+++ b/playground/main.js
@@ -3,6 +3,8 @@ const { join } = require('path');
 const { format } = require('url');
 const { mkdirSync, existsSync } = require('fs');

+app.commandLine.appendSwitch('remote-debugging-port', '9223')
+
 // for convenience, we'll store electron userData
 // in the nearby .electron-user-data directory
 if (!app.isPackaged) {
@@ -17,7 +19,7 @@ let mainWindow;

 function createWindow() {
   mainWindow = new BrowserWindow({ width: 800, height: 600 });
-
+  
   mainWindow.loadURL(format({
     pathname: join(__dirname, 'app.html'),
     protocol: 'file:',
@@ -25,13 +27,14 @@ function createWindow() {
   }));

   mainWindow.on('closed', () => mainWindow = null);
+
 }

 app.on('ready', async () => {
   createWindow();
-
+  
   require('electron-process-manager').openProcessManager();
-
+  
   // Mixmax: ocpljaamllnldhepankaeljmeeeghnid
   // Gmelius: dheionainndbbpoacpnopgmnihkcmnkl
   // Mailtracker: pgbdljpkijehgoacbjpolaomhkoffhnl
@@ -43,6 +46,7 @@ app.on('ready', async () => {
   // Lastpass: hdokiejnpimakedhajhdlcegeplioahd
   // React Developers Tools: fmkadmapgofadopljbjfkapdkoienihi
   // Redux DevTools: lmhkpmbekcpmknklioeibfkpmmfibljd
+  // Apollo DevTools: jdkknkkbebbapilgoeccciglkfbmbnfm

   const onUpdate = (update) => console.log('Extension updated: ', update);

@@ -51,8 +55,7 @@ app.on('ready', async () => {
     fetcher: { autoUpdate: true, autoUpdateInterval: 1000000 },
   });

-  // load React for the fun
-  await ECx.load('fmkadmapgofadopljbjfkapdkoienihi');
+  await ECx.load('jdkknkkbebbapilgoeccciglkfbmbnfm');
 });

 app.on('window-all-closed', () => {