Giter Club home page Giter Club logo

node-jxa's Issues

The 2.1.2 release on NPM includes a reference to a developer-local directory (and doesn't correspond to the Github tag)

Hi. If you install the current (2.1.2) release from NPM, you'll get an error when Node-jxa runs osacompile:

osacompile: couldn't write to file /Users/john/code/node-jxa/deleteme.scpt: No such file or directory

The vars at the top of node-jxa.js look like this in that release:

const HEAD = 'window = this;\nObjC.import("stdlib");\ntry {\n ';
const TAIL = ';\n} catch (e) {\n console.log( e.message );\n $.exit(1); \n}\n$.exit(0);';
const OSA_JXA_CMD = 'osacompile';
const OSA_JXA_CMD_ARGS = ['-l', 'JavaScript', '-o', '/Users/john/code/node-jxa/deleteme.scpt' ];

You can check code in NPM's module package by getting the archive address with npm view node-jxa dist.tarball and downloading the archive.

My guess is you might want to republish the release if NPM allows that, because code for the release seems to be different here on Github.

fix typos in README

.. ES6 module isn't supported, not aren't.

Should introduce node-debug-jxa along with the node-jxa command.

Issue with the JXA Application.currentApplication() Object

I get an error in VSC using Code Runner with this script:

#!/usr/bin/env osascript -l JavaScript

var app = Application.currentApplication();
app.includeStandardAdditions = true;

console.log("Test Get app name");
var appProp = app.properties();  // <== fails on this line
appProp.name;

/*
ERROR MSG:
117:148: execution error: Error on line 6: Error: Message not understood. (-1708)

NOTE:  Even though it says "line 6", the actual line is 7, as line 6 outputs correctly.
For completeness here's the entire Code Runner output:

[Running] /usr/bin/env osascript -l JavaScript "/Users/Shared/Dropbox/SW/DEV/JXA/VSC/Test Using CodeRunner Ext.js"
Test Get app name
/Users/Shared/Dropbox/SW/DEV/JXA/VSC/Test Using CodeRunner Ext.js:117:148: execution error: Error on line 6: Error: Message not understood. (-1708)

[Done] exited with code=1 in 0.11 seconds

*/

This same script, without the shebang, runs fine in Script Editor.

image

What am I doing wrong in VSC?

stderr output is too verbose

.. includes a dump of the stream meta:

{ Error: Cannot find module '/Users/jelm1/code/node-jxa/blah' from '/Users/jelm1/code/node-jxa'
    at /Users/jelm1/.config/yarn/global/node_modules/browser-resolve/node_modules/resolve/lib/async.js:55:21
    at load (/Users/jelm1/.config/yarn/global/node_modules/browser-resolve/node_modules/resolve/lib/async.js:69:43)
    at onex (/Users/jelm1/.config/yarn/global/node_modules/browser-resolve/node_modules/resolve/lib/async.js:92:31)
    at /Users/jelm1/.config/yarn/global/node_modules/browser-resolve/node_modules/resolve/lib/async.js:22:47
    at FSReqWrap.oncomplete (fs.js:152:21)
  stream:
   Labeled {
     _readableState:
      ReadableState {
        objectMode: true,
        highWaterMark: 16,
        buffer: BufferList { length: 0 },
        length: 0,
        pipes: [Object],
        pipesCount: 1,
        flowing: true,
        ended: false,
        endEmitted: false,
        reading: true,
        sync: false,
        needReadable: true,
        emittedReadable: false,
        readableListening: false,
        resumeScheduled: false,
        destroyed: false,
        defaultEncoding: 'utf8',
        awaitDrain: 0,
        readingMore: false,
        decoder: null,
        encoding: null },
     readable: true,
     domain: null,
     _events:
      { end: [Array],
        error: [Function],
        data: [Function: ondata],
        _mutate: [Object] },
     _eventsCount: 4,
     _maxListeners: undefined,
     _writableState:
      WritableState {
        objectMode: true,
        highWaterMark: 16,
        finalCalled: false,
        needDrain: false,
        ending: true,
        ended: true,
        finished: true,
        destroyed: false,
        decodeStrings: true,
        defaultEncoding: 'utf8',
        length: 0,
        writing: false,
        corked: 0,
        sync: false,
        bufferProcessing: false,
        onwrite: [Function],
        writecb: null,
        writelen: 0,
        bufferedRequest: null,
        lastBufferedRequest: null,
        pendingcb: 0,
        prefinished: true,
        errorEmitted: false,
        bufferedRequestCount: 0,
        corkedRequestsFree: [Object] },
     writable: false,
     allowHalfOpen: true,
     _options: { objectMode: true },
     _wrapOptions: { objectMode: true },
     _streams: [ [Object] ],
     length: 1,
     label: 'deps' } }

Add a headsup to README about filesystem limitations

  • can't access the file system, and modules that depend on fs access may have issues
  • browserify won't automatically include modules whose requireing is derived at runtime

why:

  • browserify built for browser, which has obvious security constraints
  • OSA has its own sandboxing constraints
    • (need to check on accessing filesystem outside sandbox folder using ObjC)

dependency graph error

I am building an electron app and I am getting the following error in my console when I call var nodejxa = require('node-jxa') from my JavaScript:

/Users/Me/Documents/git/electronHelloWorld/node_modules/node-jxa/node-jxa.js:15 Error: Can't walk dependency graph: Cannot find module '/Users/Me/Documents/git/electronHelloWorld/--field-trial-handle=1718379636,12704840948703548028,9979737565501458108,131072' from '/Users/Me/Documents/git/electronHelloWorld/_fake.js'
    required by /Users/Me/Documents/git/electronHelloWorld/_fake.js
    at /Users/Me/Documents/git/electronHelloWorld/node_modules/resolve/lib/async.js:137
    at load (/Users/Me/Documents/git/electronHelloWorld/node_modules/resolve/lib/async.js:156)
    at onex (/Users/Me/Documents/git/electronHelloWorld/node_modules/resolve/lib/async.js:181)
    at /Users/Me/Documents/git/electronHelloWorld/node_modules/resolve/lib/async.js:15
    at FSReqCallback.oncomplete (fs.js:172)

Feature Request - Add commandline option to generate compiled .scpt file from source

Hi John,

It seems that node-jxa uses browserify to generate a single script file each time it is invoked. For scripts that are called often, or that are substantial in size, this is quite a bit of overhead.

So I was wondering whether the node-jxa command could accept an option that changes its behaviour to instead generate a .scpt file using osacompile command. This .scpt file can then be used and shared as like any other applescript, but also isn't regenerated on each invocation.

Perhaps a -c option which takes a file path for the resulting compiled .scpt file.

I hope this makes sense?

Is this something you would consider adding to this great tool?

Many thanks.

Damo.

How Do I use Visual Studio Code (VSC) with JXA and Retain JavaScript Code Completion?

First, let me express my tremendous gratitude to John for providing this excellent library/resource.
I look forward to using it.

Now to my question:

How Do I use Visual Studio Code (VSC) with JXA and Retain JavaScript Code Completion?

It is great that this extension provides us with the ability to code, compile, and run JXA files:

AppleScript & JXA for Visual Studio Code

Unfortunately, JavaScript code completion is not active for a JXA file, even though JXA uses core JavaScript. Is there some way to enable it for JXA?

I am brand new to VSC, so if you can, please provide detailed instructions.

I realize this is NOT directly related to this repository, but I'm hoping the expertise is here that can answer this question. I've asked elsewhere without finding a solution.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.