/** * widthPrefs.ts — 对话内容宽度偏好的持久化与应用(client 共享,无 react 依赖)。 * * 单一事实源(官方/插件共用 localStorage): * dsh.conversation.contentWidth —— 固定宽度(px) * dsh.conversation.contentWidthFollow —— 1 = 跟随对话列宽(live) * 应用方式 = 把 --dsh-chat-user-width 写到每个对话根 [data-phase] * (与官方 onHandleDrag 一致)。 * * 本模块除 helpers(组件与恢复共用)外,提供"启动即恢复": * - applySavedWidth():follow=1 → 起全局跟随 watcher;有 fixed 值 → * 等对话根出现后发布一次。修复"重启 DSH 后宽度偏好不生效、要打开 * 设置页插件页(WidthSliderControl mount)才生效"的生命周期缺口—— * 应用逻辑原先只挂在设置页组件内。 * - setFollowEnabled():组件在开关切换时同步全局 watcher,避免面板 * 关闭后全局仍按旧模式钉宽度。 * 全部返回/登记 disposer,随功能开关卸载。 */ import type { Disposer } from '../shared/types.js'; export declare const WIDTH_PREF_KEY = "dsh.conversation.contentWidth"; export declare const FOLLOW_PREF_KEY = "dsh.conversation.contentWidthFollow"; export declare const MIN_WIDTH = 640; export declare const EDGE_BUDGET = 176; /** 读固定宽度偏好;无/非法返回 null。 */ export declare function readPreference(): number | null; /** Follow-window 模式与固定宽度分开持久。 */ export declare function readFollowPreference(): boolean; /** 读当前对话列宽(对话根 inline --dsh-conversation-column-width),兜底 DOM。 */ export declare function readColumnWidth(): number; /** 无偏好时的自适应默认宽度。 */ export declare function defaultWidth(column: number): number; /** 发布内容宽度:写 --dsh-chat-user-width 到每个对话根(同官方拖拽)。 */ export declare function publishChatWidth(px: number): void; export declare function persistWidth(px: number): void; export declare function persistFollowPreference(follow: boolean): void; /** 按开关同步全局 watcher 启停(幂等)。 */ export declare function setFollowEnabled(enabled: boolean): void; /** * 启动即恢复上次宽度偏好(随"宽度滑块"功能开关安装/卸载): * follow=1 → 全局跟随 watcher(重启后立即生效并持续跟随); * fixed 值 → 对话根出现后发布一次(幂等;官方若自行恢复也同值覆盖); * 均无 → no-op,保持官方默认。 */ export declare function applySavedWidth(): Disposer;