Giter Site home page Giter Site logo

jxa's People

Contributors

arinono avatar azu avatar bialikover avatar dependabot[bot] avatar dnicolson avatar havardh avatar jeanbarriere avatar lala7573 avatar peeja avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jxa's Issues

Application() breaks if `esModuleInterop` is `true`

TypeScript will refuse to allow Application to be called when esModuleInterop is true:

A namespace-style import cannot be called or constructed, and will cause a failure at runtime.

I don't have my head around it enough to understand if that means that the library should or can be adjusted to make it work, or if it means that it inherently can't build sensible code when esModuleInterop is true. In my case, my project was fine turning it off, but it would be useful to have a note in the Readme, since the problem was hard to track down.

Need Instructions for Installing in Visual Studio Code

Hi, your system looks great, but I can't get it work in Visual Studio Code.

I did the following:

  1. npm install @jxa/global-type -- successful
  2. Open VSC, and enter your sample code:
import "@jxa/global-type";

// your JXA application
var userName = Application("System Events").currentUser().name();

But as I type "App" I do not see the autocomplete as shown in your GIF, nor do I see it when I type "Application("Sys"

Can you please help me get your system running in VSC?

Thanks.

tsc v3.3.33 errors on dts @jxa/global-type

Hi there!

This might be a dumb question but when importing @jxa/global-type on my .ts file and then compiling I get this error:

node_modules/@jxa/global-type/src/index.d.ts:8:11 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'Application' must be of type 'typeof Application', but here has type 'typeof Application & object'.

8     const Application: typeof Application_ & object;
            ~~~~~~~~~~~
Found 1 error.

seems like its causing conflict with this two definition type..

const Application: typeof Application_ & object;

Is it necessary to check that Application is also an object?

Support for non-core applications

Hi. Great work ๐Ÿ‘

This issue might be more of a how do you do this in TypeScript, but here it goes. I think that the my use case would be interesting to others, so at least we could end up with some documentation.

I would like to add type declarations for 'non-core' types. Core as I understand it being the applications bundled with osx and defined in types/src/core . And they are manually added as return types for the Application function, right?

As an example I would like to add declarations for Emacs. I'm able to generate the .d.ts files from the .sdef file. But I'm not sure how include this file to work well with the rest of the jxa types.

Is there a way to "inject" this into the current setup or would it require changes?

Furthermore do you see a way of automating this. E.g. automatically discovering .sdef's in the Application folder and generating .d.ts files on the fly? Or would it be better to include these types in a package under the @jxa org?

Example passing args to run()

Can you provide an example of how to pass arguments to a run function?

We tried this and a few other things:

    const g = 'hello ';
    // This function is JXA
    return run((g) => {
        const sys = Application("System Events");
        return g + sys.currentUser().name();
    });

The argument just comes in as 'undefined'.

In a related question, how can we call another defined function from within the run function?

Great library by the way, very helpful.

Array.includes doesn't work anymore

Hello, I just upgrade from 1.3.4 to 1.3.6 and find out that everything crashed because JXA is not able to read [].includes.

I couldn't find any mention in the changelogs.

Do I miss something?

I got the error

"Can't find variable: _babel_runtime_corejs3_core_js_stable_instance_includes__WEBPACK_IMPORTED_MODULE_9___default"

sdef-to-dts is missing children elements

I'm not an expert in sdef or the underlying APIs here, but children elements of classes are a pretty big gap in the generated type definitions.

For example, the System Events application (Application('System Events')) has at least 4 defined child elements:

screen shot 2019-01-06 at 13 04 52

In most (all?) cases, these are accessible in at least 3 ways:

Application('System Events').processes(); // returns array
Application('System Events').processes['TextEdit']; // alias for processes.byName('TextEdit')
Application('System Events').processes[0]; // alias for processes.at(0)

If the generated types just included these methods for accessing children, it would make this 1000% more useful for UI automation. System Events relies heavily on child elements.

Thanks!

Automator integration

Thanks, I had some good time today trying this library.

I'd like to better understand something.
Once I create my useful script, I'd like to execute it with a keyboard shortcut, something that is achievable in other ways with by using Services of the Automator app and associating the keyboard shortcut.
How do I do that after I have my script working in node?

$.NSWorkspace.sharedWorkspace.iconForFile() not work

    var appIcon = $.NSWorkspace.sharedWorkspace.iconForFile('/System/Applications/TextEdit.app');
    $.CFShow(appIcon);
    // OUTPUT:
    // <NSImage 0x7fdfea675180 Size={32, 32}
    // RepProvider=<NSImageISIconRepProvider:0x7fdfe66046a0
    //     icon:<ISBundleIcon: 0x7fdfea673bc0>
    //     Bundle URL: file:///System/Applications/TextEdit.app/
    //     type: (null)
    //     tag: (null)
    //     tag class: (null)
    //     reps:(faulting)>
    //>

Can't get the correct icon.

Typings for read-write variables

Please forgive me if some of my terminology is incorrect, I'm fairly new to JXA and I haven't been able to find much documentation on it.

I'm using this project in a TypeScript application and it's working great - thank you for such a cool idea and execution.

I've run into an issue with setting read-write variables. The current typings are fine for retrieving an attribute such as .index()

const windowIndex = safariWindow.index()

But there doesn't seem like there is a way to set the attribute without TS complaining. The two ways of setting that I am aware of are

safariWindow.index = 0
safariWindow.index.set(0)

I have had a think and I don't believe we can make a TS type to satisfy both the function call getter and the direct assignment setter, so I propose new interfaces that can be added to the .d.ts files for ReadOnly and ReadWrite attributes.

e.g.

  export interface ReadWrite<T> {
    (): T;
    set: (value: T) => void;
  }

...

    index: ReadWrite<number>;

If this would be a useful and acceptable change for you, I'd be happy to do the work and make a PR.

Need Install Instructions for Visual Studio Code (VSC)

First, thanks for building and sharing a terrific tool! ๐Ÿ‘
I can't wait to start using it.

However, I need help. Can you please provide detailed, step-by-step, instructions on how to install your JXA autocomplete into Visual Studio Code?

Thanks.

Questions about @jxa/sdef-to-dts

First, let me give you many, many thanks for providing this tool.
I hope to use it to provide autocomplete in Visual Studio Code (VSC) for many of the third party apps (like Microsoft Outlook, Evernote, and Keyboard Maestro, and more) and many of the AppleScript Scripting Libraries (like Shane Stanley's "Myriad Tables Lib").

I have several questions:

Installation

My first question is about installation, using this command you provided:
npm install @jxa/sdef-to-dts

Where do I install this? What folder do I need to be in so that it is available to all folders and workspaces of VSC?

Using @jxa/sdef-to-dts

You provide this command to convert .sdef and .app files
$ npx @jxa/sdef-to-dts /Applications/Safari.app --output ./safari.d.ts

Two Questions:

  1. Where do I run this command so that the resulting dts files are fully integrated with other dts files, and so that all of these are available to all folders and workspaces of VSC?
  2. Does the name of the output dts file need to exactly match the input name?
    • For example, if the input file is "Microsoft Outlook.app", does the output file need to be "Microsoft Outlook.d.ts"?

Many 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.