Skip to content

Commit

Permalink
🔨 fix file format & import
Browse files Browse the repository at this point in the history
  • Loading branch information
nomi-san committed Aug 20, 2023
1 parent bebeef6 commit 2aa4a77
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 47 deletions.
92 changes: 46 additions & 46 deletions plugins/src/preload/api/PluginFs.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
import native from './native';
import { native } from './native';

window.PluginFS = {
read(path: string) {
return new Promise<string | undefined>((resolve) => {
const pluginName = getScriptPath()?.match(/\/([^/]+)\/index\.js$/)?.[1]
const result = native.ReadFile(pluginName + "/" + path);
resolve(result);
});
},
write(path: string, content: string, enableAppendMode: boolean = false) {
return new Promise<boolean>((resolve) => {
const pluginName = getScriptPath()?.match(/\/([^/]+)\/index\.js$/)?.[1]
const result = native.WriteFile(pluginName + "/" + path, content, enableAppendMode);
if(!result){
console.log(`PluginFS.write failed on ${path}. Please ask the plugin developer for help.`)
}
resolve(result);
});
},
mkdir(path: string) {
return new Promise<boolean>((resolve) => {
const pluginName = getScriptPath()?.match(/\/([^/]+)\/index\.js$/)?.[1]
const result = native.MkDir(pluginName!,path);
resolve(result);
});
},
stat(path: string) {
return new Promise<FileStat | undefined>((resolve) => {
const pluginName = getScriptPath()?.match(/\/([^/]+)\/index\.js$/)?.[1]
const result = native.Stat(pluginName + "/" + path);
resolve(result);
});
},
ls(path: string) {
return new Promise<string[] | undefined>((resolve) => {
const pluginName = getScriptPath()?.match(/\/([^/]+)\/index\.js$/)?.[1]
const result = native.Ls(pluginName + "/" + path);
resolve(result);
});
},
rm(path: string, recursively: boolean = false) {
return new Promise<number>((resolve) => {
const pluginName = getScriptPath()?.match(/\/([^/]+)\/index\.js$/)?.[1]
const result = native.Remove(pluginName + "/" + path, recursively);
resolve(result);
});
}
read(path: string) {
return new Promise<string | undefined>((resolve) => {
const pluginName = getScriptPath()?.match(/\/([^/]+)\/index\.js$/)?.[1]
const result = native.ReadFile(pluginName + '/' + path);
resolve(result);
});
},
write(path: string, content: string, enableAppendMode: boolean = false) {
return new Promise<boolean>((resolve) => {
const pluginName = getScriptPath()?.match(/\/([^/]+)\/index\.js$/)?.[1]
const result = native.WriteFile(pluginName + '/' + path, content, enableAppendMode);
if (!result) {
console.warn(`PluginFS.write failed on ${path}. Please ask the plugin developer for help.`)
}
resolve(result);
});
},
mkdir(path: string) {
return new Promise<boolean>((resolve) => {
const pluginName = getScriptPath()?.match(/\/([^/]+)\/index\.js$/)?.[1];
const result = native.MkDir(pluginName!, path);
resolve(result);
});
},
stat(path: string) {
return new Promise<FileStat | undefined>((resolve) => {
const pluginName = getScriptPath()?.match(/\/([^/]+)\/index\.js$/)?.[1];
const result = native.Stat(pluginName + '/' + path);
resolve(result);
});
},
ls(path: string) {
return new Promise<string[] | undefined>((resolve) => {
const pluginName = getScriptPath()?.match(/\/([^/]+)\/index\.js$/)?.[1];
const result = native.Ls(pluginName + '/' + path);
resolve(result);
});
},
rm(path: string, recursively: boolean = false) {
return new Promise<number>((resolve) => {
const pluginName = getScriptPath()?.match(/\/([^/]+)\/index\.js$/)?.[1];
const result = native.Remove(pluginName + '/' + path, recursively);
resolve(result);
});
}
}
2 changes: 1 addition & 1 deletion plugins/src/preload/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { native } from './native';

import './DataStore';
import './Effect';
import './PluginFs';
import './PluginFS';

window.openDevTools = function (remote?: boolean) {
native.OpenDevTools(Boolean(remote));
Expand Down

0 comments on commit 2aa4a77

Please sign in to comment.