@linkdesk/contracts 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/linkdesk.d.ts +113 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ window.linkdesk.configuration.get("editor.fontSize"); // 智能提示 + 类型
|
|
|
23
23
|
|
|
24
24
|
- **纯类型**:不含 `getLinkDesk`/`linkdesk` 值导出——运行时走 `window.linkdesk`(preload 注入)。
|
|
25
25
|
- **自包含**:无任何 `@src/core` 依赖,拷一个 d.ts 进项目即完整类型。
|
|
26
|
-
-
|
|
26
|
+
- **版本轴独立(2026-09-06 拆焊,反向 E5.8#22.6)**:包版本不再随壳——壳升级 ≠ 契约升级(软件升级是用户轴,与本包无关)。只有当 `window.linkdesk.*` API 面变了、作者要拿新类型时才升版发布。**内容仍与壳源码逐字节同步**(生成器比对,漂移即 `contracts:check` 红)——类型永远描述当前壳,只是版本号不绑壳。`npm update @linkdesk/contracts` 在版本升后拿新类型。
|
|
27
27
|
|
|
28
28
|
## 与仓库产物双轨
|
|
29
29
|
|
package/linkdesk.d.ts
CHANGED
|
@@ -358,6 +358,22 @@ export interface KeybindingsAPI {
|
|
|
358
358
|
onForwardedEvent?(cb: (input: ForwardedKeyboardInput) => void): () => void;
|
|
359
359
|
};
|
|
360
360
|
}
|
|
361
|
+
/** 通知主动作按钮描述(E6#13.5 缝隙 K1)——插件 notifications.show 传 actions,
|
|
362
|
+
* 经 IPC 序列化到壳;点击时壳 executeCommand(command, args) 真执行。
|
|
363
|
+
* 对标 VS Code `INotificationAction`(命令面)。按钮文案 = 最终显示文本,壳不二次翻译。 */
|
|
364
|
+
export interface PluginToastAction {
|
|
365
|
+
/** 动作 id——插件侧标识(同一通知内唯一);点击回执按位置序号,id 仅供调试/日志 */
|
|
366
|
+
id?: string;
|
|
367
|
+
/** 按钮文案(最终显示文本) */
|
|
368
|
+
label: string;
|
|
369
|
+
/** true → 主按钮(accent 色);false/未设 → 次级文本按钮 */
|
|
370
|
+
isPrimary?: boolean;
|
|
371
|
+
/** 点击执行的命令 id——壳 executeCommand(command, args)。命令 handler 由插件自注册
|
|
372
|
+
* (window.linkdesk.commands.registerCommand)。无 command → 按钮点击仅关闭 toast(无副作用) */
|
|
373
|
+
command?: string;
|
|
374
|
+
/** 透传给命令 handler 的 ...args */
|
|
375
|
+
args?: unknown[];
|
|
376
|
+
}
|
|
361
377
|
/** 进度通知句柄——progress=true 时 show() 返回 */
|
|
362
378
|
export interface NotificationHandle {
|
|
363
379
|
/** 更新进度消息 */
|
|
@@ -550,10 +566,13 @@ export type PoolFloatingPanelData = {
|
|
|
550
566
|
export interface UiAPI {
|
|
551
567
|
/** 通知——插件弹出壳侧 toast,对标 VS Code vscode.window.showInformationMessage */
|
|
552
568
|
notifications: {
|
|
553
|
-
/** 弹出通知。progress=true 时返回 ProgressHandle(含 update/finish/cancel
|
|
569
|
+
/** 弹出通知。progress=true 时返回 ProgressHandle(含 update/finish/cancel)。
|
|
570
|
+
* E6#13.5:options.actions 带主动作按钮——点击走壳 executeCommand(action.command, action.args),
|
|
571
|
+
* 命令 handler 插件自注册。不传 actions → 无按钮(现状)。error 类自动停留 8s。 */
|
|
554
572
|
show(message: string, options?: {
|
|
555
573
|
type?: "info" | "warning" | "error";
|
|
556
574
|
progress?: boolean;
|
|
575
|
+
actions?: PluginToastAction[];
|
|
557
576
|
}): Promise<NotificationHandle | undefined>;
|
|
558
577
|
};
|
|
559
578
|
/** E5#69:菜单——插件声明式读写 */
|
|
@@ -736,6 +755,8 @@ export interface EnvInfo {
|
|
|
736
755
|
appDataDir: string;
|
|
737
756
|
pluginsRootDir: string;
|
|
738
757
|
appPluginsDir: string;
|
|
758
|
+
/** E6#7(1.2-4):用户安装包代码根 {userData}/plugins——.linkdesk-plugin 解压家(与 appPluginsDir 只读根分开) */
|
|
759
|
+
userPluginsDir: string;
|
|
739
760
|
pluginDataDir?: string;
|
|
740
761
|
pluginCacheDir?: string;
|
|
741
762
|
pluginExportsDir?: string;
|
|
@@ -882,6 +903,16 @@ export interface EditorAPI {
|
|
|
882
903
|
registerView(pluginId: string, containerId: string, descriptor: Record<string, unknown>): Promise<void>;
|
|
883
904
|
};
|
|
884
905
|
}
|
|
906
|
+
/** E6#7(1.2-4):plugins.resolveEntry() 返回——resolvePath 的兄弟(discovery 族,非安装 handler)。
|
|
907
|
+
* pool/运行时按 { root, entry } 拼 dev /@fs 与 prod linkdesk:// 两种 URL。 */
|
|
908
|
+
export interface PluginEntryInfo {
|
|
909
|
+
/** 插件目录绝对路径(正斜杠);插件不存在 = null */
|
|
910
|
+
root: string | null;
|
|
911
|
+
/** 入口文件名——bundle → "index.bundle.js";源码 → manifest.entry(缺省 "src/index.tsx");无 = null */
|
|
912
|
+
entry: string | null;
|
|
913
|
+
/** 目录是否含 index.bundle.js(bundle 格式事实) */
|
|
914
|
+
bundle: boolean;
|
|
915
|
+
}
|
|
885
916
|
/**
|
|
886
917
|
* Phase 4 核心类型定义。
|
|
887
918
|
* 插件元数据、标签页扩展字段、视图注册表条目。
|
|
@@ -969,7 +1000,10 @@ export interface PluginManifest {
|
|
|
969
1000
|
screenshots?: string[];
|
|
970
1001
|
minAppVersion?: string;
|
|
971
1002
|
/** 激活事件——对标 VS Code activationEvents。空或含 "*" = 启动时立即加载。
|
|
972
|
-
*
|
|
1003
|
+
* 具体事件(canonical 无前导点——与 fileAssociations.extension 一致):
|
|
1004
|
+
* onCommand:id / onFileOpen:ext / onLanguage:ext / onPortOpen / onView:containerId。
|
|
1005
|
+
* 未写此字段 → 壳按 contributes 自动推断(#9g:fileAssociations→onLanguage / views→onView / commands→onCommand),
|
|
1006
|
+
* 写了则显式优先(精确控制)。延迟插件启动注册-only,首用事件才 import JS。 */
|
|
973
1007
|
activationEvents?: string[];
|
|
974
1008
|
/** @deprecated E5.8#14——归并到 requires(插件级激活依赖统一由 requires 声明)。
|
|
975
1009
|
* 零插件使用;loader 兼容读取直到 #14 落地迁移。 */
|
|
@@ -1010,6 +1044,33 @@ export interface PluginManifest {
|
|
|
1010
1044
|
*/
|
|
1011
1045
|
contributes?: Record<string, unknown>;
|
|
1012
1046
|
}
|
|
1047
|
+
/** 发现条目——plugins.listAll() 返回(E6#9a:主进程直扫 plugins/ 全子目录,替代渲染进程 import.meta.glob)。
|
|
1048
|
+
* 打包/市场安装的插件不在源码树——glob 发现不了;listAll 以磁盘为唯一真源,dev/prod 同一面。
|
|
1049
|
+
* 完整 manifest 为纯 JSON 数据(IPC 可序列化),statusBar/contributes 等随 manifest 携带
|
|
1050
|
+
* (#9b:statusBar 入口由消费方从 manifest.statusBar 派生,无需单独通道)。 */
|
|
1051
|
+
export interface PluginDiscoveryEntry {
|
|
1052
|
+
pluginId: string;
|
|
1053
|
+
/** manifest.entry——插件 JS 入口(无 = 纯贡献插件,只有 manifest 无组件) */
|
|
1054
|
+
entry?: string;
|
|
1055
|
+
/** 完整 plugin.json */
|
|
1056
|
+
manifest: PluginManifest;
|
|
1057
|
+
/** E6#7(1.2-4):目录含 index.bundle.js = SDK 打包的 .linkdesk-plugin 解压产物。
|
|
1058
|
+
* 磁盘格式事实(非插件身份——硬约束 11);bundle 插件 JS 入口恒 index.bundle.js(runtime 分支依据)。 */
|
|
1059
|
+
bundle?: boolean;
|
|
1060
|
+
/** E6#7(1.2-4):磁盘位置事实——home = 代码根(app = 只读 app 插件根 / userData = {userData}/plugins 用户安装家)。
|
|
1061
|
+
* subdir = 2026-09-05 塌平单根后恒 null(平铺树 root-direct 扫描不产出子目录;类型保留 null 供下游空安全)。 */
|
|
1062
|
+
origin?: {
|
|
1063
|
+
home: "app" | "userData";
|
|
1064
|
+
subdir: string | null;
|
|
1065
|
+
};
|
|
1066
|
+
}
|
|
1067
|
+
/** E6#13b(段 B):pluginManager.checkUpdates 返回——主进程 fetch catalog + semver 对比(壳传 current,壳是账本/磁盘 owner) */
|
|
1068
|
+
export interface PluginUpdateCheckResult {
|
|
1069
|
+
current: string;
|
|
1070
|
+
latestVersion: string;
|
|
1071
|
+
downloadUrl?: string;
|
|
1072
|
+
update: boolean;
|
|
1073
|
+
}
|
|
1013
1074
|
/** list() 的 manifest 序列化子集——与 handlePluginsCall "list" 7 字段对齐 */
|
|
1014
1075
|
export interface PluginListSubset {
|
|
1015
1076
|
name?: string;
|
|
@@ -1051,15 +1112,55 @@ export interface PluginInfoEntry {
|
|
|
1051
1112
|
description?: string;
|
|
1052
1113
|
version?: string;
|
|
1053
1114
|
}
|
|
1115
|
+
/** E6#11c/#13b(段 B):更新结果——PluginInstallResult 的更新扩展。
|
|
1116
|
+
* upToDate = catalog 直答已是最新(success:true 但非"更新发生"——UI 显示"已是最新"非红错误);
|
|
1117
|
+
* currentVersion 随行供 toast/日志显示 v旧→v新。needRestart 恒 true(bundle 模块缓存需重启激活)。 */
|
|
1118
|
+
export interface PluginUpdateResult extends PluginInstallResult {
|
|
1119
|
+
/** 更新前磁盘版本 */
|
|
1120
|
+
currentVersion?: string;
|
|
1121
|
+
/** 查目录后已是最新(本次无替换发生) */
|
|
1122
|
+
upToDate?: boolean;
|
|
1123
|
+
}
|
|
1054
1124
|
/** 插件发现/管理命名空间面——桥接 IpcBridgeHandler → loader 函数 */
|
|
1055
1125
|
export interface PluginsAPI {
|
|
1056
|
-
/** 插件发现——双端注入:resolvePath 双端同面;读面(listDirs/listDisabledDirs/readManifest)壳 preload 独有(loader 只在壳跑) */
|
|
1126
|
+
/** 插件发现——双端注入:resolvePath 双端同面;读面(listDirs/listAll/readAllManifests/listDisabledDirs/readManifest)壳 preload 独有(loader 只在壳跑) */
|
|
1057
1127
|
plugins: {
|
|
1058
1128
|
resolvePath(id: string): Promise<string>;
|
|
1129
|
+
/** E6#7(1.2-4):resolvePath 的兄弟(discovery 族)——返回 { root, entry, bundle }(bundle 入口恒 index.bundle.js)。
|
|
1130
|
+
* 可选——保 state.ts 守卫与两 preload 面(壳/池)编译不裂;调用方先判存在再调用。 */
|
|
1131
|
+
resolveEntry?(id: string): Promise<PluginEntryInfo>;
|
|
1059
1132
|
listDirs?(): Promise<string[]>;
|
|
1133
|
+
/** E6#9a:全量发现——[{ pluginId, entry, manifest }](替代 import.meta.glob;打包插件不在源码树,主进程读盘唯一真源) */
|
|
1134
|
+
listAll?(): Promise<PluginDiscoveryEntry[]>;
|
|
1060
1135
|
listDisabledDirs?(): Promise<string[]>;
|
|
1061
1136
|
/** 返回 plugin.json 原始 JSON 文本——消费方自行 JSON.parse */
|
|
1062
1137
|
readManifest?(id: string): Promise<string>;
|
|
1138
|
+
/** E6#9c:全量 manifest——Record<pluginId, PluginManifest>(pluginManifests eager glob 的 IPC 替代) */
|
|
1139
|
+
readAllManifests?(): Promise<Record<string, PluginManifest>>;
|
|
1140
|
+
/** E6#11/#13(1.2-5):主进程真下载段——fetch .linkdesk-plugin 包 → {userData}/tmp/<原包名>(壳 preload 独有;loader 包安装流 packageOps 调) */
|
|
1141
|
+
packageDownload?(url: string): Promise<{
|
|
1142
|
+
zipPath: string;
|
|
1143
|
+
sizeBytes?: number;
|
|
1144
|
+
}>;
|
|
1145
|
+
/** E6#11/#13(1.2-5):主进程真解压段——共享 bundle-zip 语义 → {userData}/plugins/<id>/(2026-09-05 塌平单根;壳 preload 独有;目标已存在拒绝) */
|
|
1146
|
+
packageExtract?(zipPath: string, expectedPluginId?: string): Promise<{
|
|
1147
|
+
pluginId: string;
|
|
1148
|
+
version: string;
|
|
1149
|
+
targetDir: string;
|
|
1150
|
+
}>;
|
|
1151
|
+
/** E6#13b(段 B):主进程真网络段——fetch marketplace.json → 版本对比(不碰账本——current 由壳传)。prerelease 默认忽略。 */
|
|
1152
|
+
packageUpdateCheck?(pluginId: string, catalogUrl: string, currentVersion?: string): Promise<PluginUpdateCheckResult>;
|
|
1153
|
+
/** E6#13b/c(段 B):主进程真下载+解压段——下载到 tmp → 解压到 {userData}/tmp/.stage-<id>(id 一致 + 新版>旧版校验,不碰旧目录) */
|
|
1154
|
+
packageStageUpdate?(pluginId: string, source: string, currentVersion?: string): Promise<{
|
|
1155
|
+
pluginId: string;
|
|
1156
|
+
newVersion: string;
|
|
1157
|
+
stagedDir: string;
|
|
1158
|
+
}>;
|
|
1159
|
+
/** E6#13c(段 B):主进程原子替换段——同卷 rename:target→.bak→staged→target→rm .bak(失败复原旧版) */
|
|
1160
|
+
packageCommitUpdate?(pluginId: string, stagedDir: string): Promise<{
|
|
1161
|
+
pluginId: string;
|
|
1162
|
+
version: string;
|
|
1163
|
+
}>;
|
|
1063
1164
|
};
|
|
1064
1165
|
/** 插件管理——桥接 IpcBridgeHandler → loader 函数。池权威(marketplace 插件消费),必选 */
|
|
1065
1166
|
pluginManager: {
|
|
@@ -1068,10 +1169,19 @@ export interface PluginsAPI {
|
|
|
1068
1169
|
disable(id: string): Promise<unknown>;
|
|
1069
1170
|
uninstall(id: string): Promise<unknown>;
|
|
1070
1171
|
install(path: string): Promise<PluginInstallResult>;
|
|
1172
|
+
/** E6#13(1.2-5):url/.linkdesk-plugin 包安装流显式名(installPlugin 路由别名;壳与池 preload 双面同款——池经 plugins:call 代理)。进度走 plugin:installProgress 通道 */
|
|
1173
|
+
installWithProgress?(path: string): Promise<PluginInstallResult>;
|
|
1071
1174
|
reinstall(id: string): Promise<unknown>;
|
|
1072
1175
|
getDisabled(): Promise<PluginInfoEntry[]>;
|
|
1073
1176
|
getUninstalled(): Promise<PluginInfoEntry[]>;
|
|
1074
1177
|
isDisabled(id: string): Promise<boolean>;
|
|
1178
|
+
/** E6#11c(段 B):安全更新(#11c 原子 + unload 机械路径)——opts: { catalogUrl?(走 check 选最新) | url?(直给更新包) } */
|
|
1179
|
+
update?(pluginId: string, opts?: {
|
|
1180
|
+
catalogUrl?: string;
|
|
1181
|
+
url?: string;
|
|
1182
|
+
}): Promise<PluginUpdateResult>;
|
|
1183
|
+
/** E6#13b(段 B):只读查更新——有新版返回 downloadUrl(UI 徽标数据源;更新动作走 update) */
|
|
1184
|
+
checkUpdates?(pluginId: string, catalogUrl: string): Promise<PluginUpdateCheckResult>;
|
|
1075
1185
|
/** E5.7#48:装/卸/重装成功 → 通知主进程全量重扫三表 */
|
|
1076
1186
|
notifyManifestChanged?(): void;
|
|
1077
1187
|
};
|