From 9607c6c3ce53ed1acce8f2a9d7fc04efd3a44b61 Mon Sep 17 00:00:00 2001 From: Kegongteng Date: Mon, 16 Nov 2026 14:09:15 +0800 Subject: [PATCH] [fix] dsh-mail-sender is waiting for activation --- lib/client/api.d.ts | 5 +++++ lib/client/api.js | 18 ++++++++++++------ lib/client/index.js | 14 +++++++------- src/client/api.ts | 19 ++++++++++++------- src/client/index.ts | 2 +- 5 files changed, 37 insertions(+), 21 deletions(-) diff --git a/lib/client/api.d.ts b/lib/client/api.d.ts index 822ff07..f5b3775 100644 --- a/lib/client/api.d.ts +++ b/lib/client/api.d.ts @@ -9,4 +9,9 @@ export interface MailGatewayApi { testConnection(patch: MailboxPatch): Promise>; status(): Promise>; } +/** + * 直接调用已挂载贡献的方法描述符,不经过 `ctx.remote['mail-gateway']`。 + * 命名空间访问器要求调用方声明 `inject: ['remote.mail-gateway']`,而该服务只在 + * `$mount` 之后才存在,声明它会形成等待依赖的死锁。 + */ export declare function createApi(ctx: Context): MailGatewayApi; diff --git a/lib/client/api.js b/lib/client/api.js index 750b3d3..73a52ad 100644 --- a/lib/client/api.js +++ b/lib/client/api.js @@ -1,10 +1,16 @@ +import TYPERT_REMOTE from '../remote.js'; +/** + * 直接调用已挂载贡献的方法描述符,不经过 `ctx.remote['mail-gateway']`。 + * 命名空间访问器要求调用方声明 `inject: ['remote.mail-gateway']`,而该服务只在 + * `$mount` 之后才存在,声明它会形成等待依赖的死锁。 + */ export function createApi(ctx) { - const remote = ctx.remote['mail-gateway']; + const methods = TYPERT_REMOTE.methods; return { - get: () => remote.get(), - saveMailbox: patch => remote.saveMailbox(patch), - saveWhitelist: addresses => remote.saveWhitelist(addresses), - testConnection: patch => remote.testConnection(patch), - status: () => remote.status(), + get: () => methods['mail-gateway/get'].invoke(ctx.remote, {}), + saveMailbox: patch => methods['mail-gateway/saveMailbox'].invoke(ctx.remote, { patch }), + saveWhitelist: addresses => methods['mail-gateway/saveWhitelist'].invoke(ctx.remote, { addresses }), + testConnection: patch => methods['mail-gateway/testConnection'].invoke(ctx.remote, { patch }), + status: () => methods['mail-gateway/status'].invoke(ctx.remote, {}), }; } diff --git a/lib/client/index.js b/lib/client/index.js index 35831e4..f5db48f 100644 --- a/lib/client/index.js +++ b/lib/client/index.js @@ -19984,13 +19984,13 @@ var remote_default = TYPERT_REMOTE; // src/client/api.ts function createApi(ctx) { - const remote = ctx.remote["mail-gateway"]; + const methods = remote_default.methods; return { - get: () => remote.get(), - saveMailbox: (patch) => remote.saveMailbox(patch), - saveWhitelist: (addresses) => remote.saveWhitelist(addresses), - testConnection: (patch) => remote.testConnection(patch), - status: () => remote.status() + get: () => methods["mail-gateway/get"].invoke(ctx.remote, {}), + saveMailbox: (patch) => methods["mail-gateway/saveMailbox"].invoke(ctx.remote, { patch }), + saveWhitelist: (addresses) => methods["mail-gateway/saveWhitelist"].invoke(ctx.remote, { addresses }), + testConnection: (patch) => methods["mail-gateway/testConnection"].invoke(ctx.remote, { patch }), + status: () => methods["mail-gateway/status"].invoke(ctx.remote, {}) }; } @@ -20284,7 +20284,7 @@ function MailGatewaySection({ api }) { // src/client/index.ts var name = "dsh-mail-sender"; -var inject = ["slots", "remote", "remote.mail-gateway"]; +var inject = ["slots", "remote"]; async function apply(ctx) { const disposeRemote = await ctx.remote.$mount(remote_default); const api = createApi(ctx); diff --git a/src/client/api.ts b/src/client/api.ts index 94c8787..37cd699 100644 --- a/src/client/api.ts +++ b/src/client/api.ts @@ -1,7 +1,7 @@ import type { Context } from '@deepseek-ai/cordis' import type {} from '@deepseek-ai/dsh-api-remotes/client' import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol' -import type {} from '../remote.js' +import TYPERT_REMOTE from '../remote.js' import type { ConnectionTestResult, MailSnapshot, @@ -18,13 +18,18 @@ export interface MailGatewayApi { status(): Promise> } +/** + * 直接调用已挂载贡献的方法描述符,不经过 `ctx.remote['mail-gateway']`。 + * 命名空间访问器要求调用方声明 `inject: ['remote.mail-gateway']`,而该服务只在 + * `$mount` 之后才存在,声明它会形成等待依赖的死锁。 + */ export function createApi(ctx: Context): MailGatewayApi { - const remote = ctx.remote['mail-gateway'] + const methods = TYPERT_REMOTE.methods return { - get: () => remote.get(), - saveMailbox: patch => remote.saveMailbox(patch), - saveWhitelist: addresses => remote.saveWhitelist(addresses), - testConnection: patch => remote.testConnection(patch), - status: () => remote.status(), + get: () => methods['mail-gateway/get'].invoke(ctx.remote, {}), + saveMailbox: patch => methods['mail-gateway/saveMailbox'].invoke(ctx.remote, { patch }), + saveWhitelist: addresses => methods['mail-gateway/saveWhitelist'].invoke(ctx.remote, { addresses }), + testConnection: patch => methods['mail-gateway/testConnection'].invoke(ctx.remote, { patch }), + status: () => methods['mail-gateway/status'].invoke(ctx.remote, {}), } } diff --git a/src/client/index.ts b/src/client/index.ts index 20a6f86..9d76b9a 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -8,7 +8,7 @@ import { createApi } from './api.js' import { MailGatewaySection } from './MailGatewaySection.js' export const name = 'dsh-mail-sender' -export const inject = ['slots', 'remote', 'remote.mail-gateway'] +export const inject = ['slots', 'remote'] /** 挂载本插件的 Remote 命名空间,并在设置页注册“邮件网关”分区。 */ export async function apply(ctx: Context): Promise<() => Promise> {