{"id":14978504,"url":"https://github.com/archergu/einf","last_synced_at":"2026-04-02T12:54:49.997Z","repository":{"id":57750102,"uuid":"525188469","full_name":"ArcherGu/einf","owner":"ArcherGu","description":"A simple electron main process framework","archived":false,"fork":false,"pushed_at":"2024-10-29T12:17:46.000Z","size":1715,"stargazers_count":24,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-29T14:47:00.544Z","etag":null,"topics":["decorator","electron","framework","ipc","metadata"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ArcherGu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-16T01:10:57.000Z","updated_at":"2024-10-29T12:17:49.000Z","dependencies_parsed_at":"2023-09-22T00:27:06.984Z","dependency_job_id":"d3f65d46-d98c-484e-8629-b384ac28ef91","html_url":"https://github.com/ArcherGu/einf","commit_stats":{"total_commits":868,"total_committers":4,"mean_commits":217.0,"dds":"0.040322580645161255","last_synced_commit":"e925bd657f1c47dcb3fa8e2b1b8f5f504863ce61"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArcherGu%2Feinf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArcherGu%2Feinf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArcherGu%2Feinf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArcherGu%2Feinf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ArcherGu","download_url":"https://codeload.github.com/ArcherGu/einf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230394228,"owners_count":18218707,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decorator","electron","framework","ipc","metadata"],"created_at":"2024-09-24T13:57:48.546Z","updated_at":"2026-04-02T12:54:49.937Z","avatar_url":"https://github.com/ArcherGu.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg width=\"250\" src=\"./Einf.png\" alt=\"Einf logo\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\nA simple electron main process framework.\n\u003cp\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://npm.im/mono-release\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/einf?style=flat-square\" alt=\"NPM Version\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://npm.im/mono-release\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dw/einf?style=flat-square\" alt=\"NPM Downloads\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/ArcherGu/einf/actions/workflows/ci.yml\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/ArcherGu/einf/ci.yml?style=flat-square\" alt=\"Workflow Status\"\u003e\n  \u003c/a\u003e\n\u003cp\u003e\n\n## Description\n\nEinf is a simple electron main process framework, which provides some decorators and automatic dependency injection to help you simplify the main process code.\n\n## Features\n\n- 💉‍ Support dependency injection powered by Typescript decorators.\n\n- 🪟 Support custom items injection and window object injection.\n\n- 🔗 Automatic ipc channel binding to reduce duplication of code.\n\n- 📦 Tiny size, the whole framework is less than 10kb.\n\n- 💡 Simple to use, you can use it as a base framework to build your own framework.\n\n## Installation\n\n```shell\nnpm i einf\n# Or Yarn\nyarn add einf\n# Or PNPM\npnpm add einf\n```\n\n## Usage\n\n1. Entry point of your electron application like `index.ts`:\n\n```ts\nimport { createEinf } from 'einf'\nimport { app, BrowserWindow } from 'electron'\nimport { AppController } from './app.controller'\n\nasync function bootstrap() {\n  const window = new BrowserWindow()\n  window.loadURL('https://github.com')\n\n  await createEinf({\n    // window to create\n    window,\n    // controllers will be automatically initialized\n    controllers: [AppController],\n    // custom items to inject\n    injects: [{\n      name: 'IS_DEV',\n      inject: !app.isPackaged,\n    }],\n  })\n}\n\nbootstrap()\n```\n\n2. Provide at least one controller to start the application, `app.controller.ts`:\n\n```ts\nimport type { BrowserWindow } from 'electron'\nimport { Controller, Inject, IpcHandle, IpcSend, Window } from 'einf'\nimport { app } from 'electron'\nimport { AppService } from './app.service'\n\n@Controller()\nexport class AppController {\n  constructor(\n    private appService: AppService,\n    @Inject('IS_DEV') private isDev: boolean,\n    @Window() private win: BrowserWindow,\n  ) {}\n\n  @IpcSend('reply-msg')\n  public replyMsg(msg: string) {\n    return msg\n  }\n\n  @IpcHandle('send-msg')\n  public sendMsg(msg: string) {\n    console.log(msg)\n    return 'Get msg'\n  }\n\n  @IpcHandle('exit')\n  public exit() {\n    app.quit()\n  }\n}\n```\n\n3. You can also inject service via `@Injectable` decorator, `app.service.ts`:\n\n```ts\nimport { Injectable } from 'einf'\n\n@Injectable()\nexport class AppService {\n  public createMsg(msg: string): string {\n    return `\"${msg}\" is created by app service`\n  }\n}\n```\n\n4. Typescript configuration:\n\nEnsure that `experimentalDecorators` and `emitDecoratorMetadata` are enabled in your TypeScript configuration (such as in `tsconfig.json`).\nIf not, you may encounter an error stating `Unable to resolve signature of class decorator when called as an expression`.\n\n```json\n{\n  \"compilerOptions\": {\n    // ... other options\n    \"experimentalDecorators\": true,\n    \"emitDecoratorMetadata\": true\n  }\n}\n```\n\n## License\n\nMIT License © 2022 [Archer Gu](https://github.com/archergu)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farchergu%2Feinf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farchergu%2Feinf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farchergu%2Feinf/lists"}