|
| 1 | +/*--------------------------------------------------------------------------------------------- |
| 2 | + * Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | + * Licensed under the MIT License. See License.txt in the project root for license information. |
| 4 | + *--------------------------------------------------------------------------------------------*/ |
| 5 | + |
| 6 | + |
| 7 | +// ####################################################################### |
| 8 | +// ### ### |
| 9 | +// ### electron.d.ts types we need in a common layer for reuse ### |
| 10 | +// ### (copied from Electron 8.3.0) ### |
| 11 | +// ### ### |
| 12 | +// ####################################################################### |
| 13 | + |
| 14 | + |
| 15 | +export interface MessageBoxOptions { |
| 16 | + /** |
| 17 | + * Can be `"none"`, `"info"`, `"error"`, `"question"` or `"warning"`. On Windows, |
| 18 | + * `"question"` displays the same icon as `"info"`, unless you set an icon using |
| 19 | + * the `"icon"` option. On macOS, both `"warning"` and `"error"` display the same |
| 20 | + * warning icon. |
| 21 | + */ |
| 22 | + type?: string; |
| 23 | + /** |
| 24 | + * Array of texts for buttons. On Windows, an empty array will result in one button |
| 25 | + * labeled "OK". |
| 26 | + */ |
| 27 | + buttons?: string[]; |
| 28 | + /** |
| 29 | + * Index of the button in the buttons array which will be selected by default when |
| 30 | + * the message box opens. |
| 31 | + */ |
| 32 | + defaultId?: number; |
| 33 | + /** |
| 34 | + * Title of the message box, some platforms will not show it. |
| 35 | + */ |
| 36 | + title?: string; |
| 37 | + /** |
| 38 | + * Content of the message box. |
| 39 | + */ |
| 40 | + message: string; |
| 41 | + /** |
| 42 | + * Extra information of the message. |
| 43 | + */ |
| 44 | + detail?: string; |
| 45 | + /** |
| 46 | + * If provided, the message box will include a checkbox with the given label. |
| 47 | + */ |
| 48 | + checkboxLabel?: string; |
| 49 | + /** |
| 50 | + * Initial checked state of the checkbox. `false` by default. |
| 51 | + */ |
| 52 | + checkboxChecked?: boolean; |
| 53 | + // icon?: NativeImage; |
| 54 | + /** |
| 55 | + * The index of the button to be used to cancel the dialog, via the `Esc` key. By |
| 56 | + * default this is assigned to the first button with "cancel" or "no" as the label. |
| 57 | + * If no such labeled buttons exist and this option is not set, `0` will be used as |
| 58 | + * the return value. |
| 59 | + */ |
| 60 | + cancelId?: number; |
| 61 | + /** |
| 62 | + * On Windows Electron will try to figure out which one of the `buttons` are common |
| 63 | + * buttons (like "Cancel" or "Yes"), and show the others as command links in the |
| 64 | + * dialog. This can make the dialog appear in the style of modern Windows apps. If |
| 65 | + * you don't like this behavior, you can set `noLink` to `true`. |
| 66 | + */ |
| 67 | + noLink?: boolean; |
| 68 | + /** |
| 69 | + * Normalize the keyboard access keys across platforms. Default is `false`. |
| 70 | + * Enabling this assumes `&` is used in the button labels for the placement of the |
| 71 | + * keyboard shortcut access key and labels will be converted so they work correctly |
| 72 | + * on each platform, `&` characters are removed on macOS, converted to `_` on |
| 73 | + * Linux, and left untouched on Windows. For example, a button label of `Vie&w` |
| 74 | + * will be converted to `Vie_w` on Linux and `View` on macOS and can be selected |
| 75 | + * via `Alt-W` on Windows and Linux. |
| 76 | + */ |
| 77 | + normalizeAccessKeys?: boolean; |
| 78 | +} |
| 79 | + |
| 80 | +export interface MessageBoxReturnValue { |
| 81 | + /** |
| 82 | + * The index of the clicked button. |
| 83 | + */ |
| 84 | + response: number; |
| 85 | + /** |
| 86 | + * The checked state of the checkbox if `checkboxLabel` was set. Otherwise `false`. |
| 87 | + */ |
| 88 | + checkboxChecked: boolean; |
| 89 | +} |
| 90 | + |
| 91 | +export interface OpenDevToolsOptions { |
| 92 | + /** |
| 93 | + * Opens the devtools with specified dock state, can be `right`, `bottom`, |
| 94 | + * `undocked`, `detach`. Defaults to last used dock state. In `undocked` mode it's |
| 95 | + * possible to dock back. In `detach` mode it's not. |
| 96 | + */ |
| 97 | + mode: ('right' | 'bottom' | 'undocked' | 'detach'); |
| 98 | + /** |
| 99 | + * Whether to bring the opened devtools window to the foreground. The default is |
| 100 | + * `true`. |
| 101 | + */ |
| 102 | + activate?: boolean; |
| 103 | +} |
| 104 | + |
| 105 | +export interface SaveDialogOptions { |
| 106 | + title?: string; |
| 107 | + /** |
| 108 | + * Absolute directory path, absolute file path, or file name to use by default. |
| 109 | + */ |
| 110 | + defaultPath?: string; |
| 111 | + /** |
| 112 | + * Custom label for the confirmation button, when left empty the default label will |
| 113 | + * be used. |
| 114 | + */ |
| 115 | + buttonLabel?: string; |
| 116 | + filters?: FileFilter[]; |
| 117 | + /** |
| 118 | + * Message to display above text fields. |
| 119 | + * |
| 120 | + * @platform darwin |
| 121 | + */ |
| 122 | + message?: string; |
| 123 | + /** |
| 124 | + * Custom label for the text displayed in front of the filename text field. |
| 125 | + * |
| 126 | + * @platform darwin |
| 127 | + */ |
| 128 | + nameFieldLabel?: string; |
| 129 | + /** |
| 130 | + * Show the tags input box, defaults to `true`. |
| 131 | + * |
| 132 | + * @platform darwin |
| 133 | + */ |
| 134 | + showsTagField?: boolean; |
| 135 | + properties?: Array<'showHiddenFiles' | 'createDirectory' | 'treatPackageAsDirectory' | 'showOverwriteConfirmation' | 'dontAddToRecent'>; |
| 136 | + /** |
| 137 | + * Create a security scoped bookmark when packaged for the Mac App Store. If this |
| 138 | + * option is enabled and the file doesn't already exist a blank file will be |
| 139 | + * created at the chosen path. |
| 140 | + * |
| 141 | + * @platform darwin,mas |
| 142 | + */ |
| 143 | + securityScopedBookmarks?: boolean; |
| 144 | +} |
| 145 | + |
| 146 | +export interface OpenDialogOptions { |
| 147 | + title?: string; |
| 148 | + defaultPath?: string; |
| 149 | + /** |
| 150 | + * Custom label for the confirmation button, when left empty the default label will |
| 151 | + * be used. |
| 152 | + */ |
| 153 | + buttonLabel?: string; |
| 154 | + filters?: FileFilter[]; |
| 155 | + /** |
| 156 | + * Contains which features the dialog should use. The following values are |
| 157 | + * supported: |
| 158 | + */ |
| 159 | + properties?: Array<'openFile' | 'openDirectory' | 'multiSelections' | 'showHiddenFiles' | 'createDirectory' | 'promptToCreate' | 'noResolveAliases' | 'treatPackageAsDirectory' | 'dontAddToRecent'>; |
| 160 | + /** |
| 161 | + * Message to display above input boxes. |
| 162 | + * |
| 163 | + * @platform darwin |
| 164 | + */ |
| 165 | + message?: string; |
| 166 | + /** |
| 167 | + * Create security scoped bookmarks when packaged for the Mac App Store. |
| 168 | + * |
| 169 | + * @platform darwin,mas |
| 170 | + */ |
| 171 | + securityScopedBookmarks?: boolean; |
| 172 | +} |
| 173 | + |
| 174 | +export interface OpenDialogReturnValue { |
| 175 | + /** |
| 176 | + * whether or not the dialog was canceled. |
| 177 | + */ |
| 178 | + canceled: boolean; |
| 179 | + /** |
| 180 | + * An array of file paths chosen by the user. If the dialog is cancelled this will |
| 181 | + * be an empty array. |
| 182 | + */ |
| 183 | + filePaths: string[]; |
| 184 | + /** |
| 185 | + * An array matching the `filePaths` array of base64 encoded strings which contains |
| 186 | + * security scoped bookmark data. `securityScopedBookmarks` must be enabled for |
| 187 | + * this to be populated. (For return values, see table here.) |
| 188 | + * |
| 189 | + * @platform darwin,mas |
| 190 | + */ |
| 191 | + bookmarks?: string[]; |
| 192 | +} |
| 193 | + |
| 194 | +export interface SaveDialogReturnValue { |
| 195 | + /** |
| 196 | + * whether or not the dialog was canceled. |
| 197 | + */ |
| 198 | + canceled: boolean; |
| 199 | + /** |
| 200 | + * If the dialog is canceled, this will be `undefined`. |
| 201 | + */ |
| 202 | + filePath?: string; |
| 203 | + /** |
| 204 | + * Base64 encoded string which contains the security scoped bookmark data for the |
| 205 | + * saved file. `securityScopedBookmarks` must be enabled for this to be present. |
| 206 | + * (For return values, see table here.) |
| 207 | + * |
| 208 | + * @platform darwin,mas |
| 209 | + */ |
| 210 | + bookmark?: string; |
| 211 | +} |
| 212 | + |
| 213 | +export interface CrashReporterStartOptions { |
| 214 | + companyName: string; |
| 215 | + /** |
| 216 | + * URL that crash reports will be sent to as POST. |
| 217 | + */ |
| 218 | + submitURL: string; |
| 219 | + /** |
| 220 | + * Defaults to `app.name`. |
| 221 | + */ |
| 222 | + productName?: string; |
| 223 | + /** |
| 224 | + * Whether crash reports should be sent to the server. Default is `true`. |
| 225 | + */ |
| 226 | + uploadToServer?: boolean; |
| 227 | + /** |
| 228 | + * Default is `false`. |
| 229 | + */ |
| 230 | + ignoreSystemCrashHandler?: boolean; |
| 231 | + /** |
| 232 | + * An object you can define that will be sent along with the report. Only string |
| 233 | + * properties are sent correctly. Nested objects are not supported. When using |
| 234 | + * Windows, the property names and values must be fewer than 64 characters. |
| 235 | + */ |
| 236 | + extra?: Record<string, string>; |
| 237 | + /** |
| 238 | + * Directory to store the crash reports temporarily (only used when the crash |
| 239 | + * reporter is started via `process.crashReporter.start`). |
| 240 | + */ |
| 241 | + crashesDirectory?: string; |
| 242 | +} |
| 243 | + |
| 244 | +export interface FileFilter { |
| 245 | + |
| 246 | + // Docs: http://electronjs.org/docs/api/structures/file-filter |
| 247 | + |
| 248 | + extensions: string[]; |
| 249 | + name: string; |
| 250 | +} |
0 commit comments