chore: deprecate utils.ios.getter (#7054)

This commit is contained in:
Manol Donev
2019-03-22 17:33:21 +02:00
committed by GitHub
parent 8ba5e4d887
commit 34fe24732d
28 changed files with 597 additions and 653 deletions

View File

@@ -4,19 +4,6 @@ var inspectorCommands: typeof inspectorCommandTypes = require("./InspectorBacken
import * as debuggerDomains from "./debugger";
declare var __inspectorSendEvent;
/**
* Checks if the property is a function and if it is, calls it on this.
* Designed to support backward compatibility for methods that became properties.
* Will not work on delegates since it checks if the propertyValue is a function, and delegates are marshalled as functions.
* Example: getter(NSRunLoop, NSRunLoop.currentRunLoop).runUntilDate(NSDate.dateWithTimeIntervalSinceNow(waitTime));
*/
function getter<T>(_this: any, property: T | {(): T}): T {
if (typeof property === "function") {
return (<{(): T}>property).call(_this);
} else {
return <T>property;
}
}
declare var __inspectorTimestamp;
@@ -237,9 +224,9 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
* Loads a resource in the context of a frame on the inspected page without cross origin checks.
*/
loadResource(params: inspectorCommandTypes.NetworkDomain.LoadResourceMethodArguments): { content: string, mimeType: string, status: number } {
let appPath = getter(NSBundle, NSBundle.mainBundle).bundlePath;
let appPath = NSBundle.mainBundle.bundlePath;
let pathUrl = params.url.replace("file://", appPath);
let fileManager = getter(NSFileManager, NSFileManager.defaultManager);
let fileManager = NSFileManager.defaultManager;
let data = fileManager.fileExistsAtPath(pathUrl) ? fileManager.contentsAtPath(pathUrl) : undefined;
let content = data ? NSString.alloc().initWithDataEncoding(data, NSUTF8StringEncoding) : "";