mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
The webinspector debugger now does not requre http-request
This commit is contained in:
@ -1,103 +1,39 @@
|
|||||||
import definition = require("./InspectorBackendCommands");
|
export namespace domains {
|
||||||
import http_request = require("http/http-request");
|
export namespace network {
|
||||||
|
export interface NetworkDomainDebugger {
|
||||||
|
create(): domains.network.NetworkRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Headers {
|
||||||
|
}
|
||||||
|
|
||||||
var resources_datas = [];
|
export interface Request {
|
||||||
|
url: string;
|
||||||
|
method: string;
|
||||||
|
headers: domains.network.Headers;
|
||||||
|
postData?: string;
|
||||||
|
}
|
||||||
|
|
||||||
@definition.DomainDispatcher("Network")
|
export interface Response {
|
||||||
export class NetworkDomainDebugger implements definition.NetworkDomain.NetworkDomainDispatcher {
|
url: string;
|
||||||
private events: definition.NetworkDomain.NetworkFrontend;
|
status: number;
|
||||||
|
statusText: string;
|
||||||
|
headers: Headers;
|
||||||
|
headersText?: string;
|
||||||
|
mimeType: string;
|
||||||
|
requestHeaders?: domains.network.Headers;
|
||||||
|
requestHeadersText?: string;
|
||||||
|
fromDiskCache?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
constructor(dispatchMessage: (message: String) => void) {
|
export interface NetworkRequest {
|
||||||
this.events = new definition.NetworkDomain.NetworkFrontend(dispatchMessage);
|
mimeType: string;
|
||||||
}
|
data: any;
|
||||||
|
responseReceived(response: domains.network.Response);
|
||||||
/**
|
loadingFinished();
|
||||||
* Enables network tracking, network events will now be delivered to the client.
|
requestWillBeSent(request: domains.network.Request);
|
||||||
*/
|
|
||||||
enable(): void {
|
|
||||||
http_request.domainDebugger = {
|
|
||||||
"events": this.events,
|
|
||||||
"resource_datas": resources_datas
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disables network tracking, prevents network events from being sent to the client.
|
|
||||||
*/
|
|
||||||
disable(): void {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies whether to always send extra HTTP headers with the requests from this page.
|
|
||||||
*/
|
|
||||||
setExtraHTTPHeaders(params: definition.NetworkDomain.SetExtraHTTPHeadersMethodArguments): void {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns content served for the given request.
|
|
||||||
*/
|
|
||||||
getResponseBody(params: definition.NetworkDomain.GetResponseBodyMethodArguments): { body: string, base64Encoded: boolean } {
|
|
||||||
var resource_data = resources_datas[params.requestId];
|
|
||||||
var body = resource_data.hasTextContent ? NSString.alloc().initWithDataEncoding(resource_data.data, 4).toString() :
|
|
||||||
resource_data.data.base64EncodedStringWithOptions(0);
|
|
||||||
|
|
||||||
if(resource_data) {
|
|
||||||
return {
|
|
||||||
body: body,
|
|
||||||
base64Encoded: !resource_data.hasTextContent
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tells whether clearing browser cache is supported.
|
|
||||||
*/
|
|
||||||
canClearBrowserCache(): { result: boolean } {
|
|
||||||
return {
|
|
||||||
result: false
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clears browser cache.
|
|
||||||
*/
|
|
||||||
clearBrowserCache(): void {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tells whether clearing browser cookies is supported.
|
|
||||||
*/
|
|
||||||
canClearBrowserCookies(): { result: boolean } {
|
|
||||||
return {
|
|
||||||
result: false
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clears browser cookies.
|
|
||||||
*/
|
|
||||||
clearBrowserCookies(): void {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Toggles ignoring cache for each request. If <code>true</code>, cache will not be used.
|
|
||||||
*/
|
|
||||||
setCacheDisabled(params: definition.NetworkDomain.SetCacheDisabledMethodArguments): void {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads a resource in the context of a frame on the inspected page without cross origin checks.
|
|
||||||
*/
|
|
||||||
loadResource(params: definition.NetworkDomain.LoadResourceMethodArguments): { content: string, mimeType: string, status: number } {
|
|
||||||
return {
|
|
||||||
content: "",
|
|
||||||
mimeType: "",
|
|
||||||
status: 200
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export var network: domains.network.NetworkDomainDebugger;
|
||||||
|
229
debugger/webinspector.ios.ts
Normal file
229
debugger/webinspector.ios.ts
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
import * as inspectorCommandTypes from "./InspectorBackendCommands.ios";
|
||||||
|
var inspectorCommands: typeof inspectorCommandTypes = require("./InspectorBackendCommands");
|
||||||
|
|
||||||
|
import * as debuggerDomains from "./debugger";
|
||||||
|
|
||||||
|
declare var __inspectorTimestamp;
|
||||||
|
|
||||||
|
const frameId = "NativeScriptMainFrameIdentifier";
|
||||||
|
const loaderId = "Loader Identifier";
|
||||||
|
|
||||||
|
var resources_datas = [];
|
||||||
|
|
||||||
|
var documentTypeByMimeType = {
|
||||||
|
"text/xml": "Document",
|
||||||
|
"text/plain": "Document",
|
||||||
|
"text/html": "Document",
|
||||||
|
"application/xml": "Document",
|
||||||
|
"application/xhtml+xml": "Document",
|
||||||
|
"text/css": "Stylesheet",
|
||||||
|
"text/javascript": "Script",
|
||||||
|
"text/ecmascript": "Script",
|
||||||
|
"application/javascript": "Script",
|
||||||
|
"application/ecmascript": "Script",
|
||||||
|
"application/x-javascript": "Script",
|
||||||
|
"application/json": "Script",
|
||||||
|
"application/x-json": "Script",
|
||||||
|
"text/x-javascript": "Script",
|
||||||
|
"text/x-json": "Script",
|
||||||
|
"text/typescript": "Script"
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Request {
|
||||||
|
|
||||||
|
private _resourceType: string;
|
||||||
|
private _data: any;
|
||||||
|
private _mimeType: string;
|
||||||
|
|
||||||
|
constructor(private _networkDomainDebugger: NetworkDomainDebugger, private _requestID: string) {
|
||||||
|
}
|
||||||
|
|
||||||
|
get mimeType(): string {
|
||||||
|
return this._mimeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
set mimeType(value: string) {
|
||||||
|
if (this._mimeType !== value) {
|
||||||
|
this._mimeType = value;
|
||||||
|
|
||||||
|
var resourceType = "Other";
|
||||||
|
|
||||||
|
if (this._mimeType in documentTypeByMimeType) {
|
||||||
|
resourceType = documentTypeByMimeType[this._mimeType];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this._mimeType.indexOf("image/") !== -1) {
|
||||||
|
resourceType = "Image";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._mimeType.indexOf("font/") !== -1) {
|
||||||
|
resourceType = "Font";
|
||||||
|
}
|
||||||
|
|
||||||
|
this._resourceType = resourceType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get requestID(): string {
|
||||||
|
return this._requestID;
|
||||||
|
}
|
||||||
|
|
||||||
|
get hasTextContent(): boolean {
|
||||||
|
return [ "Document", "Stylesheet", "Script", "XHR" ].indexOf(this._resourceType) !== -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
get data(): any {
|
||||||
|
return this._data;
|
||||||
|
}
|
||||||
|
|
||||||
|
set data(value: any) {
|
||||||
|
if (this._data !== value) {
|
||||||
|
this._data = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get resourceType() {
|
||||||
|
return this._resourceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
set resourceType(value: string) {
|
||||||
|
if (this._resourceType !== value) {
|
||||||
|
this._resourceType = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public responseReceived(response: inspectorCommandTypes.NetworkDomain.Response): void {
|
||||||
|
if (this._networkDomainDebugger.enabled) {
|
||||||
|
this._networkDomainDebugger.events.responseReceived(this.requestID, frameId, loaderId, __inspectorTimestamp(), <any>this.resourceType, response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public loadingFinished(): void {
|
||||||
|
if (this._networkDomainDebugger.enabled) {
|
||||||
|
this._networkDomainDebugger.events.loadingFinished(this.requestID, __inspectorTimestamp());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public requestWillBeSent(request: inspectorCommandTypes.NetworkDomain.Request): void {
|
||||||
|
if (this._networkDomainDebugger.enabled) {
|
||||||
|
this._networkDomainDebugger.events.requestWillBeSent(this.requestID, frameId, loaderId, request.url, request, __inspectorTimestamp(), { type: 'Script' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@inspectorCommands.DomainDispatcher("Network")
|
||||||
|
export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomain.NetworkDomainDispatcher {
|
||||||
|
private _enabled: boolean;
|
||||||
|
public events: inspectorCommandTypes.NetworkDomain.NetworkFrontend;
|
||||||
|
|
||||||
|
constructor(dispatchMessage: (message: String) => void) {
|
||||||
|
this.events = new inspectorCommands.NetworkDomain.NetworkFrontend(dispatchMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
get enabled(): boolean {
|
||||||
|
return this._enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables network tracking, network events will now be delivered to the client.
|
||||||
|
*/
|
||||||
|
enable(): void {
|
||||||
|
if (debuggerDomains.network) {
|
||||||
|
throw new Error("One NetworkDomainDebugger may be enabled at a time.");
|
||||||
|
} else {
|
||||||
|
debuggerDomains.network = this;
|
||||||
|
}
|
||||||
|
this._enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables network tracking, prevents network events from being sent to the client.
|
||||||
|
*/
|
||||||
|
disable(): void {
|
||||||
|
if (debuggerDomains.network === this) {
|
||||||
|
debuggerDomains.network = null;
|
||||||
|
}
|
||||||
|
this._enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies whether to always send extra HTTP headers with the requests from this page.
|
||||||
|
*/
|
||||||
|
setExtraHTTPHeaders(params: inspectorCommandTypes.NetworkDomain.SetExtraHTTPHeadersMethodArguments): void {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns content served for the given request.
|
||||||
|
*/
|
||||||
|
getResponseBody(params: inspectorCommandTypes.NetworkDomain.GetResponseBodyMethodArguments): { body: string, base64Encoded: boolean } {
|
||||||
|
var resource_data = resources_datas[params.requestId];
|
||||||
|
var body = resource_data.hasTextContent ? NSString.alloc().initWithDataEncoding(resource_data.data, 4).toString() :
|
||||||
|
resource_data.data.base64EncodedStringWithOptions(0);
|
||||||
|
|
||||||
|
if(resource_data) {
|
||||||
|
return {
|
||||||
|
body: body,
|
||||||
|
base64Encoded: !resource_data.hasTextContent
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tells whether clearing browser cache is supported.
|
||||||
|
*/
|
||||||
|
canClearBrowserCache(): { result: boolean } {
|
||||||
|
return {
|
||||||
|
result: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears browser cache.
|
||||||
|
*/
|
||||||
|
clearBrowserCache(): void {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tells whether clearing browser cookies is supported.
|
||||||
|
*/
|
||||||
|
canClearBrowserCookies(): { result: boolean } {
|
||||||
|
return {
|
||||||
|
result: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears browser cookies.
|
||||||
|
*/
|
||||||
|
clearBrowserCookies(): void {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles ignoring cache for each request. If <code>true</code>, cache will not be used.
|
||||||
|
*/
|
||||||
|
setCacheDisabled(params: inspectorCommandTypes.NetworkDomain.SetCacheDisabledMethodArguments): void {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 } {
|
||||||
|
return {
|
||||||
|
content: "",
|
||||||
|
mimeType: "",
|
||||||
|
status: 200
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static idSequence: number = 0;
|
||||||
|
create(): Request {
|
||||||
|
let id = (++NetworkDomainDebugger.idSequence).toString();
|
||||||
|
let resourceData = new Request(this, id);
|
||||||
|
resources_datas[id] = resourceData;
|
||||||
|
return resourceData;
|
||||||
|
}
|
||||||
|
}
|
32
globals/decorators.ts
Normal file
32
globals/decorators.ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
if (typeof global.__decorate !== "function") {
|
||||||
|
global.__decorate = function (decorators, target, key, desc) {
|
||||||
|
var c = arguments.length;
|
||||||
|
var r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||||
|
|
||||||
|
if (typeof global.Reflect === "object" && typeof global.Reflect.decorate === "function") {
|
||||||
|
r = global.Reflect.decorate(decorators, target, key, desc);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (var i = decorators.length - 1; i >= 0; i--) {
|
||||||
|
if (d = decorators[i]) {
|
||||||
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof global.__metadata !== "function") {
|
||||||
|
global.__metadata = function (k, v) {
|
||||||
|
if (typeof global.Reflect === "object" && typeof global.Reflect.metadata === "function") {
|
||||||
|
return global.Reflect.metadata(k, v);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof global.__param !== "function") {
|
||||||
|
global.__param = (global && global.__param) || function (paramIndex, decorator) {
|
||||||
|
return function (target, key) { decorator(target, key, paramIndex); }
|
||||||
|
};
|
||||||
|
}
|
@ -100,38 +100,7 @@ if (platform.device.os === platform.platformNames.android) {
|
|||||||
global.console.dump = function (args) { c.dump(args); };
|
global.console.dump = function (args) { c.dump(args); };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof global.__decorate !== "function") {
|
require("./decorators");
|
||||||
global.__decorate = function (decorators, target, key, desc) {
|
|
||||||
var c = arguments.length;
|
|
||||||
var r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
||||||
|
|
||||||
if (typeof global.Reflect === "object" && typeof global.Reflect.decorate === "function") {
|
|
||||||
r = global.Reflect.decorate(decorators, target, key, desc);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
||||||
if (d = decorators[i]) {
|
|
||||||
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof global.__metadata !== "function") {
|
|
||||||
global.__metadata = function (k, v) {
|
|
||||||
if (typeof global.Reflect === "object" && typeof global.Reflect.metadata === "function") {
|
|
||||||
return global.Reflect.metadata(k, v);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof global.__param !== "function") {
|
|
||||||
global.__param = (global && global.__param) || function (paramIndex, decorator) {
|
|
||||||
return function (target, key) { decorator(target, key, paramIndex); }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function Deprecated(target: Object, key?: string | symbol, descriptor?: any) {
|
export function Deprecated(target: Object, key?: string | symbol, descriptor?: any) {
|
||||||
if (descriptor) {
|
if (descriptor) {
|
||||||
|
2
http/http-request.d.ts
vendored
2
http/http-request.d.ts
vendored
@ -2,7 +2,5 @@
|
|||||||
|
|
||||||
declare module "http/http-request" {
|
declare module "http/http-request" {
|
||||||
import http = require("http");
|
import http = require("http");
|
||||||
|
|
||||||
export var domainDebugger: any;
|
|
||||||
export var request: (options: http.HttpRequestOptions) => Promise<http.HttpResponse>;
|
export var request: (options: http.HttpRequestOptions) => Promise<http.HttpResponse>;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
* iOS specific http request implementation.
|
* iOS specific http request implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare var __inspectorTimestamp;
|
|
||||||
import http = require("http");
|
import http = require("http");
|
||||||
|
|
||||||
import * as types from "utils/types";
|
import * as types from "utils/types";
|
||||||
@ -10,8 +9,7 @@ import * as imageSourceModule from "image-source";
|
|||||||
import * as utilsModule from "utils/utils";
|
import * as utilsModule from "utils/utils";
|
||||||
import * as fsModule from "file-system";
|
import * as fsModule from "file-system";
|
||||||
|
|
||||||
import resource_data = require("./resource-data");
|
import domainDebugger = require("./../debugger/debugger");
|
||||||
import debuggerDomains = require("./../debugger/debugger");
|
|
||||||
|
|
||||||
var GET = "GET";
|
var GET = "GET";
|
||||||
var USER_AGENT_HEADER = "User-Agent";
|
var USER_AGENT_HEADER = "User-Agent";
|
||||||
@ -20,8 +18,6 @@ var sessionConfig = NSURLSessionConfiguration.defaultSessionConfiguration();
|
|||||||
var queue = NSOperationQueue.mainQueue();
|
var queue = NSOperationQueue.mainQueue();
|
||||||
var session = NSURLSession.sessionWithConfigurationDelegateDelegateQueue(sessionConfig, null, queue);
|
var session = NSURLSession.sessionWithConfigurationDelegateDelegateQueue(sessionConfig, null, queue);
|
||||||
|
|
||||||
export var domainDebugger: any;
|
|
||||||
|
|
||||||
var utils: typeof utilsModule;
|
var utils: typeof utilsModule;
|
||||||
function ensureUtils() {
|
function ensureUtils() {
|
||||||
if (!utils) {
|
if (!utils) {
|
||||||
@ -40,14 +36,7 @@ export function request(options: http.HttpRequestOptions): Promise<http.HttpResp
|
|||||||
return new Promise<http.HttpResponse>((resolve, reject) => {
|
return new Promise<http.HttpResponse>((resolve, reject) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// var sessionConfig = NSURLSessionConfiguration.defaultSessionConfiguration();
|
var debugRequest = domainDebugger.network && domainDebugger.network.create();
|
||||||
// var queue = NSOperationQueue.mainQueue();
|
|
||||||
// var session = NSURLSession.sessionWithConfigurationDelegateDelegateQueue(
|
|
||||||
// sessionConfig, null, queue);
|
|
||||||
|
|
||||||
var requestId = Math.random().toString();
|
|
||||||
var resourceData = new resource_data.ResourceData(requestId);
|
|
||||||
domainDebugger.resource_datas[requestId] = resourceData;
|
|
||||||
|
|
||||||
var urlRequest = NSMutableURLRequest.requestWithURL(
|
var urlRequest = NSMutableURLRequest.requestWithURL(
|
||||||
NSURL.URLWithString(options.url));
|
NSURL.URLWithString(options.url));
|
||||||
@ -87,28 +76,22 @@ export function request(options: http.HttpRequestOptions): Promise<http.HttpResp
|
|||||||
(<any>http).addHeader(headers, key, value);
|
(<any>http).addHeader(headers, key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
domainDebugger.resource_datas[requestId].mimeType = response.MIMEType;
|
if (debugRequest) {
|
||||||
domainDebugger.resource_datas[requestId].data = data;
|
debugRequest.mimeType = response.MIMEType;
|
||||||
var debugResponse = {
|
debugRequest.data = data;
|
||||||
// Response URL. This URL can be different from CachedResource.url in case of redirect.
|
var debugResponse = {
|
||||||
url: options.url,
|
url: options.url,
|
||||||
// HTTP response status code.
|
status: response.statusCode,
|
||||||
status: response.statusCode,
|
statusText: NSHTTPURLResponse.localizedStringForStatusCode(response.statusCode),
|
||||||
// HTTP response status text.
|
headers: headers,
|
||||||
statusText: NSHTTPURLResponse.localizedStringForStatusCode(response.statusCode),
|
mimeType: response.MIMEType,
|
||||||
// HTTP response headers.
|
fromDiskCache: false
|
||||||
headers: headers,
|
}
|
||||||
// HTTP response headers text.
|
debugRequest.responseReceived(debugResponse);
|
||||||
mimeType: response.MIMEType,
|
debugRequest.loadingFinished();
|
||||||
fromDiskCache: false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loader Identifier is hardcoded in the runtime and should be the same string
|
|
||||||
// __inspectorTimestamp is provided by the runtime and returns a frontend friendly timestamp
|
|
||||||
domainDebugger.events.responseReceived(requestId, "NativeScriptMainFrameIdentifier", "Loader Identifier", __inspectorTimestamp(), exports.domainDebugger.resource_datas[requestId].resourceType, debugResponse);
|
|
||||||
domainDebugger.events.loadingFinished(requestId, __inspectorTimestamp());
|
|
||||||
|
|
||||||
resolve({
|
resolve({
|
||||||
content: {
|
content: {
|
||||||
raw: data,
|
raw: data,
|
||||||
@ -162,14 +145,13 @@ export function request(options: http.HttpRequestOptions): Promise<http.HttpResp
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(options.url) {
|
if(options.url && debugRequest) {
|
||||||
var request = {
|
var request = {
|
||||||
url: options.url,
|
url: options.url,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: options.headers
|
headers: options.headers
|
||||||
};
|
};
|
||||||
|
debugRequest.requestWillBeSent(request);
|
||||||
domainDebugger.events.requestWillBeSent(requestId, "NativeScriptMainFrameIdentifier", "Loader Identifier", options.url, request, __inspectorTimestamp(), { type: 'Script' });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dataTask.resume();
|
dataTask.resume();
|
||||||
|
@ -1,83 +0,0 @@
|
|||||||
var documentTypeByMimeType = [];
|
|
||||||
documentTypeByMimeType["text/xml"] = "Document";
|
|
||||||
documentTypeByMimeType["text/plain"] = "Document";
|
|
||||||
documentTypeByMimeType["text/html"] = "Document";
|
|
||||||
documentTypeByMimeType["application/xml"] = "Document";
|
|
||||||
documentTypeByMimeType["application/xhtml+xml"] = "Document";
|
|
||||||
documentTypeByMimeType["text/css"] = "Stylesheet";
|
|
||||||
documentTypeByMimeType["text/javascript"] = "Script";
|
|
||||||
documentTypeByMimeType["text/ecmascript"] = "Script";
|
|
||||||
documentTypeByMimeType["application/javascript"] = "Script";
|
|
||||||
documentTypeByMimeType["application/ecmascript"] = "Script";
|
|
||||||
documentTypeByMimeType["application/x-javascript"] = "Script";
|
|
||||||
documentTypeByMimeType["application/json"] = "Script";
|
|
||||||
documentTypeByMimeType["application/x-json"] = "Script";
|
|
||||||
documentTypeByMimeType["text/x-javascript"] = "Script";
|
|
||||||
documentTypeByMimeType["text/x-json"] = "Script";
|
|
||||||
documentTypeByMimeType["text/typescript"] = "Script";
|
|
||||||
|
|
||||||
export class ResourceData {
|
|
||||||
|
|
||||||
private _requestID: string;
|
|
||||||
private _resourceType: string;
|
|
||||||
private _data: any;
|
|
||||||
private _mimeType: string;
|
|
||||||
|
|
||||||
constructor(requestID: string) {
|
|
||||||
this._requestID = requestID;
|
|
||||||
}
|
|
||||||
|
|
||||||
get mimeType(): string {
|
|
||||||
return this._mimeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
set mimeType(value: string) {
|
|
||||||
if (this._mimeType !== value) {
|
|
||||||
this._mimeType = value;
|
|
||||||
|
|
||||||
var resourceType = "Other";
|
|
||||||
|
|
||||||
if (this._mimeType in documentTypeByMimeType) {
|
|
||||||
resourceType = documentTypeByMimeType[this._mimeType];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this._mimeType.indexOf("image/") !== -1) {
|
|
||||||
resourceType = "Image";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._mimeType.indexOf("font/") !== -1) {
|
|
||||||
resourceType = "Font";
|
|
||||||
}
|
|
||||||
|
|
||||||
this._resourceType = resourceType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get requestID(): string {
|
|
||||||
return this._requestID;
|
|
||||||
}
|
|
||||||
|
|
||||||
get hasTextContent(): boolean {
|
|
||||||
return [ "Document", "Stylesheet", "Script", "XHR" ].indexOf(this._resourceType) !== -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
get data(): any {
|
|
||||||
return this._data;
|
|
||||||
}
|
|
||||||
|
|
||||||
set data(value: any) {
|
|
||||||
if (this._data !== value) {
|
|
||||||
this._data = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get resourceType() {
|
|
||||||
return this._resourceType;
|
|
||||||
}
|
|
||||||
|
|
||||||
set resourceType(value: string) {
|
|
||||||
if (this._resourceType !== value) {
|
|
||||||
this._resourceType = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
2
inspector_modules.ios.ts
Normal file
2
inspector_modules.ios.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
require("./globals/decorators");
|
||||||
|
require("./debugger/webinspector");
|
@ -421,8 +421,10 @@
|
|||||||
"data/observable/observable.ts",
|
"data/observable/observable.ts",
|
||||||
"data/virtual-array/virtual-array.d.ts",
|
"data/virtual-array/virtual-array.d.ts",
|
||||||
"data/virtual-array/virtual-array.ts",
|
"data/virtual-array/virtual-array.ts",
|
||||||
"debugger/InspectorBackendCommands.ts",
|
"debugger/InspectorBackendCommands.ios.ts",
|
||||||
"debugger/debugger.ts",
|
"debugger/debugger.ts",
|
||||||
|
"debugger/webinspector.ios.ts",
|
||||||
|
"inspector_modules.ios.ts",
|
||||||
"declarations.android.d.ts",
|
"declarations.android.d.ts",
|
||||||
"declarations.d.ts",
|
"declarations.d.ts",
|
||||||
"declarations.ios.d.ts",
|
"declarations.ios.d.ts",
|
||||||
@ -442,12 +444,12 @@
|
|||||||
"fps-meter/fps-native.d.ts",
|
"fps-meter/fps-native.d.ts",
|
||||||
"fps-meter/fps-native.ios.ts",
|
"fps-meter/fps-native.ios.ts",
|
||||||
"globals/globals.ts",
|
"globals/globals.ts",
|
||||||
|
"globals/decorators.ts",
|
||||||
"http/http-request.android.ts",
|
"http/http-request.android.ts",
|
||||||
"http/http-request.d.ts",
|
"http/http-request.d.ts",
|
||||||
"http/http-request.ios.ts",
|
"http/http-request.ios.ts",
|
||||||
"http/http.d.ts",
|
"http/http.d.ts",
|
||||||
"http/http.ts",
|
"http/http.ts",
|
||||||
"http/resource-data.ts",
|
|
||||||
"image-source/image-source-common.ts",
|
"image-source/image-source-common.ts",
|
||||||
"image-source/image-source.android.ts",
|
"image-source/image-source.android.ts",
|
||||||
"image-source/image-source.d.ts",
|
"image-source/image-source.d.ts",
|
||||||
@ -712,4 +714,4 @@
|
|||||||
"atom": {
|
"atom": {
|
||||||
"rewriteTsconfig": true
|
"rewriteTsconfig": true
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user