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


TypeScript Analyzer.resolveUrl方法代码示例

本文整理汇总了TypeScript中polymer-analyzer.Analyzer.resolveUrl方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Analyzer.resolveUrl方法的具体用法?TypeScript Analyzer.resolveUrl怎么用?TypeScript Analyzer.resolveUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在polymer-analyzer.Analyzer的用法示例。


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

示例1: assertExpectedFixes

export async function assertExpectedFixes(
    linter: Linter, analyzer: Analyzer, inputFile: string, goldenFile: string) {
  const {warnings} = await linter.lint([inputFile]);
  const edits = warnings.filter((w) => w.fix).map((w) => w.fix!);
  const loader = makeParseLoader(analyzer);
  const {editedFiles, incompatibleEdits} = await applyEdits(edits, loader);
  assert.deepEqual(incompatibleEdits, []);
  const inputFileContent = editedFiles.get(analyzer.resolveUrl(inputFile)!);
  const outputFileContent =
      (await loader(analyzer.resolveUrl(goldenFile)!)).contents;
  assert.deepEqual(inputFileContent, outputFileContent);
}
开发者ID:MehdiRaash,项目名称:tools,代码行数:12,代码来源:util.ts

示例2: constructor

  constructor(options?: Options) {
    const opts = options ? options : {};

    // In order for the bundler to use a given analyzer, we'll have to fork it
    // so we can provide our own overlayUrlLoader which falls back to the
    // analyzer's load method.
    if (opts.analyzer) {
      const analyzer = opts.analyzer;
      this._overlayUrlLoader = new InMemoryOverlayUrlLoader(analyzer);
      this.analyzer = analyzer._fork({urlLoader: this._overlayUrlLoader});
    } else {
      this._overlayUrlLoader =
          new InMemoryOverlayUrlLoader(new FsUrlLoader(resolvePath('.')));
      this.analyzer = new Analyzer({urlLoader: this._overlayUrlLoader});
    }

    this.excludes = Array.isArray(opts.excludes) ? opts.excludes : [];
    this.stripComments = Boolean(opts.stripComments);
    this.enableCssInlining =
        opts.inlineCss === undefined ? true : opts.inlineCss;
    this.enableScriptInlining =
        opts.inlineScripts === undefined ? true : opts.inlineScripts;
    this.rewriteUrlsInTemplates = Boolean(opts.rewriteUrlsInTemplates);
    this.sourcemaps = Boolean(opts.sourcemaps);
    this.strategy =
        opts.strategy || bundleManifestLib.generateSharedDepsMergeStrategy();
    this.urlMapper = opts.urlMapper ||
        bundleManifestLib.generateCountingSharedBundleUrlMapper(
            this.analyzer.resolveUrl('shared_bundle_')!);
  }
开发者ID:Polymer,项目名称:vulcanize,代码行数:30,代码来源:bundler.ts

示例3: _filterExcludesFromBundles

  /**
   * Given an array of Bundles, remove all files from bundles which are in the
   * "excludes" set.  Remove any bundles which are left empty after excluded
   * files are removed.
   */
  private _filterExcludesFromBundles(bundles: Bundle[]) {
    // Remove excluded files from bundles.
    for (const bundle of bundles) {
      for (const exclude of this.excludes) {
        const resolvedExclude = this.analyzer.resolveUrl(exclude);
        if (!resolvedExclude) {
          continue;
        }
        bundle.files.delete(resolvedExclude);
        const excludeAsFolder = exclude.endsWith('/') ? exclude : exclude + '/';
        for (const file of bundle.files) {
          if (file.startsWith(excludeAsFolder)) {
            bundle.files.delete(file);
          }
        }
      }
    }

    let b = 0;
    while (b < bundles.length) {
      if (bundles[b].files.size < 0) {
        bundles.splice(b, 1);
        continue;
      }
      ++b;
    }
  }
开发者ID:Polymer,项目名称:vulcanize,代码行数:32,代码来源:bundler.ts

示例4: assertFileEdited

export async function assertFileEdited(
    analyzer: Analyzer,
    editResult: EditResult,
    inputFile: string,
    goldenFile: string) {
  assert.deepEqual(
      editResult.editedFiles.get(analyzer.resolveUrl(inputFile)!),
      (await analyzer.load(analyzer.resolveUrl(goldenFile)!)));
}
开发者ID:MehdiRaash,项目名称:tools,代码行数:9,代码来源:util.ts

示例5: generatePushManifest

  async generatePushManifest(): Promise<PushManifest> {
    // Bundler's buildDepsIndex code generates an index with all fragments and
    // all lazy-imports encountered are the keys, so we'll use that function to
    // produce the set of all fragments to generate push-manifest entries for.
    const depsIndex = await buildDepsIndex(
        this.config.allFragments.map(
            (path) => this.analyzer.resolveUrl(urlFromPath(
                this.config.root as LocalFsPath, path as LocalFsPath))!),
        this.analyzer);
    // Don't include bundler's fake "sub-bundle" URLs (e.g.
    // "foo.html>external#1>bar.js").
    const allFragments =
        new Set([...depsIndex.keys()].filter((url) => !url.includes('>')));

    // If an app-shell exists, use that as our main push URL because it has a
    // reliable URL. Otherwise, support the single entrypoint URL.
    const mainPushEntrypointUrl = this.analyzer.resolveUrl(urlFromPath(
        this.config.root as LocalFsPath,
        this.config.shell as LocalFsPath ||
            this.config.entrypoint as LocalFsPath))!;
    allFragments.add(mainPushEntrypointUrl);

    // Generate the dependencies to push for each fragment.
    const pushManifest: PushManifest = {};
    for (const fragment of allFragments) {
      const absoluteFragmentUrl =
          '/' + this.analyzer.urlResolver.relative(fragment);
      pushManifest[absoluteFragmentUrl] =
          await generatePushManifestEntryForUrl(this.analyzer, fragment);
    }

    // The URLs we got may be absolute or relative depending on how they were
    // declared in the source. This will normalize them to relative by stripping
    // any leading slash.
    //
    // TODO Decide whether they should really be relative or absolute. Relative
    // was chosen here only because most links were already relative so it was
    // a smaller change, but
    // https://github.com/GoogleChrome/http2-push-manifest actually shows
    // relative for the keys and absolute for the values.
    const normalize = (p: string) =>
        path.posix.join(this.basePath, p).replace(/^\/+/, '');

    const normalized: PushManifest = {};
    for (const source of Object.keys(pushManifest)) {
      const targets: PushManifestEntryCollection = {};
      for (const target of Object.keys(pushManifest[source])) {
        targets[normalize(target)] = pushManifest[source][target];
      }
      normalized[normalize(source)] = targets;
    }
    return normalized;
  }
开发者ID:Polymer,项目名称:tools,代码行数:53,代码来源:push-manifest.ts

示例6: _analyzeAll

  private async _analyzeAll(files: string[]) {
    const analysis = await this._analyzer.analyze(files);
    const documents = [];
    const warnings = [];

    for (const file of files) {
      const result = analysis.getDocument(this._analyzer.resolveUrl(file));
      if (!result) {
        continue;
      } else if (result instanceof Document) {
        documents.push(result);
      } else {
        warnings.push(result);
      }
    }

    return {documents, warnings, analysis};
  }
开发者ID:asdfg9822,项目名称:polymer-linter,代码行数:18,代码来源:linter.ts

示例7: _transformIter

  protected async *
      _transformIter(files: AsyncIterable<File>): AsyncIterable<File> {
    for await (const file of files) {
      this.files.set(
          this.analyzer.resolveUrl(urlFromPath(
              this.config.root as LocalFsPath, file.path as LocalFsPath))!,
          file);
      yield file;
    }

    // Generate a push manifest, and propagate any errors up.
    const pushManifest = await this.generatePushManifest();
    const pushManifestContents = JSON.stringify(pushManifest, undefined, '  ');
    // Push the new push manifest into the stream.
    yield new File({
      path: this.outPath,
      contents: Buffer.from(pushManifestContents),
    });
  }
开发者ID:Polymer,项目名称:tools,代码行数:19,代码来源:push-manifest.ts

示例8: test

 test('external script tag inlines an es6 module', async () => {
   const root = 'test/html/inline-es6-modules';
   const analyzer = new Analyzer({
     urlResolver: new FsUrlResolver(root),
     urlLoader: new FsUrlLoader(root),
     moduleResolution: 'node',
   });
   const bundler = new Bundler({analyzer});
   const externalScriptToNodeModuleUrl =
       analyzer.resolveUrl('external-script-to-node-module.html')!;
   const {documents} = await bundler.bundle(
       await bundler.generateManifest([externalScriptToNodeModuleUrl]));
   const externalScriptToNodeModuleDoc =
       documents.getHtmlDoc(externalScriptToNodeModuleUrl)!;
   assert.deepEqual(externalScriptToNodeModuleDoc.content, heredoc`
     <script type="module">
     const feature = {
       cool: 'thing'
     };
     console.log('imported some-package/main.js');
     </script>
   `);
 });
开发者ID:MehdiRaash,项目名称:tools,代码行数:23,代码来源:html-bundler_test.ts

示例9: test

    test('with 2 entrypoints and shell, all deps in their places', async () => {
      const analyzer = getAnalyzer();
      const {documents} =
          await bundleMultiple([shell, entrypoint1, entrypoint2], {
            strategy: generateShellMergeStrategy(analyzer.resolveUrl(shell)!, 2)
          });
      assert.equal(documents.size, 3);
      const shellDoc = documents.get(shell)!.ast as dom5.Node;
      assert.isDefined(shellDoc);
      const entrypoint1Doc = documents.get(entrypoint1)!.ast as dom5.Node;
      assert.isDefined(entrypoint1Doc);
      const entrypoint2Doc = documents.get(entrypoint2)!.ast as dom5.Node;
      assert.isDefined(entrypoint2Doc);
      const shellDiv = dom5.predicates.hasAttrValue('id', 'shell');
      const shellImport = dom5.predicates.AND(
          dom5.predicates.hasTagName('link'),
          dom5.predicates.hasSpaceSeparatedAttrValue('rel', 'import'),
          dom5.predicates.hasAttrValue('href', 'shell.html'));
      const commonModule = domModulePredicate('common-module');
      const elOne = domModulePredicate('el-one');
      const elTwo = domModulePredicate('el-two');
      const depOne = domModulePredicate('el-dep1');
      const depTwo = domModulePredicate('el-dep2');

      // Check that all the dom modules are in their expected shards
      assertContainsAndExcludes(
          shellDoc, [shellDiv, commonModule, depOne], [elOne, elTwo, depTwo]);
      assertContainsAndExcludes(
          entrypoint1Doc,
          [elOne],
          [commonModule, elTwo, depOne, depTwo, shellImport]);
      assertContainsAndExcludes(
          entrypoint2Doc,
          [elTwo, depTwo],
          [commonModule, elOne, depOne, shellImport]);
    });
开发者ID:MehdiRaash,项目名称:tools,代码行数:36,代码来源:shards_test.ts


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