From 70925089ebe15c52367d73965bb11720e9f1120e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 11 Jan 2024 18:35:25 +0900 Subject: [PATCH] RFC: Electron C APIs --- text/0001-electron-c-apis.md | 123 +++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 text/0001-electron-c-apis.md diff --git a/text/0001-electron-c-apis.md b/text/0001-electron-c-apis.md new file mode 100644 index 0000000..46a6239 --- /dev/null +++ b/text/0001-electron-c-apis.md @@ -0,0 +1,123 @@ +- Start Date: 2024-01-11 +- RFC PR: [electron/rfcs#3](https://github.com/electron/rfcs/pull/3) +- Status: **Proposed** + +# Electron C APIs + +## Summary + +Similar to the [Node-API (also known as N-API) of Node.js][napi], the Electron C APIs is a set of C APIs providing access to Electron and Chromium’s resources, which can be used in Node.js native modules. + +## Motivation + +### Easier to add new APIs + +The majority of Electron’s JavaScript APIs are about accessing native resources of the operating system; some of them could not be implemented as native modules because they need to interact with Electron and Chromium’s resources. + +For example, the `TouchBar` and `inAppPurchase` APIs must live as built-in APIs because the JavaScript bindings must interact with internal `ElectronApplicationDelegate` and `ElectronNSWindowDelegate`, and there is no non-intrusive way doing that outside Electron. + +With Electron C APIs we can make it possible to have those APIs as native modules. This can make Electron less bloating since we don't have to make every new API a built-in API , and for users who want to add a large set of new APIs they can now only request a few minimal C APIs in Electron and then implement anything they want in native modules. + +### Reduce Electron forks + +Some people may already know that the some Electron apps like VS Code and Discord use custom builds instead of the offical one, this is because they have some modifications that can not be upstreamed (for example some hacks to the `