npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

applescript-utils

v0.1.22

Published

Utilities for AppleScript scripts.

Downloads

35

Readme

applescript-utils

npm version

Some utilities for working with AppleScript.

Installation

npm install applescript-utils

Usage

import { getElements } from 'applescript-utils';

await getElements('System Preferences');

API

getElements(processName)

Returns: ElementReference[]

Gets all the UI elements in a process. This function runs the following AppleScript:

tell application "System Events"
  tell front window of process ${JSON.stringify(processName)}
    get entire contents
  end tell
end tell

processName

Type: string
Required: true

The name of the process to retrieve all the elements from.

waitForElementExists(options)

Waits until an element exists. This function runs the following AppleScript:

tell application "System Events"
  tell process ${JSON.stringify(elementReference.applicationProcess)}
      repeat until exists ${elementReference.pathString}
          delay ${interval}
      end repeat
  end tell
end tell

options.elementReference

Type: ElementReference
Required: true

A reference to the element to wait for.

options.interval

Type: number
Default: 0.1

The amount of time in seconds to wait for before re-checking to see if the element exists.

clickElement(elementReference)

Clicks an element. This function runs the following AppleScript:

tell application "System Events"
  tell process ${element.applicationProcess}
    set myElement to a reference to ${element.pathString}
    click myElement
  end tell
end tell

elementReference

Type: ElementReference
Required: true

A reference to the element to click.

toggleCheckbox(options)

Toggles a checkbox element. Runs the following AppleScript:

tell application "System Events" to tell process ${props.element.applicationProcess}
  set theCheckbox to ${props.element.pathString}
  tell theCheckbox
    ${checkboxAction}
  end tell
end tell

options.element

Type: ElementReference
Required: true

A reference to the checkbox element.

options.value

Type: boolean | undefined
Required: false

The value to set the checkbox. If undefined, the checkbox will be toggled to the opposite of its current state.

waitForElementHidden(options)

Waits until an element is hidden. Runs the following AppleScript:

tell application "System Events"
  tell process ${JSON.stringify(elementReference.applicationProcess)}
      repeat while exists ${elementReference}
          delay ${interval}
      end repeat
  end tell
end tell

options.elementReference

Type: ElementReference
Required: true

A reference to the element to wait for until it's hidden.

options.interval

Type: number
Default: 0.1

The amount of time to wait inbetween checks.

waitForElementMatch(windowName, elementMatcher, pWaitForOptions?)

Waits until a matching element on the window is found.

windowName

Type: string
Required: true

The name of the window.

elementMatcher

Type: (element: ElementReference) => boolean
Required: true

A function that takes an element reference and returns a boolean representing whether or not it matches.

pWaitForOptions

Type: import('p-wait-for').Options
Required: false

Options to pass to pWaitFor.

inputKeystrokes(keystrokes)

Input keystrokes. Runs the following AppleScript:

tell application "System Events" to keystroke ${JSON.stringify(keystrokes)}

keystrokes

Type: string
Required: true

The keystrokes to enter.

runAppleScript(appleScript)

Returns: string | number | boolean | Record<string, unknown> | unknown[] | Date | Buffer | undefined

Runs an AppleScript string and parses the result using parse-applescript.

appleScript

Type: string
Required: true

The AppleScript code to run.