-
Notifications
You must be signed in to change notification settings - Fork 100
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
[feat req] Use in browser via webpack, browserify #491
Comments
yeah totally agree, that's something we want for PrismarineJS/prismarine-web-client#47 Nobody tried to do it but the minimum we need is a connection provider in node-minecraft-protocol server to replace the tcp server. Opened an issue for this there PrismarineJS/node-minecraft-protocol#829 |
Good to hear that this is already in consideration. |
In addition to a TCP alternative, we'll need to provide an alternative to FS, since browsers don't have native FS access (yet). |
Yeah world storage can be done using indexeddb |
BrowserFS would be a good way to access FS in browser. |
Maybe WebSockets for the client communication? |
No network connection is necessary in single player mode |
Fair, we could use a one-sided messaging channel with some javascript, like the way socket.io works for messages. |
All that needs to be done is use the existing event emitters. Drop nmp dep and when mineflayer does a write, the event should instead be emitted to flying squid directly. |
No serialization is needed, and when flying squid wants to write it would just go right to mineflayer bot eventemitter |
webStorage isn't an actual fs, it is emulated, and indexedDB is much faster, and with a Blob But does it even make sense to webpack it??? |
I've worked on wrapping flying-squid to let it run in the browser over at https://github.com/vantezzen/electric-squid (https://squid.blymp.io/). It's still a very rough proof-of-concept, but connecting to the server via a Minecraft Client is still (mostly) possible. There were some difficulties getting webpack to build the bundle (mainly solved by increasing the RAM limit, writing custom polyfills and patching dependencies manually) but generally it seems do-able. webpack's tree-shaking also seems to be very stressed as some small changes to the code result in the bundle size fluctuating between 50-400MB. I've used the methods discussed here to create a client-server connection via WebSockets and using IndexedDB via the level filesystem to replace the fs module. |
@vantezzen that's awesome! |
Hi everyone! I couldn't find a way to polyfill all the necessary components, so I decided to debug and modify the required code instead. |
Hey! Sounds great!
If you can figure out some branching so that both in browser and in node is
supported with the same code and contribute to this repo it would be great.
…On Thu, Aug 17, 2023, 05:18 Vitaly ***@***.***> wrote:
Hi everyone! I couldn't find a way to polyfill all the necessary
components, so I decided to debug and modify the required code instead.
Right now, I've managed to use this server in the browser and implemented
the desired singleplayer support in forked mineflayer web client
<https://github.com/zardoy/prismarine-web-client>. In the browser, we can
easily save worlds in browser memory or interact with the real file system
instead (however the sad part is that Chrome doesn't allow to open folders
in %appdata% directly). I don't have a clean solution yet, though there are
already some improvements in the fork
<http://github.com/zardoy/space-squid>
—
Reply to this email directly, view it on GitHub
<#491 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAR437VYSO24MQLV35YN2KDXVWER7ANCNFSM4ZTWTRAQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Sure thing! No worries at all, as long as you're up for reviewing the code :) |
Hello,
It would be nice if flying-squid would be webpackable to use completely client-side.
What currently limits flying-squid from being webpacked, and can these limitations be ignored to create a simple server?
The text was updated successfully, but these errors were encountered: