源码目录结构

Electron 的源代码主要依据 Chromium 的拆分约定被拆成了许多部分。

为了更好地理解源代码,您可能需要了解一下 Chromium 的多进程架构

源代码的目录结构

  1. Electron
  2. ├── build/ - 使用 GN 构建所需要的配置文件。
  3. ├── buildflags/ - 条件编译时可选的Features.
  4. ├── chromium_src/ - Chromium复制的源代码,不属于内容层。
  5. ├── default_app/ - 在没有提供应用程序的情况下启动的 Electron 默认程序.
  6. ├── docs/ - Electron 的文档。
  7. | ├── api/ - Documentation for Electron's externally-facing modules and APIs.
  8. | ├── development/ - Documentation to aid in developing for and with Electron.
  9. | ├── fiddles/ - A set of code snippets one can run in Electron Fiddle.
  10. | ├── images/ - Images used in documentation.
  11. | └── tutorial/ - Tutorial documents for various aspects of Electron.
  12. ├── lib/ - JavaScript/TypeScript 源码。
  13. | ├── browser/ - Main process initialization code.
  14. | | ├── api/ - API implementation for main process modules.
  15. | | └── remote/ - Code related to the remote module as it is
  16. | | used in the main process.
  17. | ├── common/ - Relating to logic needed by both main and renderer processes.
  18. | | └── api/ - API implementation for modules that can be used in
  19. | | both the main and renderer processes
  20. | ├── isolated_renderer/ - Handles creation of isolated renderer processes when
  21. | | contextIsolation is enabled.
  22. | ├── renderer/ - Renderer process initialization code.
  23. | | ├── api/ - API implementation for renderer process modules.
  24. | | ├── extension/ - Code related to use of Chrome Extensions
  25. | | | in Electron's renderer process.
  26. | | ├── remote/ - Logic that handles use of the remote module in
  27. | | | the main process.
  28. | | └── web-view/ - Logic that handles the use of webviews in the
  29. | | renderer process.
  30. | ├── sandboxed_renderer/ - Logic that handles creation of sandboxed renderer
  31. | | | processes.
  32. | | └── api/ - API implementation for sandboxed renderer processes.
  33. | └── worker/ - Logic that handles proper functionality of Node.js
  34. | environments in Web Workers.
  35. ├── patches/ - Patches applied on top of Electron's core dependencies
  36. | | in order to handle differences between our use cases and
  37. | | default functionality.
  38. | | --boringssl/ - 对谷歌的 BoringSSL (谷歌对OpenSSL的Fork)的Patches。
  39. | ├── chromium/ - 对Chromium的Patches.
  40. | ├── node/ - 对Node.js的Patches.
  41. | └── v8/ - 对Google V8引擎的Patches.
  42. ├── shell/ - C++源代码。
  43. | ├── app/ - 系统入口代码.
  44. | ├── browser/ - 包含了主窗口、UI 和所有主进程相关的东西.
  45. | | | 它会告诉渲染进程如何管理页面.
  46. | | ├── ui/ - 不同平台上 UI 部分的实现.
  47. | | | ├── cocoa/ - Cocoa 部分的源代码.
  48. | | | ├── win/ - Windows GUI 部分的源代码.
  49. | | | └── x/ - X11 部分的源代码.
  50. | | ├── api/ - 主进程 API 的实现.
  51. | | ├── net/ - 网络相关的代码.
  52. | | ├── mac/ - 与 Mac 有关的 Objective-C 代码.
  53. | | └── resources/ - 图标、平台依赖文件等。
  54. | ├── renderer/ - 运行在渲染进程中的代码.
  55. | | └── api/ - 渲染进程 API 的实现.
  56. | └── common/ - 同时被主进程和渲染进程用到的代码,
  57. | | 包括了一些用来将 node 的消息循环整合到 Chromium 的
  58. | | 消息循环中时用到的工具函数和代码.
  59. | └── api/ - 同时被主进程和渲染进程使用到的 API 的实现,
  60. | 并且是 Electron 内置模块的基础.
  61. ├── spec/ - 运行在Electron主进程中的Electron测试套件组件.
  62. └── BUILD.gn - Electron 的构建规则.

其它目录的结构

  • .cloeci - CircleCI 的 CI 配置文件。
  • .github - GitHub专用配置文件,包括 issue 模板和 CODEOWNERS。
  • dist - 由脚本 script/create-dist.py 创建的临时发布目录.
  • node_modules - 在构建中用到的第三方 node 模块.
  • npm - 通过 npm 安装 Electron 的逻辑。
  • out - ninja 的临时输出目录.
  • script - 用于诸如构建、打包、测试等开发用途的脚本等.
  1. script/ - The set of all scripts Electron runs for a variety of purposes.
  2. ├── codesign/ - Fakes codesigning for Electron apps; used for testing.
  3. ├── lib/ - Miscellaneous python utility scripts.
  4. └── release/ - Scripts run during Electron's release process.
  5. ├── notes/ - Generates release notes for new Electron versions.
  6. └── uploaders/ - Uploads various release-related files during release.
  • typings - Electron的内部代码的 TypeScript typings。