Maddog Posted September 26, 2015 Share Posted September 26, 2015 (edited) Just got the Alfred 2.8 update. I see javascript as an option for scripting, but when I try to debug a simple script, this is what I get in the debug: [alfred.workflow.action.script] osascript: no such component "JavaScript". Also, searching for "javascript" doesn't work in the forums, it gets filtered out, probably due to XSS concerns. Thanks for any guidance. My OSX version is 10.9.5. EDIT: oops, missed the fact that it's for 10.10+ How do I delete this thread? Edited September 26, 2015 by Maddog Link to comment
rice.shawn Posted September 27, 2015 Share Posted September 27, 2015 Javascript is somewhat built into 10.10's and 10.11's AppleScript, which is why Alfred can support Javascript only for those versions. Link to comment
AndreasB Posted September 28, 2015 Share Posted September 28, 2015 Javascript is somewhat built into 10.10's and 10.11's AppleScript, which is why Alfred can support Javascript only for those versions. Do you know if there'll be support for AJAX (XHR) requests at some point? Link to comment
rice.shawn Posted September 28, 2015 Share Posted September 28, 2015 Do you know if there'll be support for AJAX (XHR) requests at some point? I'd say that it never will. Andrew tries to keep the size of Alfred small so that it keeps performing quickly. In order to do something like AJAX, he'd have to compile in all or part of a JS rendering engine (95% of which wouldn't apply to Alfred). What would you use the Ajax for with Alfred, anyway? Updating script filter results? Link to comment
AndreasB Posted September 28, 2015 Share Posted September 28, 2015 I'd say that it never will. Andrew tries to keep the size of Alfred small so that it keeps performing quickly. In order to do something like AJAX, he'd have to compile in all or part of a JS rendering engine (95% of which wouldn't apply to Alfred). What would you use the Ajax for with Alfred, anyway? Updating script filter results? Yeah. I'd simply like to call an API, get the data, and show them in the results. I used the Node.js workflow template previously, but I was stoked to see JS support in Alfred – but not very useful for me without the ability to call APIs. Link to comment
rice.shawn Posted September 28, 2015 Share Posted September 28, 2015 Yeah. I'd simply like to call an API, get the data, and show them in the results. I used the Node.js workflow template previously, but I was stoked to see JS support in Alfred – but not very useful for me without the ability to call APIs. You can still call APIs and get the data and all that jazz, but you just have to do it synchronously rather than asynchronously. So, make sure that you get the data before you render any XML for a script filter. Link to comment
deanishe Posted September 28, 2015 Share Posted September 28, 2015 You want to look into the Apple JavaScript scripting API. This has nothing to do with Alfred: it just provides access to the JavaScript scripting engine as provided by OS X. As Shawn says, there isn't a chance in hell that Andrew will include something like Node in Alfred: Node.js is well over 5 times the size of Alfred. That's a rotten payoff for including a crappy language. There's also very limited benefit in any kind of async jazz (unless you need to download multiple things at once), as workflows are entirely synchronous. You might be able to perform async queries, but you'll have to wait for the results and tie them all together in a decidedly synchronous fashion before sending any results to Alfred. Link to comment
jdfwarrior Posted September 28, 2015 Share Posted September 28, 2015 (edited) As the others have pointed out, the Javascript supported is the Javascript API that is built into OSX and not Javascript based on a specific runtime like Node.js or io.js. Alfred only provides built in support for languages that come preinstalled within OSX which eliminates things like Node.js and io.js. You could still create workflows to use node by setting your environment within the code area of a Run Script like this: /usr/local/bin/node <<-'CODE' var temp = require('underscore') console.log('testing this') CODE Edited September 30, 2015 by deanishe supposed -> supported Link to comment
deanishe Posted September 30, 2015 Share Posted September 30, 2015 It possibly bears pointing out that the example David posted above is shell script and thus requires the Language to be set to "/bin/bash". Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now