-
-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1de0ea8
commit 1291d58
Showing
13 changed files
with
338 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,8 +22,6 @@ jobs: | |
- x64 | ||
node: | ||
- 18 | ||
- 14 | ||
- 16 | ||
include: | ||
- os: windows-latest | ||
node: 18 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// swift-tools-version:5.6 | ||
// swift-tools-version:5.9 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,168 +1,162 @@ | ||
declare namespace activeWindow { | ||
interface Options { | ||
/** | ||
Enable the accessibility permission check. _(macOS)_ | ||
Setting this to `false` will prevent the accessibility permission prompt on macOS versions 10.15 and newer. The `url` property won't be retrieved. | ||
@default true | ||
*/ | ||
readonly accessibilityPermission: boolean; | ||
|
||
/** | ||
Enable the screen recording permission check. _(macOS)_ | ||
export type Options = { | ||
/** | ||
Enable the accessibility permission check. _(macOS)_ | ||
Setting this to `false` will prevent the screen recording permission prompt on macOS versions 10.15 and newer. The `title` property in the result will always be set to an empty string. | ||
Setting this to `false` will prevent the accessibility permission prompt on macOS versions 10.15 and newer. The `url` property won't be retrieved. | ||
@default true | ||
*/ | ||
readonly screenRecordingPermission: boolean; | ||
} | ||
@default true | ||
*/ | ||
readonly accessibilityPermission: boolean; | ||
|
||
interface BaseOwner { | ||
/** | ||
Name of the app. | ||
*/ | ||
name: string; | ||
|
||
/** | ||
Process identifier | ||
*/ | ||
processId: number; | ||
|
||
/** | ||
Path to the app. | ||
*/ | ||
path: string; | ||
} | ||
/** | ||
Enable the screen recording permission check. _(macOS)_ | ||
interface BaseResult { | ||
/** | ||
Window title. | ||
*/ | ||
title: string; | ||
|
||
/** | ||
Window identifier. | ||
On Windows, there isn't a clear notion of a "Window ID". Instead it returns the memory address of the window "handle" in the `id` property. That "handle" is unique per window, so it can be used to identify them. [Read more…](https://msdn.microsoft.com/en-us/library/windows/desktop/ms632597(v=vs.85).aspx#window_handle). | ||
*/ | ||
id: number; | ||
|
||
/** | ||
Window position and size. | ||
*/ | ||
bounds: { | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
}; | ||
|
||
/** | ||
App that owns the window. | ||
*/ | ||
owner: BaseOwner; | ||
|
||
/** | ||
Memory usage by the window. | ||
*/ | ||
memoryUsage: number; | ||
} | ||
Setting this to `false` will prevent the screen recording permission prompt on macOS versions 10.15 and newer. The `title` property in the result will always be set to an empty string. | ||
interface MacOSOwner extends BaseOwner { | ||
/** | ||
Bundle identifier. | ||
*/ | ||
bundleId: string; | ||
} | ||
@default true | ||
*/ | ||
readonly screenRecordingPermission: boolean; | ||
}; | ||
|
||
interface MacOSResult extends BaseResult { | ||
platform: 'macos'; | ||
export type BaseOwner = { | ||
/** | ||
Name of the app. | ||
*/ | ||
name: string; | ||
|
||
owner: MacOSOwner; | ||
/** | ||
Process identifier | ||
*/ | ||
processId: number; | ||
|
||
/** | ||
URL of the active browser tab if the active window is Safari (includes Technology Preview), Chrome (includes Beta, Dev, and Canary), Edge (includes Beta, Dev, and Canary), Brave (includes Beta and Nightly), Mighty, Ghost Browser, WaveBox, Sidekick, Opera (includes Beta and Developer), or Vivaldi. | ||
*/ | ||
url?: string; | ||
} | ||
/** | ||
Path to the app. | ||
*/ | ||
path: string; | ||
}; | ||
|
||
interface LinuxResult extends BaseResult { | ||
platform: 'linux'; | ||
} | ||
export type BaseResult = { | ||
/** | ||
Window title. | ||
*/ | ||
title: string; | ||
|
||
interface WindowsResult extends BaseResult { | ||
platform: 'windows'; | ||
} | ||
/** | ||
Window identifier. | ||
type Result = MacOSResult | LinuxResult | WindowsResult; | ||
} | ||
On Windows, there isn't a clear notion of a "Window ID". Instead it returns the memory address of the window "handle" in the `id` property. That "handle" is unique per window, so it can be used to identify them. [Read more…](https://msdn.microsoft.com/en-us/library/windows/desktop/ms632597(v=vs.85).aspx#window_handle). | ||
*/ | ||
id: number; | ||
|
||
declare const activeWindow: { | ||
/** | ||
Get metadata about the [active window](https://en.wikipedia.org/wiki/Active_window) (title, id, bounds, owner, etc). | ||
@example | ||
``` | ||
import activeWindow = require('active-win'); | ||
(async () => { | ||
const result = await activeWindow(); | ||
if (!result) { | ||
return; | ||
} | ||
if (result.platform === 'macos') { | ||
// Among other fields, result.owner.bundleId is available on macOS. | ||
console.log(`Process title is ${result.title} with bundle id ${result.owner.bundleId}.`); | ||
} else if (result.platform === 'windows') { | ||
console.log(`Process title is ${result.title} with path ${result.owner.path}.`); | ||
} else { | ||
console.log(`Process title is ${result.title} with path ${result.owner.path}.`); | ||
} | ||
})(); | ||
``` | ||
Window position and size. | ||
*/ | ||
(options?: activeWindow.Options): Promise<activeWindow.Result | undefined>; | ||
bounds: { | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
}; | ||
|
||
/** | ||
Get metadata about the [active window](https://en.wikipedia.org/wiki/Active_window) synchronously (title, id, bounds, owner, etc). | ||
@example | ||
``` | ||
import activeWindow = require('active-win'); | ||
const result = activeWindow.sync(); | ||
if (result) { | ||
if (result.platform === 'macos') { | ||
// Among other fields, result.owner.bundleId is available on macOS. | ||
console.log(`Process title is ${result.title} with bundle id ${result.owner.bundleId}.`); | ||
} else if (result.platform === 'windows') { | ||
console.log(`Process title is ${result.title} with path ${result.owner.path}.`); | ||
} else { | ||
console.log(`Process title is ${result.title} with path ${result.owner.path}.`); | ||
} | ||
} | ||
``` | ||
App that owns the window. | ||
*/ | ||
sync(options?: activeWindow.Options): activeWindow.Result | undefined; | ||
owner: BaseOwner; | ||
|
||
/** | ||
Get metadata about all open windows. | ||
Windows are returned in order from front to back. | ||
Memory usage by the window. | ||
*/ | ||
getOpenWindows(options?: activeWindow.Options): Promise<activeWindow.Result[]>; | ||
memoryUsage: number; | ||
}; | ||
|
||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
export type MacOSOwner = { | ||
/** | ||
Get metadata about all open windows synchronously. | ||
Bundle identifier. | ||
*/ | ||
bundleId: string; | ||
} & BaseOwner; | ||
|
||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
export type MacOSResult = { | ||
platform: 'macos'; | ||
|
||
Windows are returned in order from front to back. | ||
owner: MacOSOwner; | ||
|
||
/** | ||
URL of the active browser tab if the active window is Safari (includes Technology Preview), Chrome (includes Beta, Dev, and Canary), Edge (includes Beta, Dev, and Canary), Brave (includes Beta and Nightly), Mighty, Ghost Browser, WaveBox, Sidekick, Opera (includes Beta and Developer), or Vivaldi. | ||
*/ | ||
getOpenWindowsSync(options?: activeWindow.Options): activeWindow.Result[]; | ||
}; | ||
url?: string; | ||
} & BaseResult; | ||
|
||
export type LinuxResult = { | ||
platform: 'linux'; | ||
} & BaseResult; | ||
|
||
export type WindowsResult = { | ||
platform: 'windows'; | ||
} & BaseResult; | ||
|
||
export type Result = MacOSResult | LinuxResult | WindowsResult; | ||
|
||
/** | ||
Get metadata about the [active window](https://en.wikipedia.org/wiki/Active_window) (title, id, bounds, owner, etc). | ||
@example | ||
``` | ||
import {activeWindow} from 'active-win'; | ||
const result = await activeWindow(); | ||
if (!result) { | ||
return; | ||
} | ||
if (result.platform === 'macos') { | ||
// Among other fields, `result.owner.bundleId` is available on macOS. | ||
console.log(`Process title is ${result.title} with bundle id ${result.owner.bundleId}.`); | ||
} else if (result.platform === 'windows') { | ||
console.log(`Process title is ${result.title} with path ${result.owner.path}.`); | ||
} else { | ||
console.log(`Process title is ${result.title} with path ${result.owner.path}.`); | ||
} | ||
``` | ||
*/ | ||
export function activeWindow(options?: Options): Promise<Result | undefined>; | ||
|
||
/** | ||
Get metadata about the [active window](https://en.wikipedia.org/wiki/Active_window) synchronously (title, id, bounds, owner, etc). | ||
@example | ||
``` | ||
import {activeWindowSync} from 'active-win'; | ||
const result = activeWindowSync(); | ||
if (result) { | ||
if (result.platform === 'macos') { | ||
// Among other fields, `result.owner.bundleId` is available on macOS. | ||
console.log(`Process title is ${result.title} with bundle id ${result.owner.bundleId}.`); | ||
} else if (result.platform === 'windows') { | ||
console.log(`Process title is ${result.title} with path ${result.owner.path}.`); | ||
} else { | ||
console.log(`Process title is ${result.title} with path ${result.owner.path}.`); | ||
} | ||
} | ||
``` | ||
*/ | ||
export function activeWindowSync(options?: Options): Result | undefined; | ||
|
||
/** | ||
Get metadata about all open windows. | ||
Windows are returned in order from front to back. | ||
*/ | ||
export function openWindows(options?: Options): Promise<Result[]>; | ||
|
||
/** | ||
Get metadata about all open windows synchronously. | ||
export = activeWindow; | ||
Windows are returned in order from front to back. | ||
*/ | ||
export function openWindowsSync(options?: Options): Result[]; |
Oops, something went wrong.