# @litecode-ide/virtual-file-system

> This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Latest version **1.1.1** (published 2024-01-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @litecode-ide/virtual-file-system
pnpm add @litecode-ide/virtual-file-system
yarn add @litecode-ide/virtual-file-system
bun add @litecode-ide/virtual-file-system
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2024-01-05 |
| First published | 2023-12-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 13 |
| Unpacked size | 2 MB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 12 |
| Author | abel-tefera |
| Maintainers | abel-tefera |
| Keywords | virtual, file, system, file, system, file, explorer, file, tree, folder, tabs, searching |

## Links

- npm: https://www.npmjs.com/package/@litecode-ide/virtual-file-system
- Repository: https://github.com/LiteCode-IDE/virtual-file-system
- Homepage: https://github.com/LiteCode-IDE/virtual-file-system#readme
- Issues: https://github.com/LiteCode-IDE/virtual-file-system/issues
- npm.io page: https://npm.io/package/@litecode-ide/virtual-file-system

## Dependencies (13)

- [np](https://npm.io/package/np.md) ^9.2.0
- [path](https://npm.io/package/path.md) ^0.12.7
- [uuid](https://npm.io/package/uuid.md) ^9.0.1
- [jszip](https://npm.io/package/jszip.md) ^3.10.1
- [react](https://npm.io/package/react.md) ^18.2.0
- [react-dom](https://npm.io/package/react-dom.md) ^18.2.0
- [file-saver](https://npm.io/package/file-saver.md) ^2.0.5
- [localforage](https://npm.io/package/localforage.md) ^1.10.0
- [react-redux](https://npm.io/package/react-redux.md) ^9.0.2
- [react-tooltip](https://npm.io/package/react-tooltip.md) ^5.25.0
- [redux-persist](https://npm.io/package/redux-persist.md) ^6.0.0
- [@reduxjs/toolkit](https://npm.io/package/@reduxjs/toolkit.md) ^2.0.1
- [lodash.clonedeep](https://npm.io/package/lodash.clonedeep.md) ^4.5.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.1.1 (latest) — 2024-01-05
- 1.0.3-0 (next) — 2023-12-22
- 1.1.0 — 2024-01-04
- 1.0.4 — 2023-12-22
- 1.0.3 — 2023-12-22
- 1.0.2 — 2023-12-20
- 1.0.1 — 2023-12-20
- 1.0.0 — 2023-12-20
- 0.0.26 — 2023-12-19
- 0.0.25 — 2023-12-19
- 0.0.24 — 2023-12-19
- 0.0.23 — 2023-12-19
- 0.0.22 — 2023-12-19
- 0.0.21 — 2023-12-16
- 0.0.20 — 2023-12-16
- … 20 more at https://npm.io/package/@litecode-ide/virtual-file-system/versions

## README

# @litecode-ide/virtual-file-system

**@litecode-ide/virtual-file-system** (from here onwards referred to as **_VFS_**) is an customizable, browser-based file system.

## Installation

Use the package manager npm to install VFS.

```bash
npm install @litecode-ide/virtual-file-system
```

## Simple Usage

```js
import React from "react";
import ReactDOM from "react-dom/client";

import { FileExplorer } from "@litecode-ide/virtual-file-system"; // FileExplorer component
import "@litecode-ide/virtual-file-system/dist/style.css"; // Default styles

const App = () => {
  return (
    <>
      <FileExplorer validExtensions={["html", "css", "js"]} />
    </>
  );
};

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);
```

To use logos with file types, create a css class `[extension]-logo`

```css
.html-logo {
  background-image: url("./assets/html.svg");
}
```

You can clone a more detailed example from [GitHub](https://github.com/LiteCode-IDE/vfs-sample.git). Alternatively run the live example on [CodeSandbox](https://codesandbox.io/p/github/LiteCode-IDE/vfs-sample/main?layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clqci8er30006356vfnd2iny4%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clqci8er30002356v3zglr9d3%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clqci8er30004356vrajed05p%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clqci8er30005356vp8n5i57j%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B40%252C60%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clqci8er30002356v3zglr9d3%2522%253A%257B%2522id%2522%253A%2522clqci8er30002356v3zglr9d3%2522%252C%2522tabs%2522%253A%255B%255D%257D%252C%2522clqci8er30005356vp8n5i57j%2522%253A%257B%2522id%2522%253A%2522clqci8er30005356vp8n5i57j%2522%252C%2522activeTabId%2522%253A%2522clqci9sgs00bu356vreccsav2%2522%252C%2522tabs%2522%253A%255B%257B%2522type%2522%253A%2522ENV_SETUP%2522%252C%2522id%2522%253A%2522clqci8etp000o356vpam546dt%2522%252C%2522mode%2522%253A%2522permanent%2522%257D%252C%257B%2522type%2522%253A%2522UNASSIGNED_PORT%2522%252C%2522port%2522%253A5173%252C%2522id%2522%253A%2522clqci9sgs00bu356vreccsav2%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522path%2522%253A%2522%252F%2522%257D%255D%257D%252C%2522clqci8er30004356vrajed05p%2522%253A%257B%2522id%2522%253A%2522clqci8er30004356vrajed05p%2522%252C%2522activeTabId%2522%253A%2522clqci8er30003356v0nijrgme%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clqci8er30003356v0nijrgme%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TERMINAL%2522%252C%2522shellId%2522%253A%2522clqci8f5r000redh5hdbxd7po%2522%257D%252C%257B%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522dev%2522%252C%2522id%2522%253A%2522clqci8f9w005c356vc7x0fxhk%2522%252C%2522mode%2522%253A%2522permanent%2522%257D%255D%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Afalse%252C%2522sidebarPanelSize%2522%253A0%257D).

## List of Exported Components

- FileExplorer\
  [<img src="sample/structure.gif" width="200"/>](sample/structure.gif)

- BreadCrumbs\
  [<img src="sample/breadcrumbs.gif" width="200"/>](sample/breadcrumbs.gif)

- Tabs\
  [<img src="sample/tabs.gif" width="300"/>](sample/tabs.gif)

- Search\
  [<img src="sample/search.gif" width="200"/>](sample/search.gif)

## API

VFS comes with a typescript definition file.

```ts
declare module "@litecode-ide/virtual-file-system" {
  type ItemType = "file" | "folder";

  interface BreadcrumbsProps {
    containerClassName?: string;
    textClassName?: string;
    miniFolderCollapseBtnClassName?: string;
    miniFolderCollapseBtnStyle?: React.CSSProperties;
    miniFolderContainerClassName?: string;
    itemTitleClassName?: string;
    onBreadcrumbFileClick?: (id: string) => void;
  }

  interface StructureProps {
    deleteConfirmationClassName?: string;
    fileInputClassName?: string;
    fileInputStyle?: React.CSSProperties;
    contextMenuClassName?: string;
    contextMenuHrColor?: string;
    contextMenuClickableAreaClassName?: string;
    fileActionsBtnClassName?: string;
    projectName?: string;
    fileActionsDisableCollapse?: true;
    fileActionsDisableTooltip?: true;
    fileActionsDisableDownload?: true;
    folderCollapseBtnClassname?: string;
    folderCollapseBtnStyle?: React.CSSProperties;
    folderThreeDotPrimaryClass?: string;
    folderThreeDotSecondaryClass?: string;
    folderClickableAreaClassName?: string;
    folderSelectedClickableAreaClassName?: string;
    folderContextSelectedClickableAreaClassName?: string;
    itemTitleClassName?: string;
    structureContainerClassName?: string;
    containerHeight?: string;
    onItemSelected?: (item: { id: string; type: ItemType }) => void;
    onNewItemClick?: (parentFolderId: string, type: ItemType) => void;
    onAreaCollapsed?: (collapsed: boolean) => void;
    onItemContextSelected?: (item: { id: string; type: ItemType }) => void;
    onNodeDeleted?: (id: string) => void;
    onNewItemCreated?: (id: string) => void;
    validExtensions: string[];
  }

  interface TabsProps {
    containerClassName?: string;
    tabClassName?: string;
    selectedTabClassName?: string;
    onTabClick?: (id: string) => void;
    onTabClose?: (id: string) => void;
  }

  interface MatchingFile {
    id: string;
    name: string;
    extension: string;
    matches: MatchingLine[];
  }

  interface MatchingLine {
    line: number;
    content: string;
  }

  interface SearchResults {
    files: MatchingFile[];
    numOfResults: number;
    numOfLines: number;
  }

  interface SearchInputProps {
    className?: string;
    style?: React.CSSProperties;
    onSearchFiles?: (searchTerm: string, searchResults: SearchResults) => void;
  }

  interface SearchContainerProps {
    highlightedTextClassName?: string;
    headerClassName?: string;
    headerStyle?: React.CSSProperties;
    titleClassName?: string;
    searchResultClicked: (fileId: string, line: number) => void;
  }

  const FileExplorer: React.FC<StructureProps>;
  const TabsList: React.FC<TabsProps>;
  const SearchInput: React.FC<SearchInputProps>;
  const Breadcrumbs: React.FC<BreadcrumbsProps>;
  const SearchResults: React.FC<SearchContainerProps>;
  const updateFile: (id: string, content: string) => void;
  const getFileTree: () => Record<
    string,
    {
      id: string;
      content: string;
    }
  >;
  const getSelectedFile: () => string;

  export {
    FileExplorer,
    TabsList,
    SearchResults,
    Breadcrumbs,
    SearchInput,
    getFileTree,
    updateFile,
    getSelectedFile,
  };
}
```

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

## License

[MIT](./LICENSE)

---
_Source: https://npm.io/package/@litecode-ide/virtual-file-system · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
