|
1 | 1 | # protobuf-net.dev |
2 | 2 |
|
3 | 3 | The site behind **[protobuf-net.dev](https://protobuf-net.dev)**: generate C# and |
4 | | -VB.NET from `.proto` schemas, and pull apart raw protobuf payloads without a schema. |
| 4 | +VB.NET from `.proto` schemas, reach `protoc` for the languages Google's compiler provides, and |
| 5 | +pull apart raw protobuf payloads without a schema. |
5 | 6 |
|
6 | | -Everything runs in the browser. There is no server, no API and no upload — schemas and payloads |
7 | | -never leave the machine they were pasted on. The site is a folder of static files. |
| 7 | +The site is a folder of static files. C#, VB.NET and payload decoding run in the browser through |
| 8 | +WebAssembly, so a schema or payload pasted into either of those never leaves the machine it was |
| 9 | +pasted on. The `protoc` targets are the exception and cannot be otherwise — `protoc` is a native |
| 10 | +executable — so they are compiled by |
| 11 | +[protoc.protobuf-net.dev](https://github.com/protobuf-net/protoc.protobuf-net.dev), and only when |
| 12 | +the user picks one of those languages and presses Generate. |
8 | 13 |
|
9 | 14 | This replaces the older ASP.NET-hosted site that lived in the |
10 | 15 | [protobuf-net](https://github.com/protobuf-net/protobuf-net) repo under `src/protogen.site`. |
@@ -40,6 +45,11 @@ npm test # vitest, unit tests for the payload parsing |
40 | 45 | npm run build # wasm + typecheck + tests + bundle -> web/dist |
41 | 46 | ``` |
42 | 47 |
|
| 48 | +The `protoc` targets point at the live service by default. To develop against a local one, set |
| 49 | +`VITE_PROTOC_ENDPOINT` — `VITE_PROTOC_ENDPOINT=http://localhost:8787 npm run dev` alongside |
| 50 | +`wrangler dev` in the |
| 51 | +[service repo](https://github.com/protobuf-net/protoc.protobuf-net.dev). |
| 52 | + |
43 | 53 | `npm run wasm` alone re-publishes the .NET side into `web/public/_framework`. That folder is |
44 | 54 | generated and git-ignored; it is copied verbatim rather than bundled, because the .NET boot process |
45 | 55 | resolves its own content-hashed filenames. |
@@ -152,20 +162,42 @@ are live. |
152 | 162 |
|
153 | 163 | ## Scope |
154 | 164 |
|
155 | | -**C# and VB.NET only.** The old site also offered C++, Java, JavaScript, Objective-C, PHP, Python |
156 | | -and Ruby by shelling out to `protoc` on the server. `protoc` is a native executable and cannot run |
157 | | -client-side, so those targets are gone rather than quietly broken. |
158 | | - |
159 | | -Compiling `protoc` itself to WebAssembly was investigated and parked. There is no maintained build: |
160 | | -`kwonoj/protobuf-wasm` and `mjz20/protobuf_wasm` patch the protobuf *runtime* for Emscripten and |
161 | | -explicitly do not build the compiler, and the one recent attempt at the compiler proper |
| 165 | +**C# and VB.NET locally; everything else through `protoc`.** protobuf-net generates the first two, |
| 166 | +in the browser. C++, Java, Kotlin, Objective-C, PHP, Python, Ruby and Google's own C# come from |
| 167 | +`protoc`, which is a native executable and cannot run client-side, so they are compiled by |
| 168 | +[protoc.protobuf-net.dev](https://github.com/protobuf-net/protoc.protobuf-net.dev) — a Cloudflare |
| 169 | +Worker in front of a container. That repository documents the service; what matters here is the |
| 170 | +contract: |
| 171 | + |
| 172 | +- `web/src/protoc.ts` holds the target list, the endpoint and the response reader. Adding a target |
| 173 | + protoc already supports means one entry there and one in the service's own table. |
| 174 | +- The service answers with the same `GenerateResponse` shape the WebAssembly path returns, so both |
| 175 | + render through `applyResponse` in `web/src/schema.ts` and there is one code path for output, |
| 176 | + diagnostics and the editor gutter. |
| 177 | +- Nothing is sent while typing. Choosing a `protoc` target generates once, because choosing it is |
| 178 | + the decision to use it; after that the output is marked stale on edit and re-sent only when the |
| 179 | + user presses Generate. |
| 180 | +- The service carries the same `.proto` corpus that `protobuf-net.Reflection` embeds, so imports of |
| 181 | + `google/**` and `protobuf-net/**` resolve identically on both paths. Nothing about imports is |
| 182 | + sent from here. |
| 183 | + |
| 184 | +Compiling `protoc` itself to WebAssembly — which would have avoided the server altogether — was |
| 185 | +investigated and parked. There is no maintained build: `kwonoj/protobuf-wasm` and |
| 186 | +`mjz20/protobuf_wasm` patch the protobuf *runtime* for Emscripten and explicitly do not build the |
| 187 | +compiler, and the one recent attempt at the compiler proper |
162 | 188 | ([protobuf#20819](https://github.com/protocolbuffers/protobuf/issues/20819)) produces a `protoc.js` |
163 | 189 | that builds but fails code generation on path resolution. The real work is MEMFS plumbing for |
164 | 190 | `--proto_path` and generated outputs, unmaintained upstream, on top of a C++ binary that links |
165 | | -every language generator and would likely dwarf the .NET runtime. |
| 191 | +every language generator and would likely dwarf the .NET runtime. If that ever lands, the service |
| 192 | +becomes unnecessary rather than merely unfortunate. |
| 193 | + |
| 194 | +JavaScript and TypeScript are on neither list: `protoc` dropped its JavaScript generator in v21. |
| 195 | +`protobufjs` and `@bufbuild/protobuf` generate both in pure JS, so that one belongs back in the |
| 196 | +browser if it is ever worth having. |
166 | 197 |
|
167 | | -If a target language is ever worth restoring, JavaScript/TypeScript is the cheap one: `protobufjs` |
168 | | -and `@bufbuild/protobuf` generate it in pure JS with no `protoc` involved. |
| 198 | +PHP output is not syntax-highlighted. `@codemirror/legacy-modes` has no PHP mode, and |
| 199 | +`@codemirror/lang-php` brings the HTML, CSS and JavaScript parsers with it — too much weight for |
| 200 | +colouring output that is read once and copied. |
169 | 201 |
|
170 | 202 | See [`docs/trimming.md`](docs/trimming.md) for why the build suppresses `IL2104`. |
171 | 203 |
|
|
0 commit comments