OmniJS is a completely different embedding of a JSContext, and doesn’t expose JXA’s Automation object at all.
You won’t be able to evaluate Standard Additions code in the omniJS interpreter, but you can evaluate omniJS source code from JXA, using the OO.evaluate(strSource) method, and get a return value back to JXA, so its possible to write scripts in which JXA and omniJS cooperate.
PS a useful way of shining a torch around a new or unfamiliar JS interpreter, and seeing what interfaces are available in its global namespace, is to evaluate the following snippet:
Object.getOwnPropertyNames(this)
The landscape will look very different in each of the following, for example:
I would love an example showing how to evaluate OmniJS from JXA with a return value. (I know how to execute OmniJS source from JXA via a URL, but that doesn’t provide a return value.)
I see what you are saying, and I realize how naïve my post was, but I can’t quite put the pieces together. In particular, what (where) is OO.evaluate? A very simple example for which I would want to get the result back to JXA would be:
This is very cool, and of particular interest to me, because getting a class tree is my favorite exercise when working with a new language/environment (starting with Smalltalk-76!!).
The JXA interface for the omniOutliner application object has an .evaluateJavascript(strCode) method.
As you probably know, JS functions have a .toString() method (and can even be coerced to their source code by simple string concatenation), so you can define the main omniJS function in your JXA code, and then pass a stringification of it into the omniJS interpreter with .evaluateJavascript(strCode).
That method can return a string value.
There are some notes here on the use of the omnigraffle instance of .evaluateJavascript: