mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
Compare commits
12 Commits
debug-unsa
...
test-push-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dde9f9d3ef | ||
|
|
5db9939e9c | ||
|
|
0edcc985fa | ||
|
|
38fe14041d | ||
|
|
996945d3e3 | ||
|
|
d7ef8b79ae | ||
|
|
6aa3665b96 | ||
|
|
37402a18a4 | ||
|
|
a21afc3e45 | ||
|
|
cafcfe106d | ||
|
|
1b1be6e1b3 | ||
|
|
efafa08682 |
12
.github/actions/checkout/action.yml
vendored
12
.github/actions/checkout/action.yml
vendored
@@ -117,12 +117,7 @@ runs:
|
||||
git update-index --refresh || true
|
||||
if ! git diff-index --quiet HEAD --; then
|
||||
# There are changes to the patches. Make a git commit with the updated patches
|
||||
git add patches
|
||||
GIT_COMMITTER_NAME="PatchUp" GIT_COMMITTER_EMAIL="73610968+patchup[bot]@users.noreply.github.com" git commit -m "chore: update patches" --author="PatchUp <73610968+patchup[bot]@users.noreply.github.com>"
|
||||
# Export it
|
||||
mkdir -p ../../patches
|
||||
git format-patch -1 --stdout --keep-subject --no-stat --full-index > ../../patches/update-patches.patch
|
||||
if node ./script/push-patch.js; then
|
||||
if node ./script/patch-up.js; then
|
||||
echo
|
||||
echo "======================================================================"
|
||||
echo "Changes to the patches when applying, we have auto-pushed the diff to the current branch"
|
||||
@@ -130,6 +125,11 @@ runs:
|
||||
echo "======================================================================"
|
||||
exit 1
|
||||
else
|
||||
git add patches
|
||||
GIT_COMMITTER_NAME="PatchUp" GIT_COMMITTER_EMAIL="73610968+patchup[bot]@users.noreply.github.com" git commit -m "chore: update patches" --author="PatchUp <73610968+patchup[bot]@users.noreply.github.com>"
|
||||
# Export it
|
||||
mkdir -p ../../patches
|
||||
git format-patch -1 --stdout --keep-subject --no-stat --full-index > ../../patches/update-patches.patch
|
||||
echo
|
||||
echo "======================================================================"
|
||||
echo "There were changes to the patches when applying."
|
||||
|
||||
2
.github/workflows/scorecards.yml
vendored
2
.github/workflows/scorecards.yml
vendored
@@ -50,6 +50,6 @@ jobs:
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
|
||||
uses: github/codeql-action/upload-sarif@fca7ace96b7d713c7035871441bd52efbe39e27e # v3.28.19
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
||||
@@ -99,6 +99,10 @@ Process: [Main](../glossary.md#main-process)
|
||||
|
||||
It creates a new `BaseWindow` with native properties as set by the `options`.
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### `new BaseWindow([options])`
|
||||
|
||||
* `options` [BaseWindowConstructorOptions](structures/base-window-options.md?inline) (optional)
|
||||
|
||||
@@ -38,6 +38,10 @@ Process: [Main](../glossary.md#main-process)
|
||||
This module cannot be used until the `ready` event of the `app`
|
||||
module is emitted.
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### Example
|
||||
|
||||
```js
|
||||
|
||||
@@ -151,6 +151,10 @@ Process: [Main](../glossary.md#main-process)
|
||||
|
||||
It creates a new `BrowserWindow` with native properties as set by the `options`.
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### `new BrowserWindow([options])`
|
||||
|
||||
* `options` [BrowserWindowConstructorOptions](structures/browser-window-options.md?inline) (optional)
|
||||
|
||||
@@ -43,6 +43,10 @@ Process: [Main](../glossary.md#main-process)
|
||||
|
||||
`ImageView` is an [EventEmitter][event-emitter].
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### `new ImageView()` _Experimental_
|
||||
|
||||
Creates an ImageView.
|
||||
|
||||
@@ -11,6 +11,10 @@ Process: [Main](../glossary.md#main-process)
|
||||
|
||||
<!-- TODO(samuelmaddock): refactor doc gen to allow generics to reduce duplication -->
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### Instance Methods
|
||||
|
||||
#### `ipcMainServiceWorker.on(channel, listener)`
|
||||
|
||||
@@ -6,6 +6,10 @@ Process: [Main](../glossary.md#main-process)
|
||||
|
||||
See [`Menu`](menu.md) for examples.
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### `new MenuItem(options)`
|
||||
|
||||
* `options` Object
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### `new Menu()`
|
||||
|
||||
Creates a new menu.
|
||||
|
||||
@@ -37,6 +37,10 @@ ipcRenderer.on('port', (e) => {
|
||||
})
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### Instance Properties
|
||||
|
||||
#### `channel.port1`
|
||||
|
||||
@@ -4,12 +4,9 @@
|
||||
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
:::info Renderer process notifications
|
||||
|
||||
If you want to show notifications from a renderer process you should use the
|
||||
[web Notifications API](../tutorial/notifications.md)
|
||||
|
||||
:::
|
||||
> [!NOTE]
|
||||
> If you want to show notifications from a renderer process you should use the
|
||||
> [web Notifications API](../tutorial/notifications.md)
|
||||
|
||||
## Class: Notification
|
||||
|
||||
@@ -21,6 +18,10 @@ Process: [Main](../glossary.md#main-process)
|
||||
|
||||
It creates a new `Notification` with native properties as set by the `options`.
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### Static Methods
|
||||
|
||||
The `Notification` class has the following static methods:
|
||||
|
||||
@@ -73,5 +73,6 @@ command line flag is provided `--password-store="basic"`.
|
||||
is provided `--password-store="kwallet"`.
|
||||
* `kwallet5` - When the desktop session is `kde5` or if the following command line flag
|
||||
is provided `--password-store="kwallet5"`.
|
||||
* `kwallet6` - When the desktop session is `kde6`.
|
||||
* `kwallet6` - When the desktop session is `kde6` or if the following command line flag
|
||||
is provided `--password-store="kwallet6"`.
|
||||
* `unknown` - When the function is called before app has emitted the `ready` event.
|
||||
|
||||
@@ -13,6 +13,10 @@ For including the share menu as a submenu of other menus, please use the
|
||||
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### `new ShareMenu(sharingItem)`
|
||||
|
||||
* `sharingItem` SharingItem - The item to share.
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# TouchBar
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
## Class: TouchBar
|
||||
|
||||
> Create TouchBar layouts for native macOS applications
|
||||
|
||||
@@ -25,6 +25,10 @@ app.whenReady().then(() => {
|
||||
})
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
**Platform Considerations**
|
||||
|
||||
**Linux**
|
||||
|
||||
@@ -26,6 +26,10 @@ Process: [Main](../glossary.md#main-process)
|
||||
|
||||
`View` is an [EventEmitter][event-emitter].
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### `new View()`
|
||||
|
||||
Creates a new `View`.
|
||||
|
||||
@@ -33,6 +33,10 @@ Process: [Main](../glossary.md#main-process)
|
||||
|
||||
`WebContentsView` is an [EventEmitter][event-emitter].
|
||||
|
||||
> [!WARNING]
|
||||
> Electron's built-in classes cannot be subclassed in user code.
|
||||
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
|
||||
|
||||
### `new WebContentsView([options])`
|
||||
|
||||
* `options` Object (optional)
|
||||
|
||||
@@ -156,6 +156,14 @@ The effect is visible only on (some?) LCD screens. Even if you don't see a diffe
|
||||
|
||||
Notice that just setting the background in the CSS does not have the desired effect.
|
||||
|
||||
## Class inheritance does not work with Electron built-in modules
|
||||
|
||||
Electron classes cannot be subclassed with the [`extends`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/extends)
|
||||
keyword (also known as class inheritance). This feature was never implemented in Electron due
|
||||
to the added complexity it would add to C++/JavaScript interop in Electron's internals.
|
||||
|
||||
For more information, see [electron/electron#23](https://github.com/electron/electron/issues/23).
|
||||
|
||||
[memory-management]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management
|
||||
[closures]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures
|
||||
[storage]: https://developer.mozilla.org/en-US/docs/Web/API/Storage
|
||||
|
||||
128
script/patch-up.js
Normal file
128
script/patch-up.js
Normal file
@@ -0,0 +1,128 @@
|
||||
const { appCredentialsFromString, getAuthOptionsForRepo } = require('@electron/github-app-auth');
|
||||
|
||||
const { Octokit } = require('@octokit/rest');
|
||||
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const { PATCH_UP_APP_CREDS } = process.env;
|
||||
|
||||
const REPO_OWNER = 'electron';
|
||||
const REPO_NAME = 'electron';
|
||||
|
||||
async function getAllPatchFiles (dir) {
|
||||
const files = [];
|
||||
|
||||
async function walkDir (currentDir) {
|
||||
const entries = await fs.promises.readdir(currentDir, { withFileTypes: true });
|
||||
|
||||
for (const entry of entries) {
|
||||
const fullPath = path.join(currentDir, entry.name);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
await walkDir(fullPath);
|
||||
} else if (entry.isFile() && (entry.name.endsWith('.patch') || entry.name === 'README.md' || entry.name === 'config.json')) {
|
||||
const relativePath = path.relative(process.cwd(), fullPath);
|
||||
const content = await fs.promises.readFile(fullPath, 'utf8');
|
||||
files.push({
|
||||
path: relativePath,
|
||||
content
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await walkDir(dir);
|
||||
return files;
|
||||
}
|
||||
|
||||
function getCurrentCommitSha () {
|
||||
return process.env.GITHUB_SHA;
|
||||
}
|
||||
|
||||
function getCurrentBranch () {
|
||||
return process.env.GITHUB_HEAD_REF;
|
||||
}
|
||||
|
||||
async function main () {
|
||||
if (!PATCH_UP_APP_CREDS) {
|
||||
throw new Error('PATCH_UP_APP_CREDS environment variable not set');
|
||||
}
|
||||
|
||||
const currentBranch = getCurrentBranch();
|
||||
|
||||
if (!currentBranch) {
|
||||
throw new Error('GITHUB_HEAD_REF environment variable not set. Patch Up only works in PR workflows currently.');
|
||||
}
|
||||
|
||||
const octokit = new Octokit({
|
||||
...await getAuthOptionsForRepo({
|
||||
name: REPO_OWNER,
|
||||
owner: REPO_NAME
|
||||
}, appCredentialsFromString(PATCH_UP_APP_CREDS))
|
||||
});
|
||||
|
||||
const patchesDir = path.join(process.cwd(), 'patches');
|
||||
|
||||
// Get current git state
|
||||
const currentCommitSha = getCurrentCommitSha();
|
||||
|
||||
// Get the tree SHA from the current commit
|
||||
const currentCommit = await octokit.git.getCommit({
|
||||
owner: REPO_OWNER,
|
||||
repo: REPO_NAME,
|
||||
commit_sha: currentCommitSha
|
||||
});
|
||||
const baseTreeSha = currentCommit.data.tree.sha;
|
||||
|
||||
// Find all patch files
|
||||
const patchFiles = await getAllPatchFiles(patchesDir);
|
||||
|
||||
if (patchFiles.length === 0) {
|
||||
throw new Error('No patch files found');
|
||||
}
|
||||
|
||||
console.log(`Found ${patchFiles.length} patch files`);
|
||||
|
||||
// Create a new tree with the patch files
|
||||
const tree = patchFiles.map(file => ({
|
||||
path: file.path,
|
||||
mode: '100644',
|
||||
type: 'blob',
|
||||
content: file.content
|
||||
}));
|
||||
|
||||
const treeResponse = await octokit.git.createTree({
|
||||
owner: REPO_OWNER,
|
||||
repo: REPO_NAME,
|
||||
base_tree: baseTreeSha,
|
||||
tree
|
||||
});
|
||||
|
||||
// Create a new commit
|
||||
const commitMessage = 'chore: update patches';
|
||||
const commitResponse = await octokit.git.createCommit({
|
||||
owner: REPO_OWNER,
|
||||
repo: REPO_NAME,
|
||||
message: commitMessage,
|
||||
tree: treeResponse.data.sha,
|
||||
parents: [currentCommitSha]
|
||||
});
|
||||
|
||||
// Update the branch reference
|
||||
await octokit.git.updateRef({
|
||||
owner: REPO_OWNER,
|
||||
repo: REPO_NAME,
|
||||
ref: `heads/${currentBranch}`,
|
||||
sha: commitResponse.data.sha
|
||||
});
|
||||
|
||||
console.log(`Successfully pushed commit ${commitResponse.data.sha} to ${currentBranch}`);
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
main().catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
const { appCredentialsFromString, getTokenForRepo } = require('@electron/github-app-auth');
|
||||
|
||||
const cp = require('node:child_process');
|
||||
|
||||
const { PATCH_UP_APP_CREDS } = process.env;
|
||||
|
||||
async function main () {
|
||||
if (!PATCH_UP_APP_CREDS) {
|
||||
throw new Error('PATCH_UP_APP_CREDS environment variable not set');
|
||||
}
|
||||
|
||||
const token = await getTokenForRepo(
|
||||
{
|
||||
name: 'electron',
|
||||
owner: 'electron'
|
||||
},
|
||||
appCredentialsFromString(PATCH_UP_APP_CREDS)
|
||||
);
|
||||
|
||||
const remoteURL = `https://x-access-token:${token}@github.com/electron/electron.git`;
|
||||
|
||||
// NEVER LOG THE OUTPUT OF THIS COMMAND
|
||||
// GIT LEAKS THE ACCESS CREDENTIALS IN CONSOLE LOGS
|
||||
const { status } = cp.spawnSync('git', ['push', '--set-upstream', remoteURL], {
|
||||
stdio: 'ignore'
|
||||
});
|
||||
|
||||
if (status !== 0) {
|
||||
throw new Error('Failed to push to target branch');
|
||||
}
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
main().catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
@@ -81,7 +81,11 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
|
||||
|
||||
void Debugger::RenderFrameHostChanged(content::RenderFrameHost* old_rfh,
|
||||
content::RenderFrameHost* new_rfh) {
|
||||
if (agent_host_) {
|
||||
// ConnectWebContents uses the primary main frame of the webContents,
|
||||
// so if the new_rfh is not the primary main frame, we don't want to
|
||||
// reconnect otherwise we'll end up trying to reconnect to a RenderFrameHost
|
||||
// that already has a DevToolsAgentHost associated with it.
|
||||
if (agent_host_ && new_rfh->IsInPrimaryMainFrame()) {
|
||||
agent_host_->DisconnectWebContents();
|
||||
auto* web_contents = content::WebContents::FromRenderFrameHost(new_rfh);
|
||||
agent_host_->ConnectWebContents(web_contents);
|
||||
|
||||
Reference in New Issue
Block a user