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

BrowserFS → ZenFS #113

Open
james-pre opened this issue May 5, 2024 · 11 comments
Open

BrowserFS → ZenFS #113

james-pre opened this issue May 5, 2024 · 11 comments

Comments

@james-pre
Copy link

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?

@james-pre james-pre changed the title BrowserFS -> ZenFS BrowserFS → ZenFS May 5, 2024
@zardoy
Copy link
Owner

zardoy commented May 5, 2024

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
Copy link
Author

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
Copy link
Owner

zardoy commented May 5, 2024

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
Copy link
Owner

zardoy commented May 15, 2024

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
Copy link
Owner

zardoy commented Aug 25, 2024

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 zen-fs/archives#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: #113 (comment)

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

@james-pre
Copy link
Author

@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
Copy link
Owner

zardoy commented Oct 30, 2024

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
Copy link
Author

@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
Copy link
Owner

zardoy commented Oct 30, 2024

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
Copy link
Owner

zardoy commented Oct 30, 2024

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

@james-pre
Copy link
Author

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...

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

No branches or pull requests

2 participants