/** @jsx jsx */ import { jsx } from '@emotion/core'; import PropTypes from 'prop-types'; import { formatBytes } from '../utils/format.js'; import { createHTML } from '../utils/markup.js'; import { usePackageInfo } from './PackageInfo.js'; function getBasename(path) { const segments = path.split('/'); return segments[segments.length - 1]; } function ImageViewer({ path, uri }) { return (
{getBasename(path)}
); } function CodeListing({ highlights }) { const lines = highlights.slice(0); const hasTrailingNewline = lines.length && lines[lines.length - 1] === ''; if (hasTrailingNewline) { lines.pop(); } return (
{lines.map((line, index) => { const lineNumber = index + 1; return ( ); })} {!hasTrailingNewline && ( )}
{lineNumber}
\ No newline at end of file
); } function BinaryViewer() { return (

No preview available.

); } export default function FileViewer({ path, details }) { const { packageName, packageVersion } = usePackageInfo(); const { highlights, uri, language, size } = details; const segments = path.split('/'); const filename = segments[segments.length - 1]; return (
{formatBytes(size)} {language}{' '} View Raw
{highlights ? ( ) : uri ? ( ) : ( )}
); } if (process.env.NODE_ENV !== 'production') { FileViewer.propTypes = { path: PropTypes.string.isRequired, details: PropTypes.shape({ contentType: PropTypes.string.isRequired, highlights: PropTypes.arrayOf(PropTypes.string), // code uri: PropTypes.string, // images integrity: PropTypes.string.isRequired, language: PropTypes.string.isRequired, size: PropTypes.number.isRequired }).isRequired }; }