Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 160 additions & 26 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
"@types/wavesurfer.js": "^3.3.2",
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"@zenfs/core": "^0.9.7",
"@zenfs/dom": "^0.2.6",
"@zenfs/core": "^1.0.0",
"@zenfs/dom": "^1.0.0",
"babel-loader": "^9.1.0",
"bootstrap": "^4.6.0",
"clean-webpack-plugin": "^4.0.0",
Expand Down
26 changes: 12 additions & 14 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type FaustEditorEnv = {
jQuery: JQueryStatic;
faustCompiler: FaustCompiler;
recorder: Recorder;
browserFS: typeof import("@zenfs/core").promises;
zenfs: typeof import("@zenfs/core").promises;
};
type FaustEditorAudioEnv = {
audioCtx?: AudioContext;
Expand Down Expand Up @@ -108,14 +108,12 @@ $(async () => {
const faustPrimitiveLib = await faustPrimitiveLibFile.text();
libFaust.fs().writeFile("/usr/share/faust/primitives.lib", faustPrimitiveLib);

const BrowserFS = await import("@zenfs/core");
const { configureSingle, promises: zenfs } = await import("@zenfs/core");
const { IndexedDB } = await import("@zenfs/dom");
await BrowserFS.configure({
await configureSingle({
backend: IndexedDB,
storeName: "FaustIDE" as any
storeName: "FaustIDE"
});
const bfs = BrowserFS.promises;

const JSZip = (await import("jszip") as any).default as import("jszip");
const WaveSurfer = (await import("wavesurfer.js") as any).default as import("wavesurfer.js");
const QRCode = await import("qrcode");
Expand Down Expand Up @@ -186,13 +184,13 @@ $(async () => {
const loadProject = async () => {
const mfs = libFaust.fs();
mfs.mkdir(PROJECT_DIR);
let files = await bfs.readdir("/");
let files = await zenfs.readdir("/");
files = files.filter(n => n !== "." && n !== "..");
if (!compileOptions.saveCode) {
await Promise.all(files.map(filename => bfs.unlink(filename)));
await Promise.all(files.map(filename => zenfs.unlink(filename)));
} else {
await Promise.all(files.map(async (filename) => {
const data = await bfs.readFile(filename);
const data = await zenfs.readFile(filename);
mfs.writeFile(PROJECT_DIR + filename, new Uint8Array(data.buffer));
}));
}
Expand Down Expand Up @@ -522,7 +520,7 @@ $(async () => {
editor,
faustCompiler,
recorder: new Recorder(),
browserFS: bfs
zenfs
};
safeStorage.setItem("faust_editor_version", VERSION);
uiEnv.plotScope = new StaticScope({ container: $<HTMLDivElement>("#plot-ui")[0] });
Expand Down Expand Up @@ -554,11 +552,11 @@ $(async () => {
clearTimeout(saveTimeout);
saveTimeout = setTimeout(async () => {
try {
const exist = await bfs.exists(fileName);
const exist = await zenfs.exists(fileName);
if (exist) {
await bfs.unlink(fileName);
await zenfs.unlink(fileName);
}
await bfs.writeFile(fileName, content, typeof content === "string" ? { encoding: "utf8" } : {});
await zenfs.writeFile(fileName, content, typeof content === "string" ? { encoding: "utf8" } : {});
} catch (e) {
showError(e);
}
Expand All @@ -578,7 +576,7 @@ $(async () => {
safeStorage.setItem("faust_editor_project", JSON.stringify(project));
*/
try {
await bfs.unlink(fileName);
await zenfs.unlink(fileName);
} catch (e) {
showError(e);
}
Expand Down