当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript chrome-launcher.LaunchedChrome类代码示例

本文整理汇总了TypeScript中chrome-launcher.LaunchedChrome的典型用法代码示例。如果您正苦于以下问题:TypeScript LaunchedChrome类的具体用法?TypeScript LaunchedChrome怎么用?TypeScript LaunchedChrome使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了LaunchedChrome类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: create

export async function create(html: string, options?: CreateOptions): Promise<CreateResult> {
  const myOptions = Object.assign({}, options);
  let chrome: LaunchedChrome;

  myOptions._canceled = false;
  if (myOptions.timeout >= 0) {
    setTimeout(() => {
      myOptions._canceled = true;
    }, myOptions.timeout);
  }

  await throwIfCanceled(myOptions);
  if (!myOptions.host && !myOptions.port) {
    await throwIfCanceled(myOptions);
    chrome = await launchChrome(myOptions);
  }

  try {
    const tab = await CDP.New(myOptions);
    try {
      return await generate(html, myOptions, tab);
    } finally {
      await CDP.Close({ ...myOptions, id: tab.id });
    }
  } finally {
    if (chrome) {
      await chrome.kill();
    }
  }
}
开发者ID:timonweb-forks,项目名称:html-pdf-chrome,代码行数:30,代码来源:index.ts

示例2: runLighthouse

export async function runLighthouse(
    url: string, flags: Flags, config: Object|null): Promise<{}|void> {
  let launchedChrome: LaunchedChrome|undefined;

  try {
    launchedChrome = await getDebuggableChrome(flags);
    flags.port = launchedChrome.port;
    const results = await lighthouse(url, flags, config);

    const artifacts = results.artifacts;
    delete results.artifacts;

    await saveResults(results, artifacts!, flags);
    if (flags.interactive) {
      await performanceXServer.hostExperiment({url, flags, config}, results);
    }

    await launchedChrome.kill();

    return results;
  } catch (err) {
    if (typeof launchedChrome !== 'undefined') {
      await launchedChrome!.kill();
    }

    return handleError(err);
  }
}
开发者ID:hmeng7,项目名称:lighthouse,代码行数:28,代码来源:run.ts

示例3: launchChrome

export function launchChrome(url): [Promise<void>, IChromeProcess] {
    let resolveFinish: (code: number) => void;
    let rejectFinish: (err: Error) => void;
    let launchedChrome: LaunchedChrome;
    let res: IChromeProcess = {
        // crash/finish notification does not work with chrome-launcher
        finish: new Promise<number>((resolve, reject) => {
            resolveFinish = resolve;
            rejectFinish = reject;
        }),
        kill() {
            if (launchedChrome) launchedChrome.kill();
        }
    };

    return [
        chromeLauncher
            .launch({
                startingUrl: url,
                chromeFlags: ["--headless", "--disable-gpu"]
            })
            .then(chrome => {
                launchedChrome = chrome;
            })
            .catch(rejectFinish),
        res
    ];
}
开发者ID:Bobris,项目名称:bobril-build,代码行数:28,代码来源:chromeRunner.ts

示例4: close

  async close(): Promise<void> {
    const { client } = await this.runtimeClientPromise

    if (this.options.cdp.closeTab) {
      await CDP.Close({ id: client.target.id })
    }

    if (this.chromeInstance) {
      this.chromeInstance.kill()
    }

    await client.close()
  }
开发者ID:nylen,项目名称:chromeless,代码行数:13,代码来源:local.ts


注:本文中的chrome-launcher.LaunchedChrome类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。