Compare commits

...

4 Commits

Author SHA1 Message Date
trop[bot]
b244963d63 fix: potential devtools crash on empty (#49488)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2026-01-22 09:46:08 +01:00
trop[bot]
95417f9e46 docs: document that shell.trashItem requires backslashes (#49481)
docs: Update shell.md: Document that shell.trashItem requires backslashes

In Windows many functions relating to files (e.g. shell.openItem, the Node fs functions, as well as native Win32 APIs) will accept either type of slash / or \ as a folder separator.

shell.trashItem does not work with / as folder separator in Windows. This documentation change explains that.

See also:
https://github.com/electron/electron/issues/28831

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: sam marshall <s.marshall@open.ac.uk>
2026-01-21 14:51:12 -05:00
trop[bot]
5976fa394b docs: add a few API history fragments (#49478)
* docs: add a few API history fragments

Co-authored-by: Erick Zhao <erick@hotmail.ca>

* manual fixes

Co-authored-by: Erick Zhao <erick@hotmail.ca>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Erick Zhao <erick@hotmail.ca>
2026-01-21 13:12:06 -05:00
trop[bot]
5ed82c16e8 revert: use deprecated setAllowedFileTypes in macOS dialogs (#49470)
* revert: use deprectated setAllowedFileTypes in macOS dialogs

Closes https://github.com/electron/electron/issues/48191

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* chore: remove stray import

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2026-01-21 17:57:39 +01:00
8 changed files with 112 additions and 59 deletions

View File

@@ -100,6 +100,13 @@ On Windows only `releaseName` is available.
### Event: 'before-quit-for-update'
<!--
```YAML history
added:
- pr-url: https://github.com/electron/electron/pull/12619
```
-->
This event is emitted after a user calls `quitAndInstall()`.
When this API is called, the `before-quit` event is not emitted before all windows are closed. As a result you should listen to this event if you wish to perform actions before the windows are closed while a process is quitting, as well as listening to `before-quit`.
@@ -110,6 +117,16 @@ The `autoUpdater` object has the following methods:
### `autoUpdater.setFeedURL(options)`
<!--
```YAML history
changes:
- pr-url: https://github.com/electron/electron/pull/5879
description: "Added `headers` as a second parameter."
- pr-url: https://github.com/electron/electron/pull/11925
description: "Changed API to accept a single `options` argument (contains `url`, `headers`, and `serverType` properties)."
```
-->
* `options` Object
* `url` string
* `headers` Record\<string, string\> (optional) _macOS_ - HTTP request headers.

View File

@@ -9,6 +9,13 @@ For including the share menu as a submenu of other menus, please use the
## Class: ShareMenu
<!--
```YAML history
added:
- pr-url: https://github.com/electron/electron/pull/25629
```
-->
> Create share menu on macOS.
Process: [Main](../glossary.md#main-process)

View File

@@ -29,6 +29,14 @@ Show the given file in a file manager. If possible, select the file.
### `shell.openPath(path)`
<!--
```YAML history
added:
- pr-url: https://github.com/electron/electron/pull/20682
breaking-changes-header: api-changed-shellopenitem-is-now-shellopenpath
```
-->
* `path` string
Returns `Promise<string>` - Resolves with a string containing the error message corresponding to the failure if a failure occurred, otherwise "".
@@ -37,6 +45,18 @@ Open the given file in the desktop's default manner.
### `shell.openExternal(url[, options])`
<!--
```YAML history
changes:
- pr-url: https://github.com/electron/electron/pull/4508
description: "Added `activate` option."
- pr-url: https://github.com/electron/electron/pull/15065
description: "Added `workingDirectory` option."
- pr-url: https://github.com/electron/electron/pull/37139
description: "Added `logUsage` option."
```
-->
* `url` string - Max 2081 characters on Windows.
* `options` Object (optional)
* `activate` boolean (optional) _macOS_ - `true` to bring the opened application to the foreground. The default is `true`.
@@ -50,6 +70,14 @@ Open the given external protocol URL in the desktop's default manner. (For examp
### `shell.trashItem(path)`
<!--
```YAML history
added:
- pr-url: https://github.com/electron/electron/pull/25114
breaking-changes-header: deprecated-shellmoveitemtotrash
```
-->
* `path` string - path to the item to be moved to the trash.
Returns `Promise<void>` - Resolves when the operation has been completed.
@@ -58,6 +86,10 @@ Rejects if there was an error while deleting the requested item.
This moves a path to the OS-specific trash location (Trash on macOS, Recycle
Bin on Windows, and a desktop-environment-specific location on Linux).
The path must use the default path separator for the platform (backslash on
Windows). Use `path.resolve()` from the `node:path` module to ensure correct
handling on all filesystems.
### `shell.beep()`
Play the beep sound.

View File

@@ -2685,6 +2685,18 @@ Replace with: https://atom.io/download/electron
The following list includes the breaking API changes made in Electron 2.0.
### `autoUpdater`
```js
// Deprecated
autoUpdater.setFeedURL(url, headers)
// Replace with
autoUpdater.setFeedURL({
url,
headers
})
```
### `BrowserWindow`
```js

View File

@@ -99,7 +99,7 @@ Using `autoUpdater` as an example:
## Methods
### `autoUpdater.setFeedURL(url[, requestHeaders])`
### `autoUpdater.setFeedURL(options)`
```
### Classes

View File

@@ -11,12 +11,14 @@ const { contextIsolationEnabled } = internalContextBridge;
* 1) Use menu API to show context menu.
*/
window.onload = function () {
if (contextIsolationEnabled) {
internalContextBridge.overrideGlobalValueFromIsolatedWorld([
'InspectorFrontendHost', 'showContextMenuAtPoint'
], createMenu);
} else {
window.InspectorFrontendHost!.showContextMenuAtPoint = createMenu;
if (window.InspectorFrontendHost) {
if (contextIsolationEnabled) {
internalContextBridge.overrideGlobalValueFromIsolatedWorld([
'InspectorFrontendHost', 'showContextMenuAtPoint'
], createMenu);
} else {
window.InspectorFrontendHost.showContextMenuAtPoint = createMenu;
}
}
};

View File

@@ -11,7 +11,6 @@
#import <Cocoa/Cocoa.h>
#import <CoreServices/CoreServices.h>
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
@@ -30,7 +29,7 @@
@interface PopUpButtonHandler : NSObject
@property(nonatomic, weak) NSSavePanel* savePanel;
@property(nonatomic, strong) NSArray* contentTypesList;
@property(nonatomic, strong) NSArray* fileTypesList;
- (instancetype)initWithPanel:(NSSavePanel*)panel
andTypesList:(NSArray*)typesList;
@@ -41,14 +40,14 @@
@implementation PopUpButtonHandler
@synthesize savePanel;
@synthesize contentTypesList;
@synthesize fileTypesList;
- (instancetype)initWithPanel:(NSSavePanel*)panel
andTypesList:(NSArray*)typesList {
self = [super init];
if (self) {
[self setSavePanel:panel];
[self setContentTypesList:typesList];
[self setFileTypesList:typesList];
}
return self;
}
@@ -56,19 +55,17 @@
- (void)selectFormat:(id)sender {
NSPopUpButton* button = (NSPopUpButton*)sender;
NSInteger selectedItemIndex = [button indexOfSelectedItem];
NSArray* list = [self contentTypesList];
NSArray* content_types = [list objectAtIndex:selectedItemIndex];
NSArray* list = [self fileTypesList];
NSArray* fileTypes = [list objectAtIndex:selectedItemIndex];
__block BOOL allowAllFiles = NO;
[content_types
enumerateObjectsUsingBlock:^(UTType* type, NSUInteger idx, BOOL* stop) {
if ([[type preferredFilenameExtension] isEqual:@"*"]) {
allowAllFiles = YES;
*stop = YES;
}
}];
[[self savePanel] setAllowedContentTypes:allowAllFiles ? @[] : content_types];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// If we meet a '*' file extension, we allow all file types.
if ([fileTypes count] == 0 || [fileTypes containsObject:@"*"])
[[self savePanel] setAllowedFileTypes:nil];
else
[[self savePanel] setAllowedFileTypes:fileTypes];
#pragma clang diagnostic pop
}
@end
@@ -105,7 +102,7 @@ void SetAllowedFileTypes(NSSavePanel* dialog, const Filters& filters) {
// Create array to keep file types and their name.
for (const Filter& filter : filters) {
NSMutableOrderedSet* content_types_set =
NSMutableOrderedSet* file_type_set =
[NSMutableOrderedSet orderedSetWithCapacity:filters.size()];
[filter_names addObject:@(filter.first.c_str())];
@@ -119,46 +116,30 @@ void SetAllowedFileTypes(NSSavePanel* dialog, const Filters& filters) {
ext.erase(0, pos + 1);
}
if (ext == "*") {
[content_types_set addObject:[UTType typeWithFilenameExtension:@"*"]];
break;
} else if (ext == "app") {
// This handles a bug on macOS where the "app" extension by default
// maps to "com.apple.application-file", which is for an Application
// file (older single-file carbon based apps), and not modern
// Application Bundles (multi file packages as you'd see for all modern
// applications).
UTType* superType =
[UTType typeWithIdentifier:@"com.apple.application-bundle"];
if (UTType* utt = [UTType typeWithFilenameExtension:@"app"
conformingToType:superType]) {
[content_types_set addObject:utt];
}
} else {
if (UTType* utt = [UTType typeWithFilenameExtension:@(ext.c_str())])
[content_types_set addObject:utt];
}
[file_type_set addObject:@(ext.c_str())];
}
[file_types_list addObject:content_types_set];
[file_types_list addObject:[file_type_set array]];
}
NSArray* content_types = [file_types_list objectAtIndex:0];
// Passing empty array to setAllowedFileTypes will cause exception.
NSArray* file_types = nil;
NSUInteger count = [file_types_list count];
if (count > 0) {
file_types = [[file_types_list objectAtIndex:0] allObjects];
// If we meet a '*' file extension, we allow all the file types and no
// need to set the specified file types.
if ([file_types count] == 0 || [file_types containsObject:@"*"])
file_types = nil;
}
__block BOOL allowAllFiles = NO;
[content_types
enumerateObjectsUsingBlock:^(UTType* type, NSUInteger idx, BOOL* stop) {
if ([[type preferredFilenameExtension] isEqual:@"*"]) {
allowAllFiles = YES;
*stop = YES;
}
}];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[dialog setAllowedFileTypes:file_types];
#pragma clang diagnostic pop
[dialog setAllowedContentTypes:allowAllFiles ? @[] : content_types];
// Don't add file format picker.
if ([file_types_list count] <= 1)
return;
if (count <= 1)
return; // don't add file format picker
// Add file format picker.
ElectronAccessoryView* accessoryView = [[ElectronAccessoryView alloc]

View File

@@ -830,7 +830,9 @@ gin_helper::Dictionary TraceKeyPath(const gin_helper::Dictionary& start,
const std::vector<std::string>& key_path) {
gin_helper::Dictionary current = start;
for (size_t i = 0; i < key_path.size() - 1; i++) {
CHECK(current.Get(key_path[i], &current));
CHECK(current.Get(key_path[i], &current))
<< "Failed to get property '" << key_path[i] << "' at index " << i
<< " in key path";
}
return current;
}