Skip to content
/ jxa Public

JavaScript for Automation (JXA) scripting for Deno

License

Notifications You must be signed in to change notification settings

pnlng/jxa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JXA

Deno modules for running JavaScript for Automation (JXA), mostly ported from Node packages by JXA-userland/JXA.

Run JXA in Deno

// script.js
import { run } from "https://deno.land/x/jxa_run/mod.ts"

const result = await run((name, emoji) =>
  `Hello ${name} ${emoji}!`, "Deno", "🦕");
console.log(result)
$ deno run --allow-run script.js
Hello Deno 🦕!

See run/ for detailed documentation.

TypeScript Support

// script.ts
import { run } from "https://deno.land/x/jxa_run/mod.ts";
import type {} from "https://deno.land/x/jxa_run/global.d.ts";
// Generated with @jxa/sdef-to-dts
import type { GoogleChrome } from "https://raw.githubusercontent.com/JXA-userland/JXA/master/packages/%40jxa/types/test/fixtures/GoogleChrome.d.ts";

const result = await run(
  () => {
    const chrome = Application<GoogleChrome>("Google Chrome");
    const windows: GoogleChrome.Window[] = chrome.windows();
    const activeTab: GoogleChrome.Tab = windows[0].activeTab();
    return activeTab.title();
  },
);
console.log(result);

deno run --allow-run script.ts will output the title of your active tab in Chrome.

See run/types/ for more information about TypeScript support.