Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/SatanWoo/JSDebugger
JavaScript-Based Debugger For Inspecting Running State Of Your Application
https://github.com/SatanWoo/JSDebugger
Last synced: about 1 month ago
JSON representation
JavaScript-Based Debugger For Inspecting Running State Of Your Application
- Host: GitHub
- URL: https://github.com/SatanWoo/JSDebugger
- Owner: SatanWoo
- License: gpl-3.0
- Created: 2018-10-02T15:49:49.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-01T09:25:02.000Z (over 5 years ago)
- Last Synced: 2024-08-03T18:19:57.526Z (4 months ago)
- Language: Objective-C
- Homepage: http://satanwoo.github.io
- Size: 400 KB
- Stars: 650
- Watchers: 18
- Forks: 51
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- Awesome-iOS - JSDebugger - JavaScript-Based Debugger For Inspecting Running State Of Your Application (Tools)
- awesome-hacking-lists - SatanWoo/JSDebugger - JavaScript-Based Debugger For Inspecting Running State Of Your Application (Objective-C)
README
# JSDebugger
**JavaScript-Based Tool For Inspecting Running State Of Your Application**
> The status of this project is under rapid development and first stable version is v0.8
JSDebugger is a runtime inspecting tool for you to dig into details of your applications or change application logics dynamically.
**You have call any Objective-C method at anytime without manually define JSExport!**
![](https://github.com/SatanWoo/BeeHive/blob/master/jstester.gif?raw=true)
## Usage
### Calling Methods
var view = UIView.alloc().init();
var k = NSMutableArray.alloc().init();
view.setBackgroundColor_(UIColor.redColor());
You may notice the method name is to some extent different from Objective-C. To illustrate it more precisely, the following two steps are executed underlying before calling an Objective-C method:- All colons are converted to underscores.
- Each part of the Objective-C selector is concatenated into single string.For Example:
application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
will be converted into following string:application_didFinishLaunchingWithOptions_(application, launchOptions)
### Variadic Arguments
**JSDebugger** Support Variadic Arguments with NIL termination
For Example:
var array = NSArray.arrayWithObjects_(1, 2, 3);
Or you can define your own method with variadic argumentsIn Objective-C, you define a class method `+ (void)test:(int)first,...NS_REQUIRES_NIL_TERMINATION` in `ViewController`,
then you call it with following codes:
ViewController.test_(1, 2, 3, 5, 7, 9, 8);
### Getter & Setter
view.backgroundColor = UIColor.redColor();
var color = view.backgroundColor();
var bounds = view.bounds();Getter Is Not Supported. Use Method Instead Of Getter!!!
For Example:
view.backgroundColor; // It's Wrong
view.backgroundColor(); // It's Correct
### JavaScriptThe running context of **JSDebugger** is totally the same as an ordinary JavaScript file. You can do whatever your want in **JSDebugger** as long as it satisfied the requirement of JavaScript:
var z = 5;
var k = [1, 2, 3];
var z = {name:'haha', age:15, data:k};
## Plugin
Excluded from the core functions provided with **JSDebugger**, we develop plugin mechanism for you to enhance the ability that **JSDebugger** able to cover.
### Choose
`Choose` aims to provide your with the ability to access any objects on heaps. The function will search all instances that match the class name you provided **exactly** and return all found results as an array.
For Example, suppose you have a class named `XXXViewController`
var vc = choose(XXXViewController);
Then you will make some operation on it:vc.isViewLoaded();
var view = vc.view();
view.backgroundColor = UIColor.orangeColor();## Playground
We provide you with a mechanism to debug instantly with the help of **JSDebugger Playground**
It's already integrated into **JSDebugger**. The usage of it is quite simple, suppose you have a `test.js` on your `Desktop`.
Follow steps listed below,
1. include `'JDLocalFileObserver.h'` and declare a reference to it.
`@property (nonatomic, strong) JDLocalFileObserver *fileWatcher;`
2. Init it with path to your `test.js` and file change callback.NSString *jsFilePath = @"PathToDesktop/test.js";
if ([[NSFileManager defaultManager] fileExistsAtPath: jsFilePath]) {
self.fileWatcher = [[JDLocalFileObserver alloc] initWithFilePath: jsFilePath changeBlock:^{
NSLog(@"[JSDebugger]::found test.js change");
dispatch_async(dispatch_get_main_queue(), ^{
[[JDEngine engine] evaluateScriptAtPath: jsFilePath];
});
}];
[self.fileWatcher start];
}3. Now, whenever you change something in your `test.js` and **save it(Command + S)**, your will find **JSDebugger** automatically reload the content of `test.js` and start to evaluate it.
4. **Do not forget to stop the local file watch whenever you don't need it**
[self.fileWatch stop]
If you still get confused, just checkout the code in the JSDebuggerDemo.## Example
Checkout `demo.js` in the JSDebuggerDemo, it shows great detail of what you can do with **JSDebugger**.
## Contribution
Please file a new issue if you feel confused or found some bugs.
## Features:
Here we list all features currently supported by **JSDebugger**:
- [x] Class Methods
- [x] Instance Methods
- [x] Instance Property
- [x] Custom Setter
- [x] Playground
- [x] Data Structes: `primitive types`, `object`, `class`, `struct` (Partially)
- [x] Choose
- [x] Introspect (Partially)
- [ ] Customized Struct
- [x] Getter
- [x] VA_LIST
- [x] Associate Object
- [ ] Block
- [x] C Pointer## What's Next
An IDE with live Objective-C to JavaScript convertion is under development.
You can really look forward to it!## Reference
The great works listed below inspired me a lot during the development of **JSDebugger**.
- Cycript
- [JSPatch](https://github.com/bang590/JSPatch) @Bang
- [Choose](https://github.com/BlueCocoa/choose) @BlueCocoa## License
Copyright 2018 @SatanWoo
Checkout [License](https://github.com/SatanWoo/JSDebugger/blob/master/LICENSE)