Skip to content

Commit

Permalink
⚡ Reorder and expand docs for Bun API
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmoMyzrailGorynych committed Dec 23, 2024
1 parent 9b445f4 commit cd8934c
Showing 1 changed file with 35 additions and 9 deletions.
44 changes: 35 additions & 9 deletions docs/bun-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,42 @@ Hides the window.
### exit(target: string): Promise<void>
Closes the specified window. Alias: `close(target: string)`

### getPosition(target: string): Promise<WindowPosOptions>
Returns the current window position.
### setAlwaysOnTop(target: string, onTop: boolean): Promise<void>
Sets whether the window should stay on top of other windows.

### getSize(target: string): Promise<WindowSizeOptions>
Returns the current window size.

### setAlwaysOnTop(target: string, onTop: boolean): Promise<void>
Sets whether the window should stay on top of other windows.

### setSize(target: string, options: WindowSizeOptions): Promise<void>
Sets the window size.
- `options`: Partial WindowSizeOptions object, merges with current size

- `options`: Partial WindowSizeOptions object; merges with the current size.

`WindowSizeOptions` is:

```typescript
interface WindowSizeOptions {
width?: number;
height?: number;
minWidth?: number;
minHeight?: number;
maxWidth?: number;
maxHeight?: number;
resizable?: boolean;
}
```

### getPosition(target: string): Promise<WindowPosOptions>
Returns the current window position.

`WindowPosOptions` is:

```typescript
interface WindowPosOptions {
x: number;
y: number;
}
```

### move(target: string, x: number, y: number): Promise<void>
Moves the window to specified coordinates. Alias: `setPosition(target: string, x: number, y: number)`
Expand All @@ -103,15 +127,15 @@ Gets the window title.
### setTitle(target: string, title: string): Promise<void>
Sets the window title.

### evalJs(target: string, js: string): Promise<void>
Evaluates JavaScript code in the window context.

### navigate(target: string, url: string): Promise<void>
Navigates the window to a new URL.

### reload(target: string): Promise<void>
Reloads the current window.

### evalJs(target: string, js: string): Promise<void>
Evaluates JavaScript code in the window context.

## Method Registration

For simpler, promisified calls of native functions and complex tasks, you can register methods with `registerMethod` and/or `registerMethodMap` calls. The functions registered here will then be callable in browser contexts with [`buntralino.run`](/client-api.html#buntralino-run-method-payload) method.
Expand Down Expand Up @@ -169,6 +193,8 @@ Checks if a connection to a named window is currently open. Can be used to check

## Events

### `events` property

The package exports an EventEmitter instance as `events` that emits:

- 'open': When a window is opened (payload: window name)
Expand Down

0 comments on commit cd8934c

Please sign in to comment.