@linkdesk/contracts 0.1.0
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 +35 -0
- package/linkdesk.d.ts +1941 -0
- package/package.json +24 -0
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# @linkdesk/contracts
|
|
2
|
+
|
|
3
|
+
LinkDesk 插件契约类型——`window.linkdesk.*` 全量类型定义。
|
|
4
|
+
|
|
5
|
+
> 本包由 LinkDesk 壳的**契约生成器**(`scripts/generate-contract.mjs`)从 `src/core/api/linkdesk-api.ts` 自动生成,**唯一**类型真相源。第三方插件作者用它拿到与壳完全同步的 API 类型——漂移即编译错误。
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -D @linkdesk/contracts
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 使用
|
|
14
|
+
|
|
15
|
+
包只含类型(`linkdesk.d.ts`,`types` 入口直指它),零运行时。装完后:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import type { LinkDeskAPI } from "@linkdesk/contracts";
|
|
19
|
+
|
|
20
|
+
// window.linkdesk 自动有类型(声明内置 global Window 接口),无需额外 global.d.ts
|
|
21
|
+
window.linkdesk.configuration.get("editor.fontSize"); // 智能提示 + 类型检查
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
- **纯类型**:不含 `getLinkDesk`/`linkdesk` 值导出——运行时走 `window.linkdesk`(preload 注入)。
|
|
25
|
+
- **自包含**:无任何 `@src/core` 依赖,拷一个 d.ts 进项目即完整类型。
|
|
26
|
+
- **版本联动**:包版本 = 壳版本(同版本发布)。升级壳即换契约——插件 `npm update @linkdesk/contracts` 拿到新类型。
|
|
27
|
+
|
|
28
|
+
## 与仓库产物双轨
|
|
29
|
+
|
|
30
|
+
- **推荐**:`npm i -D @linkdesk/contracts`(真实发布链,类型随版本走)
|
|
31
|
+
- **备选**:从 LinkDesk 仓库 `contracts/linkdesk.d.ts` 拷贝(无 npm 环境时兜底)
|
|
32
|
+
|
|
33
|
+
## 协议
|
|
34
|
+
|
|
35
|
+
MIT
|