zardoy / minecraft-web-client

The most advanced Minecraft online/offline client + server in your browser! [IOS SUPPORTED]
https://mcraft.fun
MIT License
56 stars 56 forks source link

BrowserFS → ZenFS #113

Open james-pre opened 7 months ago

james-pre commented 7 months ago

Hey @zardoy, I've been going through the dependents of browserfs and found this repository.

As you already know, browserfs is deprecated and I am working on ZenFS.

Would you be interested in updating migrating to ZenFS?

zardoy commented 7 months ago

I was already experimenting with ZenFS in a separate project since I was running some issues: eg IOS crashing the page when trying to load big files (~400 MB zips). Also need to update internal patching so I can track all read / write operations, redirect or disable them as needed.

Would you be interested in updating and migrating to ZenFS?

Yes, of course!

james-pre commented 7 months ago

Also need to update internal patching so I can track all read / write operations

I plan on adding some event system to the ZenFS internals as part of the FS watch features, though it wouldn't allow for changing the operations.

If you want to change operations it may be better to write a class that extends ZipFS and then intercept the operations using that.

zardoy commented 7 months ago

If you want to change operations it may be better to write a class that extends ZipFS and then intercept the operations using that.

Thanks, will try it, though I also plan to use remote HTTP and WebAccess backends (already using the last one for writing files back to the user's selected folder). Currently, I'm just overwriting FS methods so it was easy to patch for me the internals...

zardoy commented 6 months ago

Sorry, the suggestion to migrate to newer versions is great, but I've just realized I'll not have any time to work on it :( (just because everything works fine with the old version), but I'm definitely looking into migration for smaller codebase

zardoy commented 3 months ago

Hey, sorry, just wanted to keep you updated. Unfortunately, the old BrowserFS works just too well to remove it / migrate from it (well, maybe until https://github.com/zen-fs/zip/issues/3 is fixed :). I still want to have a clear codebase that uses updated / modern libs (that's why I had to remember your issue). The app is currently using 6 various backends (HTTPRequest, IndexedDB, Zip, LocalStorage, FileSystemAccess, GoogleDrive - made by me) and everything works perfectly for me and I don't see what ZenFS improves, moreover, ZenFS introduces new constraints: https://github.com/zardoy/minecraft-web-client/issues/113#issuecomment-2094890978

However, I might prioritize this issue if you come up with a more powerful API for taking full control over all operations!

james-pre commented 3 months ago

@zardoy,

Thanks for the update.

Adding events and the FS watch features is currently my top priority, though I've been busy with classes IRL.

I'll see if I can make some time this week and get this done. Sorry for taking so long.

zardoy commented 1 month ago

Adding events and the FS watch features is currently my top priority, though I've been busy with classes IRL.

I'll see if I can make some time this week and get this done. Sorry for taking so long.

Hey, @james-pre how are doing, still have a hope you work on the project 🙌

james-pre commented 1 month ago

@zardoy, it's all implemented, though events and watch features are handled entirely in the emulation layer. 1.0 has been out for almost a whole month now, and a ton of features have been added.

zardoy commented 1 month ago

it's all implemented, though events and watch features are handled entirely in the emulation layer

That's all is very interesting, though as I said earlier I don't need events, but interceptors (like spy-fs) so I can extend the functionality of fs. Also looking forward to ZipFS update!

zardoy commented 1 month ago

Actually, if my project used ZenFS, I think it would significantly boost your visibility!

james-pre commented 1 month ago

I don't need events, but interceptors (like spy-fs) so I can extend the functionality of fs.

It will be much easier to create your own backend, or to reuse an exiting one. For example, you could implement RPC.Port:


class MyPort implements RPC.Port {
    _listener;

    constructor(public postMessage: (typeof RPC.Port)['postMessage']) {}

    public emit(value) {
        this._listener?.(value);
    }
    public on(_event, listener) {
        this._listener = listener;
    }
    public off() {
        this._listener = null;
    }
}

const back = new MyPort((value) => front._listener(value));

const front = new MyPort((value) => {
    if (!RPC.isMessage(value)) return;

    // Do something

    const newValue = value; // pretend something got changed

    back._listener(newValue);
});

const interceptedFS = InMemory.create({ name: 'example' });

attachFS(back, interceptedFS);

await configure({
    mounts: {
        '/': { backend: Port, port: front },
    },
});

Also looking forward to ZipFS update!

Could you please clarify what exactly you're talking about? A lot of stuff has happened over the past few months...