<commit_before>﻿// imported for definition purposes only
import * as httpModule from "../../http";
import * as imageSourceModule from "../../image-source";
import * as platformModule from "../../platform";
import * as fsModule from "../../file-system";

import { getFilenameFromUrl } from "./http-request-common";
import { NetworkAgent } from "../../debugger/debugger";

export enum HttpResponseEncoding {
    UTF8,
    GBK
}

function parseJSON(source: string): any {
    const src = source.trim();
    if (src.lastIndexOf(")") === src.length - 1) {
        return JSON.parse(src.substring(src.indexOf("(") + 1, src.lastIndexOf(")")));
    }

    return JSON.parse(src);
}

let requestIdCounter = 0;
const pendingRequests = {};

let imageSource: typeof imageSourceModule;
function ensureImageSource() {	
    if (!imageSource) {	
        imageSource = require("image-source");	
    }	
}

let platform: typeof platformModule;	
function ensurePlatform() {	
    if (!platform) {	
        platform = require("platform");	
    }	
}

let fs: typeof fsModule;
function ensureFileSystem() {	
    if (!fs) {	
        fs = require("file-system");	
    }	
}

let completeCallback: org.nativescript.widgets.Async.CompleteCallback;
function ensureCompleteCallback() {
    if (completeCallback) {
        return;
    }

    completeCallback = new org.nativescript.widgets.Async.CompleteCallback({
        onComplete: function (result: any, context: any) {
            // as a context we will receive the id of the request
            onRequestComplete(context, result);
        },
        onError: function (error: string, context: any) {
            onRequestError(error, context);
      },
    });
}

function onRequestComplete(requestId: number, result: org.nativescript.widgets.Async.Http.RequestResult) {<commit_msg>chore: Fix http-request short imports on Android.<commit_after>﻿// imported for definition purposes only
import * as httpModule from "../../http";
import * as imageSourceModule from "../../image-source";
import * as platformModule from "../../platform";
import * as fsModule from "../../file-system";

import { getFilenameFromUrl } from "./http-request-common";
import { NetworkAgent } from "../../debugger/debugger";

export enum HttpResponseEncoding {
    UTF8,
    GBK
}

function parseJSON(source: string): any {
    const src = source.trim();
    if (src.lastIndexOf(")") === src.length - 1) {
        return JSON.parse(src.substring(src.indexOf("(") + 1, src.lastIndexOf(")")));
    }

    return JSON.parse(src);
}

let requestIdCounter = 0;
const pendingRequests = {};

let imageSource: typeof imageSourceModule;
function ensureImageSource() {
    if (!imageSource) {
        imageSource = require("tns-core-modules/image-source");
    }
}

let platform: typeof platformModule;
function ensurePlatform() {
    if (!platform) {
        platform = require("tns-core-modules/platform");
    }
}

let fs: typeof fsModule;
function ensureFileSystem() {
    if (!fs) {
        fs = require("tns-core-modules/file-system");
    }
}

let completeCallback: org.nativescript.widgets.Async.CompleteCallback;
function ensureCompleteCallback() {
    if (completeCallback) {
        return;
    }

    completeCallback = new org.nativescript.widgets.Async.CompleteCallback({
        onComplete: function (result: any, context: any) {
            // as a context we will receive the id of the request
            onRequestComplete(context, result);
        },
        onError: function (error: string, context: any) {
            onRequestError(error, context);
      },
    });
}

function onRequestComplete(requestId: number, result: org.nativescript.widgets.Async.Http.RequestResult) {
{'fraction_non_alphanumeric': 0.13665943600867678, 'fraction_numerical': 0.0021691973969631237, 'mean_word_length': 3.168361581920904, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2493961', 'n_tokens_mistral': 1043, 'n_tokens_neox': 1036, 'n_words': 274}