メインコンテンツへ飛ぶ

ソースコードのディレクトリ構造

Electron のソースコードは、いくつかの部分に分けられています。ほとんどの場合、分離規約上 Chromium に従っています。

ソースコードをよりよく理解するためには、Chromium のマルチプロセスアーキテクチャ に慣れる必要があるかもしれません。

Project structure

Electron is a complex project containing multiple upstream dependencies, which are tracked in source control via the DEPS file. When initializing a local Electron checkout, Electron's source code is just one of many nested folders within the project root.

The project contains a single src folder that corresponds a specific git checkout of Chromium's src folder. In addition, Electron's repository code is contained in src/electron (with its own nested git repository), and other Electron-specific third-party dependencies (e.g. nan or node) are located in src/third_party (along with all other Chromium third-party dependencies, such as WebRTC or ANGLE).

For all code outside of src/electron, Electron-specific code changes are maintained via git patches. See the Patches development guide for more information.

Project Root
└── src
├── electron
├── third_party
│   ├── nan
│   ├── electron_node
│   └── ...other third party deps
└── ...other folders

Structure of Electron source code

Electron
├── build/ - GN でビルドするために必要なコンフィグファイルをビルドします。
├── buildflags/ - 条件付きビルドに使用できる機能の集合を定義します。
├── chromium_src/ - コンテンツレイヤーの一部でない Chromium からコピーされたソースコード。
├── default_app/ - 消費者向けアプリ以外から Electron が起動されたときに
| 実行されるデフォルトアプリ。
├── docs/ - Electron のドキュメント。
| ├── api/ - Electron の外部向けモジュールと API のドキュメント。
| ├── development/ - Electron の開発と Electron による開発の支援ドキュメント。
| ├── fiddles/ - Electron Fiddle で実行できるコードスニペットの集合。
| ├── images/ - ドキュメントで使用される画像。
| └── tutorial/ - Electron のさまざまな観点におけるチュートリアルドキュメント。
/ lib / - JavaScript / TypeScript شفرة المصدر.
| ├── browser/ - メインプロセス初期化コード。
| | ├── api/ - メインプロセスモジュール API の実装。
| ├── common/ - メインとレンダラー両方のプロセスに必要なロジックに関連するものです。
| | └── api/ - メインとレンダラー両方のプロセスに必要な
| | モジュール API の実装
| ├── isolated_renderer/ - contextIsolation が有効なとき
| | イソレートレンダラープロセスの作成を処理します。
| ├── node/ - Initialization code for Node.js in the main process.
│   ├── preload_realm/ - Initialization code for sandboxed renderer preload scripts.
│   │   └── api/ - API implementation for preload scripts.
| ├── renderer/ - レンダラープロセス初期化コード。
| | ├── api/ - レンダラープロセスモジュール API の実装。
| | └── web-view/ - レンダラープロセスでの webview の
| | 使用を処理するロジック。
| ├── sandboxed_renderer/ - サンドボックスレンダラープロセスの作成を処理する
| | | ロジック。
| | └── api/ - サンドボックスレンダラープロセス API の実装。
│   ├── utility/ - Utility process initialization code.
│   │   └── api/ - API implementation for utility process modules.
| └── worker/ - Web Worker で Node.js 環境の適切な機能を
| 処理するロジック。
├── patches/ - ユースケースと元の機能との差異を扱うために、
| | Electron のコア依存関係上に適用されたパッチ。
| ├── boringssl/ - Google の OpenSSL フォークである BoringSSL に適用されているパッチ。
| ├── chromium/ - Chromium に適用されているパッチ。
| ├── node/ - Node.js 上に適用されているパッチ。
| └── v8/ - Google の V8 エンジンの上に適用されているパッチ。
├── shell/ - C++ ソースコード。
| ├── app/ - システムのエントリコード。
| ├── browser/ - メインウィンドウ、UI と
| | | メインプロセスの全てを含むフロントエンド。 これはレンダラーと連絡して Web ページを
| | | 管理します。
| | ├── ui/ - 異なるプラットフォーム間での UI のローレベルの実装。
| | | ├── cocoa/ - Cocoa に関連したソースコード。
| | | ├── win/ - Windows のGUIに関連したソースコード。
| | | └── x/ - X11 に関連したソースコード。
| | ├── api/ - メインプロセス API の実装。
| | ├── net/ - ネットワークに関連したコード。
| | ├── mac/ - Mac に関連した Objective-C のソースコード。
| | └── resources/ - アイコン、プラットフォーム固有のファイルなど。
| ├── renderer/ - レンダラープロセスで動くコード。
| | └── api/ - レンダラープロセス API の実装。
| ├── common/ - Code that used by both the main and renderer processes,
| | | including some helper functions and code to integrate node's
| | | message loop into Chromium's message loop.
| | └── api/ - The implementation of common APIs, and foundations of
| | Electron's built-in modules.
│   ├── services/node/ - Provides a Node.js runtime to utility processes.
│   └── utility - Code that runs in the utility process.
├── spec/ - メインプロセスで実行される Electron のテストスートのコンポーネント。
├── typings/ - Internal TypeScript types that aren't exported in electron.d.ts.
└── BUILD.gn - Electronのビルドルール。

Structure of other Electron directories

  • .github - Issue テンプレート、GitHub Actions での CI、コードオーナーを含む GitHub 固有の構成ファイル。
  • dist - 配布用に作成したときに script/create-dist.py スクリプトが作成する一時的なディレクトリ。
  • node_modules - ビルドに使用する第三者のnodeモジュール。
  • npm - npm を介した Electron のインストールロジック。
  • out - Temporary output directory for siso.
  • script - ビルド、パッケージ、テストなどの開発目的に使用されるスクリプト。
script/ - Electron がさまざまな目的で実行するすべてのスクリプトの集合。
├── codesign/ - Electron アプリのコード署名を偽装します。テスト用です。
├── lib/ - その他の Python のユーティリティスクリプト。
└── release/ - Electron のリリースプロセス中に実行されるスクリプト。
├── notes/ - 新しいバージョンの Electron のリリースノートを生成します。
└── uploaders/ - リリース中にさまざまなリリースに関するファイルをアップロードします。
  • typings - Electron 内部コードの TypeScript 型定義。