Add napcat-rpc package with deep RPC
Introduce a new napcat-rpc package implementing a deep-proxy RPC system. Adds client (createDeepProxy, proxy helpers), server (RpcServer, createRpcServer), serializer (serialize/deserialize, callback registry), and transport layers (LocalTransport, MessageTransport, message server handler), plus an easy API (createRpcPair, mockRemote, createServer, createClient). Includes TypeScript types, tsconfig and package.json. Wire-up: add package alias in napcat-schema vite config and add napcat-rpc dependency to napcat-test along with comprehensive rpc tests.
This commit is contained in:
1 parent
bcf985f92c
commit
fa74176160
14 files changed
+2828
No files matched your search
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* napcat-rpc
|
||||
*
|
||||
* 深层 RPC 代理库 - 将对象的所有层级操作转换为 RPC 调用
|
||||
*/
|
||||
|
||||
// 简化 API(推荐使用)
|
||||
export {
|
||||
createRpcPair,
|
||||
mockRemote,
|
||||
createServer,
|
||||
createClient,
|
||||
} from './easy.js';
|
||||
|
||||
// 类型导出
|
||||
export {
|
||||
RpcOperationType,
|
||||
SerializedValueType,
|
||||
PROXY_META,
|
||||
type RpcRequest,
|
||||
type RpcResponse,
|
||||
type SerializedValue,
|
||||
type RpcTransport,
|
||||
type RpcServerHandler,
|
||||
type RpcServerOptions,
|
||||
type DeepProxyOptions,
|
||||
type ProxyMeta,
|
||||
} from './types.js';
|
||||
|
||||
// 序列化工具
|
||||
export {
|
||||
serialize,
|
||||
deserialize,
|
||||
extractCallbackIds,
|
||||
SimpleCallbackRegistry,
|
||||
type CallbackRegistry,
|
||||
type SerializeContext,
|
||||
type DeserializeContext,
|
||||
} from './serializer.js';
|
||||
|
||||
// 客户端代理
|
||||
export {
|
||||
createDeepProxy,
|
||||
getProxyMeta,
|
||||
isRpcProxy,
|
||||
} from './client.js';
|
||||
|
||||
// 服务端
|
||||
export {
|
||||
RpcServer,
|
||||
createRpcServer,
|
||||
} from './server.js';
|
||||
|
||||
// 传输层
|
||||
export {
|
||||
LocalTransport,
|
||||
MessageTransport,
|
||||
createMessageServerHandler,
|
||||
type MessageTransportOptions,
|
||||
} from './transport.js';
|
||||
Reference in new issue
Block a user