Making Your App Extensible with JavaScriptCore
The idea here is that JavaScript is basically the only way nowadays that you can ship plugins or scripts with your apps on macOS that is not broken since Big Sur, I think. Because Ruby and Python and all these other scripting languages were yeeted from the operating system.
Of course, apps can still offer places where users can hook in AppleScripts.
So it’s not like new technology. It works with really old stuff. And the thing I’ve found is that you can actually make plugins for your applications that don’t expose the app’s internals or the user’s file system or any sensitive data unless you actually decide to expose this. Which means that plugin installing can become rather safe. It’s easy to break things, but it’s also easy to make things secure.
[…]
The most important piece that I found is the context, and the
JSValue
that you see below, and theJSManagedValue
, which is something we will completely ignore. If you have worked with CoreData, for example, you will know theNSManagedObject
, and theJSManagedValue
is kind of similar: It’s bridging into the JavaScript context and automatically updates when you mutate an object from within the script. And the JavaScript site sees values reflected as you change them in your swift code on these managed values. This is very handy, I guess, but it’s something that I find, well, utterly unnecessary for my purposes. And too hard to control.[…]
I’m teaching the script to call a function for the input and I call function for the output.
Previously:
- Using JavaScript in a Swift App
- The Unexpected Return of JavaScript for Automation
- Scripting Languages to Be Removed
2 Comments RSS · Twitter · Mastodon
But that’s not the purpose of JSManagedValue. 🙈 JSManagedValue is immutable too. How can anyone take the article seriously after those few sentences?