The main reason is to use the Safari Debugger.
This is the ONLY debugger I know of for JXA.
Also, the SE log pane (at the bottom) provides more output than simply console.log(). If there is a better way, with better output solely using VSC I am open to that.
DanThomas:
No Intellisense for any other applications, like "Keyboard Maestro", etc. However, if you delve into the source files, I can't believe he typed them all by hand, so I'm guessing there's a way to import a Dictionary entry to create these files.
Bingoβ Found a converter:
I am such a novice at Terminal and VSC that I don't understand how to use this tool. It looks like it offers a script that can be run from VSC, but I don't understand how. Maybe one of you VSC gurus can figure this out:
From the GitHub
Install with npm :
npm install @jxa/sdef-to-dts
Usage as library
Convert ./input/*.sdef file and output it as d.ts to ./output directory.
const fs = require("fs");
const path = require("path");
const { transform } = require("@jxa/sdef-to-dts");
const sdefDir = path.join(__dirname, "./input");
const outputDir = path.join(__dirname, "./output");
const promises = fs.readdirSync(sdefDir).map(async caseName => {
const fileName = path.basename(caseName, ".sdef");
const normalizedTestName = fileName.replace(/\s/g, "");
const actualContent = fs.readFileSync(path.join(fixturesDir, caseName), "utf-8");
console.log("transform " + normalizedTestName);
const actual = await transform(normalizedTestName, actualContent);
fs.writeFileSync(path.join(outputDir, normalizedTestName) + ".d.ts", actual, "utf-8");
});
Promise.all(promises).then(() => {
console.log("All write");
});
How do we use as "library" to convert .sdef
files (actually the .app
file)???
sims
June 4, 2021, 2:05am
43
Oh. I did not realize that Safari Debugger cannot be invoked from JXA using Code Runner. In that case, it makes most sense to try and use the .scpt route that you found and marry VS Code, SE and KBM. Very creative solution. Will work on adopting it.
@DanThomas @sims , @ccstone , @ComplexPoint et al:
I have just posted a macro and video:
My sincere thanks to everyone who has helped us all understand how to use VSC to develop JXA.
1 Like
JMichaelTX
Split this topic
July 2, 2021, 4:44pm
45
3 posts were split to a new topic: Problems with KMFAM Macro System
I am wondering if Keyboard Maestro can plug into the text cursor position within VSCode.
I think you would probably need to explore the VSC extension API:
Your First Extension | Visual Studio Code Extension API
1 Like
ccstone
August 29, 2021, 10:55pm
48
In a word β nyet .
@ComplexPoint 's idea is intriguing, athough I don't know of any way to run external code in VSC and return a result.
Worth a peek:
visual studio code - vscode API: get Position of last character of line - Stack Overflow
-Chris
I think that's right β the obvious route would be to do the whole thing from inside the VSC extension.