Skip to content

Commit

Permalink
Upgrade to electron v31.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tong committed Jun 26, 2024
1 parent 1c0a69c commit e7ff578
Show file tree
Hide file tree
Showing 17 changed files with 616 additions and 339 deletions.
15 changes: 8 additions & 7 deletions demo/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"start": "electron ."
},
"devDependencies": {
"electron": "v30.0.8"
"electron": "v31.1.0"
}
}
810 changes: 491 additions & 319 deletions electron-api.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion haxelib.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"description": "Type definitions for the electron framework",
"releasenote": "See CHANGELOG",
"version": "30.0.8",
"version": "31.1.0",
"contributors": [
"tong",
"fponticelli"
Expand Down
5 changes: 5 additions & 0 deletions src/electron/WebPreferences.hx
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,9 @@ typedef WebPreferences = {
**/
@:optional
var enablePreferredSizeMode : Bool;
/**
Whether to enable background transparency for the guest page. Default is `true`. **Note:** The guest page's text and background colors are derived from the color scheme of its root element. When transparency is enabled, the text color will still change accordingly but the background will remain transparent.
**/
@:optional
var transparent : Bool;
}
25 changes: 25 additions & 0 deletions src/electron/WindowOpenHandlerResponse.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package electron;
/**
@see https://electronjs.org/docs/api/structures/window-open-handler-response
**/
typedef WindowOpenHandlerResponse = {
/**
Can be `allow` or `deny`. Controls whether new window should be created.
**/
var action : String;
/**
Allows customization of the created window.
**/
@:optional
var overrideBrowserWindowOptions : electron.BrowserWindowConstructorOptions;
/**
By default, child windows are closed when their opener is closed. This can be changed by specifying `outlivesOpener: true`, in which case the opened window will not be closed when its opener is closed.
**/
@:optional
var outlivesOpener : Bool;
/**
If specified, will be called instead of `new BrowserWindow` to create the new child window and event `did-create-window` will not be emitted. Constructed child window should use passed `options` object. This can be used for example to have the new window open as a BrowserView instead of in a separate window.
**/
@:optional
var createWindow : electron.BrowserWindowConstructorOptions;
}
4 changes: 2 additions & 2 deletions src/electron/main/App.hx
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ package electron.main;
* `openAtLogin` boolean - `true` if the app is set to open at login.
* `openAsHidden` boolean _macOS_ _Deprecated_ - `true` if the app is set to open as hidden at login. This does not work on macOS 13 and up.
* `wasOpenedAtLogin` boolean _macOS_ _Deprecated_ - `true` if the app was opened at login automatically. This setting is not available on MAS builds or on macOS 13 and up.
* `wasOpenedAtLogin` boolean _macOS_ - `true` if the app was opened at login automatically.
* `wasOpenedAsHidden` boolean _macOS_ _Deprecated_ - `true` if the app was opened as a hidden login item. This indicates that the app should not open any windows at startup. This setting is not available on MAS builds or on macOS 13 and up.
* `restoreState` boolean _macOS_ _Deprecated_ - `true` if the app was opened as a login item that should restore the state from the previous session. This indicates that the app should restore the windows that were open the last time the app was closed. This setting is not available on MAS builds or on macOS 13 and up.
* `status` string _macOS_ - can be one of `not-registered`, `enabled`, `requires-approval`, or `not-found`.
Expand Down Expand Up @@ -497,7 +497,7 @@ package electron.main;
**/
@:optional
var openAtLogin : Bool; /**
`true` to open the app as hidden. Defaults to `false`. The user can edit this setting from the System Preferences so `app.getLoginItemSettings().wasOpenedAsHidden` should be checked when the app is opened to know the current value. This setting is not available on MAS build s or on macOS 13 and up.
`true` to open the app as hidden. Defaults to `false`. The user can edit this setting from the System Preferences so `app.getLoginItemSettings().wasOpenedAsHidden` should be checked when the app is opened to know the current value. This setting is not available on MAS builds or on macOS 13 and up.
**/
@:optional
var openAsHidden : Bool; /**
Expand Down
32 changes: 32 additions & 0 deletions src/electron/main/Session.hx
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,38 @@ package electron.main;
The absolute file system path where data for this session is persisted on disk. For in memory sessions this returns `null`.
**/
function getStoragePath():haxe.extern.EitherType<String, Dynamic>;
/**
resolves when all data has been cleared.
Clears various different types of data.
This method clears more types of data and is more thourough than the `clearStorageData` method.
**Note:** Cookies are stored at a broader scope than origins. When removing cookies and filtering by `origins` (or `excludeOrigins`), the cookies will be removed at the registrable domain level. For example, clearing cookies for the origin `https://really.specific.origin.example.com/` will end up clearing all cookies for `example.com`. Clearing cookies for the origin `https://my.website.example.co.uk/` will end up clearing all cookies for `example.co.uk`.
For more information, refer to Chromium's `BrowsingDataRemover` interface.
**/
function clearData(?options:{ /**
The types of data to clear. By default, this will clear all types of data.
**/
@:optional
var dataTypes : Array<String>; /**
Clear data for only these origins. Cannot be used with `excludeOrigins`.
**/
@:optional
var origins : Array<String>; /**
Clear data for all origins except these ones. Cannot be used with `origins`.
**/
@:optional
var excludeOrigins : Array<String>; /**
Skips deleting cookies that would close current network connections. (Default: `false`)
**/
@:optional
var avoidClosingConnections : Bool; /**
The behavior for matching data to origins.
**/
@:optional
var originMatchingMode : String; }):js.lib.Promise<Any>;
}
enum abstract SessionEvent<T:(haxe.Constraints.Function)>(js.node.events.EventEmitter.Event<T>) from js.node.events.EventEmitter.Event<T> {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/electron/main/SystemPreferences.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package electron.main;
/**
> Get system preferences.
Process: Main
Process: Main, Utility
@see https://electronjs.org/docs/api/system-preferences
**/
@:jsRequire("electron", "systemPreferences") extern class SystemPreferences extends js.node.events.EventEmitter<electron.main.SystemPreferences> {
Expand Down
2 changes: 2 additions & 0 deletions src/electron/main/WebContents.hx
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ package electron.main;
function setIgnoreMenuShortcuts(ignore:Bool):Void;
/**
Called before creating a window a new window is requested by the renderer, e.g. by `window.open()`, a link with `target="_blank"`, shift+clicking on a link, or submitting a form with `<form target="_blank">`. See `window.open()` for more details and how to use this in conjunction with `did-create-window`.
An example showing how to customize the process of new `BrowserWindow` creation to be `BrowserView` attached to main window instead:
**/
function setWindowOpenHandler(handler:haxe.Constraints.Function):Void;
/**
Expand Down
6 changes: 5 additions & 1 deletion src/electron/main/WebContentsView.hx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ package electron.main;
Settings of web page's features.
**/
@:optional
var webPreferences : electron.WebPreferences; }):Void;
var webPreferences : electron.WebPreferences; /**
If present, the given WebContents will be adopted by the WebContentsView. A WebContents may only be presented in one WebContentsView at a time.
**/
@:optional
var webContents : electron.main.WebContents; }):Void;
}
enum abstract WebContentsViewEvent<T:(haxe.Constraints.Function)>(js.node.events.EventEmitter.Event<T>) from js.node.events.EventEmitter.Event<T> {

Expand Down
4 changes: 2 additions & 2 deletions src/electron/remote/App.hx
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ package electron.remote;
* `openAtLogin` boolean - `true` if the app is set to open at login.
* `openAsHidden` boolean _macOS_ _Deprecated_ - `true` if the app is set to open as hidden at login. This does not work on macOS 13 and up.
* `wasOpenedAtLogin` boolean _macOS_ _Deprecated_ - `true` if the app was opened at login automatically. This setting is not available on MAS builds or on macOS 13 and up.
* `wasOpenedAtLogin` boolean _macOS_ - `true` if the app was opened at login automatically.
* `wasOpenedAsHidden` boolean _macOS_ _Deprecated_ - `true` if the app was opened as a hidden login item. This indicates that the app should not open any windows at startup. This setting is not available on MAS builds or on macOS 13 and up.
* `restoreState` boolean _macOS_ _Deprecated_ - `true` if the app was opened as a login item that should restore the state from the previous session. This indicates that the app should restore the windows that were open the last time the app was closed. This setting is not available on MAS builds or on macOS 13 and up.
* `status` string _macOS_ - can be one of `not-registered`, `enabled`, `requires-approval`, or `not-found`.
Expand Down Expand Up @@ -497,7 +497,7 @@ package electron.remote;
**/
@:optional
var openAtLogin : Bool; /**
`true` to open the app as hidden. Defaults to `false`. The user can edit this setting from the System Preferences so `app.getLoginItemSettings().wasOpenedAsHidden` should be checked when the app is opened to know the current value. This setting is not available on MAS build s or on macOS 13 and up.
`true` to open the app as hidden. Defaults to `false`. The user can edit this setting from the System Preferences so `app.getLoginItemSettings().wasOpenedAsHidden` should be checked when the app is opened to know the current value. This setting is not available on MAS builds or on macOS 13 and up.
**/
@:optional
var openAsHidden : Bool; /**
Expand Down
32 changes: 32 additions & 0 deletions src/electron/remote/Session.hx
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,38 @@ package electron.remote;
The absolute file system path where data for this session is persisted on disk. For in memory sessions this returns `null`.
**/
function getStoragePath():haxe.extern.EitherType<String, Dynamic>;
/**
resolves when all data has been cleared.
Clears various different types of data.
This method clears more types of data and is more thourough than the `clearStorageData` method.
**Note:** Cookies are stored at a broader scope than origins. When removing cookies and filtering by `origins` (or `excludeOrigins`), the cookies will be removed at the registrable domain level. For example, clearing cookies for the origin `https://really.specific.origin.example.com/` will end up clearing all cookies for `example.com`. Clearing cookies for the origin `https://my.website.example.co.uk/` will end up clearing all cookies for `example.co.uk`.
For more information, refer to Chromium's `BrowsingDataRemover` interface.
**/
function clearData(?options:{ /**
The types of data to clear. By default, this will clear all types of data.
**/
@:optional
var dataTypes : Array<String>; /**
Clear data for only these origins. Cannot be used with `excludeOrigins`.
**/
@:optional
var origins : Array<String>; /**
Clear data for all origins except these ones. Cannot be used with `origins`.
**/
@:optional
var excludeOrigins : Array<String>; /**
Skips deleting cookies that would close current network connections. (Default: `false`)
**/
@:optional
var avoidClosingConnections : Bool; /**
The behavior for matching data to origins.
**/
@:optional
var originMatchingMode : String; }):js.lib.Promise<Any>;
}
enum abstract SessionEvent<T:(haxe.Constraints.Function)>(js.node.events.EventEmitter.Event<T>) from js.node.events.EventEmitter.Event<T> {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/electron/remote/SystemPreferences.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package electron.remote;
/**
> Get system preferences.
Process: Main
Process: Main, Utility
@see https://electronjs.org/docs/api/system-preferences
**/
@:jsRequire("electron", "remote.systemPreferences") extern class SystemPreferences extends js.node.events.EventEmitter<electron.remote.SystemPreferences> {
Expand Down
2 changes: 2 additions & 0 deletions src/electron/remote/WebContents.hx
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ package electron.remote;
function setIgnoreMenuShortcuts(ignore:Bool):Void;
/**
Called before creating a window a new window is requested by the renderer, e.g. by `window.open()`, a link with `target="_blank"`, shift+clicking on a link, or submitting a form with `<form target="_blank">`. See `window.open()` for more details and how to use this in conjunction with `did-create-window`.
An example showing how to customize the process of new `BrowserWindow` creation to be `BrowserView` attached to main window instead:
**/
function setWindowOpenHandler(handler:haxe.Constraints.Function):Void;
/**
Expand Down
6 changes: 5 additions & 1 deletion src/electron/remote/WebContentsView.hx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ package electron.remote;
Settings of web page's features.
**/
@:optional
var webPreferences : electron.WebPreferences; }):Void;
var webPreferences : electron.WebPreferences; /**
If present, the given WebContents will be adopted by the WebContentsView. A WebContents may only be presented in one WebContentsView at a time.
**/
@:optional
var webContents : electron.remote.WebContents; }):Void;
}
enum abstract WebContentsViewEvent<T:(haxe.Constraints.Function)>(js.node.events.EventEmitter.Event<T>) from js.node.events.EventEmitter.Event<T> {

Expand Down
4 changes: 1 addition & 3 deletions src/electron/renderer/WebviewTag.hx
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ package electron.renderer;
<webview src="https://github.com" webpreferences="allowRunningInsecureContent, javascript=no"></webview>
```
A `string` which is a comma separated list of strings which specifies the web preferences to be set on the webview. The full list of supported preference strings can be found in BrowserWindow. In addition, webview supports the following preferences:
* `transparent` boolean (optional) - Whether to enable background transparency for the guest page. Default is `true`. **Note:** The guest page's text and background colors are derived from the color scheme of its root element. When transparency is enabled, the text color will still change accordingly but the background will remain transparent.
A `string` which is a comma separated list of strings which specifies the web preferences to be set on the webview. The full list of supported preference strings can be found in BrowserWindow.
The string follows the same format as the features string in `window.open`. A name by itself is given a `true` boolean value. A preference can be set to another value by including an `=`, followed by the value. Special values `yes` and `1` are interpreted as `true`, while `no` and `0` are interpreted as `false`.
Expand Down

0 comments on commit e7ff578

Please sign in to comment.