I'm trying to parse a protobuf-packet in the browser and while trying to get this working encountered several questions:
1. Is it possible to use protobuf without node and the closure library?
2. The fact that the protobuf-repository version contains the "jsbp.BinaryReader" made me play around with this option.
After playing around for a while, I figured out, that it is necessary to run "npm install" before "gulp dist" as pointed out in the documentation (
https://developers.google.com/protocol-buffers/docs/reference/javascript-generated). This generates the "google-protobuf.js" file.
Is this the correct way? Does this answer my first question with "no" - as this step requires node?
3. I now tried to run the "closure-builder" again (I use the closure library version that was installed in the previous step):
./protobuf/js/node_modules/google-closure-library/closure/bin/build/closurebuilder.py \
--root="protobuf/js" \
--root="testJS/" \
--namespace="proto.test"
The folder "testJS" contains the javascript-files produced by protoc.
This produces the error:
depstree.MultipleProvideError: Namespace "protobuf.runtime.KernelTest" provided more than once in sources:
PathSource protobuf/js/experimental/runtime/kernel/kernel_repeated_test.js
PathSource protobuf/js/experimental/runtime/kernel/kernel_test.js
My next idea was to include only the subfolders of "protobuf/js" that I need - however, this doesn't work, as I need to include "protobuf/js/message.js" because this file contains "goog.provide('jspb.Message')" - the definition of "jsbp.Message".
How can I handle this? Do I need to include all files individually with the "-i" option? I have noticed, that there is an exclude option on the current master of protobuf (which seems to break the "closure-builder" on the current master branch - but apparently there is already a fix underway) - do I need to use this option?
4. Final question - does all this stuff make sense? Is anybody using a similar approach or is there a different, simpler way to get protobuf working in a browser?