{"id":13588836,"url":"https://github.com/Tatsh/jxa-lib","last_synced_at":"2025-04-08T06:32:52.610Z","repository":{"id":42490818,"uuid":"144194741","full_name":"Tatsh/jxa-lib","owner":"Tatsh","description":"Library to simplify use of JXA with ES6 and TypeScript.","archived":false,"fork":false,"pushed_at":"2024-09-02T13:51:19.000Z","size":584,"stargazers_count":34,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-06T03:59:50.459Z","etag":null,"topics":["applescript","es6","javascript","jxa","typescript"],"latest_commit_sha":null,"homepage":"https://tatsh.github.io/jxa-lib/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tatsh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-09T19:25:35.000Z","updated_at":"2025-02-22T16:32:58.000Z","dependencies_parsed_at":"2024-11-06T08:34:10.994Z","dependency_job_id":"907c44f2-7824-4e0f-9533-a5ead0c097df","html_url":"https://github.com/Tatsh/jxa-lib","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tatsh%2Fjxa-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tatsh%2Fjxa-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tatsh%2Fjxa-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tatsh%2Fjxa-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tatsh","download_url":"https://codeload.github.com/Tatsh/jxa-lib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247792204,"owners_count":20996879,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["applescript","es6","javascript","jxa","typescript"],"created_at":"2024-08-01T15:06:58.195Z","updated_at":"2025-04-08T06:32:47.600Z","avatar_url":"https://github.com/Tatsh.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Typings for JXA\n\nThis is a set of typings for AppleScript in JavaScript that works on macOS 10.10 and above.\n\nThis is a work in progress and is not yet stable.\n\n## Build\n\nTo run the examples, run `webpack` in the root of the project. Then Execute `dist/main.js` like so:\n\n```sh\nosascript -l JavaScript dist/examples/index.js\n```\n\nA prompt window will appear for the Finder application.\n\n## Library\n\nIn the `lib` directory, a helper library is available to make this easier to use in TypeScript (or ES6). It removes prefixes where possible to be more like Swift and removes long method names. Example:\n\n```typescript\nimport { FileManager } from \"jxa-lib\";\n\nconst fm = new FileManager();\nlet attr;\ntry {\n  attr = fm.attributesOfItem(\"/some-file\");\n} catch (e) {\n  // Instead of having to pass \u0026error (Ref object) like in Objective-C,\n  // an exception is thrown\n  console.log(\"Maybe /some-file does not exist?\");\n}\n\n// attr type is FileAttributes or undefined, which does not have prefixes removed\nif (attr) {\n  console.log(attr.NSFileGroupOwnerAccountID); // string\n  console.log(attr.NSFileModificationDate); // Date object\n}\n```\n\n### Examples\n\nSee the [examples](examples) directory.\n\n### Example with C functions\n\nYou do not have to use `ObjC.import()` because all modules will do this on their own.\n\n```typescript\nimport { exit, free, malloc } from \"jxa-lib/stdlib\";\nimport { memchr, memset } from \"jxa-lib/string\";\n\nconst size = 32;\nconst buf = malloc(size); // returns Ref\u003cnumber\u003e\nmemset(buf, 0, size);\nfor (let i = 0, c = \"a\".charCodeAt(0); i \u003c size; i++, c++) {\n  buf[i] = c;\n}\n\nconst asciiC = \"c\".charCodeAt(0);\nconst asciiD = \"d\".charCodeAt(0);\n\n// memchr() returns Ref\u003cnumber\u003e or Ref to NULL\nconst result = memchr(buf, asciiC, size);\nif (result[0]) {\n  // this will be asciiC or null/undefined\n  console.log(result[0] === asciiC); // true\n  console.log(result[1] === asciiD); // true\n\n  // Getting result[30] or above is not defined behaviour\n}\n\nfree(result);\n\n// Do not print the result of the last expression\nexit(0);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTatsh%2Fjxa-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTatsh%2Fjxa-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTatsh%2Fjxa-lib/lists"}