All files / src/components/debugger DebuggerPluginUsage.tsx

100% Statements 11/11
100% Branches 2/2
100% Functions 3/3
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 501x   1x 1x 1x       1x 1x   1x         3x       3x               5x                                          
import React from "react";
import type { BuildUsagePlugin } from "lib/compiler/buildUsage";
import l10n from "shared/lib/lang/l10n";
import { DebuggerUsageCard } from "ui/debugger/DebuggerUsageCard";
import {
  RegionUsageHeader,
  RegionUsageTable,
} from "ui/debugger/DebuggerUsageTable";
import { bytesToHumanReadable } from "shared/lib/helpers/formatBytes";
import { DebuggerBankUsage } from "ui/debugger/DebuggerBankUsage";
 
export const DebuggerPluginUsage = ({
  plugins,
}: {
  plugins: BuildUsagePlugin[];
}) => (
  <DebuggerUsageCard title={l10n("FIELD_PLUGIN_MEMORY_USAGE")}>
    <RegionUsageTable>
      <RegionUsageHeader first={l10n("FIELD_PLUGIN")} />
      <tbody>
        {plugins.flatMap((plugin) => [
          <tr key={plugin.pluginName}>
            <td>{plugin.pluginName}</td>
            <td>{bytesToHumanReadable(plugin.usage.bank0)}</td>
            <td>{bytesToHumanReadable(plugin.usage.wram)}</td>
            <td>{bytesToHumanReadable(plugin.usage.bankedRom)}</td>
          </tr>,
          ...plugin.files.map((file) => (
            <tr key={`${plugin.pluginName}:${file.sourceFile}`}>
              <td>
                ↳ {file.sourceFile}
                {file.replacesDefault
                  ? ` (${l10n("FIELD_REPLACES_DEFAULT_ENGINE_FILE")})`
                  : ""}
              </td>
              <td>
                <DebuggerBankUsage size={file.usage.bank0} />
              </td>
              <td>{bytesToHumanReadable(file.usage.wram)}</td>
              <td>
                <DebuggerBankUsage size={file.usage.bankedRom} />
              </td>
            </tr>
          )),
        ])}
      </tbody>
    </RegionUsageTable>
  </DebuggerUsageCard>
);