How to use the @hint/utils.debug function in @hint/utils

To help you get started, we’ve selected a few @hint/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webhintio / hint / packages / connector-chrome / src / chrome-launcher.ts View on Github external
/**
 * @fileoverview Launches the given browser with the right configuration to be used via the Chrome Debugging Protocol
 *
 */
import * as chromeLauncher from 'chrome-launcher';
import * as isCI from 'is-ci';

import { debug as d, fs, misc } from '@hint/utils';
import { Launcher } from '@hint/utils-debugging-protocol-common';
import { BrowserInfo, LauncherOptions } from 'hint';

const { readFileAsync, writeFileAsync } = fs;
const { delay } = misc;

const debug: debug.IDebugger = d(__filename);

export class CDPLauncher extends Launcher {
    /** Indicates if the default profile should be used by Chrome or not */
    private userDataDir: string | boolean;
    private chromeFlags: string[];

    public constructor(options: LauncherOptions) {
        const flags = options && options.flags || ['--no-default-browser-check'];

        /* istanbul ignore next */
        if (isCI) {
            flags.push('--headless', '--disable-gpu');
        } else if (process.env.DOCKER === 'true') { // eslint-disable-line no-process-env
            flags.push('--headless');
        }
github webhintio / hint / packages / utils-debugging-protocol-common / src / debugging-protocol-connector.ts View on Github external
import { contentType, debug as d, dom, HTMLDocument, HTMLElement, HttpHeaders, misc, network } from '@hint/utils';

import {
    BrowserInfo, IConnector, Engine,
    Event, FetchEnd, FetchError, ILauncher,
    Response, Request, NetworkData
} from 'hint';
import { normalizeHeaders, Requester } from '@hint/utils-connector-tools';

import { RequestResponse } from './request-response';

const { createHTMLDocument, getElementByUrl, traverse } = dom;
const { getType } = contentType;
const { cutString, delay } = misc;
const { isHTMLDocument } = network;
const debug: debug.IDebugger = d(__filename);
const lock = promisify(lockfile.lock) as (path: string, options: lockfile.Options) => Promise;
const unlock = promisify(lockfile.unlock);

export class Connector implements IConnector {
    /** The final set of options resulting of merging the users, and default ones. */
    private _options: any;
    /** The original URL to collect. */
    private _href: string = '';
    /** The final URL after redirects (if they exist) */
    private _finalHref: string = '';
    /** The instance of hint that is using this connector. */
    private _server: Engine;
    /** The client to talk to the browser. */
    private _client!: Crdp.CrdpClient;
    /** A set of requests done by the connector to retrieve initial information more easily. */
    private _requests: Map;
github webhintio / hint / packages / connector-edge / src / connector-edge-launcher.ts View on Github external
import * as net from 'net';
import * as os from 'os';
import * as path from 'path';
import { promisify } from 'util';

import * as nodeWindows from 'node-windows';

import { debug as d, logger, misc } from '@hint/utils';
import { Launcher } from '@hint/utils-debugging-protocol-common';
import { BrowserInfo, LauncherOptions } from 'hint';

const { delay } = misc;
const diagnosticsPath = require.resolve('edge-diagnostics-adapter');
const elevate = promisify(nodeWindows.elevate);

const debug = d(__filename);

export class EdgeLauncher extends Launcher {
    private retryDelay: number = 500;

    public constructor(options: LauncherOptions) {
        super(options);
    }

    /** Removes all references to the client used by `isDebuggerReady`. */
    private cleanup(client: net.Socket) {
        client.removeAllListeners();
        client.end();
        client.destroy();
        client.unref();
    }
github webhintio / hint / packages / utils-debugging-protocol-common / src / request-response.ts View on Github external
import { atob } from 'abab';
import { Crdp } from 'chrome-remote-debug-protocol';

import { contentType, debug as d, HTMLElement, HttpHeaders } from '@hint/utils';
import { Response } from 'hint';

import { normalizeHeaders, Requester } from '@hint/utils-connector-tools';

const debug: debug.IDebugger = d(__filename);

const { getContentTypeData } = contentType;

export enum RequestStatus {
    willBeSent = 'willBeSent',
    responseReceived = 'responseReceived',
    loadingFinished = 'loadingFinished',
    loadingFailed = 'loadingFailed'
}

export class RequestResponse {
    private _ignoreHTTPSErrors: boolean;

    /** The debugging protocol Network Client used to download the response body. */
    private _network: Crdp.NetworkClient;