GithubHelp home page GithubHelp logo

tatsh / jxa-lib Goto Github PK

View Code? Open in Web Editor NEW
32.0 4.0 3.0 558 KB

Library to simplify use of JXA with ES6 and TypeScript.

Home Page: https://tatsh.github.io/jxa-lib/

TypeScript 96.19% JavaScript 3.81%
jxa applescript typescript es6 javascript

jxa-lib's Issues

Support CLI args?

Does your webpack configuration for jxa-lib allow keeping the run function global for passing in CLI arguments?

This library for example has a webpack config file + custom webpack plugin that allows for this: https://github.com/pahund/patricks-little-jxa-helpers

The entire module gets set to main and then the global run function gets defined as such: function run(args) { this.main(args); }.

nitpicks (or "draft types that i don't have time to check")

  • whose
  • ObjC C typing
  • Byte type guard

whose filter on Array

Apple has a whose filter for arrays. It is basically filter with an object predicate.

// documentation only gives string and num; we are guessing here
type JXAPrimitive = string | number | boolean | void
interface JXAWhosePredicateExpression {
  // equals, beginsWith...
}
type JXALogical= '_and' | '_or' | '_not'
interface JXAWhosePredicate {
  [logi: JXALogical]: JXAWhosePredicate[],
  [key: string]?: string | number | boolean | JXAWhosePredicateExpression
}
interface JXAArray<T> extends Array<T>, JXAReadonlyArray<T> {}
interface JXAReadonlyArray<T> extends ReadonlyArray<T> {
    /**
     * Returns the elements of an array that meet the condition specified in a filter predicate.
     */
  whose(predicate: JXAWhosePredicate, thisArg?: any): JXAArray<T>;
}

It is possible that they went forward and changed the entire Array.prototype. In that case just remove the extends BS.

ObjC FFI types

Currently bindFunction and registerSubclass do not have type signatures. Judging from the doc it should resemble:

type ObjCType = string | RefType
type ObjCSignature = [ObjCType, ObjCType []]
interface ObjCClass {
  name: string
  properties: {
    [key: string]: string
  }
  methods: (...x?: any[]) => any | {
    type: ObjCSignature
    implementation: (...x?: any[]) => any
  }
}
namespace ObjC {
  export function bindFunction(name: string, args: ObjCSignature);
  export function registerSubclass(class: ObjCClass);
}

Byte concept

Since Ref operates on bytes (uint8_t), it might be a good idea to define a concept of bytes somewhere so it becomes more clear. We will also need utility functions for reading/writing longer integer types and even floats.

Unfortunately the typing part is not something we can do perfectly right now; see microsoft/TypeScript#15480.

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.