electron/docs/api/dock.md
Samuel Attard 81795744cf
fix: ensure the typescript definitions only export correct value types (#28712)
* fix: ensure the typescript definitions only export correct value types

In typescript there are two main types of "types" you can export, value types (class, const) and definition types (type, interface).  The typescript compiler will let anything declared via const or class be used as a value.  Unfortunately we were exporting a bunch of things (see the diff) as class/const when they weren't actually exported values. This lead to typescript being happy but the runtime throwing errors (not something we want).

This change passes "exported-in" context through our docs, to the parser and then to the definitions generator to ensure we only mark things as exported in the ts defs that we actually export.

Fixes #22167

* chore: update typescript-defs

* chore: update typescript-defs

* chore: fix bad typescript in IPC test

* docs: test rendering of new syntax

* chore: update per feedback, use same syntax but with 'this is not exportedd' line
2021-06-15 13:50:31 -07:00

81 lines
2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## Class: Dock
> Control your app in the macOS dock
Process: [Main](../glossary.md#main-process)<br />
_This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._
The following example shows how to bounce your icon on the dock.
```javascript
const { app } = require('electron')
app.dock.bounce()
```
### Instance Methods
#### `dock.bounce([type])` _macOS_
* `type` String (optional) - Can be `critical` or `informational`. The default is
`informational`
Returns `Integer` - an ID representing the request.
When `critical` is passed, the dock icon will bounce until either the
application becomes active or the request is canceled.
When `informational` is passed, the dock icon will bounce for one second.
However, the request remains active until either the application becomes active
or the request is canceled.
**Nota Bene:** This method can only be used while the app is not focused; when the app is focused it will return -1.
#### `dock.cancelBounce(id)` _macOS_
* `id` Integer
Cancel the bounce of `id`.
#### `dock.downloadFinished(filePath)` _macOS_
* `filePath` String
Bounces the Downloads stack if the filePath is inside the Downloads folder.
#### `dock.setBadge(text)` _macOS_
* `text` String
Sets the string to be displayed in the docks badging area.
#### `dock.getBadge()` _macOS_
Returns `String` - The badge string of the dock.
#### `dock.hide()` _macOS_
Hides the dock icon.
#### `dock.show()` _macOS_
Returns `Promise<void>` - Resolves when the dock icon is shown.
#### `dock.isVisible()` _macOS_
Returns `Boolean` - Whether the dock icon is visible.
#### `dock.setMenu(menu)` _macOS_
* `menu` [Menu](menu.md)
Sets the application's [dock menu][dock-menu].
#### `dock.getMenu()` _macOS_
Returns `Menu | null` - The application's [dock menu][dock-menu].
#### `dock.setIcon(image)` _macOS_
* `image` ([NativeImage](native-image.md) | String)
Sets the `image` associated with this dock icon.