Home / File/ fetchFileWithCaching.js — react Source File

fetchFileWithCaching.js — react Source File

Architecture documentation for fetchFileWithCaching.js, a javascript file in the react codebase. 2 imports, 1 dependents.

File javascript BabelCompiler Validation 2 imports 1 dependents 4 functions

Entity Profile

Dependency Diagram

graph LR
  8128576f_0171_0141_7371_cfb7e102597e["fetchFileWithCaching.js"]
  627bb742_21aa_b4fd_fe2d_4a963a1f9278["utils"]
  8128576f_0171_0141_7371_cfb7e102597e --> 627bb742_21aa_b4fd_fe2d_4a963a1f9278
  55d27179_f566_db64_927b_e95655abee00["constants"]
  8128576f_0171_0141_7371_cfb7e102597e --> 55d27179_f566_db64_927b_e95655abee00
  b5e42467_7633_e234_1d51_a93bfc4818c7["index.js"]
  b5e42467_7633_e234_1d51_a93bfc4818c7 --> 8128576f_0171_0141_7371_cfb7e102597e
  style 8128576f_0171_0141_7371_cfb7e102597e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/* global chrome */

import {normalizeUrlIfValid} from 'react-devtools-shared/src/utils';
import {__DEBUG__} from 'react-devtools-shared/src/constants';

let debugIDCounter = 0;

const debugLog = (...args) => {
  if (__DEBUG__) {
    console.log(...args);
  }
};

const fetchFromNetworkCache = (url, resolve, reject) => {
  // Debug ID allows us to avoid re-logging (potentially long) URL strings below,
  // while also still associating (potentially) interleaved logs with the original request.
  let debugID = null;

  if (__DEBUG__) {
    debugID = debugIDCounter++;
    debugLog(`[main] fetchFromNetworkCache(${debugID})`, url);
  }

  chrome.devtools.network.getHAR(harLog => {
    for (let i = 0; i < harLog.entries.length; i++) {
      const entry = harLog.entries[i];
      if (url !== entry.request.url) {
        continue;
      }

      debugLog(
        `[main] fetchFromNetworkCache(${debugID}) Found matching URL in HAR`,
        url,
      );

      if (entry.getContent != null) {
        entry.getContent(content => {
          if (content) {
            debugLog(
              `[main] fetchFromNetworkCache(${debugID}) Content retrieved`,
            );

            resolve(content);
          } else {
            debugLog(
              `[main] fetchFromNetworkCache(${debugID}) Invalid content returned by getContent()`,
              content,
            );

            // Edge case where getContent() returned null; fall back to fetch.
            fetchFromPage(url, resolve, reject);
          }
        });
      } else {
        const content = entry.response.content.text;

        if (content != null) {
          debugLog(
            `[main] fetchFromNetworkCache(${debugID}) Content retrieved`,
          );
// ... (99 more lines)

Domain

Subdomains

Dependencies

  • constants
  • utils

Frequently Asked Questions

What does fetchFileWithCaching.js do?
fetchFileWithCaching.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in fetchFileWithCaching.js?
fetchFileWithCaching.js defines 4 function(s): debugLog, fetchFromNetworkCache, fetchFromPage, pendingFetchRequestsCleanup.
What does fetchFileWithCaching.js depend on?
fetchFileWithCaching.js imports 2 module(s): constants, utils.
What files import fetchFileWithCaching.js?
fetchFileWithCaching.js is imported by 1 file(s): index.js.
Where is fetchFileWithCaching.js in the architecture?
fetchFileWithCaching.js is located at packages/react-devtools-extensions/src/main/fetchFileWithCaching.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-extensions/src/main).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free