源码目录结构
优质
小牛编辑
136浏览
2023-12-01
Electron 的源代码主要依据 Chromium 的拆分约定被拆成了许多部分。
为了更好地理解源代码,您可能需要了解一下 Chromium 的多进程架构。
源代码的目录结构
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.
| | └── remote/ - Code related to the remote module as it is
| | used in the main process.
| ├── 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.
| ├── renderer/ - Renderer process initialization code.
| | ├── api/ - API implementation for renderer process modules.
| | ├── extension/ - Code related to use of Chrome Extensions
| | | in Electron's renderer process.
| | ├── remote/ - Logic that handles use of the remote module in
| | | the main process.
| | └── 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.
| └── 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/ - 系统入口代码.
| ├── browser/ - 包含了主窗口、UI 和所有主进程相关的东西.
| | | 它会告诉渲染进程如何管理页面.
| | ├── ui/ - 不同平台上 UI 部分的实现.
| | | ├── cocoa/ - Cocoa 部分的源代码.
| | | ├── win/ - Windows GUI 部分的源代码.
| | | └── x/ - X11 部分的源代码.
| | ├── api/ - 主进程 API 的实现.
| | ├── net/ - 网络相关的代码.
| | ├── mac/ - 与 Mac 有关的 Objective-C 代码.
| | └── resources/ - Icons, platform-dependent files, etc.
| ├── renderer/ - Code that runs in renderer process.
| | └── api/ - 渲染进程 API 的实现.
| └── common/ - 同时被主进程和渲染进程用到的代码,
| | 包括了一些用来将 node 的消息循环整合到 Chromium 的
| | 消息循环中时用到的工具函数和代码.
| └── api/ - 同时被主进程和渲染进程使用到的 API 的实现,
| 并且是 Electron 内置模块的基础.
├── spec/ - Components of Electron's test suite run in the renderer process.
├── spec-main/ - Components of Electron's test suite run in the main process.
└── BUILD.gn - Electron 的构建规则.
其它目录的结构
- .cloeci - CircleCI 的 CI 配置文件。
- .github - GitHub专用配置文件,包括 issue 模板和 CODEOWNERS。
- dist - 由脚本
script/create-dist.py
创建的临时发布目录. - node_modules - 在构建中用到的第三方 node 模块.
- npm - 通过 npm 安装 Electron 的逻辑。
- out -
ninja
的临时输出目录. - script - 用于诸如构建、打包、测试等开发用途的脚本等.
script/ - The set of all scripts Electron runs for a variety of purposes.
├── codesign/ - Fakes codesigning for Electron apps; used for testing.
├── lib/ - Miscellaneous python utility scripts.
└── release/ - Scripts run during Electron's release process.
├── notes/ - Generates release notes for new Electron versions.
└── uploaders/ - Uploads various release-related files during release.
- typings - Electron的内部代码的 TypeScript typings。