Files
zeekay 4ccc8a3292 feat: browser-safe root + zapgen bin + interface grammar (v1.2.0)
Three foundation fixes for the in-flight tRPC migrations, all additive
(no struct wire-format change, no major bump):

FIX 1 — root entry is now universal (browser-safe).
  The Node-only TCP transport (ZapClient, pipeline — uses node:net) moved
  to a new `@zap-proto/zap/node` sub-path. src/index.ts re-exports only the
  universal wire runtime (wire/view/builder/envelope); dist/index.js imports
  zero Node builtins. New happy-dom test asserts the root import resolves
  under a DOM environment and that the built bundle has no node: import.

FIX 3 — ship `zapgen` as a package bin.
  New TS-native zapgen (src/zapgen/{schema,parser,emit}.ts + src/bin/zapgen.ts)
  ported from the canonical Go emitter (github.com/zap-proto/go/cmd/zapgen),
  emitting TS over @zap-proto/zap. Wired as `bin.zapgen -> dist/bin/zapgen.mjs`
  (shebang preserved by tsup). Consumers can `npx zapgen schema.zap` after
  install. README documents schema syntax, command, and output.

FIX 4 — `.zap` grammar gains `interface` + `method`.
  interface MyService { m1(in: Req) returns (out: Resp)  m2() returns () }
  Each interface codegens a typed Client class, an abstract Server class
  (with ordinal-routed dispatch), and a method-ordinal table auto-assigned
  1,2,3,... by declaration order (stable wire compat — appending never
  renumbers). Struct View/Builder emission is unchanged. Fixture
  test/fixtures/echo.zap + tests assert EchoClient/EchoServer emission and
  ordinal stability; emitted code typechecks against the runtime.
2026-06-16 11:08:34 -07:00

21 lines
492 B
Plaintext

# Echo service fixture — exercises the interface/method grammar (FIX 4).
#
# Two structs carry the request/response payloads; the interface declares one
# method whose ordinal auto-assigns to 1. zapgen must emit EchoClient,
# EchoServer, and the EchoMethod ordinal table from this — alongside the
# unchanged struct View/Builder emission.
package echo
struct EchoReq {
Msg text @0
}
struct EchoResp {
Msg text @0
}
interface Echo {
echo(req: EchoReq) returns (resp: EchoResp)
}