Forge “protocol” defines the browser-local contract for procedures that run inside the Forge React runtime. These procedures are executed locally (no network), but still use tRPC-style typing and a consistent call surface.
The goal is:
- keep local UX actions (e.g. showLogin, authorize, ui state changes) type-safe
- allow OneJS/Unity to call into Forge using string-path
core.*methods that normalize toforge.core.* - avoid duplicating contract shapes in multiple places
Forge creates a browser-safe router:
initTRPC.context<AppCtx>().create({ isServer: true })t.router({ core: Core.createRouter(t) })- invoked via
t.createCallerFactory(router)(ctx)insidelocalLink
Local procedures should be defined once:
- prefer a
core.router.tsthat builds procedures with zod schemas - optionally also export a “contract” object (zod inputs/outputs) if UI code needs the schema
Consumers should derive types from the real router:
export type ForgeRouter = typeof router(from localLink/router factory)
forge.core.showLogin(mutation/command)forge.core.authorize(if implemented as local tRPC proc)forge.account.*(future)
Unity inbound normalization:
core.authorize→forge.core.authorize
Forge should preserve:
trpc.forge.core.showLogin.useMutation()
This requires:
- exporting
trpc = createTRPCReact<AppRouter>() - including
forge: ForgeRouterinAppRoutertyping
arken/forge/web/src/modules/core/core.router.ts- defines local procedures
arken/forge/web/src/utils/localLink.ts- builds local router + caller + intercept link
arken/forge/web/src/utils/trpc.ts- defines AppRouter type for hooks and exports
trpc
- defines AppRouter type for hooks and exports
- Local-only procedures are always under the
forge.*namespace - If Unity sends bare
core.*, the web app normalizes it toforge.core.* - Keep these procedures side-effect oriented (commands), not data fetching, unless it’s truly local state
- If Unity calls land in localLink but fail:
- confirm the proc exists in
Core.createRouter(t) - confirm normalization to
forge.core.*matches link routing
- confirm the proc exists in
- If hooks fail to typecheck:
- verify
AppRouterincludesforge: ForgeRouter - verify
trpcis exported and Provider usestrpcClientReact
- verify