Skip to content

Commit

Permalink
Replace memfs with lightning-fs because of Safari issue
Browse files Browse the repository at this point in the history
  • Loading branch information
colebemis committed Nov 3, 2023
1 parent 37ffe27 commit 75e2218
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 128 deletions.
164 changes: 43 additions & 121 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"preview": "vite preview"
},
"dependencies": {
"@isomorphic-git/lightning-fs": "^4.6.0",
"@xstate/react": "^4.0.0-beta.10",
"isomorphic-git": "^1.25.0",
"memfs": "^4.6.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-lag-radar": "^1.0.0",
Expand Down
15 changes: 9 additions & 6 deletions src/fs.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { FsaNodeFs } from "memfs/lib/fsa-to-node";
import { IFileSystemDirectoryHandle } from "memfs/lib/fsa/types";
import LightningFS from "@isomorphic-git/lightning-fs";

// Reference: https://github.com/streamich/memfs/blob/c8bfa38aa15f1d3c9f326e9c25c8972326193a26/demo/git-opfs/main.ts
const rootDir =
navigator.storage.getDirectory() as unknown as Promise<IFileSystemDirectoryHandle>;
const DB_NAME = "fs";

export const fs = new FsaNodeFs(rootDir);
// TODO: Investigate replacing lightning-fs with memfs + OPFS for better performance
export const fs = new LightningFS(DB_NAME);

/** Delete file system database */
export function fsWipe() {
window.indexedDB.deleteDatabase(DB_NAME);
}

0 comments on commit 75e2218

Please sign in to comment.