源代码目录结构¶
Electron 的源代码被划分为几个部分,主要遵循 Chromium 的分离约定。
为了更好地理解源代码,您可能需要熟悉 Chromium 的多进程架构。
项目结构¶
Electron 是一个复杂的项目,包含多个上游依赖,这些依赖通过 DEPS 文件在源代码控制中进行跟踪。当 初始化本地 Electron 检出 时,Electron 的源代码只是项目根目录中众多嵌套文件夹之一。
项目包含一个单一的 src 文件夹,它对应于 Chromium 的 src 文件夹 的特定 git 检出。此外,Electron 的仓库代码位于 src/electron(带有自己的嵌套 git 仓库),而其他 Electron 特定的第三方依赖(例如 nan 或 node)位于 src/third_party 中(与所有其他 Chromium 第三方依赖一起,例如 WebRTC 或 ANGLE)。
对于 src/electron 之外的所有代码,Electron 特定的代码更改都是通过 git 补丁来维护的。有关更多信息,请参阅 补丁 开发指南。
Project Root
└── src
├── electron
├── third_party
│ ├── nan
│ ├── electron_node
│ └── ...other third party deps
└── ...other folders
Electron 源代码的结构¶
Electron
├── build/ - Build configuration files needed to build with GN.
├── buildflags/ - Determines the set of features that can be conditionally built.
├── chromium_src/ - Source code copied from Chromium that isn't part of the content layer.
├── default_app/ - A default app run when Electron is started without
| providing a consumer app.
├── docs/ - Electron's documentation.
| ├── api/ - Documentation for Electron's externally-facing modules and APIs.
| ├── development/ - Documentation to aid in developing for and with Electron.
| ├── fiddles/ - A set of code snippets one can run in Electron Fiddle.
| ├── images/ - Images used in documentation.
| └── tutorial/ - Tutorial documents for various aspects of Electron.
├── lib/ - JavaScript/TypeScript source code.
| ├── browser/ - Main process initialization code.
| | ├── api/ - API implementation for main process modules.
| ├── common/ - Relating to logic needed by both main and renderer processes.
| | └── api/ - API implementation for modules that can be used in
| | both the main and renderer processes
| ├── isolated_renderer/ - Handles creation of isolated renderer processes when
| | contextIsolation is enabled.
| ├── 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/ - Renderer process initialization code.
| | ├── api/ - API implementation for renderer process modules.
| | └── web-view/ - Logic that handles the use of webviews in the
| | renderer process.
| ├── sandboxed_renderer/ - Logic that handles creation of sandboxed renderer
| | | processes.
| | └── api/ - API implementation for sandboxed renderer processes.
│ ├── utility/ - Utility process initialization code.
│ │ └── api/ - API implementation for utility process modules.
| ├── webview/ - Entry point of the bundle that registers the `<webview>`
| | element in renderers that enable it.
| └── worker/ - Logic that handles proper functionality of Node.js
| environments in Web Workers.
├── patches/ - Patches applied on top of Electron's core dependencies
| | in order to handle differences between our use cases and
| | default functionality.
| ├── boringssl/ - Patches applied to Google's fork of OpenSSL, BoringSSL.
| ├── chromium/ - Patches applied to Chromium.
| ├── node/ - Patches applied on top of Node.js.
| └── v8/ - Patches applied on top of Google's V8 engine.
├── shell/ - C++ source code.
| ├── app/ - System entry code.
| ├── browser/ - The frontend including the main window, UI, and all of the
| | | main process things. This talks to the renderer to manage web
| | | pages.
| | ├── ui/ - Implementation of UI stuff for different platforms.
| | | ├── cocoa/ - Cocoa specific source code.
| | | ├── win/ - Windows GUI specific source code.
| | | └── x/ - X11 specific source code.
| | ├── api/ - The implementation of the main process APIs.
| | ├── net/ - Network related code.
| | ├── mac/ - Mac specific Objective-C source code.
| | └── resources/ - Icons, platform-dependent files, etc.
| ├── renderer/ - Code that runs in renderer process.
| | └── api/ - The implementation of renderer process APIs.
| ├── 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/ - Components of Electron's test suite run in the main process.
├── typings/ - Internal TypeScript types that aren't exported in electron.d.ts.
└── BUILD.gn - Building rules of Electron.
其他 Electron 目录的结构¶
- .github - GitHub 特定的配置文件,包括 issue 模板、使用 GitHub Actions 的 CI 以及 CODEOWNERS。
- dist - 由
script/create-dist.py脚本在创建发行版时创建的临时目录。 - node_modules - 用于构建的第三方 node 模块。
- npm - 通过 npm 安装 Electron 的逻辑。
- out -
siso的临时输出目录。 - script - 用于开发目的的脚本,例如构建、打包、测试等。
script/ - Electron 为各种目的运行的所有脚本集合。
├── codesign/ - 为 Electron 应用伪造代码签名;用于测试。
├── lib/ - 各种 Python 实用脚本。
└── release/ - Electron 发布过程中运行的脚本。
├── notes/ - 生成新 Electron 版本的发布说明。
└── uploaders/ - 在发布期间上传各种与发布相关的文件。
- typings - Electron 内部代码的 TypeScript 类型定义。
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 el/electron