Add capnweb-typecheck for TypeScript RPC validation codegen#169
Draft
teamchong wants to merge 9 commits into
Draft
Add capnweb-typecheck for TypeScript RPC validation codegen#169teamchong wants to merge 9 commits into
teamchong wants to merge 9 commits into
Conversation
🦋 Changeset detectedLatest commit: 23c1f7e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
commit: |
c0dc243 to
a762c16
Compare
e1b7d41 to
400182b
Compare
400182b to
7d866ac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds build-time TypeScript RPC validation codegen to the single
capnwebpackage. Thecapnwebbin readsRpcTargetclasses from TypeScript and generates runtime validators that fire when RPC methods are called.capnwebstays dependency-free at install time. Tooling is exposed as thecapnweb typecheck genCLI command,capnweb/vite, and the generated-code-onlycapnweb/internal/typechecksubpath.What this PR adds
Typecheck tooling in
capnweb:capnwebCLI (bin) for Wrangler-style builds:capnweb typecheck gen src/worker.ts --out .capnweb.capnweb/viteplugin for Vite builds.typia, nots-morph, no.npmrc, and no separatepackages/capnweb-typecheckpackage.RpcTargetmethod, the generator emits runtime validators for every parameter and return value, plus glue that registers them on the class at startup. Generated artifacts are written to.capnweb/(configurable).Runtime integration:
capnweb/internal/typecheckconsumed only by generated code, not by user code.RpcTargetconstructor; runs indeliverCall()before invoking the method and before returning a result.RpcStub, preservingRpcPromisepipelining, disposal, andStubBasesemantics. Typednew RpcSession<T>(...)is supported via a session-shape wrapper that binds validators onsession.getRemoteMain()without changing the caller-visible value.VS Code Debug
./examples/worker-react/dev-debug.sh # ./examples/worker-react/dev-debug.sh --typecheck # for checking how the typecheck workhttp://127.0.0.1:5173Set breakpoints in examples/worker-react/web/src/main/App.tsx, then click Run demo.
Testing
Changeset
.changeset/typescript-rpc-validators.md — minor bump for capnweb.