Update gitignore (sorry)
Some checks failed
Android Build / publish (push) Successful in 33s
Linux Build / publish (push) Failing after 25s

This commit is contained in:
olcxja 2026-05-10 14:02:17 +02:00
commit cca8b02fea
6604 changed files with 1219661 additions and 4 deletions

View file

@ -0,0 +1,29 @@
{
"branches": [
"main",
{ "name": "next", "prerelease": true }
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/npm",
{
"npmPublish": false
}
],
[
"@semantic-release/git",
{
"assets": [
"package.json",
"pnpm-lock.json",
"CHANGELOG.md"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}\n\n\nskip-checks: true"
}
],
"@semantic-release/github"
]
}

View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) Mike Summerfeldt.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,69 @@
<p align="center">
<img src="https://user-images.githubusercontent.com/20338451/124627505-9cd53a80-de4d-11eb-8d74-f81685804b05.png" width="835" height="168" /><br />
</p>
<p align="center">
Bring your Capacitor ⚡ apps to the desktop with Electron! 🖥
</p>
<p align="center">
<a href="https://github.com/capacitor-community/electron"><img src="https://img.shields.io/badge/maintenance%20status-maintained-yellow" /></a>
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
<a href="#contributors"><img src="https://img.shields.io/badge/all%20contributors-11-orange?style=flat-square" /></a>
<!-- ALL-CONTRIBUTORS-BADGE:END -->
<a href="https://www.electronjs.org/releases/stable?version=26"><img src="https://img.shields.io/badge/supported%20electron%20version-^26.2.0-blue" /></a>
</p>
<p align="center">
<a href="https://npmjs.com/package/@capacitor-community/electron"><img src="https://img.shields.io/npm/v/@capacitor-community/electron.svg" /></a>
<a href="https://npmjs.com/package/@capacitor-community/electron"><img alt="npm" src="https://img.shields.io/npm/dw/@capacitor-community/electron"></a>
<a href="https://npmjs.com/package/@capacitor-community/electron"><img src="https://img.shields.io/npm/l/@capacitor-community/electron.svg?color=blue" /></a>
<a href="https://github.com/capacitor-community/electron"><img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/capacitor-community/electron/ci.yml?branch=main"></a>
</p>
## ⚠ 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](https://github.com/capacitor-community/electron/tree/main/plugin-examples) for examples.
## 📖 Documentation:
[You can find the docs site here.](https://capacitor-community.github.io/electron/)
## 🔐 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](https://www.electronjs.org/docs/tutorial/security#checklist-security-recommendations) 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](https://github.com/IT-MikeS) | [@IT_MikeS](https://twitter.com/IT_MikeS) | Volunteer | Yes |
## ✨ Contributors
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="http://ionicframework.com/"><img src="https://avatars3.githubusercontent.com/u/11214?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Max Lynch</b></sub></a><br /><a href="https://github.com/capacitor-community/electron/commits?author=mlynch" title="Code">💻</a> <a href="https://github.com/capacitor-community/electron/commits?author=mlynch" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/IT-MikeS"><img src="https://avatars0.githubusercontent.com/u/20338451?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Mike Summerfeldt</b></sub></a><br /><a href="https://github.com/capacitor-community/electron/commits?author=IT-MikeS" title="Code">💻</a> <a href="https://github.com/capacitor-community/electron/commits?author=IT-MikeS" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/danielsogl"><img src="https://avatars2.githubusercontent.com/u/15234844?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Daniel Sogl</b></sub></a><br /><a href="https://github.com/capacitor-community/electron/commits?author=danielsogl" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/vevedh"><img src="https://avatars1.githubusercontent.com/u/1430389?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Hervé de CHAVIGNY</b></sub></a><br /><a href="https://github.com/capacitor-community/electron/commits?author=vevedh" title="Code">💻</a> <a href="https://github.com/capacitor-community/electron/commits?author=vevedh" title="Documentation">📖</a></td>
<td align="center"><a href="http://twitter.com/leMaikOfficial"><img src="https://avatars2.githubusercontent.com/u/5544859?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Maik Marschner</b></sub></a><br /><a href="https://github.com/capacitor-community/electron/commits?author=leMaik" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/stewones"><img src="https://avatars1.githubusercontent.com/u/719763?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Stew</b></sub></a><br /><a href="https://github.com/capacitor-community/electron/commits?author=stewones" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/coreyjv"><img src="https://avatars3.githubusercontent.com/u/2730750?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Corey Vaillancourt</b></sub></a><br /><a href="https://github.com/capacitor-community/electron/commits?author=coreyjv" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/jgoux"><img src="https://avatars0.githubusercontent.com/u/1443499?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Julien Goux</b></sub></a><br /><a href="https://github.com/capacitor-community/electron/commits?author=jgoux" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/MathisTLD"><img src="https://avatars.githubusercontent.com/u/42317770?v=4?s=75" width="75px;" alt=""/><br /><sub><b>MathisTLD</b></sub></a><br /><a href="https://github.com/capacitor-community/electron/commits?author=MathisTLD" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/challenger71498"><img src="https://avatars.githubusercontent.com/u/43464986?v=4?s=75" width="75px;" alt=""/><br /><sub><b>challenger71498</b></sub></a><br /><a href="https://github.com/capacitor-community/electron/commits?author=challenger71498" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/jdgjsag67251"><img src="https://avatars.githubusercontent.com/u/88368191?v=4?s=75" width="75px;" alt=""/><br /><sub><b>jdgjsag67251</b></sub></a><br /><a href="https://github.com/capacitor-community/electron/commits?author=jdgjsag67251" title="Code">💻</a></td>
</tr>
</table>
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->

View file

@ -0,0 +1,53 @@
/* eslint-disable no-undef */
/* eslint-disable @typescript-eslint/no-var-requires */
const esbuild = require('esbuild');
const { readdirSync } = require('fs');
const { join } = require('path');
const tar = require('tar');
async function packTemplate() {
const templateSrc = join('./', 'src', 'electron-platform-template');
const destTemplateFilePath = join('./', 'template.tar.gz');
const files = [];
readdirSync(templateSrc).forEach((file) => {
files.push(file);
});
await tar.create({ gzip: true, file: destTemplateFilePath, cwd: templateSrc }, files);
console.log(`Packed ${destTemplateFilePath}!`);
}
async function buildCliScrpts() {
await esbuild.build({
entryPoints: ['src/cli-scripts/index.ts'],
bundle: true,
outfile: 'dist/cli-scripts/cap-scripts.js',
platform: 'node',
target: 'node16',
minify: true,
external: ['child_process', 'fs', 'path', 'fs-extra', 'crypto', 'chalk', 'ora'],
});
}
async function buildPlatformCore() {
await esbuild.build({
entryPoints: ['src/electron-platform/index.ts'],
bundle: true,
outfile: 'dist/core/index.js',
platform: 'node',
target: 'node16',
minify: true,
external: ['electron', 'fs', 'path', 'mime-types', 'events'],
});
}
(async () => {
try {
await buildPlatformCore();
await buildCliScrpts();
await packTemplate();
console.log('\nPlatform Build Complete.\n');
} catch (e) {
console.error(e);
process.exit(1);
}
})();

View file

@ -0,0 +1,164 @@
---
sidebar_position: 5
---
# Create a Capacitor Electron Plugin
1. Create or open a Capacitor V3 compatible plugin in your editor of choice.
2. Create a folder named `electron` in the root of this plugin, with a sub-folder of `src` in it.
3. Create a ts file in the above `src` folder named `index.ts` and either paste in the following example code of the `@capacitor/dialog` plugin and edit away, or create your own from scratch:
```typescript
import { dialog } from 'electron'
import type {
DialogPlugin,
AlertOptions,
PromptOptions,
PromptResult,
ConfirmOptions,
ConfirmResult,
} from '../../src/definitions';
export class DialogElectron implements DialogPlugin {
async alert(options: AlertOptions): Promise<void> {
await dialog.showMessageBox({message: options.message + ' --- electron'});
}
async prompt(options: PromptOptions): Promise<PromptResult> {
const val = window.prompt(options.message, options.inputText || '');
return {
value: val !== null ? val : '',
cancelled: val === null,
};
}
async confirm(options: ConfirmOptions): Promise<ConfirmResult> {
const val = window.confirm(options.message);
return {
value: val,
};
}
}
```
4. Create a `.gitignore` file in the `electron` folder with the following:
```
dist
```
5. Create a `.npmignore` file in the `electron` folder with the following:
```
src
```
6. Create a `rollup.config.js` file in the `electron` folder with the following:
```javascript
export default {
input: 'electron/build/electron/src/index.js',
output: [
{
file: 'electron/dist/plugin.js',
format: 'cjs',
sourcemap: true,
inlineDynamicImports: true,
},
],
external: ['@capacitor/core'],
};
```
7. Create a `tsconfig.json` file in the `electron` folder with the following:
```json
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": true,
"experimentalDecorators": true,
"noEmitHelpers": true,
"importHelpers": true,
"lib": ["dom", "es2020"],
"module": "commonjs",
"noImplicitAny": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "build",
"sourceMap": true,
"strict": false,
"target": "ES2017"
},
"include": ["src/**/*"]
}
```
8. Modify the main `package.json` in the root directory, add a property to the `capacitor` object so it reflects the following (android and ios shown for example only):
```json
"capacitor": {
"ios": {
"src": "ios"
},
"android": {
"src": "android"
},
"electron": {
"src": "electron"
}
},
```
9. Add your electron implementation to the `<root>/src/index.ts` where your web implementation is registered:
```typescript
const Dialog = registerPlugin<DialogPlugin>('Dialog', {
web: () => import('./web').then(m => new m.DialogWeb()),
electron: () => (window as any).CapacitorCustomPlatform.plugins.DialogElectron
});
```
10. Modify the main `package.json` in the root directory, add an entry into the `files` array of the following:
`electron/`
11. Modify the main `package.json` in the root directory, add an entry into the `scripts` object of the following:
`"build-electron": "tsc --project electron/tsconfig.json && rollup -c electron/rollup.config.js && rimraf ./electron/build",`
12. Modify the main `package.json` in the root directory, edit the `build` entry in the `scripts` object to be the following:
`"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js && npm run build-electron",`
13. Run the `build` npm script to build your plugin.
14. Release it to NPM then use in your capacitor apps as any other native plugin like android or ios. (dont forget to use `npx cap sync/copy/update/open @capacitor-community/electron`)
### Check out the `plugin-example` folder in the repo for a small demo plugin.
## Events
If you want to emit events from your plugin, your class has to extend the [NodeJS event emitter class](https://nodejs.org/api/events.html#events_class_eventemitter). This is used by Capacitor Electron to determine if it should expose the `addListener` & `removeListener` functions to the Electron runtime plugin.
```typescript
import { EventEmitter } from 'events';
export default class MyPlugin extends EventEmitter {
constructor() {
setInterval(() => {
this.emit('my-event', 'You successfully listened to the 10sec event!');
}, 10_000);
}
}
```
In your client code you can do the following:
```typescript
const id = CapacitorCustomPlatform.plugins.MyPlugin.addListener('my-event', console.log);
// SOME CODE
CapacitorCustomPlatform.plugins.MyPlugin.removeListener(id);
```
## Config
Plugins get access to the `capacitor.config.ts` config object as the first argument to the constructor. E.g.:
```typescript
export default class App {
private config?: Record<string, any>;
constructor(config?: Record<string, any>) {
this.config = config;
}
getLaunchUrl(): string | undefined {
const url = this.config?.server?.url;
return url ? { url } : undefined;
}
}
```
**Keep in mind that the config could possibly be `undefined`.**

View file

@ -0,0 +1,84 @@
{
"name": "@capacitor-community/electron",
"version": "5.0.1",
"description": "Capacitor community support for the Electron platform!",
"main": "dist/core/index.js",
"typings": "dist/core/index.d.ts",
"scripts": {
"lint": "pnpm eslint . --ext ts && pnpm prettier \"./**/*.{css,html,ts,js,java}\" --check",
"fmt": "pnpm eslint . --ext ts --fix && pnpm prettier \"./**/*.{css,html,ts,js,java}\" --write",
"clean": "rimraf ./dist && rimraf ./template.tar.gz",
"build": "pnpm run clean && pnpm run fmt && pnpm run build-platform && pnpm run build-platform-types",
"capacitor:add": "node dist/cli-scripts/cap-scripts.js add",
"capacitor:copy": "node dist/cli-scripts/cap-scripts.js copy",
"capacitor:update": "node dist/cli-scripts/cap-scripts.js update",
"capacitor:sync": "node dist/cli-scripts/cap-scripts.js sync",
"capacitor:open": "node dist/cli-scripts/cap-scripts.js open",
"build-platform": "node ./build.js",
"build-platform-types": "tsc ./src/electron-platform/index.ts --outDir ./dist/core --declaration --emitDeclarationOnly --esModuleInterop",
"shipit": "pnpm semantic-release && npm publish --tag latest --provenance",
"shipit-next": "pnpm semantic-release && npm publish --tag next --provenance",
"commit": "git add . && pnpm git-cz && git push"
},
"license": "MIT",
"author": "IT-MikeS",
"devDependencies": {
"@commitlint/cli": "^17.6.3",
"@commitlint/config-conventional": "^17.6.3",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^9.0.2",
"@semantic-release/git": "^10.0.1",
"@semantic-release/npm": "^10.0.3",
"@semantic-release/release-notes-generator": "^11.0.1",
"@types/events": "^3.0.0",
"@types/fs-extra": "^11.0.1",
"@types/node": "^18.16.8",
"@typescript-eslint/eslint-plugin": "^5.59.5",
"@typescript-eslint/parser": "^5.59.5",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"electron": "^26.2.2",
"esbuild": "^0.17.18",
"eslint": "^8.40.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"is-ci": "^3.0.1",
"prettier": "^2.8.8",
"rimraf": "^5.0.0",
"semantic-release": "^21.0.2",
"tar": "^6.1.14",
"typescript": "^5.0.4"
},
"dependencies": {
"@capacitor/cli": ">=5.4.0",
"@capacitor/core": ">=5.4.0",
"@ionic/utils-fs": "~3.1.6",
"chalk": "^4.1.2",
"electron-is-dev": "~2.0.0",
"events": "~3.3.0",
"fs-extra": "~11.1.1",
"keyv": "^4.5.2",
"mime-types": "~2.1.35",
"ora": "^5.4.1"
},
"repository": {
"type": "git",
"url": "https://github.com/capacitor-community/electron"
},
"bugs": {
"url": "https://github.com/capacitor-community/electron/issues"
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
}
}

Binary file not shown.