Matchstic / InfoStats2

An API for JavaScript, and Objective-C
BSD 2-Clause "Simplified" License
23 stars 6 forks source link

Move away from WebCycript (et al) as a dependancy #8

Open Matchstic opened 7 years ago

Matchstic commented 7 years ago

I propose to move away from WebCycript being utilised as an underlying dependancy for access to InfoStats 2 in widgets. This will remove the wait for fixes to WebCycript (if required) between iOS versions, and will serve to consolidate InfoStats 2 into a self-contained package.

To achieve this:

  1. A new method of bridging native code to JavaScript is required.
  2. A method to ensure backwards compatibility with Cycript is required.

Other benefits include code usually accessed via Cycript now runs outside JavaScript's environment, meaning speed improvements, and significant reliability/stability improvements.


For (1) I propose a simple extension to JavaScript, which will simply expose global variables with the namespace of the class names within InfoStats 2, such as IS2Weather.(method), IS2Location.(method) and so forth. Existing classes within SpringBoard can be accessed via another global variable with the namespace of SpringBoard.(class).(method).

This can be achieved in a similar manner to XWebView, which may be used as a basis.


For (2) I propose "compiling" from Cycript code into this new "IS2Script", using the form:

var thing = [IS2Weather doThing]; // existing var thing = IS2Weather.doThing(); // new

var anotherThing = [[SBExampleClass sharedInstance] anotherThing]; // existing var anotherThing = SpringBoard.SBExampleClass.sharedInstance().anotherThing(); // new

var object = [SBExampleClass sharedInstance]; // existing var object = SpringBoard.SBExampleClass.sharedInstance(); // new var thingWithObject = [object anotherThing]; // existing var thingWithObject = object.anotherThing(); // new

This will utilise at minimum a deterministic finite automata, and will interpose the loading of web pages into both UIWebView and WKWebView. I also propose the addition of pre-processor flags to this compiler, which will be in the form of a comment within a Githubissues.

  • Githubissues is a development platform for aggregating issues.