How bang590/jspatch works
Core Engine and Loader
• Core Engine: At the heart of the project is the JSPatch core (files like JPEngine.h, JPEngine.m, and JSPatch.js) that provides the runtime bridging. This component is responsible for starting the JavaScript engine, evaluating scripts, and invoking Objective-C methods from JavaScript.
• Loader: The Loader module (in the Loader directory) acts as a helper for fetching, unpacking, and (optionally) decrypting or packaging the scripts. It includes libraries such as RSA for security and ZipArchive for handling compressed assets.
Extensions and Additional Bridging Components
• The “Extensions” folder contains various modules (e.g., JPBlock, JPCFunction, JPCFunctionBinder, JPPlaygroundTool) that extend the capabilities of the core engine. Each extension adds support for extra functionality, such as handling blocks, C functions, or integrating with UIKit/CoreGraphics. These modules could be invoked from both the engine and the sample apps.
• Device-specific or specialized extensions (like JPLibffi, JPDispatch, JPProtocol, etc.) expand how Objective-C types and calls are bridged, making the system highly modular and extensible.
Demo Applications and Integration Examples
• The “Demo” directory includes multiple subprojects such as DribbbleDemo, OSXDemo, SwiftDemo, iOSDemo, iOSPlayground (and its tool demo), and tvOSDemo. Each of these is an example iOS (or macOS/tvOS) project that demonstrates how to integrate JSPatch into an application. The demos include sample code that initiates the engine ([JPEngine startEngine]), loads JavaScript (via a bundled script or from a network), and illustrates the bridging in action.
• The inclusion of several demos under different platforms (Objective-C and Swift, plus different device targets) shows the versatility and integration strategy the library promotes.