<commit_before>// Type definitions for SlimerJS 0.10
// Project: https://docs.slimerjs.org/current/index.html#api-reference
// Definitions by: <NAME> <https://github.com/alexwall>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped


declare var phantom: IPhantom;
declare var slimer: ISlimer;

interface ISlimer {
  version: number;
  geckoVersion: number;

  clearHttpAuth(): void;
  isExiting(): boolean;
  hasFeature(featureName: string): boolean;
  exit(returnValue?: number): void;
  wait(milliseconds: number): void;
}

interface IPhantom {

    // Properties
    args: string[];  // DEPRECATED
    cookies: ICookie[];
    cookiesEnabled: boolean;
    libraryPath: string;
    scriptName: string;  // DEPRECATED
    version: {
        major: number;
        minor: number;
        patch: number;
    };

    // Functions
    addCookie(cookie: ICookie): boolean;
    clearCookies(): void;
    deleteCookie(cookieName: string): boolean;
    exit(returnValue?: any): boolean;
    injectJs(filename: string): boolean;

    // Callbacks
    onError: (msg: string, trace: string[]) => any;
}

interface IStd {
    read(): any;
    write(arg: any): void;
}

interface ISystemModule {
    pid: number;
    platform: string;
    os: {
        architecture: string;
        name: string;
        version: string;
    };
    env: { [name: string]: string; };
    args: string[];
    standarderr: IStd;
    standardin: IStd;
    standardout: IStd;
    stdout: IStd;
    stderr: IStd;
    stdin: IStd;
}

interface IHttpConf {
    operation: string;
    data: any;
    headers: any
}

interface IWebPage {

    // Properties
    canGoBack: boolean;
    canGoForward: boolean;
    clipRect: IClipRect;
    content: string;
    cookies: ICookie[];
    customHeaders: { [name: string]: string; };
    event: any; // :TODO: elaborate this when documentation improves
    focusedFrameName: string;
    frameContent: string;
    frameName: string;
    framePlainText: string;
    frameTitle: string;
    frameUrl: string;
    framesCount: number;
    framesName: any; // :TODO: elaborate this when documentation improves
    libraryPath: string;
    navigationLocked: boolean;
    offlineStoragePath: string;
    offlineStorageQuota: number;
    ownsPages: boolean;
    pages: IWebPage[];
    pagesWindowName: string;
    paperSize: IPaperSize;
    plainText: string;
    scrollPosition: ITopLeft;
    settings: IWebPageSettings;
    title: string;
    url: string;
    viewportSize: ISize;
    windowName: string;
    zoomFactor: number;
    captureContent: Array<RegExp>; // slimerjs only

    // Functions
    addCookie(cookie: ICookie): boolean;
    childFramesCount(): number;  // DEPRECATED
    childFramesName(): string;  // DEPRECATED
    clearCookies(): void;
    close(): Promise<void>;
    close(): void;
    currentFrameName(): string;  // DEPRECATED
    deleteCookie(cookieName: string): boolean;
    // evaluate<R>(callback: () => R): Promise<R>;
    // evaluate<T, R>(callback: (arg: T) => R, arg: T): Promise<R>;
    // evaluate<T1, T2, R>(callback: (arg1: T1, arg2: T2) => R, arg1: T1, arg2: T2): Promise<R>;
    // evaluate<T1, T2, T3, R>(callback: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1, arg2: T2, arg3: T3): Promise<R>;
    // evaluate<R>(callback: (...args: any[]) => R, ...args: any[]): Promise<R>;
    evaluate<R>(callback: () => R, ...args: any[]): R;
    evaluateAsync(fn: () => void): void;
    evaluateJavaScript(str: string): any; // :TODO: elaborate this when documentation improves
    getPage(windowName: string): IWebPage;
    go(index: number): void;
    goBack(): void;
    goForward(): void;
    includeJs(url: string): Promise<void>;
    includeJs(url: string, callback: () => void): void;
    injectJs(filename: string): Promise<boolean>;
    injectJs(filename: string): boolean;
    open(url: string): Promise<string>;
    open(url: string, callback: (status: string) => any): Promise<string>;
    open(url: string, method: string, callback: (status: string) => any): Promise<string>; // maybe data is missing
    open(url: string, method: string, data: any, callback?: (status: string) => any): Promise<string>;
    open(url: string, method: string, data: any, headers: any, callback: (status: string) => any): Promise<string>;
    openUrl(url: string, httpConf: IHttpConf, settings: any): Promise<string>; // :TODO: elaborate this when documentation improves
    release(): void;  // DEPRECATED
    reload(): void;
    render(filename: string): Promise<void>;
    render(filename: string, options?: { format?: string; quality?: string; ratio?: number; onlyViewport?: boolean }): Promise<void>;
    renderBase64(type: string): Promise<string>;
    render(filename: string): void;
    renderBase64(format: string): string;
    sendEvent(mouseEventType: string, mouseX?: number, mouseY?: number, button?: string): Promise<void>;
    sendEvent(keyboardEventType: string, key: string, null1?: undefined, null2?: undefined, modifier?: number): Promise<void>;
    sendEvent(mouseEventType: string, mouseX?: number, mouseY?: number, button?: string): void;
    sendEvent(keyboardEventType: string, keyOrKeys: any, aNull?: any, bNull?: any, modifier?: number): void;
    setContent(html: string, url: string): Promise<string>;
    setContent(content: string, url: string): void;
    stop(): void;
    switchToFocusedFrame(): void;
    switchToFrame(frameName: string): void;
    switchToFrame(framePosition: number): void;
    switchToChildFrame(frameName: string): void;
    switchToChildFrame(framePosition: number): void;
    switchToMainFrame(): void;  // DEPRECATED
    switchToParentFrame(): void;  // DEPRECATED
    uploadFile(selector: string, filename: string): void;

    // Callbacks
    onAlert: (msg: string) => any;
    onCallback: () => void;  // EXPERIMENTAL
    onClosing: (closingPage: IWebPage) => any;
    onConfirm: (msg: string) => boolean;
    onConsoleMessage: (msg: string, lineNum?: number, sourceId?: string) => any;
    onError: (msg: string, trace: string[]) => any;
    onFilePicker: (oldFile: string) => string;
    onInitialized: () => any;
    onLoadFinished: (status: string) => any;
    onLoadStarted: () => any;
    onNavigationRequested: (url: string, type: string, willNavigate: boolean, main: boolean) => any;
    onPageCreated: (newPage: IWebPage) => any;
    onPrompt: (msg: string, defaultVal: string) => string;
    onResourceError: (resourceError: IResourceError) => any;
    onResourceReceived: (response: IResourceResponse) => any;
    onResourceRequested: (requestData: IResourceRequest, networkRequest: INetworkRequest) => any;
    onUrlChanged: (targetUrl: string) => any;

    // Callback triggers
    closing(closingPage: IWebPage): void;
    initialized(): void;
    javaScriptAlertSent(msg: string): void;
    javaScriptConsoleMessageSent(msg: string, lineNum?: number, sourceId?: string): void;
    loadFinished(status: string): void;<commit_msg>undefined to null<commit_after>// Type definitions for SlimerJS 0.10
// Project: https://docs.slimerjs.org/current/index.html#api-reference
// Definitions by: <NAME> <https://github.com/alexwall>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped


declare var phantom: IPhantom;
declare var slimer: ISlimer;

interface ISlimer {
  version: number;
  geckoVersion: number;

  clearHttpAuth(): void;
  isExiting(): boolean;
  hasFeature(featureName: string): boolean;
  exit(returnValue?: number): void;
  wait(milliseconds: number): void;
}

interface IPhantom {

    // Properties
    args: string[];  // DEPRECATED
    cookies: ICookie[];
    cookiesEnabled: boolean;
    libraryPath: string;
    scriptName: string;  // DEPRECATED
    version: {
        major: number;
        minor: number;
        patch: number;
    };

    // Functions
    addCookie(cookie: ICookie): boolean;
    clearCookies(): void;
    deleteCookie(cookieName: string): boolean;
    exit(returnValue?: any): boolean;
    injectJs(filename: string): boolean;

    // Callbacks
    onError: (msg: string, trace: string[]) => any;
}

interface IStd {
    read(): any;
    write(arg: any): void;
}

interface ISystemModule {
    pid: number;
    platform: string;
    os: {
        architecture: string;
        name: string;
        version: string;
    };
    env: { [name: string]: string; };
    args: string[];
    standarderr: IStd;
    standardin: IStd;
    standardout: IStd;
    stdout: IStd;
    stderr: IStd;
    stdin: IStd;
}

interface IHttpConf {
    operation: string;
    data: any;
    headers: any
}

interface IWebPage {

    // Properties
    canGoBack: boolean;
    canGoForward: boolean;
    clipRect: IClipRect;
    content: string;
    cookies: ICookie[];
    customHeaders: { [name: string]: string; };
    event: any; // :TODO: elaborate this when documentation improves
    focusedFrameName: string;
    frameContent: string;
    frameName: string;
    framePlainText: string;
    frameTitle: string;
    frameUrl: string;
    framesCount: number;
    framesName: any; // :TODO: elaborate this when documentation improves
    libraryPath: string;
    navigationLocked: boolean;
    offlineStoragePath: string;
    offlineStorageQuota: number;
    ownsPages: boolean;
    pages: IWebPage[];
    pagesWindowName: string;
    paperSize: IPaperSize;
    plainText: string;
    scrollPosition: ITopLeft;
    settings: IWebPageSettings;
    title: string;
    url: string;
    viewportSize: ISize;
    windowName: string;
    zoomFactor: number;
    captureContent: Array<RegExp>; // slimerjs only

    // Functions
    addCookie(cookie: ICookie): boolean;
    childFramesCount(): number;  // DEPRECATED
    childFramesName(): string;  // DEPRECATED
    clearCookies(): void;
    close(): Promise<void>;
    close(): void;
    currentFrameName(): string;  // DEPRECATED
    deleteCookie(cookieName: string): boolean;
    // evaluate<R>(callback: () => R): Promise<R>;
    // evaluate<T, R>(callback: (arg: T) => R, arg: T): Promise<R>;
    // evaluate<T1, T2, R>(callback: (arg1: T1, arg2: T2) => R, arg1: T1, arg2: T2): Promise<R>;
    // evaluate<T1, T2, T3, R>(callback: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1, arg2: T2, arg3: T3): Promise<R>;
    // evaluate<R>(callback: (...args: any[]) => R, ...args: any[]): Promise<R>;
    evaluate<R>(callback: () => R, ...args: any[]): R;
    evaluateAsync(fn: () => void): void;
    evaluateJavaScript(str: string): any; // :TODO: elaborate this when documentation improves
    getPage(windowName: string): IWebPage;
    go(index: number): void;
    goBack(): void;
    goForward(): void;
    includeJs(url: string): Promise<void>;
    includeJs(url: string, callback: () => void): void;
    injectJs(filename: string): Promise<boolean>;
    injectJs(filename: string): boolean;
    // open(url: string): Promise<string>;
    open(url: string, callback?: (status: string) => any): Promise<string>;
    open(url: string, method: string, callback: (status: string) => any): Promise<string>; // maybe data is missing
    open(url: string, method: string, data: any, callback?: (status: string) => any): Promise<string>;
    open(url: string, method: string, data: any, headers: any, callback: (status: string) => any): Promise<string>;
    openUrl(url: string, httpConf: IHttpConf, settings: any): Promise<string>; // :TODO: elaborate this when documentation improves
    release(): void;  // DEPRECATED
    reload(): void;
    // render(filename: string): Promise<void>;
    render(filename: string, options?: { format?: string; quality?: string; ratio?: number; onlyViewport?: boolean }): Promise<void>;
    renderBase64(type: string): Promise<string>;
    render(filename: string): void;
    renderBase64(format: string): string;
    sendEvent(mouseEventType: string, mouseX?: number, mouseY?: number, button?: string): Promise<void>;
    sendEvent(keyboardEventType: string, key: string, null1?: null, null2?: null, modifier?: number): Promise<void>;
    sendEvent(mouseEventType: string, mouseX?: number, mouseY?: number, button?: string): void;
    sendEvent(keyboardEventType: string, keyOrKeys: any, aNull?: any, bNull?: any, modifier?: number): void;
    setContent(html: string, url: string): Promise<string>;
    setContent(content: string, url: string): void;
    stop(): void;
    switchToFocusedFrame(): void;
    switchToFrame(framePosOrName: number | string): void;
    // switchToFrame(framePosition: number): void;
    switchToChildFrame(framePosOrName: number | string): void;
    // switchToChildFrame(framePosition: number): void;
    switchToMainFrame(): void;  // DEPRECATED
    switchToParentFrame(): void;  // DEPRECATED
    uploadFile(selector: string, filename: string): void;

    // Callbacks
    onAlert: (msg: string) => any;
    onCallback: () => void;  // EXPERIMENTAL
    onClosing: (closingPage: IWebPage) => any;
    onConfirm: (msg: string) => boolean;
    onConsoleMessage: (msg: string, lineNum?: number, sourceId?: string) => any;
    onError: (msg: string, trace: string[]) => any;
    onFilePicker: (oldFile: string) => string;
    onInitialized: () => any;
    onLoadFinished: (status: string) => any;
    onLoadStarted: () => any;
    onNavigationRequested: (url: string, type: string, willNavigate: boolean, main: boolean) => any;
    onPageCreated: (newPage: IWebPage) => any;
    onPrompt: (msg: string, defaultVal: string) => string;
    onResourceError: (resourceError: IResourceError) => any;
    onResourceReceived: (response: IResourceResponse) => any;
    onResourceRequested: (requestData: IResourceRequest, networkRequest: INetworkRequest) => any;
    onUrlChanged: (targetUrl: string) => any;

    // Callback triggers
    closing(closingPage: IWebPage): void;
    initialized(): void;
    javaScriptAlertSent(msg: string): void;
    javaScriptConsoleMessageSent(msg: string, lineNum?: number, sourceId?: string): void;
    loadFinished(status: string): void;
{'fraction_non_alphanumeric': 0.14263131422001868, 'fraction_numerical': 0.004886110512323058, 'mean_word_length': 3.8444135050469894, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 121, 'https://': 6, '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': '5364232', 'n_tokens_mistral': 4311, 'n_tokens_neox': 4261, 'n_words': 1187}