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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@devscholar/node-with-jxa

v0.0.3

Published

Node.js IPC Bridge for JXA (JavaScript for Automation, macOS)

Readme

@devscholar/node-with-jxa

⚠️ Alpha — expect breaking changes.

Node.js IPC bridge for JXA (JavaScript for Automation) on macOS. Drive Cocoa / AppKit / Foundation from a regular Node.js process by spawning osascript -l JavaScript in the background and proxying every property read, property write, and method call across a pair of Unix FIFOs.

Status: experimental (0.0.x). Modeled directly on @devscholar/node-with-gjs — same architecture, different ObjC-flavoured runtime on the other side.

Requirements

  • macOS 10.10 or later (osascript -l JavaScript is built in).
  • Node.js 18+.

Quick start

import { $, ObjC } from '@devscholar/node-with-jxa';

ObjC.import('AppKit');

const app = $.NSApplication.sharedApplication;
app.setActivationPolicy($.NSApplicationActivationPolicyRegular);

const alert = $.NSAlert.alloc.init;
alert.setMessageText('Hello from Node.js');
alert.runModal;

Public API

| Export | Purpose | | --- | --- | | $ | Root proxy. $.NSWindow, $.NSString, … resolve to ObjC class refs. | | ObjC.import(name) | Load an Objective-C framework. | | ObjC.unwrap(ref) | NSString/NSNumber → JS value (single-level). | | ObjC.deepUnwrap(ref) | NSArray/NSDictionary → JS value, recursively. | | ObjC.registerSubclass(spec) | Define a new ObjC class whose methods are JS functions. | | Application(name) | JXA scripting bridge to a macOS app (Finder, Safari, …). | | Path(posix) | JXA file-path literal for scripting methods. | | delay(seconds) | Sleep on the JXA host thread (JXA's built-in delay). | | Ref() | Allocate a JXA out-parameter holder. | | releaseObject(ref) | Drop a ref proactively (otherwise V8 GC handles it). | | init() | Force-spawn the host (rarely needed; called lazily on first $ access). |

$, ObjC, Application, Path, delay, and Ref match standard JXA 1:1 — code that works in a standalone osascript -l JavaScript script reads the same under node-with-jxa. Everything else (releaseObject, init) is node-with-jxa-specific plumbing.

Calling-convention notes

Standard JXA lets you write a zero-arg ObjC method either as bare property access (arr.count, $.NSAlert.alloc.init) or with parens (arr.count(), $.NSAlert.alloc().init()). Both forms are supported here.

One divergence: property reads that return a primitive (number/string/boolean) come back as a callable wrapper so arr.count() works too — arithmetic, string concat, template interpolation, JSON.stringify, and console.log all still show the underlying value (via Symbol.toPrimitive / valueOf / toJSON / custom inspect), but typeof arr.count === 'function', not 'number'. If you need the primitive kind, use Number(x) / String(x) / Boolean(x) or call it (x()).

Architecture

 Node.js main thread          IPC worker thread        osascript (JXA) main thread
 ─────────────────────        ────────────────         ──────────────────────────
   $ proxy            ──────► fdWrite (FIFO)  ──────► fd 3  →  NSFileHandle
                                                                  │
                                                                  ▼
                                                             readInBackgroundAndNotify
                                                              → executeCommand →
                                                                 Get / Set / Invoke /
                                                                 LoadFramework / Eval / …
                                                                  │
   waitResponse() ◄────────── fdRead  (FIFO) ◄────────── fd 4  ◄  writeData
  • Sync nested commands (Cocoa → JS callback → more IPC) work the same way they do in node-with-gjs: the JXA host pumps its main run loop until a {type: 'reply'} arrives, and inNestedRead makes the notification observer back off so the nested loop owns the buffer.
  • Async callbacks bypass the round-trip: the host writes an async_event straight to fd 4, and Node's IPC worker thread forwards it to the main thread via MessagePort.

Build

npm install
npm run build      # tsc → dist/ + types/

Examples

See node-with-jxa-examples:

  • src/finder-open-home.ts — pure JXA style: Application('Finder') opens your home folder.
  • src/foundation-hello.ts — pure Foundation, no GUI.
  • src/alert.ts — modal NSAlert.
  • src/window.tsNSWindow + NSApplication.run().
cd node-with-jxa-examples
node start.js src/window.ts

License

MIT