Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: PluginFS API #71

Open
6 of 7 tasks
BakaFT opened this issue Aug 10, 2023 · 2 comments
Open
6 of 7 tasks

Feature: PluginFS API #71

BakaFT opened this issue Aug 10, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@BakaFT
Copy link
Member

BakaFT commented Aug 10, 2023

Community devs often need to access the file system to complete certain operations, such as opening a folder for users to add or delete files, outputting logs to a file, and so on.

So a PluginFS API is needed, and it should be plugin scoped meaning that a plugin only have permission on it's own folder.
In this case top-level js will not have any permission because it don't have its own folder.

Actually I've done some job on that using std::filesystem from C++17, so I think if is ok we can move to C++17 to gain more convenience and improved cross-platform compatibility.

  • PluginFS.read
  • PluginFS.write
  • PluginFS.mkdir
  • PluginFS.stat
  • PluginFS.ls
  • PluginFS.rm
  • Scoped filesystem
@BakaFT
Copy link
Member Author

BakaFT commented Aug 26, 2023

We have added a sync-blocking PluginFS implementation in #75
API Docs: https://beta.pengu.lol/runtime-api/plugin-fs

@nomi-san nomi-san added the enhancement New feature or request label Sep 30, 2023
@nomi-san
Copy link
Member

There's a way to isolate the PluginFS for scoped plugin folder.

First remove the global PluginFS and turn it into a class.

class PluginFS {
  constructor(name) { }
  read(path) { /*do path check*/ }
  // ...
}

Pass an instance for each plugin init call.

function loadPlugin(name) {
  // ...
  ctx.fs = new PluginFS(name)
  // ...
} 
export function init(ctx) {
  ctx.read('some/path/to/file')
}

Important

With top-level JS files (aka single file plugins), they should not access fs and skip this prop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants