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

Javascript integration #10

Open
rom1504 opened this issue May 9, 2017 · 16 comments
Open

Javascript integration #10

rom1504 opened this issue May 9, 2017 · 16 comments

Comments

@rom1504
Copy link
Member

rom1504 commented May 9, 2017

@mhsjlw compiled protodefc to js using an emscripten target.
It would be nice to try and put protodefc in a API-similar to node-protodef module.

That way we could just replace node-protodef by that new module in node-minecraft-protocol and get perf gain.

I'm opening this here to talk about it, but there might not be anything to do about it in this repo.

@hansihe
Copy link
Member

hansihe commented May 9, 2017

So the plan is to make node-protodef more semantically similar to protodefc in the future then?

@rom1504
Copy link
Member Author

rom1504 commented May 9, 2017

I guess.
I mean my objective here is to be able to use protodefc in prismarinejs projects.
I think it would be nice to be able to have some kind of interchangeability with node-protodef.

I think the easier to make all this happen is just to try to use protodefc in something, for example node-minecraft-protocol, so we can see what we really need in a node-protodefc api.

The part of node-protodef api we really use are the serializer/parser transform streams. So if a node-protodefc provided that, it would probably be enough.
That example only use that for example https://github.com/ProtoDef-io/node-protodef/blob/master/example.js

https://github.com/ProtoDef-io/node-protodef/blob/master/src/serializer.js

@hansihe
Copy link
Member

hansihe commented May 9, 2017

If I where to suggest a first step to actually using protodefc in anything, it would be to add a protocol.pds file in addition to a protocol.json file in minecraft-data.

It would make sense to start with a single version, then when all of the issues are ironed out, we can start thinking about adding it for multiple versions.

Would this be something you would be open to doing?

@rom1504
Copy link
Member Author

rom1504 commented May 9, 2017

yeah I'm ok with that

@ghost
Copy link

ghost commented May 10, 2017

I'm thinking (and willing to work on something like this):

  • Some sort of build script (or task, normal script, whatever) to compile pds files to their JavaScript equivalent (see below)
  • An API close enough to node-ProtoDef to be implemented externally that can be dropped into node-minecraft-protocol, PrismarineJS projects, etc.

At the same time, I'm thinking we could completely bypass the build script, protodefc is fast, why not just take the 0.01ms startup cost to compile the pds at runtime and run it though the node-ProtoDef-compatible API?

Another option is to rewrite node-ProtoDef to use this new compiler (probably the easiest) but I think it should be 100% optional and external

@roblabla
Copy link

roblabla commented May 10, 2017 via email

@hansihe
Copy link
Member

hansihe commented May 10, 2017

What features do you need runtime compilation for? Where you thinking about plugin channel messages?

@rom1504
Copy link
Member Author

rom1504 commented May 10, 2017

Another option is to rewrite node-ProtoDef to use this new compiler (probably the easiest) but I think it should be 100% optional and external

I think it makes more sense to keep node-protodef as an interpreter and makes a new module for the compilation based version (with protodefc)

@hansihe
Copy link
Member

hansihe commented May 11, 2017

The main thing blocking this in my mind is a way to build and distribute the emscripten-compiled version of protodefc. Does anyone have any ideas how this could be done?

@ghost
Copy link

ghost commented May 11, 2017

I was thinking

  1. A build server that serves a git repo with an npm module of the latest compiled protodefc
  2. An npm module that compiles protodefc (requires rust) and then loads it into your module

I like option 2, because when you publish your module you can publish your dist/ with the build you used, but it requires developers to have Rust installed but users don't need Rust. Option 1 can be run on Jenkins or even Travis/Circle

@rom1504
Copy link
Member Author

rom1504 commented May 11, 2017

I think we can just have a node-protodefc that git submodule protodefc and has a prepublish script running the build for emscripten. Then npm publish and done.
No need to involve any CI, just publish a new version whenever needed.

@rom1504
Copy link
Member Author

rom1504 commented May 11, 2017

ah yeah same thing than option 2 of @mhsjlw

@CertainLach
Copy link
Contributor

What about moving protodefc js backend to npm?

@ghost
Copy link

ghost commented Aug 28, 2017

@creeplays https://github.com/ProtoDef-io/protodefc-prebuilt/releases

I package asmjs-unknown-emscripten

@ghost
Copy link

ghost commented May 31, 2018

FYI, we've settled on using WASM on platforms that do not have Rust installed, otherwise, we will build the native bindings.

@ghost
Copy link

ghost commented Oct 3, 2018

I still really do not like evaling it at runtime... I'd prefer to have it be part of a build system. Would it make sense to have it build a Gulp, Webpack, Parcel, etc. plugin?

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

4 participants