GithubHelp home page GithubHelp logo

capacitor-community / electron Goto Github PK

View Code? Open in Web Editor NEW
305.0 16.0 58.0 8.79 MB

Deploy your Capacitor apps to Linux, Mac, and Windows desktops, with the Electron platform! πŸ–₯️

Home Page: https://capacitor-community.github.io/electron/

License: MIT License

TypeScript 91.78% JavaScript 8.22%
electron capacitor capacitor-platform

electron's Introduction


Bring your Capacitor ⚑ apps to the desktop with Electron! πŸ–₯

npm GitHub Workflow Status

⚠ Version 4 or Above Info

  • You will need version 5.4.0+ of capacitor.
  • The template and inner workings have changed a lot, a migration guide will be done but for now creating a new project to tinker with before migrating main projects is a good idea.
  • Plugins from previous versions @capacitor-community/electron will not function in V4 or above, however all web plugins will continue to function as normal.
  • V4 and later comes with no plugins out of the box. Instead V4 and later and above follow Capacitor in seperated plugins, see Plugin Examples Directory for examples.

πŸ“– Documentation:

You can find the docs site here.

πŸ” Security

While this platform strives to be inline with current secure practices, there are things outside of this platforms control. Please take the time to read through the security checklist the electron team has created to keep your application as safe and secure as you possibly can.

πŸ›  Maintainers

Maintainer GitHub Social Sponsoring Company Primary
Mike Summerfeldt IT-MikeS @IT_MikeS Volunteer Yes

✨ Contributors


Max Lynch

πŸ’» πŸ“–

Mike Summerfeldt

πŸ’» πŸ“–

Daniel Sogl

πŸ’»

HervΓ© de CHAVIGNY

πŸ’» πŸ“–

Maik Marschner

πŸ’»

Stew

πŸ’»

Corey Vaillancourt

πŸ’»

Julien Goux

πŸ’»

MathisTLD

πŸ’»

challenger71498

πŸ’»

jdgjsag67251

πŸ’»

electron's People

Contributors

allcontributors[bot] avatar challenger71498 avatar danielsogl avatar dependabot[bot] avatar dharmaturtle avatar it-mikes avatar jdgjsag67251 avatar jgoux avatar lemaik avatar mathistld avatar mlynch avatar semantic-release-bot avatar stewones avatar vevedh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

electron's Issues

Set Window Size

How do you set the window size for the Electron BrowserWindow?

It feels like I should be able to do this using the config object passed to myCapacitorApp.init(); but I don't see anything like that in the docs.

Unable to add Electron if there is a space in the parent folder name

Describe the bug
I have an Angular Ionic app with Capacitor integrated to it. I am referring the documentation.
When I run command npx cap add @capacitor-community/electron i get below error


> node dist/cap-scripts.js add

β ™ Adding Electron platformError: undefined
βœ– Adding Electron platform: 
(node:4502) UnhandledPromiseRejectionWarning: /bin/sh: line 0: cd: /Users/priteshbonde/Code: No such file or directory

(node:4502) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:4502) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

if you observed line `(node:4502) UnhandledPromiseRejectionWarning: /bin/sh: line 0: cd: /Users/priteshbonde/Code: No such file or directory` that truncated the rest of the repo URL.

To Reproduce

  1. Create a Angular ionic application with a parent folder have a space in the name example code repository/electronAPP
  2. Open Terminal
  3. Run npm i @capacitor-community/electron
  4. Run npx cap add @capacitor-community/electron

Expected behaviour
No matter what the repo url is the electron app should be created in the app.

Screenshots

image

Desktop (please complete the following information):

  • OS: MAC OS Big Sur
  • Angular 11, Ionic 5, capacitor 2

FYI I was able to resolve the issue by removing the space in the parent folder name but ideally i think that the package should handle this scenario.

404 when trying to load bundle.js from webpack

404 when trying to load bundle.js from webpack. It is trying to load from capacitor-electron://-/bundle.js

To Reproduce

  1. Create a project with webpack, building to dist folder with bundle.js
  2. Include your page with index.html in dist folder with <script src="bundle.js"></script>
  3. Set up capacitor.config.json with webDir: "dist"
  4. npx cap add @capacitor-community/electron
  5. npx cap open @capacitor-community/electron

Expected behavior
Page launches and loads bundle.js

Screenshots
image

image

  • OS: Windows 10 version 2004

electron.exe seems to be included twice

Describe the bug
I have just moved onto capacitor-community/electron after using capacitor/electron for quite a while. I noticed that my finished exe files generated after switching were twice the size as the exe files produced by capacitor/electron. Upon some investigation it appears as though in win-unpacked I have the exe file (renamed to match my exe name) in the root of win-unpacked but I also have it in "win-unpacked\resources\app.asar.unpacked\node_modules\electron\dist\electron.exe". At 108MB, I'm guessing this is the problem. I guess this could be a problem with electron-builder config or something, but it's worked fine so far with capacitor/electron so if there are some changes I need to make to the config for community-capacitor then I really need to know.

To Reproduce
Steps to reproduce the behavior:

  1. Take a project that has been using capacitor/electron.
  2. Remove the capacitor/electron platform and setup capacitor-community/electron as per the instructions on the website.
  3. Build the app and npx cap copy
  4. Run npm run electron:build-windows

Expected behavior
I would expect the exe file to be a similar size as to when I was using capacitor/electron - not twice the size. If there is a config change needed, I'd expect some sort of instruction on it.

Screenshots
If applicable, add screenshots to help explain your problem.
image
image

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Edge
  • Version: 85

The js source map for electron-bridge.js is not included in the build output - could not load content.

Describe the bug
The js source map for electron-bridge.js is not included in the build output.
DevTools failed to load SourceMap: Could not load content for capacitor-electron://-/electron-bridge.js.map:

To Reproduce
An electron app built with this package produces the above warning in Developer Tools console.

Expected behavior
File electron-bridge.js includes the source map reference and so expect this to be available in the build output. Perhaps the typescript compiler does not understand this or specific compilerOptions need to be set in tsconfig.json?

Accept file::// urls

Is your feature request related to a problem? Please describe.
For the product I am working on, I am now using a custom build of capacitor-community/electron as we need the filesystem aspect to be able to accept file:// urls. Currently it works by not passing in a directory at all, which triggers my code to check if there is a valid URL and whether the protocol is file://. Is this something useful for the main project? I have tested my code for file and directory reading but it probably needs some more testing around some other areas of filesystem.ts, e.g. mkdir etc. I can try to get around to finding some time to do that! Let me know if you want a PR for what I have.

Docs?

Are the docs going to be updated soon from the "coming soon" -- looking for the ts config options for createCapacitorElectronApp()

thnx

INIT_CWD not always accurate in CLI

Describe the bug
Adding the platform results in a strange file-not-found error, although the file exists.

To Reproduce
Steps to reproduce the behavior:

  1. Use rather recent Ionic templated app which generates web and apk builds nicely
  2. Run npx cap add @capacitor-community/electron
  3. Get error about missing configuration

Expected behavior
It should add the capacitor-community electron platform

Screenshots

➜ npx cap add @capacitor-community/electron

> @capacitor-community/[email protected] capacitor:add
> node dist/cap-scripts.js add

β ‹ Adding Electron platformError: capacitor.config.json does not exist, did you setup capacitor in your project root?
βœ– Adding Electron platform: capacitor.config.json does not exist, did you setup capacitor in your project root?
(node:4565) UnhandledPromiseRejectionWarning: Error: capacitor.config.json does not exist, did you setup capacitor in your project root?
    at Object.n [as doAdd] (/home/riot/src/isomer/isomer_modules/leerstandsmelder/leerstandsmelder-2/frontend/leerstandsmelder-ionic-ng-autoentities/node_modules/@capacitor-community/electron/dist/cap-scripts.js:6:1016)
    at /home/riot/src/isomer/isomer_modules/leerstandsmelder/leerstandsmelder-2/frontend/leerstandsmelder-ionic-ng-autoentities/node_modules/@capacitor-community/electron/dist/cap-scripts.js:12:363
    at Object.g [as runTask] (/home/riot/src/isomer/isomer_modules/leerstandsmelder/leerstandsmelder-2/frontend/leerstandsmelder-ionic-ng-autoentities/node_modules/@capacitor-community/electron/dist/cap-scripts.js:2:1902)
    at i (/home/riot/src/isomer/isomer_modules/leerstandsmelder/leerstandsmelder-2/frontend/leerstandsmelder-ionic-ng-autoentities/node_modules/@capacitor-community/electron/dist/cap-scripts.js:12:311)
    at /home/riot/src/isomer/isomer_modules/leerstandsmelder/leerstandsmelder-2/frontend/leerstandsmelder-ionic-ng-autoentities/node_modules/@capacitor-community/electron/dist/cap-scripts.js:12:718
    at Object.parcelRequire.Focm../common (/home/riot/src/isomer/isomer_modules/leerstandsmelder/leerstandsmelder-2/frontend/leerstandsmelder-ionic-ng-autoentities/node_modules/@capacitor-community/electron/dist/cap-scripts.js:12:915)
    at f (/home/riot/src/isomer/isomer_modules/leerstandsmelder/leerstandsmelder-2/frontend/leerstandsmelder-ionic-ng-autoentities/node_modules/@capacitor-community/electron/dist/cap-scripts.js:1:468)
    at parcelRequire.FoEN (/home/riot/src/isomer/isomer_modules/leerstandsmelder/leerstandsmelder-2/frontend/leerstandsmelder-ionic-ng-autoentities/node_modules/@capacitor-community/electron/dist/cap-scripts.js:1:771)
    at Object.<anonymous> (/home/riot/src/isomer/isomer_modules/leerstandsmelder/leerstandsmelder-2/frontend/leerstandsmelder-ionic-ng-autoentities/node_modules/@capacitor-community/electron/dist/cap-scripts.js:1:1023)
    at Module._compile (internal/modules/cjs/loader.js:1015:30)
(node:4565) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:4565) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Desktop (please complete the following information):

  • OS: Debian Sid
  • Version:
    • npm: 7.3.0
    • ionic: 6.12.3

Additional context
The capacitor configuration exists and has been used to add android and ios platforms already:

➜ cat capacitor.config.json 
{
  "appId": "de.foobar.app",
  "appName": "foobar",
  "bundledWebRuntime": false,
  "npmClient": "npm",
  "webDir": "www",
  "plugins": {
    "SplashScreen": {
      "launchShowDuration": 0
    }
  },
  "cordova": {}
}

Deeplinking not working

Describe the bug
I've created a Capacitor application with Oauth2 (Okta, AppAuth-js) which runs fine on IOS and in the browser. Now trying with Electron using this package and deeplinking I'm getting an error which I can't really figure out. I've set up the electron app with deeplinking according to the documentation.

const myCapacitorApp = createCapacitorElectronApp()
createCapacitorElectronDeepLinking(myCapacitorApp, {
  customProtocol: 'electronboogie',
  customHandler: url => {
    console.log('The url: ' + url)
  }
})

i've also added the following code to listen for the URL open call inside my Capacitor app

 App.addListener('appUrlOpen', (data: any) => {
        console.log('dataurl: ' + data.url)
      })

I Run the application using npx cap open @capacitor-community/electron and opening the window to the Okta Authorization server works well but when Okta tries to redirect me back to the application using electronboogie://callback as redirect url i get the following error message

image

Any idea about what could be wrong?

To Reproduce
Hard to reproduce the entire setup but i could try if no other option.

I'm running the following commands when starting the electron app,

  1. npm run build
  2. npx cap copy @capacitor-community/electron
  3. npx cap open @capacitor-community/electron

Expected behavior
Expect the deeplink to be fired and the electron app to send the Url to the initiating browser window

Screenshots
added in the description

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Chromium
  • Version 1.3.4

Additional context
Nothing else to add

Integrate with Ionic

Hi, I just want to try to create an electron app with ionic capacitor using the new electron platform in this repository but I don't understand how to integrate the iPCRenderer in my web app on ionic side.
In the "old" version of electron I saw that we could use a service wrapper named 'ngx-electron', but is incompatible with this version.

So on, the point is, what is the way to use the ipcRenderer on ionic side for enable IPC communications? or there are any alternatives? Thank you in advance

Electron 11 only shows Web Content after resize, minimize or drag Main Window

Describe the bug
I'm building an app with Electron, Capacitor, Ionic and Angular.

My app runs smooth without any problems if I use electron version 10.2.0, but if I upgrade to Electron 11.2.0 my app starts with an empty white screen. The strange thing is, if I inspect the page the HTML is there but the window shows only white (black if dark mode). My apps starts displaying if I do one of the following:

  • Resize the app window
  • Move the window;
  • Minimize or maximize the window;
  • Run for example a registered shortcut command (CTRL + H for a MessageBox with App help screen);

It looks like the main windows looses focus or stops to render, but then when I click, min/max the windows or drag it gain focus and continuous to render... I already tried to force focus without success.

MainWindow.focus();

Any hint on what may be causing this?

To Reproduce
Update to Electron from 10.2.0 or 10.3.0 to 11.2.0.

Expected behavior
App should run without the need to resize, move or minimize/maximize the window.

Screenshots
App shows nothing until something is done with the window (drag, min/max, loose focus, etc).
image

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Electron 11.2.0
  • Capacitor 2.4.6
  • Capacitor Electron 1.3.2

Additional context
If I try to force MainWindow.show(); in my main.ts after the app inits it shows and render the web page, but it breaks the splashcreen, showing an white area (same as the window size) around the splashscreen image...

image

fs-extra compile error

I followed this guide to build an Ionic electron app: https://capacitor-community.github.io/electron/#/./getting-started/index

when I run npx cap open @capacitor-community/electron get error:

node_modules/@types/fs-extra/index.d.ts:243:49 - error TS2694: Namespace '"fs"' has no exported member 'RmOptions'.
243 export function rm(path: PathLike, options?: fs.RmOptions): Promise<void>;

I went to check source code, found it's caused by "@types/fs-extra": "9.0.7" witch used by "@capacitor-community/electron": "^1.3.1" ( @capacitor-community/electron": "^1.4.0" exists same problem as well )

So I changed "@types/fs-extra": "9.0.7" into "@types/fs-extra": "9.0.1", problem resolved!

Put information here, may help somebody.

Desktop

  • OS: OSX 10.15

using HTTPS protocol for Strict-Transport-Security reason

Describe the bug
Embedding Stripe.js integration requires HTTPS as the security protocol. Right now the base url is capacitor-electron://.

To Reproduce

  1. install nix-stripe
  2. Compile the app and run in Electron

Expected behavior
Use https:// as the security protocol instead of capacitor-electron:// so I can use Stripe.js in my app.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Electron on macOS. @capacitor-community/electron-core

Custom url scheme for CORS purpose

Is your feature request related to a problem? Please describe.
I want to config my custom scheme for CORS purpose, I don't want to use default one with capacitor-electron://

Describe the solution you'd like
I want to have the way to override the default scheme with mine (I know about deeplinks but it doesn't fit my using), I have tried to use the deeplinks solution but it doesn't change the fact that the origin of app still be capacitor-electron://

Describe alternatives you've considered
I think you can define loadWebApp inside init function or constructor then reading scheme and directory from config
const loadWebApp = electronServe({ directory: config.directory, scheme: config.scheme, });

Additional context
If you OK, I can create pull request for doing this thing. or if you have another solution, please feel free to contact me

Error: cannot find module `electron-bridge`

Describe the bug
When I start my electron app, it shows this error:

Bildschirmfoto 2020-08-28 um 09 09 54

To Reproduce
Steps to reproduce the behavior:

  1. ionic cap sync @capacitor-community/electron
  2. cd electron
  3. npm run build && electron ./

Expected behavior
Well, there shouldn't be any errors during start.

Desktop (please complete the following information):

  • OS: macOS 10.15.6

Source Maps "Unexpected end of JSON input" in main BrowserWindow

Describe the bug
I am seeing many messages like the following in my BrowserWindow's DevTools console:

DevTools failed to load SourceMap: Could not parse content for capacitor-electron://-/17-es2015.js.map: Unexpected end of JSON input
DevTools failed to load SourceMap: Could not parse content for capacitor-electron://-/default~firebase-auth~pages-social-profile-profile-module-es2015.js.map: Unexpected end of JSON input
DevTools failed to load SourceMap: Could not parse content for capacitor-electron://-/swipe-back-2154c9a7-js-es2015.js.map: Unexpected end of JSON input
DevTools failed to load SourceMap: Could not parse content for capacitor-electron://-/5-es2015.js.map: Unexpected end of JSON input
DevTools failed to load SourceMap: Could not parse content for capacitor-electron://-/28-es2015.js.map: Unexpected end of JSON input

In my tsconfig.json file I tried all combinations of :

  "sourceMap": true,
    "inlineSourceMap": true,
    "inlineSources": true

To Reproduce
Steps to reproduce the behavior:
I see the messages on startup of my app.

Expected behavior
No messages about source maps.

Desktop (please complete the following information):

  • OS: mac osx

I am not sure if this is a bug or if I am doing something wrong.

Capacitor Camera Plugin not working with context isolation

Bug Report

Capacitor Version

Latest Dependencies:

  @capacitor/cli: 2.4.4
  @capacitor/core: 2.4.4
  @capacitor/android: 2.4.4
  @capacitor/electron: 2.4.4
  @capacitor/ios: 2.4.4

Installed Dependencies:

  @capacitor/android not installed
  @capacitor/ios not installed
  @capacitor/cli 2.4.3
  @capacitor/core 2.4.3
  @capacitor/electron not installed
 @capacitor-community/electron:  1.3.2

Platform(s)

Electron on macOS

Current Behavior

Throws error when calling "Camera.getPhoto()"

'Uncaught (in promise) TypeErrror: Cannot read property 'get' of null
at r. electron-bridge.js:113
at Object.next electron-bridge.js:111
at electron-bridge.js:111
at new Promise ()
at L electron-bridge.js:111
at electron-bridge.js:113
at new Promise ():13
at electron-bridge.js:111

Expected Behavior

open Camera dialog

Code Reproduction

Configured the Electron App with context isolation:

in index.html:

  <script type="module" src="https://unpkg.com/@ionic/pwa-elements@latest/dist/ionicpwaelements/ionicpwaelements.esm.js"></script>
  <script nomodule src="https://unpkg.com/@ionic/pwa-elements@latest/dist/ionicpwaelements/ionicpwaelements.js"></script>

in index.js:

mainWindow: {
    windowOptions: {
      webPreferences: {
        nodeIntegration: false,
        nodeIntegrationInWorker: false,
        nodeIntegrationInSubFrames: false,
        contextIsolation: true,
        enableRemoteModule: true, // we need this to get prelaoder to work
        preload: path.join(__dirname, "../preloader.js"),
      }
    }
  }

in preloader.js

getCameraPicture: async (args) => {
        try {
            const { Camera, Permissions } = Plugins;
            const hasPermission = await Permissions.query({ name: "camera"});

            const base64data = await Camera.getPhoto({
              quality: 80,
              allowEditing: true,
              resultType: CameraResultType.Base64
            });
            return { result: base64data };
        }
        catch (e) {
            return {success: false, stack: e};
        }
    }

in renderer.js

window.cap.getCameraPicture().then(base64data => {
                editorInstance.insertHtml( '<img src="data:image/jpeg;base64,' + base64data + '">' );
            }).catch(e => {
                console.debug("Unable to obtain picture: " + e, "app");
            })

Other Technical Details

npm --version output: 6.14.8

node --version output: v12.13.0

pod --version output (iOS issues only):

Additional Context

build for linux ubuntu

Hi, is there an option to build for ubuntu arm? can only find option for windows and mac

Compilation error when using an Ionic app with Jest

Describe the bug

I tried to add Electron support to an Ionic app I have. My app uses Jest for testing. When I run npm run electron:start, I get a number of compilation errors:

➜  electron git:(master) βœ— npm run electron:start

> [email protected] electron:start /Users/mraible/ionic4j/electron
> npm run build && electron ./


> [email protected] build /Users/mraible/ionic4j/electron
> tsc

../node_modules/@types/jasmine/index.d.ts:26:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: beforeAll, beforeEach, afterAll, afterEach, describe, fdescribe, xdescribe, it, fit, xit, expect, DEFAULT_TIMEOUT_INTERVAL, CustomMatcherFactory, CustomEqualityTester

26 type ImplementationCallback = jasmine.ImplementationCallback;
   ~~~~

  ../node_modules/@types/jest/index.d.ts:33:1
    33 declare var beforeAll: jest.Lifecycle;
       ~~~~~~~
    Conflicts are in this file.

../node_modules/@types/jasmine/index.d.ts:314:15 - error TS2428: All declarations of 'ArrayContaining' must have identical type parameters.

314     interface ArrayContaining<T> extends AsymmetricMatcher<any> {
                  ~~~~~~~~~~~~~~~

../node_modules/@types/jasmine/index.d.ts:318:15 - error TS2428: All declarations of 'ObjectContaining' must have identical type parameters.

318     interface ObjectContaining<T> extends AsymmetricMatcher<T> {
                  ~~~~~~~~~~~~~~~~

../node_modules/@types/jasmine/index.d.ts:378:9 - error TS2687: All declarations of 'message' must have identical modifiers.

378         message?: string;
            ~~~~~~~

../node_modules/@types/jasmine/index.d.ts:928:15 - error TS2428: All declarations of 'SpyAnd' must have identical type parameters.

928     interface SpyAnd<Fn extends Func> {
                  ~~~~~~

../node_modules/@types/jasmine/index.d.ts:949:15 - error TS2428: All declarations of 'Calls' must have identical type parameters.

949     interface Calls<Fn extends Func> {
                  ~~~~~

../node_modules/@types/jasmine/index.d.ts:970:15 - error TS2428: All declarations of 'CallInfo' must have identical type parameters.

970     interface CallInfo<Fn extends Func> {
                  ~~~~~~~~

../node_modules/@types/jest/index.d.ts:33:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: beforeAll, beforeEach, afterAll, afterEach, describe, fdescribe, xdescribe, it, fit, xit, expect, DEFAULT_TIMEOUT_INTERVAL, CustomMatcherFactory, CustomEqualityTester

33 declare var beforeAll: jest.Lifecycle;
   ~~~~~~~

  ../node_modules/@types/jasmine/index.d.ts:26:1
    26 type ImplementationCallback = jasmine.ImplementationCallback;
       ~~~~
    Conflicts are in this file.

../node_modules/@types/jest/index.d.ts:1369:46 - error TS2314: Generic type 'ArrayContaining<T>' requires 1 type argument(s).

1369     function arrayContaining(sample: any[]): ArrayContaining;
                                                  ~~~~~~~~~~~~~~~

../node_modules/@types/jest/index.d.ts:1370:45 - error TS2314: Generic type 'ObjectContaining<T>' requires 1 type argument(s).

1370     function objectContaining(sample: any): ObjectContaining;
                                                 ~~~~~~~~~~~~~~~~

../node_modules/@types/jest/index.d.ts:1397:15 - error TS2428: All declarations of 'ArrayContaining' must have identical type parameters.

1397     interface ArrayContaining {
                   ~~~~~~~~~~~~~~~

../node_modules/@types/jest/index.d.ts:1403:15 - error TS2428: All declarations of 'ObjectContaining' must have identical type parameters.

1403     interface ObjectContaining {
                   ~~~~~~~~~~~~~~~~

../node_modules/@types/jest/index.d.ts:1406:9 - error TS2386: Overload signatures must all be optional or required.

1406         jasmineToString(): string;
             ~~~~~~~~~~~~~~~

../node_modules/@types/jest/index.d.ts:1412:14 - error TS2314: Generic type 'SpyAnd<Fn>' requires 1 type argument(s).

1412         and: SpyAnd;
                  ~~~~~~

../node_modules/@types/jest/index.d.ts:1413:16 - error TS2314: Generic type 'Calls<Fn>' requires 1 type argument(s).

1413         calls: Calls;
                    ~~~~~

../node_modules/@types/jest/index.d.ts:1419:15 - error TS2428: All declarations of 'SpyAnd' must have identical type parameters.

1419     interface SpyAnd {
                   ~~~~~~

../node_modules/@types/jest/index.d.ts:1452:15 - error TS2428: All declarations of 'Calls' must have identical type parameters.

1452     interface Calls {
                   ~~~~~

../node_modules/@types/jest/index.d.ts:1478:16 - error TS2314: Generic type 'CallInfo<Fn>' requires 1 type argument(s).

1478         all(): CallInfo[];
                    ~~~~~~~~

../node_modules/@types/jest/index.d.ts:1483:23 - error TS2314: Generic type 'CallInfo<Fn>' requires 1 type argument(s).

1483         mostRecent(): CallInfo;
                           ~~~~~~~~

../node_modules/@types/jest/index.d.ts:1488:18 - error TS2314: Generic type 'CallInfo<Fn>' requires 1 type argument(s).

1488         first(): CallInfo;
                      ~~~~~~~~

../node_modules/@types/jest/index.d.ts:1495:15 - error TS2428: All declarations of 'CallInfo' must have identical type parameters.

1495     interface CallInfo {
                   ~~~~~~~~

../node_modules/@types/jest/index.d.ts:1503:9 - error TS2717: Subsequent property declarations must have the same type.  Property 'args' must be of type 'Parameters<Fn>', but here has type 'any[]'.

1503         args: any[];
             ~~~~

  ../node_modules/@types/jasmine/index.d.ts:974:9
    974         args: Parameters<Fn>;
                ~~~~
    'args' was also declared here.

../node_modules/@types/jest/index.d.ts:1507:9 - error TS2717: Subsequent property declarations must have the same type.  Property 'returnValue' must be of type 'ReturnType<Fn>', but here has type 'any'.

1507         returnValue: any;
             ~~~~~~~~~~~

  ../node_modules/@types/jasmine/index.d.ts:976:9
    976         returnValue: ReturnType<Fn>;
                ~~~~~~~~~~~
    'returnValue' was also declared here.

../node_modules/@types/jest/index.d.ts:1511:9 - error TS2374: Duplicate string index signature.

1511         [index: string]: CustomMatcherFactory;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../node_modules/@types/jest/index.d.ts:1532:9 - error TS2687: All declarations of 'message' must have identical modifiers.

1532         message: string | (() => string);
             ~~~~~~~

../node_modules/@types/jest/index.d.ts:1532:9 - error TS2717: Subsequent property declarations must have the same type.  Property 'message' must be of type 'string', but here has type 'string | (() => string)'.

1532         message: string | (() => string);
             ~~~~~~~

  ../node_modules/@types/jasmine/index.d.ts:378:9
    378         message?: string;
                ~~~~~~~
    'message' was also declared here.

../node_modules/@types/jest/index.d.ts:1537:9 - error TS2375: Duplicate number index signature.

1537         [n: number]: T;
             ~~~~~~~~~~~~~~~


Found 27 errors.

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mraible/.npm/_logs/2020-10-04T15_29_31_782Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] electron:start: `npm run build && electron ./`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] electron:start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mraible/.npm/_logs/2020-10-04T15_29_31_804Z-debug.log

To Reproduce
Steps to reproduce the behavior:

  1. Create a new app with the Ionic JHipster starter:

    ionic start ionic4j oktadeveloper/jhipster --type angular

  2. Add Electron support using these instructions.

  3. In a terminal, navigate into the electron directory and run npm run electron:start.

Expected behavior

I'd expect everything to compile, inheriting from the parent tsconfig files so node_modules is ignored.

Desktop (please complete the following information):

  • OS: macOS 10.15.7
  • Browser N/A

Additional context

$ node --version
v14.10.1

Documentation for how to use deep linking with Electron

Is your feature request related to a problem? Please describe.

Please publish documentation on how to use deep linking with Electron. My expectation is that I'd be able to provide the custom protocol to Electron which would subsequently be registered in a fashion like: app.setAsDefaultProtocolClient('com.domain.for.my.app').

Describe the solution you'd like

I'd like to understand how to use deep linking with Electron. My expectation is that I can use the addListener('appUrlOpen' model like we can on iOS and Android

import { Plugins } from "@capacitor/core";

const { App } = Plugins;

App.addListener('appUrlOpen', (data: any) => {
   console.log('App Open', data)
})

Getting started Guide: How to start?

Describe the bug
Following the guide
https://capacitor-community-electron-docs-site.vercel.app/getting-started
It says use the script electron:start
I don't know how do that? in the electron folder there is no script like that
I also tried every combination with npx cap without luck

How can I even start it?

To Reproduce
Steps to reproduce the behavior:
Following all steps in https://capacitor-community-electron-docs-site.vercel.app/getting-started

Dependencies

"dependencies": {
"@angular/common": "~10.0.0",
"@angular/core": "~10.0.0",
"@angular/forms": "~10.0.0",
"@angular/platform-browser": "~10.0.0",
"@angular/platform-browser-dynamic": "~10.0.0",
"@angular/router": "~10.0.0",
"@capacitor-community/electron": "^1.2.3",
"@capacitor/core": "2.4.0",
"@ionic-native/core": "^5.0.0",
"@ionic-native/splash-screen": "^5.0.0",
"@ionic-native/status-bar": "^5.0.0",
"@ionic/angular": "^5.0.0",
"@ionic/storage": "^2.3.0",
"electron": "^9.2.1",
"ngx-electron": "^2.2.0",
"rxjs": "~6.5.5",
"tslib": "^2.0.0",
"zone.js": "~0.10.3"
},

Expected behavior
Electron starting as with the old way npx cap open electron

Desktop (please complete the following information):

  • OS: Windows 10 x64
  • Browser Firefox, but irrelevant as it does not open
  • Version 79.0

Add method of adding to preload

There is currently no way to add code to the preload without creating a plugin. Changing the preloader.js file works, but the changes are overwritten on every cap sync.

It would be nice to be able to add code, such as contextBridge.exposeInMainWorld calls, to the preloader without the large boilerplate associated with making a plugin.

Build Windows on Mac

Describe the bug
Started a clean project and tried to build for windows using Mac (10.15.7 Catalina).

cannot build native dependency reason=prebuild-install failed with error and build from sources not possible because platform or arch not compatible
cause=exit status 1
errorOut=prebuild-install info begin Prebuild-install version 6.0.0

prebuild-install WARN install prebuilt binaries enforced with --force!
prebuild-install WARN install prebuilt binaries may be out of date!
prebuild-install info looking for cached prebuild @ /Users/xxx/.npm/_prebuilds/90c5a2-sharp-v0.27.0-electron-v85-win32-x64.tar.gz
prebuild-install http request GET https://github.com/lovell/sharp/releases/download/v0.27.0/sharp-v0.27.0-electron-v85-win32-x64.tar.gz
prebuild-install http 404 https://github.com/lovell/sharp/releases/download/v0.27.0/sharp-v0.27.0-electron-v85-win32-x64.tar.gz
prebuild-install WARN install No prebuilt binaries found (target=11.2.0 runtime=electron arch=x64 libc= platform=win32)

  • OS: Mac Os Catalina
  • Capacitor/Electron: 1.3.1
  • Electron: 11.0.1
  • Electron-builder: 22.9.1

Source maps having wrong paths

Describe the bug
I am developing a cross-platform application, and part of that is using @capacitor-community/electron for desktop.
The build and export itself works fine, and the electron application is functioning, but I cannot get the source maps to work.

I am updating the electron build like this:
ionic cap sync

And then run it by going to the electron directory and:
npm run build && electron ./

It seems to me that the .map files are just blindly copied from root/build/static/js to root/electron/app/static/js.
Naturally, the paths inside of the .map files won’t work in that location, as an additional β€œβ€¦/” (or even β€œβ€¦/…/”?) would be required.

The errors all look like this:

devtools failed to load sourcemap could not load content for β€œcapacitor-electron://-/static/js/16.45739f90.chunk.js.map”

Is there a way to tell ionic (or capacitor) to change the paths so that the source maps will work with the electron target?
I'm not entirely sure if this is a bug or something additional I'd need to do to make it work properly.

Desktop (please complete the following information):

  • OS: Manjaro Linux

Expose Electron builder configuration properties via capacitor.config.json and change build process to read them dynamically

In doing some testing on deep linking in #36 I realized that the built app was pulling statically defined properties from the electron/package.json which is mentioned in the Quick Setup guide for Electron Builder.

I would like to see these values pulled dynamically from the capacitor.config.json at the root of the project.

So the mapping would be as follows:

Capacitor Property Electron Builder Property
appId appId
appName productName

There's likely additional properties we'd want to expose as well like Electron Builder's mac.category.

Finally I believe for deep linking to work for built application it has to be statically defined per the discussion here: electron-userland/electron-builder#1552 so I think it's worth exposing the custom protocol or scheme in the configuration and not have to modify the electron.index.ts to set it.

Cannot find module './server'

Describe the bug
I have created a separate module that is an express server which is being started in the main i.e index.js file. The issue is that the imported module works fine when I do npm run electron:start and the server listens but when I build it throws an exeption saying Cannot find module './server'.

To Reproduce
Steps to reproduce the behavior:

  1. Initialize a new capacitor project.
  2. Add electron using these steps
  3. Add a module in the ./src and import it in index.jsfile.
  4. Create build and run the app.

Expected behavior
Compiled code from ./build folder should all go to production build.

Screenshots
production:
image
electron:start
image

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Chrome
  • Version 85.0.4183.102 (Official Build) (64-bit)

Additional context
By the way the app and server works find if I do everything in one file.

Livereload for Ionic React app

Is the livereload for this electron platform currently possible?

I have an Ionic React app. I'm trying calling this command from project root folder:
ionic cap run @capacitor-community/electron -l

It first tries to add the electron platform again:
capacitor add @capacitor-community/electron
which fails with Error: Electron platform already exists. but continues with build process, so in my case these steps:

react-scripts start
capacitor copy @capacitor-community/electron
capacitor open @capacitor-community/electron

So in the end, it opens the electron window, but the content displayed is outdated - actually an old build I made in the past by manually doing
ionic build && npx cap copy
The content is not live-reloaded.

Am I doing something wrong or livereload is not available for electron?

Thank you!

Using Cordova plugins with Electron platform support

I have a cordova plugin which supports electron platform, together with android and ios platforms. The plugin has electron entry in its plugin.xml and a source file in ./src/electron folder.

When I do
npx cap sync

the sync correctly recognizes this cordova plugin for android and ios and copies it to the appropriate folders in native projects:

  • ./android/capacitor-cordova-android-plugins/ for android, and
  • ./ios/capacitor-cordova-ios-plugins/ for ios.

However, no such thing happens for electron, nothing is copied as far as I can tell. I also tried
npx cap sync @capacitor-community/electron
but the cordova plugin isn't copied either.

When I try
npx cap ls
a part of the output says [info] Listing plugins for electron is not possible.

Is this feature implemented, or is it even possible to implement?

OSX Native

Has anyone made a capacitor plugin that accesses native osx code via an electron app? E.g. permission to access contacts or calendar? Is this possible? thnx

capacitor:add @capacitor-community/electron fails on BigSur

Problem

Today I tried to install the @capacitor-community/electron package. The installation works fine at first, but when I try to "npx cap add @capacitor-community/electron" I get the following error:

> @capacitor-community/[email protected] capacitor:add
> node dist/cap-scripts.js add

βœ– Adding Electron platform: The "path" argument must be of type string. Received undefined
node:internal/process/promises:225
          triggerUncaughtException(err, true /* fromPromise */);
          ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:278:15)
    at validateString (node:internal/validators:123:11)
    at Object.join (node:path:1039:7)
    at Object.i [as getCwd] (/Users/user/project/node_modules/@capacitor-community/electron/dist/cap-scripts.js:2:521)
    at a (/Users/user/project/node_modules/@capacitor-community/electron/dist/cap-scripts.js:6:197)
    at Object.n [as doAdd] (/Users/user/project/node_modules/@capacitor-community/electron/dist/cap-scripts.js:6:960)
    at /Users/user/project/node_modules/@capacitor-community/electron/dist/cap-scripts.js:12:363
    at Object.g [as runTask] (/Users/user/project/node_modules/@capacitor-community/electron/dist/cap-scripts.js:2:1902)
    at i (/Users/user/project/node_modules/@capacitor-community/electron/dist/cap-scripts.js:12:311)
    at /Users/user/project/node_modules/@capacitor-community/electron/dist/cap-scripts.js:12:718 {
  code: 'ERR_INVALID_ARG_TYPE'
}
npm ERR! code 1
npm ERR! path /Users/user/project/node_modules/@capacitor-community/electron
npm ERR! command failed
npm ERR! command sh -c node dist/cap-scripts.js add

npm ERR! A complete log of this run can be found in:
npm ERR!    /Users/user/.npm/_logs/2020-12-11T06_57_03_068Z-debug.log

Environment

  • MacOS BigSur 11.0.1
  • @capacitor/cli version: 2.4.4
  • @capacitor/core version 2.4.4

confusing npm setup

not a big deal but we issue npm install @capacitor-community/electron and it does install electron-core ? should I've electron-core or just electron? it's a bit confusing

Screen Shot 2020-08-26 at 11 00 03

Also I see lerna being used here, is that really needed? I think we could keep things as simple as possible so others can better understand and contribute.

Overwrite electron BrowserWindow config

Currently only a few possible options can be overwritten like height, width and icon. The full electron config interface should be exposed to be overwritten by the user.

Maybe the CapacitorElectronConfig can reference the existing electron interface.

Cannot find index.js in built MacOS app

Describe the bug
Error at application startup

To Reproduce
Steps to reproduce the behavior:

  1. Build and run the Electron app on MacOS, shows alert with:

`Uncaught Exception:
Error: Cannot find module ```
/Users/mhicks/projects/clients/courio/courio/capacitor/electron/out/make/zip/darwin/x64/Courio.app/Contents/Resources/app/build/index.js'
at Module._resolveFilename (internal/modules/cjs/loader.js:972:15)
at Function.n._resolveFilename (electron/js2c/browser_init.js:249:921)
at Object. (electron/js2c/browser_init.js:185:3470)
at Object../lib/browser/init.ts (electron/js2c/browser_init.js:185:3714)
at webpack_require (electron/js2c/browser_init.js:1:128)
at electron/js2c/browser_init.js:1:1200
at electron/js2c/browser_init.js:1:1267
at NativeModule.compileForInternalLoader (internal/bootstrap/loaders.js:277:7)
at NativeModule.compileForPublicLoader (internal/bootstrap/loaders.js:219:10)
at loadNativeModule (internal/modules/cjs/helpers.js:24:9)


**Expected behavior**
A clear and concise description of what you expected to happen.

**Desktop (please complete the following information):**

- OS: MacOS

Application Menu configuration only applied in Development

Describe the bug
If supplying an applicationMenuTemplate in the config, this seems to only be applied in development mode.

To Reproduce
Steps to reproduce the behavior:

const appConfig = {
    applicationMenuTemplate: [ 
        { label: 'Custom Menu', submenu: [{ label: 'Custom Option' }] } 
    ]
}
const myCapacitorApp = createCapacitorElectronApp(appConfig)
  1. electron:start - custom menu applied
  2. electron:build - custom menu not applied, package defaults also not applied

Expected behavior
Expect that custom menu is applied in development and production builds.

Additional context
The only use of applicationMenuTemplate is in CapacitorElectronApp.js line 121:

if (electronIsDev && this.config.applicationMenuTemplate !== null) {
    // Set our above template to the Menu Object if we are in development mode, dont want users having the devtools.
    Menu.setApplicationMenu(Menu.buildFromTemplate(this.config.applicationMenuTemplate));
}

Perhaps the supplied menu can be always applied regardless whether running in development or production.

Instead, offer a config option like hideDevtoolsInProduction: boolean and if true, remove any menu objects containing { role: 'toggledevtools' }.

Capacitor Filesystem

I added electron to my capacitor project, I'm having problems with the Filesystem plugin. I downloaded some pdf files and saved with the method

let result = await Filesystem.writeFile ({
  path: path,
  data: fileData,
  directory: FilesystemDirectory.Data
})

my problem is being able to show them to electron api.
if I try to fetch the uri of the saved file I see it with the Filesystem plugin, but I don't understand where it is saved or how to use it with electron.

let result = await Filesystem.getUri ({
  path: pathFile,
  directory: FilesystemDirectory.Data
});

console.log (result.uri) /DATA/example.pdf

`npx cap` does not seem to work with `@capacitor/community-electron` 3 beta and Capacitor RC 3

Describe the bug

While using the latest release candidate for Capacitor 3 (3.0.0-rc.3 at the time of writing) I'm unable to use the various npx cap <cmd> with @capacitor/community-electron

To Reproduce

~/app
$ npm i @capacitor-community/electron@next
npm WARN @babel/[email protected] requires a peer of @babel/core@^7.13.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic/[email protected] requires a peer of react@^16.8.6 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic/[email protected] requires a peer of @testing-library/react@^9.4.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic/[email protected] requires a peer of jest@^24.9.0 but none is installed. You must install peer dependencies yourself.

+ @capacitor-community/[email protected]
added 23 packages from 27 contributors and audited 2268 packages in 12.172s
found 5252 vulnerabilities (79 moderate, 5173 high)
  run `npm audit fix` to fix them, or `npm audit` for details

~/app
$ npx cap add @capacitor-community/electron
βœ” Adding Electron platform in 26.06s
β ‹ Updating Electron plugins
/* eslint-disable @typescript-eslint/no-var-requires */

module.exports = {
}


/app/electron/node_modules/@capacitor-community/electron/dist/runtime/electron-plugins.js
βœ” Updating Electron plugins in 15.32ms

~/app
$ npx cap sync @capacitor/community-electron
[error] Platform @capacitor/community-electron not found.
[error] Platform @capacitor/community-electron not found.

~/app
$ npx cap open @capacitor/community-electron
[error] Platform @capacitor/community-electron not found.

Expected behavior

npx cap commands work as noted in the documentation

Can not add platform with Yarn2/PnP

> yarn cap add @capacitor-community/electron                                                     # ppm -> 1-setup |β€’ β€” ! + ?
[error] platform @capacitor-community/electron not found
> yarn info -A @capacitor-community/electron                                                     # ppm -> 1-setup |β€’ β€” ! + ?
└─ @capacitor-community/electron@npm:1.3.1
   β”œβ”€ Version: 1.3.1
   β”‚
   └─ Dependencies
      β”œβ”€ @capacitor/core@npm:^2.0.0 β†’ npm:2.4.2
      β”œβ”€ chalk@npm:^4.1.0 β†’ npm:4.1.0
      β”œβ”€ electron-is-dev@npm:^1.2.0 β†’ npm:1.2.0
      β”œβ”€ electron-serve@npm:^1.0.0 β†’ npm:1.0.0
      β”œβ”€ fs-extra@npm:^8.1.0 β†’ npm:8.1.0
      β”œβ”€ mime-types@npm:~2.1.27 β†’ npm:2.1.27
      └─ ora@npm:^4.0.4 β†’ npm:4.1.1

might be related to this which I opened, but since the error is different ionic-team/capacitor#3805

Not able to start electron app

Describe the bug
When i try to start an electron app then it fails with a weird log. Electron platform does get added successfully but on starting electron app it crash

shashwattripathi@Shashwats-MacBook-Pro electron-test % npx cap add @capacitor-community/electron

> @capacitor-community/[email protected] capacitor:add /Users/shashwattripathi/projects/electron-test/node_modules/@capacitor-community/electron
> node dist/cap-scripts.js add

βœ” Adding Electron platform in 25.98s
βœ” Updating Electron plugins in 12.87ms

shashwattripathi@Shashwats-MacBook-Pro electron-test % npx cap open @capacitor-community/electron

> @capacitor-community/[email protected] capacitor:open /Users/shashwattripathi/projects/electron-test/node_modules/@capacitor-community/electron
> node dist/cap-scripts.js open

β ΄ Opening Electron platformError: undefined
βœ– Opening Electron platform: 
(node:17308) UnhandledPromiseRejectionWarning: 
> [email protected] electron:start /Users/shashwattripathi/projects/electron-test/electron
> npm run build && electron ./


> [email protected] build /Users/shashwattripathi/projects/electron-test/electron
> tsc

node_modules/@types/fs-extra/index.d.ts(232,38): error TS2694: Namespace '"fs"' has no exported member 'BaseEncodingOptions'.
node_modules/@types/fs-extra/index.d.ts(233,38): error TS2694: Namespace '"fs"' has no exported member 'BufferEncodingOption'.
node_modules/@types/fs-extra/index.d.ts(234,38): error TS2694: Namespace '"fs"' has no exported member 'BaseEncodingOptions'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `tsc`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/shashwattripathi/.npm/_logs/2021-03-21T08_29_09_297Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] electron:start: `npm run build && electron ./`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the [email protected] electron:start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/shashwattripathi/.npm/_logs/2021-03-21T08_29_09_332Z-debug.log

(Use `node --trace-warnings ...` to show where the warning was created)
(node:17308) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:17308) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

shashwattripathi@Shashwats-MacBook-Pro electron-test % 

To Reproduce
Steps to reproduce the behavior:

Here is a project that i added using Ionic CLI
https://github.com/stripathix/electron-test
Commands sequence i used in process

ionic start
// Then used vue project with tabs to setup project
npm run build
npm i @capacitor-community/electron
npx cap add @capacitor-community/electron
npx cap open @capacitor-community/electron.  ->>>> here it fails

Expected behavior
On using npx cap add electron application works as electron app but in log it says it is depricated and asks to use capacitor-communit/electron

Screenshots
If applicable, add screenshots to help explain your problem.
Screenshot 2021-03-21 at 2 07 45 PM

Desktop (please complete the following information):

  • OS: MacOS BigSur 11.2.3
  • Browser Chrome

Unable to add Electron to existing Capacitor project

Describe the bug

I receive the following error when adding @capacitor-community/electron:

$ npx cap add @capacitor-community/electron
[error] Invalid platform: "@capacitor-community/electron". Valid platforms include: android, electron, ios, web

To Reproduce

Followed the installation instructions in the README

Expected behavior

Community version of electron should be installed and able to be used.

Additional context

Relevant versions of dependencies in project:

    "@capacitor-community/electron": "^0.5.4",
    "@capacitor/android": "^2.3.0",
    "@capacitor/core": "^2.3.0",
    "@capacitor/ios": "^2.3.0",
    "@ionic-enterprise/auth": "^3.1.1",
    "@ionic-native/core": "^5.27.0",
    "@ionic/react": "^5.2.3",

The electron platform is deprecated

Hi!

I have an Ionic app and now I was deploying to Windows using Electron.
When I ran the command npx cap add electron I received the warning The electron platform is deprecated!
What is the reason for this warning? Is there a better alternative?

How can I share local storage, IndexedDb, Session storage between BrowserWindows ?

Describe the bug
I haven't been able to figure out how to share the data in the various storage mechanisms between the main window and new browser windows I create from clicking on tray menu options. I have tried using "parent", "session" and "partition" on the BrowserWindow Objects I create. For example:

const trayWindow: BrowserWindow = new BrowserWindow({
            backgroundColor: '#FFF',
            width: 300,
            height: 150,
            show: false,
            frame: false,
            fullscreenable: false,
            resizable: true,
            //parent: this.mainWindow,
            webPreferences: {
                //partition: 'persist:myapp', 
                session: mySession,  // tried with/without
                nativeWindowOpen: true, //tried both true/false
                devTools: isDevMode,
                enableRemoteModule: true, 
                nodeIntegration: true, //tried both true/false
                preload: path.join(app.getAppPath(), "preloader.js"),

             }
        });

Where mySession is an object set as the session object in the main window's config or retrieved through
this.mainWindow.webContents.session. Neither way seemed to help.
Using partition: 'persist:myapp', gives this error, but because setting session doesn't help I don't think that would help anyway:

(node:74976) UnhandledPromiseRejectionWarning: Error: ERR_FAILED (-2) loading 'capacitor-electron://-' at rejectAndCleanup (electron/js2c/browser_init.js:205:1493) at Object.stopLoadingListener (electron/js2c/browser_init.js:205:1868) at Object.emit (events.js:315:20) (node:74976) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:74976) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

To Reproduce
Steps to reproduce the behavior:

Create an electron-capacitor app and main window:

  const mySession: Session = session.fromPartition("persist:myapp");
const config: CapacitorElectronConfig = this.createCapacitorElectronConfig(mySession);
       this.capacitorApp = createCapacitorElectronApp(config);
       this.capacitorApp.init();
    private createCapacitorElectronConfig(mySession: Session): CapacitorElectronConfig {
        
        const menuItems: MenuItem[] = this.makeMenuItems();

        //https://capacitor-community.github.io/electron/#/./config-options/index
        const config: CapacitorElectronConfig = {
            trayMenu: {
                useTrayMenu: true,
                trayIconPath: TrayGenerator.makeIconPath(),
               trayContextMenu: menuItems
            },

            mainWindow: {
                windowOptions: {
                    height: 920,
                    width: 1600,
                    show: true,
                    webPreferences: {
                        session: mySession,
                        //partition: 'persist:myapp',
                        nativeWindowOpen: true,
                        enableRemoteModule: true,
                        nodeIntegration: true,   
                        },
                }
            }
        };
        return config;
    }

I tried making the Tray through the above config as well as making the tray object separately.

Create another window as above "trayWindow" is created and load a url :
const loadPromise: Promise<void> = trayWindow.loadURL(trayUrl);

Expected behavior
The main window's local storage, session storage and indexedDb storage is shared with other windows created in the app.

Screenshots
Notice the main window uses the capacitor-electron:// schema in the following screenshot:
Screen Shot 2021-01-03 at 11 36 51 PM

However the other browser windows created use the file:// schema:
Screen Shot 2021-01-03 at 11 36 22 PM

The IndexedDb is different regardless.

Desktop (please complete the following information):

  • OS: MacOs High Sierra 10.13.6
  • Browser: Electron
  • Version
"electron": "^11.0.1",
   "@capacitor-community/electron": "^1.3.1"

Additional context
I am not writing to IndexedDb directly, but am rather using AngularFire and AngularFireAuth in the renderer process, so I can't grab the data in the main process and pass it to the various windows without significant alterations. I don't want to login again in a new browser window when I open a window from the tray if I have already logged in to the main window. The login info is stored in IndexedDB, as show in the screenshots.
This seems to be related to this stackoverflow question : sharing indexdDb

However because of the different schemas ("capacitor-electron://" vs "file://" )in my use case I am posting it here as well.

Adding Electron platform: capacitor.config.json does not exist

Describe the bug
I want to add Electron support to a sample Ionic application. First I used yarn, but also tried with npm and I get the same error message when executing npx cap add @capacitor-community/electron:

> @capacitor-community/[email protected] capacitor:add
> node dist/cap-scripts.js add

β ‹ Adding Electron platformError: capacitor.config.json does not exist, did you setup capacitor in your project root?
βœ– Adding Electron platform: capacitor.config.json does not exist, did you setup capacitor in your project root?
/home/dev/projects/photo-gallery/node_modules/@capacitor-community/electron/dist/cap-scripts.js:6
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.doAdd=void 0;const e=require("fs"),t=require("fs-extra"),r=require("path"),o=require("./common");function a(){const t=o.getCwd(),a={errorText:null,usersProjectCapConfigPath:null,srcTemplatePath:null,destTemplatePath:null,webAppPath:null},n=r.join(t,"capacitor.config.json"),i=r.join(__dirname,"../","template"),s=r.join(t,"electron");if(e.existsSync(n)){const c=o.readJSON(n);if(c.webDir){const o=r.join(t,c.webDir);e.existsSync(o)?e.existsSync(s)?a.errorText="Electron platform already exists.":(a.destTemplatePath=s,a.srcTemplatePath=i,a.usersProjectCapConfigPath=n,a.webAppPath=o):a.errorText="WebDir defined in capacitor.config.json does not exist, did you build your webapp?"}else a.errorText="No webDir defined in capacitor.config.json."}else a.errorText="capacitor.config.json does not exist, did you setup capacitor in your project root?";return a}async function n(){const n=a();if(null!==n.errorText)throw o.errorLog(n.errorText),new Error(n.errorText);try{e.mkdirSync(n.destTemplatePath,{recursive:!0}),t.copySync(n.srcTemplatePath,n.destTemplatePath),e.renameSync(r.join(n.destTemplatePath,"gitignore"),r.join(n.destTemplatePath,".gitignore")),t.copySync(n.usersProjectCapConfigPath,r.join(n.destTemplatePath,"capacitor.config.json"));const a=o.readJSON(r.join(n.destTemplatePath,"capacitor.config.json")).appName,s=o.readJSON(r.join(n.destTemplatePath,"package.json"));s.name=a,o.writePrettyJSON(r.join(n.destTemplatePath,"package.json"),s),t.copySync(n.webAppPath,r.join(n.destTemplatePath,"app")),await o.runExec(`cd ${n.destTemplatePath} && npm i`)}catch(i){throw o.errorLog(i.message),i}}exports.doAdd=n;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ^

Error: capacitor.config.json does not exist, did you setup capacitor in your project root?
    at Object.n [as doAdd] (/home/dev/projects/photo-gallery/node_modules/@capacitor-community/electron/dist/cap-scripts.js:6:1016)
    at /home/dev/projects/photo-gallery/node_modules/@capacitor-community/electron/dist/cap-scripts.js:12:363
    at Object.g [as runTask] (/home/dev/projects/photo-gallery/node_modules/@capacitor-community/electron/dist/cap-scripts.js:2:1902)
    at i (/home/dev/projects/photo-gallery/node_modules/@capacitor-community/electron/dist/cap-scripts.js:12:311)
    at /home/dev/projects/photo-gallery/node_modules/@capacitor-community/electron/dist/cap-scripts.js:12:718
    at Object.parcelRequire.Focm../common (/home/dev/projects/photo-gallery/node_modules/@capacitor-community/electron/dist/cap-scripts.js:12:915)
    at f (/home/dev/projects/photo-gallery/node_modules/@capacitor-community/electron/dist/cap-scripts.js:1:468)
    at parcelRequire.FoEN (/home/dev/projects/photo-gallery/node_modules/@capacitor-community/electron/dist/cap-scripts.js:1:771)
    at Object.<anonymous> (/home/dev/projects/photo-gallery/node_modules/@capacitor-community/electron/dist/cap-scripts.js:1:1023)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
npm ERR! code 1
npm ERR! path /home/dev/projects/photo-gallery/node_modules/@capacitor-community/electron
npm ERR! command failed
npm ERR! command sh -c node dist/cap-scripts.js add

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/dev/.npm/_logs/2021-01-25T18_39_12_965Z-debug.log

To Reproduce
Steps to reproduce the behavior:

I created an Ionic sample application following and then tried to follow https://sunilrk.medium.com/ionic-desktop-apps-with-capacitor-and-electron-community-plugin-the-electron-platform-is-487e6171c447 to add Electron support.

  1. Create the sample application following https://ionicframework.com/docs/angular/your-first-app
  2. Run npx cap init
  3. Follow https://sunilrk.medium.com/ionic-desktop-apps-with-capacitor-and-electron-community-plugin-the-electron-platform-is-487e6171c447 to add Electron support until the second step (building ionic app for production and adding Electron support libraries)

Expected behavior
Getting output similar to the tutorial and Electron support has been added.

Desktop (please complete the following information):

  • OS: Windows 10 Pro with WSL 2 (Ubuntu 20.04 LTS).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.