@guidepup/guidepup
Advanced tools
Comparing version 0.7.1 to 0.7.2
import { Applications } from "./Applications"; | ||
import "@jxa/global-type"; | ||
export declare function activate(applicationName: Applications | string): Promise<void>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.activate = void 0; | ||
const run_1 = require("@jxa/run"); | ||
const runAppleScript_1 = require("./runAppleScript"); | ||
const errors_1 = require("./errors"); | ||
require("@jxa/global-type"); | ||
async function activate(applicationName) { | ||
const script = `tell application "${applicationName}"\nactivate\nend tell`; | ||
try { | ||
return await (0, run_1.run)((name) => Application(name).activate(), applicationName); | ||
return await (0, runAppleScript_1.runAppleScript)(script); | ||
} | ||
@@ -11,0 +11,0 @@ catch (e) { |
import type { KeyCodeCommand } from "./KeyCodeCommand"; | ||
import "@jxa/global-type"; | ||
export declare function keyCode(command: KeyCodeCommand): Promise<void>; | ||
export declare function keyCode({ keyCode, modifiers, }: KeyCodeCommand): Promise<void>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.keyCode = void 0; | ||
const run_1 = require("@jxa/run"); | ||
const runAppleScript_1 = require("./runAppleScript"); | ||
const Applications_1 = require("./Applications"); | ||
require("@jxa/global-type"); | ||
async function keyCode(command) { | ||
return await (0, run_1.run)((name, { keyCode, modifiers = [] }) => Application(name).keyCode(keyCode, { using: modifiers }), Applications_1.Applications.SYSTEM_EVENTS, command); | ||
async function keyCode({ keyCode, modifiers = [], }) { | ||
const script = `tell application "${Applications_1.Applications.SYSTEM_EVENTS}"\nkey code ${Array.isArray(keyCode) ? `{${keyCode.join(", ")}}` : keyCode}${modifiers.length ? ` using {${modifiers.join(", ")}}` : ""}\nend tell`; | ||
return await (0, runAppleScript_1.runAppleScript)(script); | ||
} | ||
exports.keyCode = keyCode; |
import { Applications } from "./Applications"; | ||
import "@jxa/global-type"; | ||
export declare function quit(applicationName: Applications): Promise<void>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.quit = void 0; | ||
const run_1 = require("@jxa/run"); | ||
const runAppleScript_1 = require("./runAppleScript"); | ||
const errors_1 = require("./errors"); | ||
require("@jxa/global-type"); | ||
async function quit(applicationName) { | ||
const script = `tell application "${applicationName}"\nquit\nend tell`; | ||
try { | ||
return await (0, run_1.run)((name) => Application(name).quit(), applicationName); | ||
return await (0, runAppleScript_1.runAppleScript)(script); | ||
} | ||
@@ -11,0 +11,0 @@ catch (e) { |
@@ -1,2 +0,3 @@ | ||
import "@jxa/global-type"; | ||
export declare function runAppleScript(script: string): Promise<void>; | ||
export declare function runAppleScript<T = string | void>(script: string, { timeout }?: { | ||
timeout?: number; | ||
}): Promise<T>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.runAppleScript = void 0; | ||
const run_1 = require("@jxa/run"); | ||
require("@jxa/global-type"); | ||
async function runAppleScript(script) { | ||
return await (0, run_1.run)((appleScript) => { | ||
const app = Application.currentApplication(); | ||
app.includeStandardAdditions = true; | ||
app.runScript(appleScript); | ||
}, script); | ||
const child_process_1 = require("child_process"); | ||
const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100; | ||
const DEFAULT_TIMEOUT = 30; | ||
async function runAppleScript(script, { timeout = DEFAULT_TIMEOUT } = { timeout: DEFAULT_TIMEOUT }) { | ||
const scriptWithTimeout = `with timeout of ${timeout} seconds\n${script}\nend timeout`; | ||
return (await new Promise((resolve, reject) => { | ||
const child = (0, child_process_1.execFile)("/usr/bin/osascript", [], { | ||
maxBuffer: DEFAULT_MAX_BUFFER, | ||
}, (e, stdout, stderr) => { | ||
if (e) { | ||
return reject(e); | ||
} | ||
if (stderr) { | ||
console.error(stderr); | ||
} | ||
if (!stdout) { | ||
return resolve(); | ||
} | ||
else { | ||
return resolve(stdout.trim()); | ||
} | ||
}); | ||
child.stdin.write(scriptWithTimeout); | ||
child.stdin.end(); | ||
})); | ||
} | ||
exports.runAppleScript = runAppleScript; |
import { KeystrokeCommand } from "../KeystrokeCommand"; | ||
import "@jxa/global-type"; | ||
export declare function keystroke(command: KeystrokeCommand): Promise<void>; | ||
export declare function keystroke({ characters, modifiers, }: KeystrokeCommand): Promise<void>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.keystroke = void 0; | ||
const run_1 = require("@jxa/run"); | ||
const runAppleScript_1 = require("../runAppleScript"); | ||
const Applications_1 = require("../Applications"); | ||
require("@jxa/global-type"); | ||
async function keystroke(command) { | ||
return await (0, run_1.run)((name, { characters, modifiers = [] }) => Application(name).keystroke(characters, { using: modifiers }), Applications_1.Applications.SYSTEM_EVENTS, command); | ||
async function keystroke({ characters, modifiers = [], }) { | ||
const script = `tell application "${Applications_1.Applications.SYSTEM_EVENTS}"\nkeystroke "${characters}"${modifiers.length ? ` using {${modifiers.join(", ")}}` : ""}\nend tell`; | ||
return await (0, runAppleScript_1.runAppleScript)(script); | ||
} | ||
exports.keystroke = keystroke; |
@@ -1,2 +0,1 @@ | ||
import "@jxa/global-type"; | ||
export declare function copyLastSpokenPhrase(): Promise<void>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.copyLastSpokenPhrase = void 0; | ||
const run_1 = require("@jxa/run"); | ||
const runAppleScript_1 = require("../runAppleScript"); | ||
const Applications_1 = require("../Applications"); | ||
const retry_1 = require("../../retry"); | ||
const errors_1 = require("../errors"); | ||
require("@jxa/global-type"); | ||
async function copyLastSpokenPhrase() { | ||
const script = `tell application "${Applications_1.Applications.VOICE_OVER}"\ntell last phrase to copy to pasteboard\nend tell`; | ||
try { | ||
return await (0, retry_1.retry)(() => (0, run_1.run)((name) => { | ||
const app = Application(name); | ||
const lastPhrase = app.lastPhrase; | ||
return app.copyToPasteboard(lastPhrase); | ||
}, Applications_1.Applications.VOICE_OVER)); | ||
return await (0, retry_1.retry)(() => (0, runAppleScript_1.runAppleScript)(script)); | ||
} | ||
@@ -17,0 +13,0 @@ catch (e) { |
@@ -1,2 +0,1 @@ | ||
import "@jxa/global-type"; | ||
export declare function getItemText(): Promise<string>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getItemText = void 0; | ||
const run_1 = require("@jxa/run"); | ||
const runAppleScript_1 = require("../runAppleScript"); | ||
const Applications_1 = require("../Applications"); | ||
const retry_1 = require("../../retry"); | ||
const errors_1 = require("../errors"); | ||
require("@jxa/global-type"); | ||
async function getItemText() { | ||
const script = `tell application "${Applications_1.Applications.VOICE_OVER}"\nreturn text under cursor of vo cursor\nend tell`; | ||
try { | ||
return await (0, retry_1.retry)(() => (0, run_1.run)((name) => { | ||
const app = Application(name); | ||
const voCursor = app.voCursor; | ||
return voCursor.textUnderCursor(); | ||
}, Applications_1.Applications.VOICE_OVER)); | ||
return await (0, retry_1.retry)(() => (0, runAppleScript_1.runAppleScript)(script)); | ||
} | ||
@@ -17,0 +13,0 @@ catch (e) { |
@@ -1,2 +0,1 @@ | ||
import "@jxa/global-type"; | ||
export declare function getLastSpokenPhrase(): Promise<string>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getLastSpokenPhrase = void 0; | ||
const run_1 = require("@jxa/run"); | ||
const runAppleScript_1 = require("../runAppleScript"); | ||
const Applications_1 = require("../Applications"); | ||
const retry_1 = require("../../retry"); | ||
const errors_1 = require("../errors"); | ||
require("@jxa/global-type"); | ||
async function getLastSpokenPhrase() { | ||
const script = `tell application "${Applications_1.Applications.VOICE_OVER}"\nreturn content of last phrase\nend tell`; | ||
try { | ||
return await (0, retry_1.retry)(() => (0, run_1.run)((name) => { | ||
const app = Application(name); | ||
const lastPhrase = app.lastPhrase; | ||
return lastPhrase.content(); | ||
}, Applications_1.Applications.VOICE_OVER)); | ||
return await (0, retry_1.retry)(() => (0, runAppleScript_1.runAppleScript)(script)); | ||
} | ||
@@ -17,0 +13,0 @@ catch (e) { |
@@ -1,2 +0,1 @@ | ||
import "@jxa/global-type"; | ||
export declare function isRunning(): Promise<boolean>; |
@@ -5,6 +5,5 @@ "use strict"; | ||
const child_process_1 = require("child_process"); | ||
const run_1 = require("@jxa/run"); | ||
const Applications_1 = require("../Applications"); | ||
const activate_1 = require("../activate"); | ||
require("@jxa/global-type"); | ||
const runAppleScript_1 = require("../runAppleScript"); | ||
async function isRunning() { | ||
@@ -24,4 +23,4 @@ const processRunning = await new Promise((resolve, reject) => { | ||
} | ||
const appleScriptRunning = await (0, run_1.run)((name) => Application(name).running(), Applications_1.Applications.VOICE_OVER); | ||
if (!appleScriptRunning) { | ||
const appleScriptRunning = await (0, runAppleScript_1.runAppleScript)(`tell application "${Applications_1.Applications.VOICE_OVER}"\nreturn running\nend tell`); | ||
if (appleScriptRunning === "false") { | ||
return false; | ||
@@ -28,0 +27,0 @@ } |
@@ -1,2 +0,1 @@ | ||
import "@jxa/global-type"; | ||
export declare function saveLastSpokenPhrase(): Promise<void>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.saveLastSpokenPhrase = void 0; | ||
const run_1 = require("@jxa/run"); | ||
const runAppleScript_1 = require("../runAppleScript"); | ||
const Applications_1 = require("../Applications"); | ||
@@ -9,10 +9,6 @@ const waitForSaved_1 = require("./waitForSaved"); | ||
const errors_1 = require("../errors"); | ||
require("@jxa/global-type"); | ||
async function saveLastSpokenPhrase() { | ||
const script = `tell application "${Applications_1.Applications.VOICE_OVER}"\ntell last phrase to save\nend tell`; | ||
try { | ||
await (0, retry_1.retry)(() => (0, run_1.run)((name) => { | ||
const app = Application(name); | ||
const lastPhrase = app.lastPhrase; | ||
app.save(lastPhrase); | ||
}, Applications_1.Applications.VOICE_OVER)); | ||
return await (0, retry_1.retry)(() => (0, runAppleScript_1.runAppleScript)(script)); | ||
} | ||
@@ -19,0 +15,0 @@ catch (e) { |
@@ -1,2 +0,1 @@ | ||
import "@jxa/global-type"; | ||
export declare function takeScreenshot(): Promise<string>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.takeScreenshot = void 0; | ||
const run_1 = require("@jxa/run"); | ||
const runAppleScript_1 = require("../runAppleScript"); | ||
const Applications_1 = require("../Applications"); | ||
const retry_1 = require("../../retry"); | ||
const errors_1 = require("../errors"); | ||
require("@jxa/global-type"); | ||
async function takeScreenshot() { | ||
const script = `tell application "${Applications_1.Applications.VOICE_OVER}"\ntell vo cursor to grab screenshot\nend tell`; | ||
try { | ||
return await (0, retry_1.retry)(() => (0, run_1.run)((name) => { | ||
const app = Application(name); | ||
const voCursor = app.voCursor; | ||
return voCursor.grabScreenshot(); | ||
}, Applications_1.Applications.VOICE_OVER)); | ||
return await (0, retry_1.retry)(() => (0, runAppleScript_1.runAppleScript)(script)); | ||
} | ||
@@ -17,0 +13,0 @@ catch (e) { |
{ | ||
"name": "@guidepup/guidepup", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "screen-reader driver for automation testing", | ||
@@ -35,8 +35,3 @@ "main": "lib/index.js", | ||
}, | ||
"dependencies": { | ||
"@jxa/global-type": "^1.3.4", | ||
"@jxa/run": "^1.3.4" | ||
}, | ||
"devDependencies": { | ||
"@jxa/types": "^1.3.4", | ||
"@types/node": "^16.11.11", | ||
@@ -43,0 +38,0 @@ "@typescript-eslint/eslint-plugin": "^5.5.0", |
Sorry, the diff of this file is not supported yet
0
9
370588
10541
9
- Removed@jxa/global-type@^1.3.4
- Removed@jxa/run@^1.3.4
- Removed@jxa/global-type@1.3.6(transitive)
- Removed@jxa/run@1.3.6(transitive)
- Removed@jxa/types@1.3.6(transitive)
- Removedmacos-version@5.2.1(transitive)
- Removedsemver@5.7.2(transitive)