By executing the following code snippet in NS:IDE, we can see which native APIs have been exposed to JS, at least in the global context:
Object.keys(global).sort();
Thus, we can see that the following keys exist on the global
object, most of which are iOS APIs. There is also precious little overlap with Node.js's global
interface.
[
"CAAnimationDelegate",
"CADisplayLink",
"CALayer",
"CATransaction",
"CGAffineTransformMake",
"CGAffineTransformMakeTranslation",
"CGDataProviderCreateWithCFData",
"CGFontCreateWithDataProvider",
"CGPointMake",
"CGRect",
"CGRectEqualToRect",
"CGRectMake",
"CGRectZero",
"CGSize",
"CGSizeMake",
"CTFontManagerRegisterGraphicsFont",
"CodeAttributedString",
"Deprecated",
"Experimental",
"Highlightr", // This is a plugin I added myself.
"NSArray",
"NSData",
"NSDictionary",
"NSFileManager",
"NSFontAttributeName",
"NSForegroundColorAttributeName",
"NSInvocation",
"NSLayoutManager",
"NSMakeRange",
"NSMethodSignature",
"NSMutableArray",
"NSMutableAttributedString",
"NSNotification",
"NSNotificationCenter",
"NSNumber",
"NSObject",
"NSString",
"NSStringFromClass",
"NSTextContainer",
"NSURL",
"ObjC",
"ObjCClass",
"ObjCMethod",
"ObjCParam",
"System",
"UIApplication",
"UIApplicationDidBecomeActiveNotification",
"UIApplicationDidEnterBackgroundNotification",
"UIApplicationDidFinishLaunchingNotification",
"UIApplicationDidReceiveMemoryWarningNotification",
"UIApplicationMain",
"UIApplicationWillTerminateNotification",
"UIBarButtonItem",
"UIButton",
"UIColor",
"UIDevice",
"UIDeviceOrientationDidChangeNotification",
"UIDocumentInteractionControllerDelegate",
"UIEdgeInsetsMake",
"UIFont",
"UIFontDescriptor",
"UIFontDescriptorFamilyAttribute",
"UIFontDescriptorTraitsAttribute",
"UIFontSymbolicTrait",
"UIFontWeightRegular",
"UIFontWeightTrait",
"UIGestureRecognizer",
"UIGestureRecognizerDelegate",
"UIImage",
"UILabel",
"UILayoutGuide",
"UINavigationBar",
"UINavigationController",
"UINavigationControllerDelegate",
"UINavigationItem",
"UINode",
"UIResponder",
"UIScreen",
"UIScreenEdgePanGestureRecognizer",
"UIScrollView",
"UIScrollViewDelegate",
"UITabBar",
"UITabBarController",
"UITabBarControllerDelegate",
"UITabBarItem",
"UITableViewCell",
"UITableViewDataSource",
"UITableViewDelegate",
"UITextView",
"UITextViewDelegate",
"UIView",
"UIViewController",
"UIViewControllerAnimatedTransitioning",
"UIWindow",
"WeakRef",
"Worker",
"__assign",
"__asyncDelegator",
"__asyncGenerator",
"__asyncValues",
"__await",
"__awaiter",
"__decorate",
"__exportStar",
"__generator",
"__importDefault",
"__importStar",
"__makeTemplateObject",
"__metadata",
"__onLiveSync",
"__onLiveSyncCore",
"__onUncaughtError",
"__param",
"__read",
"__rest",
"__spread",
"__values",
"app", // I added this; it is a reference to the app root.
"design", // I added this; it is a reference to a view.
"loadModule",
"moduleExists",
"moduleMerge",
"moduleResolvers",
"registerModule",
"registerWebpackModules",
"webpackJsonp",
"zonedCallback"
]
It's clear that most of these APIs are from UIKit, or correspond to fundamental data types (which I've tracked down to inlineFunctions.js
).
However, there are a lot more hiding that don't show up as keys on global
. For example, global.AVCaptureDevice
(also accessible as just AVCaptureDevice
)...
You can see many properties are added in GlobalObject.mm
.