This repository contains a JavaScriptCore-only version of NodeKit.
It follows the full NodeKit API (NKScripting currently implemented) using only JSExport on JavaScriptCore.
Use Carthage (nodekit-io/nodekit-darwin-lite
) or CocoaPods (NKScriptingLite
)
let options = Dictionary<String, AnyObject>()
NKScriptContextFactory().createScriptContext(options, delegate: self.scriptContextDelegate)
func NKScriptEngineDidLoad(context: NKScriptContext) -> Void
func NKScriptEngineReady(context: NKScriptContext) -> Void {
func loadPlugin(object: AnyObject, namespace: String, options: Dictionary<String, AnyObject>) -> Void
func evaluateJavaScript(javaScriptString: String, completionHandler: ((AnyObject?,NSError?) -> Void)?)
Example to create plugin
context.loadPlugin(storage(), namespace: "io.nodekit.scripting.storage", options: ["js": "lib-scripting.nkar/lib-scripting/native_module.js"])
Plugins should implement an @objc protocol that injerits from NKScriptExport; each method in this protocol is exposed automatically to JavaScript
See SamplePlugin.swift for an example