Skip to content

Commit 05f0f10

Browse files
committed
docs: move objects to separate files
1 parent 67c619c commit 05f0f10

File tree

7 files changed

+206
-195
lines changed

7 files changed

+206
-195
lines changed

README.md

Lines changed: 1 addition & 195 deletions
Original file line numberDiff line numberDiff line change
@@ -29,198 +29,4 @@ window.setBounds({ x: 0, y: 0 });
2929
```
3030

3131
# Documentation
32-
33-
## Object `Rectangle`
34-
35-
- `x` number
36-
- `y` number
37-
- `width` number
38-
- `height` number
39-
40-
## Object `WindowInfo`
41-
42-
- `title` string
43-
- `processId` string
44-
- `path` string - path to executable associated with the window
45-
- `bounds` [`Rectangle`](#object-rectangle)
46-
- `opacity` number (`Windows`)
47-
- `owner` [`Window`](#class-window) (`Windows`) - owner window of the current window
48-
49-
## Object `MonitorInfo`
50-
51-
- `isPrimary` boolean
52-
- `bounds` [`Rectangle`](#object-rectangle) - the monitor position and bounds
53-
- `workArea` [`Rectangle`](#object-rectangle) - the monitor working area bounds
54-
55-
## Class `WindowManager`
56-
57-
### Instance methods
58-
59-
#### windowManager.requestAccessibility() `macOS`
60-
Required before any action on macOS.
61-
- Returns `boolean`
62-
63-
#### windowManager.getActiveWindow() `Windows` `macOS`
64-
65-
- Returns [`Window`](#class-window)
66-
67-
#### windowManager.getWindows() `Windows` `macOS`
68-
69-
- Returns [`Window[]`](#class-window)
70-
71-
#### windowManager.getMonitors() `Windows`
72-
73-
- Returns [`Monitor[]`](#class-monitor)
74-
75-
#### windowManager.getPrimaryMonitor() `Windows`
76-
77-
- Returns [`Monitor`](#class-monitor)
78-
79-
### Events
80-
81-
#### Event 'window-activated' `Windows` `macOS`
82-
83-
Returns:
84-
85-
- [`Window`](#class-window)
86-
87-
Emitted when a window has been activated.
88-
89-
## Class `Window`
90-
91-
We try to keep this class similar to Electron's known [`BrowserWindow`](https://electronjs.org/docs/api/browser-window) class, to keep it simple to use.
92-
93-
### new Window(id: number)
94-
95-
- `id` number
96-
97-
### Instance properties
98-
99-
- `id` number
100-
- `processId` number - process id associated with the window
101-
- `path` string - path to executable associated with the window
102-
103-
### Instance methods
104-
105-
#### win.getBounds() `Windows` `macOS`
106-
107-
- Returns [`Rectangle`](#object-rectangle)
108-
109-
#### win.setBounds(bounds: Rectangle) `Windows` `macOS`
110-
111-
Resizes and moves the window to the supplied bounds. Any properties that are not supplied will default to their current values.
112-
113-
```javascript
114-
window.setBounds({ height: 50 });
115-
```
116-
117-
#### win.getInfo() `Windows` `macOS`
118-
119-
Returns [`WindowInfo`](#object-windowinfo)
120-
121-
#### win.getTitle() `Windows` `macOS`
122-
123-
- Returns `string`
124-
125-
#### win.show() `Windows`
126-
127-
Shows the window.
128-
129-
#### win.hide() `Windows`
130-
131-
Hides the window.
132-
133-
#### win.minimize() `Windows` `macOS`
134-
135-
Minimizes the window.
136-
137-
#### win.restore() `Windows` `macOS`
138-
139-
Restores the window.
140-
141-
#### win.maximize() `Windows` `macOS`
142-
143-
Maximizes the window.
144-
145-
#### win.bringToTop() `Windows` `macOS`
146-
147-
Brings the window to top and focuses it.
148-
149-
#### win.setOpacity(opacity: number) `Windows`
150-
151-
- `opacity` - a value between 0 and 1.
152-
153-
Sets the window opacity.
154-
155-
#### win.getOpacity() `Windows`
156-
157-
Gets the window opacity
158-
159-
Returns `number` between 0 and 1.
160-
161-
#### win.getMonitor() `Windows`
162-
163-
Gets monitor which the window belongs to.
164-
165-
Returns [`Monitor`](#class-monitor)
166-
167-
#### win.isWindow() `Windows` `macOS`
168-
169-
Returns `boolean` - whether the window is a valid window.
170-
171-
#### win.isVisible() `Windows`
172-
Returns `boolean` - whether the window is visible or not.
173-
174-
#### win.getOwner() `Windows`
175-
176-
Returns [`Window`](#class-window)
177-
178-
#### win.setOwner(win: [`Window`](#class-window) | number | null) `Windows`
179-
180-
- `win` [Window](#class-window) | number | null
181-
- pass null to unset window owner.
182-
183-
#### win.getIcon(size: number) `Windows` `macOS`
184-
185-
- `size` number - can be only `16`, `32`, `64`, `256`. By default it's `64`.
186-
187-
Returns a png Buffer
188-
189-
190-
## Class `Monitor` `Windows`
191-
192-
### new Monitor(id: number)
193-
194-
- `id` number - the monitor handle
195-
196-
### Instance properties
197-
198-
- `id` number
199-
200-
### Instance methods
201-
202-
#### monitor.getBounds() `Windows`
203-
204-
- Returns [`Rectangle`](#object-rectangle)
205-
206-
#### monitor.getWorkArea() `Windows`
207-
208-
Gets monitor working area bounds.
209-
210-
- Returns [`Rectangle`](#object-rectangle)
211-
212-
#### monitor.getInfo() `Windows`
213-
214-
Returns [`MonitorInfo`](#object-monitorinfo)
215-
216-
#### monitor.isPrimary() `Windows`
217-
218-
Whether the monitor is primary.
219-
220-
- Returns `boolean`
221-
222-
#### monitor.getScaleFactor() `Windows`
223-
224-
Gets monitor scale factor (DPI).
225-
226-
- Returns `number`
32+
The documentation and API references are located in the [`docs`](docs) directory.

docs/monitor-info.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Object `MonitorInfo`
2+
3+
- `isPrimary` boolean
4+
- `bounds` [`Rectangle`](#object-rectangle) - the monitor position and bounds
5+
- `workArea` [`Rectangle`](#object-rectangle) - the monitor working area bounds

docs/monitor.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## Class `Monitor` `Windows`
2+
3+
Control monitors.
4+
5+
### new Monitor(id: number)
6+
7+
- `id` number - the monitor handle
8+
9+
### Instance properties
10+
11+
- `id` number
12+
13+
### Instance methods
14+
15+
#### monitor.getBounds() `Windows`
16+
17+
- Returns [`Rectangle`](#object-rectangle)
18+
19+
#### monitor.getWorkArea() `Windows`
20+
21+
Gets monitor working area bounds.
22+
23+
- Returns [`Rectangle`](#object-rectangle)
24+
25+
#### monitor.getInfo() `Windows`
26+
27+
Returns [`MonitorInfo`](#object-monitorinfo)
28+
29+
#### monitor.isPrimary() `Windows`
30+
31+
Whether the monitor is primary.
32+
33+
- Returns `boolean`
34+
35+
#### monitor.getScaleFactor() `Windows`
36+
37+
Gets monitor scale factor (DPI).
38+
39+
- Returns `number`

docs/rectangle.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## Object `Rectangle`
2+
3+
- `x` number
4+
- `y` number
5+
- `width` number
6+
- `height` number

docs/window-info.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Object `WindowInfo`
2+
3+
- `title` string
4+
- `processId` string
5+
- `path` string - path to executable associated with the window
6+
- `bounds` [`Rectangle`](#object-rectangle)
7+
- `opacity` number (`Windows`)
8+
- `owner` [`Window`](#class-window) (`Windows`) - owner window of the current window

docs/window-manager.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## `windowManager`
2+
3+
Get monitors and opened windows.
4+
5+
```typescript
6+
import { windowManager } from 'node-window-manager';
7+
8+
windowManager.requestAccessibility();
9+
10+
const window = windowManager.getActiveWindow();
11+
12+
// Prints the currently focused window title.
13+
console.log(window.getTitle());
14+
```
15+
16+
### Instance methods
17+
18+
#### windowManager.requestAccessibility() `macOS`
19+
Required before any action on macOS.
20+
- Returns `boolean`
21+
22+
#### windowManager.getActiveWindow() `Windows` `macOS`
23+
24+
- Returns [`Window`](#class-window)
25+
26+
#### windowManager.getWindows() `Windows` `macOS`
27+
28+
- Returns [`Window[]`](#class-window)
29+
30+
#### windowManager.getMonitors() `Windows`
31+
32+
- Returns [`Monitor[]`](#class-monitor)
33+
34+
#### windowManager.getPrimaryMonitor() `Windows`
35+
36+
- Returns [`Monitor`](#class-monitor)
37+
38+
### Events
39+
40+
#### Event 'window-activated' `Windows` `macOS`
41+
42+
Returns:
43+
44+
- [`Window`](#class-window)
45+
46+
Emitted when a window has been activated.

0 commit comments

Comments
 (0)