dsh-im-ops/plugin-src/host/channels/weixin/index.mjs
2026-08-15 15:40:53 +08:00

32 lines
1.2 KiB
JavaScript

import { createProductionController } from './production.mjs';
import { installWeixinRpc } from './rpc.mjs';
export const name = 'dsh-weixin-host';
export const inject = ['connection', 'credentials', 'webServer'];
export async function apply(ctx, config = {}) {
if (config?.controller) return installWeixinRpc(ctx, config.controller, config.rpcOptions);
const production = await createProductionController(ctx, config, config.internals);
const disposeRpc = installWeixinRpc(ctx, production.controller, config.rpcOptions);
ctx.effect(() => async () => {
await production.close();
}, 'dsh-weixin: close account connections');
return disposeRpc;
}
export function createWeixinHostPlugin(config) {
return Object.freeze({ name, inject, apply: (ctx) => apply(ctx, config) });
}
export { createConnectionSupervisor, ConnectionSupervisor } from './connection-supervisor.mjs';
export { createProductionController } from './production.mjs';
export {
WEIXIN_ENDPOINTS,
WEIXIN_RPC_CHANNEL,
WEIXIN_RPC_ENDPOINTS,
createWeixinRpcHandler,
installWeixinRpc,
} from './rpc.mjs';
export { WeixinController } from '../../../../src/channels/weixin/weixin-controller.mjs';
export { WeixinRuntime } from '../../../../src/channels/weixin/weixin-runtime.mjs';