[TIMOB-26572] TiAPI: Extend global console API to be more Node-compatible
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-03-06T16:35:54.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 9.1.0 |
Components | TiAPI |
Labels | n/a |
Reporter | Christopher Williams |
Assignee | Christopher Williams |
Created | 2018-11-16T16:24:13.000+0000 |
Updated | 2020-03-31T17:11:05.000+0000 |
Description
Our current console global object has the most common methods, but is missing some easy ones to target.
- assert
- count
- countReset
- trace
Some other methods may be useful to simply implement as no-ops (like #clear())
https://nodejs.org/api/console.html
Tony Lukasavage has a JS impl to add trace/assert/dir here: https://github.com/tonylukasavage/ti-console/blob/master/src/ti-console.js
I think given that on Android and Windows we already have JS code to implement some of console, it'd be fairly simple to move this into the common area and expand upon it. https://github.com/appcelerator/titanium_mobile/blob/master/android/runtime/common/src/js/console.js https://github.com/appcelerator/titanium_mobile_windows/blob/master/Source/TitaniumKit/src/TiModule.cpp#L493-L531
[~cwilliams] I started to look into this, I'm not sure whether we would consider it a breaking change? iOS defines a [TiConsole](https://github.com/appcelerator/titanium_mobile/blob/master/iphone/TitaniumKit/TitaniumKit/Sources/API/TiConsole.m), which is then added to the globals [here](https://github.com/appcelerator/titanium_mobile/blob/master/iphone/TitaniumKit/TitaniumKit/Sources/API/KrollBridge.m#L557-L560). Is TitaniumKit itself seen as a public API, or is just Titanium SDK our public API. As I understand, if it's the former then this should be a breaking change
The original goal from Matt Langston back in the early days of TitaniumKit/HAL was to make that the core foundation of all the platforms, but no one has the appetite to throw away our core stuff on iOS and replace it - let alone consider how we'd hook up JSC for Android. I'd only consider the SDK as our public API. I don't think this should be a breaking change, basically we just move any methods we can into the common JS code we ship in the SDK and leave say the base methods (like
#log()
) done natively. If we want to be extra safe, we can sniff if the console object already has an implementation for any given method and not override it.WIP PR: https://github.com/appcelerator/titanium_mobile/pull/11425
https://github.com/appcelerator/titanium_mobile/pull/11425
Merged to master for 9.1.0 target
FR Passed: Tested by looking at the results of the Unit tests in Jenkins and a quick titanium application outlining various features.
*Test environment*