@xiongtao.xt/tau-plugins 0.40.0 → 0.41.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/CHANGELOG.md +7 -0
- package/client/chunk-TOYS6GBE.js +151 -0
- package/docs/README.md +1 -1
- package/docs/api-support.md +21 -21
- package/docs/editor.md +3 -11
- package/docs/getting-started.md +2 -2
- package/docs/plugin-basics.md +16 -20
- package/docs/portability.md +14 -27
- package/docs/release.md +1 -1
- package/docs/whiteboard.md +1 -2
- package/package.json +1 -1
- package/portable.js +1 -9
- package/publish-artifacts.js +11 -48
- package/types/packages/plugins/src/portable.d.ts +8 -32
- package/types/packages/plugins/src/rendering.d.ts +9 -35
- package/types/packages/plugins/src/whiteboard.d.ts +1 -1
- package/types/packages/whiteboard/src/extensions/api.d.ts +2 -19
- package/client/chunk-PRPTZJX2.js +0 -301
- package/types/packages/plugins/src/capabilities.d.ts +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# 更新记录
|
|
2
2
|
|
|
3
|
+
## 0.41.0
|
|
4
|
+
|
|
5
|
+
- 插件功能直接使用统一 API 或注册实际扩展,不再填写宿主能力列表、正文节点等级或贡献标记。
|
|
6
|
+
- 正文转换、源码编辑、样式编译、媒体、同步和上传沿用现有接口,宿主负责装配。
|
|
7
|
+
- 白板服务直接通过 getService/tryGetService 获取,不再重复填写服务依赖表;插件与工作区存储隔离保持。
|
|
8
|
+
- 作者清单只保留插件资料、支持平台、最低客户端版本和用户数据权限,新发行拒绝重复声明。
|
|
9
|
+
|
|
3
10
|
## 0.40.0
|
|
4
11
|
|
|
5
12
|
- 白板装配信息从构建的实际宿主模块依赖自动生成,作者只保留现有扩展 API 与平台声明。
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import {
|
|
2
|
+
comparePluginVersions,
|
|
3
|
+
validatePluginManifest
|
|
4
|
+
} from "./chunk-FZTR4KOY.js";
|
|
5
|
+
|
|
6
|
+
// packages/plugins/src/portable.ts
|
|
7
|
+
var PORTABLE_PLATFORMS = ["desktop", "android", "ios"];
|
|
8
|
+
var PORTABLE_SHARED_MODULES = [
|
|
9
|
+
"@tau/plugins",
|
|
10
|
+
"@tau/plugins/whiteboard",
|
|
11
|
+
"@tau/ui",
|
|
12
|
+
"react",
|
|
13
|
+
"react-dom",
|
|
14
|
+
"react-dom/client",
|
|
15
|
+
"react/jsx-runtime",
|
|
16
|
+
"react/jsx-dev-runtime"
|
|
17
|
+
];
|
|
18
|
+
function assertKeys(item, keys, label) {
|
|
19
|
+
if (Object.keys(item).some((key) => !keys.includes(key))) throw new Error(`${label}\u5305\u542B\u672A\u77E5\u5B57\u6BB5`);
|
|
20
|
+
}
|
|
21
|
+
function buildPortablePluginManifest(value, output) {
|
|
22
|
+
const item = record(value, "\u4F5C\u8005\u6E05\u5355");
|
|
23
|
+
const files = record(output, "\u6784\u5EFA\u6587\u4EF6\u4FE1\u606F");
|
|
24
|
+
assertKeys(files, ["main", "styles", "integrity", "skills", "imports"], "\u6784\u5EFA\u6587\u4EF6\u4FE1\u606F");
|
|
25
|
+
const imports = files.imports ?? [];
|
|
26
|
+
if (!Array.isArray(imports) || imports.some((name) => !PORTABLE_SHARED_MODULES.includes(name)))
|
|
27
|
+
throw new Error("\u6784\u5EFA\u6A21\u5757\u4F9D\u8D56\u65E0\u6548");
|
|
28
|
+
const { imports: _imports, ...buildFiles } = files;
|
|
29
|
+
assertKeys(
|
|
30
|
+
item,
|
|
31
|
+
["id", "name", "version", "description", "categories", "keywords", "permissions", "targets"],
|
|
32
|
+
"\u4F5C\u8005\u6E05\u5355"
|
|
33
|
+
);
|
|
34
|
+
const targets = record(item.targets, "\u76EE\u6807\u5E73\u53F0");
|
|
35
|
+
const normalized = Object.fromEntries(
|
|
36
|
+
Object.entries(targets).map(([platform, input]) => {
|
|
37
|
+
const target = record(input, "\u5E73\u53F0\u914D\u7F6E");
|
|
38
|
+
assertKeys(target, ["minAppVersion"], "\u5E73\u53F0\u914D\u7F6E");
|
|
39
|
+
return [platform, { minAppVersion: target.minAppVersion }];
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
const { targets: _targets, ...metadata } = item;
|
|
43
|
+
return validatePortableDistributionManifest({
|
|
44
|
+
...metadata,
|
|
45
|
+
formatVersion: 3,
|
|
46
|
+
apiVersion: 1,
|
|
47
|
+
platform: "portable",
|
|
48
|
+
profile: "web-v1",
|
|
49
|
+
format: "cjs",
|
|
50
|
+
...buildFiles,
|
|
51
|
+
targets: normalized
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function record(value, label) {
|
|
55
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null)
|
|
56
|
+
throw new Error(`${label}\u5FC5\u987B\u662F\u666E\u901A\u5BF9\u8C61`);
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
function validatePortablePluginManifest(value) {
|
|
60
|
+
return parsePortablePluginManifest(value);
|
|
61
|
+
}
|
|
62
|
+
var readPortablePluginManifest = validatePortablePluginManifest;
|
|
63
|
+
function validatePortableDistributionManifest(value) {
|
|
64
|
+
const manifest = validatePortablePluginManifest(value);
|
|
65
|
+
if (/[-+]/.test(manifest.version)) throw new Error("\u6B63\u5F0F\u8DE8\u7AEF\u5305\u7248\u672C\u4E0D\u80FD\u542B\u9884\u53D1\u5E03\u6216\u6784\u5EFA\u6807\u8BC6");
|
|
66
|
+
if ((manifest.targets.android || manifest.targets.ios) && manifest.permissions?.length)
|
|
67
|
+
throw new Error("\u79FB\u52A8\u7AEF\u5C1A\u672A\u63A5\u5165\u4E1A\u52A1\u6570\u636E\u6388\u6743\uFF0C\u4E0D\u80FD\u53D1\u5E03\u58F0\u660E\u8FD9\u4E9B\u6743\u9650\u7684\u79FB\u52A8\u76EE\u6807");
|
|
68
|
+
return manifest;
|
|
69
|
+
}
|
|
70
|
+
function parsePortablePluginManifest(value) {
|
|
71
|
+
const item = record(value, "\u8DE8\u7AEF\u6E05\u5355");
|
|
72
|
+
const keys = /* @__PURE__ */ new Set([
|
|
73
|
+
"formatVersion",
|
|
74
|
+
"apiVersion",
|
|
75
|
+
"id",
|
|
76
|
+
"name",
|
|
77
|
+
"description",
|
|
78
|
+
"version",
|
|
79
|
+
"platform",
|
|
80
|
+
"profile",
|
|
81
|
+
"targets",
|
|
82
|
+
"format",
|
|
83
|
+
"main",
|
|
84
|
+
"styles",
|
|
85
|
+
"categories",
|
|
86
|
+
"keywords",
|
|
87
|
+
"permissions",
|
|
88
|
+
"integrity",
|
|
89
|
+
"skills"
|
|
90
|
+
]);
|
|
91
|
+
if (Object.keys(item).some((key) => !keys.has(key))) throw new Error("\u8DE8\u7AEF\u6E05\u5355\u5305\u542B\u672A\u652F\u6301\u5B57\u6BB5");
|
|
92
|
+
if (item.formatVersion !== 3 || item.platform !== "portable" || item.profile !== "web-v1")
|
|
93
|
+
throw new Error("\u8DE8\u7AEF\u5305\u683C\u5F0F\u6216\u8FD0\u884C\u914D\u7F6E\u4E0D\u517C\u5BB9");
|
|
94
|
+
if (item.description !== void 0 && (typeof item.description !== "string" || !item.description.trim() || item.description.length > 160))
|
|
95
|
+
throw new Error("\u63D2\u4EF6\u7B80\u4ECB\u5FC5\u987B\u4E3A 1 \u81F3 160 \u5B57");
|
|
96
|
+
const base = validatePluginManifest(
|
|
97
|
+
{ ...item, formatVersion: 1, platform: "desktop" },
|
|
98
|
+
{ strict: true }
|
|
99
|
+
);
|
|
100
|
+
const rawTargets = record(item.targets, "\u76EE\u6807\u5E73\u53F0");
|
|
101
|
+
if (!Object.keys(rawTargets).length || Object.keys(rawTargets).some((key) => !PORTABLE_PLATFORMS.some((platform) => platform === key)))
|
|
102
|
+
throw new Error("\u76EE\u6807\u5E73\u53F0\u4E3A\u7A7A\u6216\u5305\u542B\u672A\u77E5\u5E73\u53F0");
|
|
103
|
+
const targets = {};
|
|
104
|
+
for (const platform of PORTABLE_PLATFORMS) {
|
|
105
|
+
if (!Object.hasOwn(rawTargets, platform)) continue;
|
|
106
|
+
const target = record(rawTargets[platform], "\u5E73\u53F0\u914D\u7F6E");
|
|
107
|
+
assertKeys(target, ["minAppVersion"], "\u5E73\u53F0\u914D\u7F6E");
|
|
108
|
+
if (typeof target.minAppVersion !== "string") throw new Error("\u5E73\u53F0\u7F3A\u5C11\u6700\u4F4E\u5BA2\u6237\u7AEF\u7248\u672C");
|
|
109
|
+
comparePluginVersions(target.minAppVersion, target.minAppVersion);
|
|
110
|
+
targets[platform] = Object.freeze({ minAppVersion: target.minAppVersion });
|
|
111
|
+
}
|
|
112
|
+
const files = record(item.integrity, "\u6587\u4EF6\u6458\u8981");
|
|
113
|
+
if (Object.keys(files).some((file) => !Object.hasOwn(base.integrity, file)))
|
|
114
|
+
throw new Error("\u8DE8\u7AEF\u5305\u5305\u542B\u672A\u58F0\u660E\u6587\u4EF6");
|
|
115
|
+
for (const file of Object.keys(files)) {
|
|
116
|
+
if (file === base.main || file === base.styles) continue;
|
|
117
|
+
if (!file.endsWith(".md") || file.split("/").includes("scripts") || file.includes("\\"))
|
|
118
|
+
throw new Error("\u8DE8\u7AEF Skill \u4EC5\u652F\u6301\u7EAF Markdown \u6587\u6863\uFF0C\u4E0D\u652F\u6301\u811A\u672C\u6216\u9644\u4EF6");
|
|
119
|
+
}
|
|
120
|
+
return Object.freeze({
|
|
121
|
+
...base,
|
|
122
|
+
formatVersion: 3,
|
|
123
|
+
platform: "portable",
|
|
124
|
+
profile: "web-v1",
|
|
125
|
+
...typeof item.description === "string" ? { description: item.description } : {},
|
|
126
|
+
targets: Object.freeze(targets)
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function assertPortablePluginCompatibility(manifest, host) {
|
|
130
|
+
if (!host.profiles.includes(manifest.profile)) throw new Error("\u5BBF\u4E3B\u672A\u63A5\u5165\u8DE8\u7AEF\u8FD0\u884C\u914D\u7F6E");
|
|
131
|
+
const platform = host.environment.platform;
|
|
132
|
+
if (!PORTABLE_PLATFORMS.some((value) => value === platform))
|
|
133
|
+
throw new Error("\u5F53\u524D\u5E73\u53F0\u4E0D\u80FD\u6FC0\u6D3B\u8DE8\u7AEF\u5E94\u7528\u63D2\u4EF6");
|
|
134
|
+
const target = manifest.targets[platform];
|
|
135
|
+
if (!target) throw new Error("\u63D2\u4EF6\u4E0D\u652F\u6301\u5F53\u524D\u5E73\u53F0");
|
|
136
|
+
if ((platform === "android" || platform === "ios") && manifest.permissions?.length)
|
|
137
|
+
throw new Error("\u79FB\u52A8\u5BBF\u4E3B\u5C1A\u672A\u63A5\u5165\u4E1A\u52A1\u6570\u636E\u6388\u6743");
|
|
138
|
+
if (comparePluginVersions(host.appVersion, target.minAppVersion) < 0)
|
|
139
|
+
throw new Error("\u5BA2\u6237\u7AEF\u7248\u672C\u4F4E\u4E8E\u63D2\u4EF6\u8981\u6C42");
|
|
140
|
+
return target;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export {
|
|
144
|
+
PORTABLE_PLATFORMS,
|
|
145
|
+
PORTABLE_SHARED_MODULES,
|
|
146
|
+
buildPortablePluginManifest,
|
|
147
|
+
validatePortablePluginManifest,
|
|
148
|
+
readPortablePluginManifest,
|
|
149
|
+
validatePortableDistributionManifest,
|
|
150
|
+
assertPortablePluginCompatibility
|
|
151
|
+
};
|
package/docs/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Tau 插件开发文档
|
|
2
2
|
|
|
3
|
-
默认模板使用 SDK 0.
|
|
3
|
+
默认模板使用 SDK 0.41.0、UI 0.5.0,生成格式 3 的同一插件包。中心 v2 支持上传待审,格式 3 普通提交人工批准,具审核权限的作者本人经已绑定仓库 CI 发布可自动批准;平台测试由作者负责,不要求审核者测试或填写验证记录。Android/iOS 正式安装要求客户端至少 0.2.4,并通过中心兼容选版。先读 [API 支持矩阵](api-support.md)、[跨端契约](portability.md)与[快速开始](getting-started.md)。下文桌面领域接口不表示移动端可用。
|
|
4
4
|
|
|
5
5
|
Tau 插件用 TypeScript 和 React 编写,打包成一个 ZIP,按声明在兼容的 Tau 宿主运行。插件可以给 Tau 加页面和侧边栏入口,在文档里放自定义块,给 AI 提供工具,接入第三方存储、语音、视频等服务,或者读写用户的卡片和待办。
|
|
6
6
|
|
package/docs/api-support.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# 插件 API 支持矩阵
|
|
4
4
|
|
|
5
|
-
本表描述当前 SDK
|
|
5
|
+
本表描述当前 SDK 与仓库宿主实现,不代表线上已发布客户端。统一 API 契约随 SDK、模板、中心和作者插件一起更新,不保留旧能力别名。桌面与移动均接入格式 3 的安装和内容装配,实际发行版本与设备验收独立记录。网页插件中心只浏览与分发,不执行插件;具体发行和设备验证见任务记录。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
作者使用同一套 API,宿主负责具体实现和作用域。作者清单只声明支持平台、最低版本与用户数据权限,不填写能力列表;未接入移动端业务接口的插件暂不声明移动目标。调用失败、只读与用户授权继续遵循各 API 的明确语义。
|
|
8
8
|
|
|
9
9
|
## 上下文 API
|
|
10
10
|
|
|
@@ -39,34 +39,34 @@
|
|
|
39
39
|
|
|
40
40
|
## 正文、UI 与交互
|
|
41
41
|
|
|
42
|
-
| 能力 | 已实现范围
|
|
43
|
-
| -------------------------------------------------- |
|
|
44
|
-
| 静态 editorExtensions/editorCodecs | 三端共用节点/codec
|
|
45
|
-
| useElement、SourceBlockEditor/useSourceBlock | 公共节点操作、只读保护、草稿保存/取消;ABC 已在两端模拟器编辑保存
|
|
46
|
-
| 插入与块菜单 | 手机触摸插入、上下移动/删除等标准命令
|
|
47
|
-
| Dialog/Drawer 与页面退出 | 公共浮层回收和系统返回仲裁,页面离开守卫
|
|
48
|
-
| ContentEditor/ContentPreview、EntityRef 等业务组件 | 桌面有相应内容/引用适配
|
|
49
|
-
| 媒体与资源 | 正文节点资源声明与原文保留
|
|
50
|
-
| Skill 与博客正文渲染 | 格式 3 可附纯 Markdown Skill;桌面消费、移动仅校验保存;博客可读取原清单
|
|
51
|
-
| 白板与博客静态模板 | 桌面格式 3 支持白板扩展与现有装配
|
|
52
|
-
| runtimeStyles | 桌面使用原有编译服务,移动通过 Worker 解析 HTML/TSX 静态类并生成主题 CSS
|
|
53
|
-
| media | 移动插件复用当前文档的资源上传/解析、媒体槽位和图片查看器
|
|
54
|
-
| 搜索、摘要与同步 | 移动保留插件原始节点及 KV;前端导入导出使用 codec
|
|
42
|
+
| 能力 | 已实现范围 | 作者需要适配 | 宿主未接或待验收 |
|
|
43
|
+
| -------------------------------------------------- | ------------------------------------------------------------------------ | ---------------------------------------------------------- | ----------------------------------------------------------------------------- |
|
|
44
|
+
| 静态 editorExtensions/editorCodecs | 三端共用节点/codec;移动普通正文与预览装配;编辑权限由宿主作用域控制 | 在代码注册节点,公共数据与节点 type 不变 | 移动闪卡等其他 Kit 不自动装配;博客读取原始格式 3 清单并装配静态贡献 |
|
|
45
|
+
| useElement、SourceBlockEditor/useSourceBlock | 公共节点操作、只读保护、草稿保存/取消;ABC 已在两端模拟器编辑保存 | 使用标准组件;处理外部更新、取消、失活;专有编辑器自行适配 | 真机软键盘、中文输入法、最低 WebView 待验收 |
|
|
46
|
+
| 插入与块菜单 | 手机触摸插入、上下移动/删除等标准命令 | 自定义编辑动作不能仅有 hover/右键;手机提供可点击入口 | 完整长按拖拽、边缘手势、平板与手感待验收 |
|
|
47
|
+
| Dialog/Drawer 与页面退出 | 公共浮层回收和系统返回仲裁,页面离开守卫 | 关闭/取消不误保存;复杂布局使用响应式或分开视图 | 不是所有 @tau/ui 控件都已逐项完成移动交互验收 |
|
|
48
|
+
| ContentEditor/ContentPreview、EntityRef 等业务组件 | 桌面有相应内容/引用适配 | 不能因为组件可导入就宣称手机可编辑任意 Tau 正文 | 移动作者业务组件适配未接;区别于插件节点在已有正文中的渲染 |
|
|
49
|
+
| 媒体与资源 | 正文节点资源声明与原文保留 | 在 nodes 声明资源字段;分别验证目标场景 | 不承诺移动作者媒体 API 的上传/缓存/查看器全集;普通包内展示不等于领域服务已接 |
|
|
50
|
+
| Skill 与博客正文渲染 | 格式 3 可附纯 Markdown Skill;桌面消费、移动仅校验保存;博客可读取原清单 | 使用新版构建器,更新博客模板中的加载器 | 不支持移动 Skill 执行或脚本;博客 runtimeVersion 仍为 1 |
|
|
51
|
+
| 白板与博客静态模板 | 桌面格式 3 支持白板扩展与现有装配 | 在 whiteboardExtensions 注册实际元素 | 不纳入移动 web-v1 运行能力 |
|
|
52
|
+
| runtimeStyles | 桌面使用原有编译服务,移动通过 Worker 解析 HTML/TSX 静态类并生成主题 CSS | 写完整类名,不拼接动态类名;处理编译失败 | 不执行作者源码;移动源码上限 1 MiB,设备资源预算仍需验证 |
|
|
53
|
+
| media | 移动插件复用当前文档的资源上传/解析、媒体槽位和图片查看器 | 只读不上传;图册等自定义控件自行适配触摸 | media 与 upload 为独立功能;上传提供方使用 context.upload.register |
|
|
54
|
+
| 搜索、摘要与同步 | 移动保留插件原始节点及 KV;前端导入导出使用 codec | 新字段保持旧版可读,代码回退不回退数据 | 移动搜索不索引插件内部源码;真实同步冲突、长文资源预算待验收 |
|
|
55
55
|
|
|
56
|
-
##
|
|
56
|
+
## 声明边界
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
宿主功能不再维护重复的字符串词表。context.fetch/sync/upload、源码编辑、媒体与样式编译直接使用现有 API;editorExtensions/editorCodecs/whiteboardExtensions 是实际注册内容。清单不再有 requires、required、optional、editor、whiteboard 或节点等级,新构建和上传严格拒绝这些字段。
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
白板 getService 和 tryGetService 直接访问宿主按扩展绑定的服务注册表,不再重复填写依赖表。必需服务缺失抛错,可缺省服务通过 tryGetService 返回 undefined;插件存储隔离与资源回收继续由宿主控制。
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
权限、节点数据校验、资源字段、样式源码字段以及 AI 功能定义继续保留,它们分别约束授权、数据或实际行为。移动目标的非空 permissions 仍在构建、上传和求值前拒绝。
|
|
63
63
|
|
|
64
64
|
## 作者选择与发行边界
|
|
65
65
|
|
|
66
66
|
1. 先列出插件用到的 API;全部落在移动已接范围,才声明对应移动 target。
|
|
67
|
-
2. 若仅交互不同,共用数据/codec
|
|
67
|
+
2. 若仅交互不同,共用数据/codec,按容器宽度与输入提供操作;未完整适配的平台暂不声明。
|
|
68
68
|
3. 若依赖宿主未接的业务能力,保留桌面版本,不用改清单假装兼容。计数器和 ABC 的结论不能外推到所有插件。
|
|
69
69
|
4. 官方插件新发行统一使用格式 3;仅桌面插件也声明 desktop target。历史已发行记录不改写,历史客户端选版边界保留。增加平台需同一插件 ID 的更高版本,不覆盖已发布 ZIP、重命名节点或自动清数据。
|
|
70
|
-
5. SDK
|
|
70
|
+
5. SDK、模板、中心与宿主共用平台和版本契约;不保留重复能力声明或名称映射。普通提交人工批准,具审核权限的作者本人通过已绑定仓库 CI 发布可自动批准。平台适配与功能测试由作者负责,不要求审核者测试或填写验证记录。是否可安装由平台、客户端版本与中心开关共同决定,不能由 npm 版本推断。移动中心首次安装默认保存启用意图,下次打开生效;桌面新装默认停用,用户启用后重启内容插件;更新保留显式启停选择。任意开发 URL 安装仅限调试构建。
|
|
71
71
|
|
|
72
72
|
已完成的自动测试与模拟器行为验证不替代真机、最低系统、完整 IPA、桌面原生安装包发行、未知旧作者迁移或应用商店验收。
|
package/docs/editor.md
CHANGED
|
@@ -6,17 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
## 第一个块:计数器
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
正文节点在 editorExtensions 中注册,Markdown 转换在 editorCodecs 中注册。宿主据此装配正文、源码编辑和样式编译;manifest 不重复登记节点、等级或能力。targets 只声明已完整适配的平台及最低客户端版本。
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
{
|
|
13
|
-
"editor": { "elements": { "yourname.counter": "edit" } }
|
|
14
|
-
}
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
把声明加进作者 manifest.json,未单独覆盖的平台继承该等级。构建器生成内部编辑器要求与发行标记;使用标准源码组件时另声明 requires: ["sourceEditor"]。
|
|
18
|
-
|
|
19
|
-
### 2. 定义节点和扩展
|
|
11
|
+
### 1. 定义节点和扩展
|
|
20
12
|
|
|
21
13
|
```tsx
|
|
22
14
|
import { useState } from "react";
|
|
@@ -102,7 +94,7 @@ export default definePlugin({
|
|
|
102
94
|
});
|
|
103
95
|
```
|
|
104
96
|
|
|
105
|
-
###
|
|
97
|
+
### 2. 构建、安装、重启
|
|
106
98
|
|
|
107
99
|
`pnpm build` 并安装后,**完全退出并重新打开 Tau**。编辑器扩展在启动时装配,启用、停用和更新都要重启才生效。之后在文档里输入 `/计数器`,就能插入这个块。
|
|
108
100
|
|
package/docs/getting-started.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 快速开始
|
|
2
2
|
|
|
3
|
-
模板使用同一套 SDK:`@tau/plugins` 为 npm 别名 @xiongtao.xt/tau-plugins 0.40.0,`@tau/ui` 为 @xiongtao.xt/tau-ui 0.5.0。移动正式安装要求 Android/iOS 客户端至少 0.2.
|
|
3
|
+
模板使用同一套 SDK:`@tau/plugins` 为 npm 别名 @xiongtao.xt/tau-plugins 0.40.0,`@tau/ui` 为 @xiongtao.xt/tau-ui 0.5.0。移动正式安装要求 Android/iOS 客户端至少 0.2.4;具体支持范围先看 [API 矩阵](api-support.md)。
|
|
4
4
|
|
|
5
5
|
## 准备与构建
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@ pnpm install --frozen-lockfile
|
|
|
12
12
|
pnpm build
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
SDK 0.
|
|
15
|
+
SDK 0.41.0 已发布到 npm,直接使用上述冻结安装与构建命令,无需本地 tarball。SDK 发布不代表插件或 APP 已发布;客户端要求以清单和支持矩阵为准。
|
|
16
16
|
|
|
17
17
|
3. 构建生成 `dist/<插件ID>-<版本>.zip`;再次安装可用 `pnpm install --frozen-lockfile`。
|
|
18
18
|
4. 在目标宿主验证后按发布指南上传待审;格式 3 普通提交人工审核,具审核权限的作者本人通过已绑定仓库 CI 发布可自动批准。移动用户从应用内中心安装,首次安装保存启用意图,重开应用生效;桌面 0.59.1 支持格式 3 中心安装,首次安装后需在已安装页启用并重启。install:local 不把格式 3 写进旧桌面正式目录。
|
package/docs/plugin-basics.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 插件的组成
|
|
2
2
|
|
|
3
|
-
默认模板维护作者清单,构建器生成格式 3
|
|
3
|
+
默认模板维护作者清单,构建器生成格式 3 发行清单;平台声明与静态注册见[跨端契约](portability.md)。作者不手写包格式、入口或摘要。
|
|
4
4
|
|
|
5
5
|
一个 Tau 插件由以下几部分组成:
|
|
6
6
|
|
|
@@ -24,34 +24,30 @@
|
|
|
24
24
|
"keywords": ["计数", "打卡"],
|
|
25
25
|
"version": "1.0.0",
|
|
26
26
|
"targets": {
|
|
27
|
-
"desktop": { "minAppVersion": "0.59.
|
|
28
|
-
"android": { "minAppVersion": "0.2.
|
|
29
|
-
"ios": { "minAppVersion": "0.2.
|
|
27
|
+
"desktop": { "minAppVersion": "0.59.4" },
|
|
28
|
+
"android": { "minAppVersion": "0.2.4" },
|
|
29
|
+
"ios": { "minAppVersion": "0.2.4" }
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
### 需要你填写的字段
|
|
35
35
|
|
|
36
|
-
| 字段
|
|
37
|
-
|
|
|
38
|
-
| `id`
|
|
39
|
-
| `name`
|
|
40
|
-
| `description`
|
|
41
|
-
| `version`
|
|
42
|
-
| `targets`
|
|
43
|
-
| `categories`
|
|
44
|
-
| `keywords`
|
|
45
|
-
| `permissions`
|
|
46
|
-
| `
|
|
47
|
-
| `whiteboard` | 声明了白板扩展时写 `true`,见[白板扩展](whiteboard.md) |
|
|
48
|
-
| `backend` | 需要本机后台时填写,同时把 `formatVersion` 改为 `2`,见[本机后台](backend.md) |
|
|
36
|
+
| 字段 | 说明 |
|
|
37
|
+
| ------------- | ----------------------------------------------------------------------------------------------- |
|
|
38
|
+
| `id` | 插件的唯一标识,由小写字母、数字组成,用点或连字符分段,例如 `yourname.counter`。发布后不要再改 |
|
|
39
|
+
| `name` | 插件名称,显示在插件页和插件中心 |
|
|
40
|
+
| `description` | 一句话简介,1 至 160 字 |
|
|
41
|
+
| `version` | 插件版本,格式为 `主版本.次版本.修订号`,可带预发布后缀,如 `1.2.0-beta.1` |
|
|
42
|
+
| `targets` | 各平台最低应用版本;填写完整版本号,不写范围。省略平台表示不支持安装 |
|
|
43
|
+
| `categories` | 插件中心的分类,可多选,也可以不写,见下表 |
|
|
44
|
+
| `keywords` | 插件中心的搜索词,最多 5 个,每个不超过 20 字。例如 S3 插件可以写 `MinIO`、`R2` |
|
|
45
|
+
| `permissions` | 插件可能申请的用户数据权限,见[用户数据 · 权限](user-data.md#权限)和 [AI](ai.md) |
|
|
46
|
+
| `backend` | 需要本机后台时填写,同时把 `formatVersion` 改为 `2`,见[本机后台](backend.md) |
|
|
49
47
|
|
|
50
48
|
| 分类 | 适合的插件 |
|
|
51
49
|
| --------------- | ----------------------------- |
|
|
52
50
|
| `page` | 提供页面和侧边栏入口 |
|
|
53
|
-
| `editor` | 在文档中添加块 |
|
|
54
|
-
| `whiteboard` | 在白板中添加元素或工具 |
|
|
55
51
|
| `ai` | MCP 工具、AI 功能、图片生成 |
|
|
56
52
|
| `skill` | Skill 包,或附带 Skill 的插件 |
|
|
57
53
|
| `sync` | 同步存储 |
|
|
@@ -65,7 +61,7 @@
|
|
|
65
61
|
|
|
66
62
|
### 保持模板值的字段
|
|
67
63
|
|
|
68
|
-
`formatVersion`、`apiVersion`、`platform`、`profile`、`format`、`main` 按所选协议保持一致。`styles` 和 `integrity`
|
|
64
|
+
`formatVersion`、`apiVersion`、`platform`、`profile`、`format`、`main` 按所选协议保持一致。`styles` 和 `integrity` 由构建生成;纯 Markdown Skill 从目录收集。不要直接修改 ZIP。
|
|
69
65
|
|
|
70
66
|
## 入口与插件定义
|
|
71
67
|
|
package/docs/portability.md
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
一个 SDK、一套模板、同一插件 ID/版本对应同一 ZIP。普通页面直接使用公共 API;宿主在加载前检查兼容性。具体宿主实现范围见 [API 支持矩阵](api-support.md),SDK 类型存在不等于所有接口都已在移动端接入。
|
|
6
6
|
|
|
7
|
-
格式 3 也承载仅桌面的插件。使用业务数据、视频、语音、图片生成或博客发布等桌面能力时,只声明 desktop;不要增加尚未实现对应 API 的移动目标。白板插件继续使用 whiteboardExtensions
|
|
7
|
+
格式 3 也承载仅桌面的插件。使用业务数据、视频、语音、图片生成或博客发布等桌面能力时,只声明 desktop;不要增加尚未实现对应 API 的移动目标。白板插件继续使用 whiteboardExtensions,作者清单不重复填写白板类型,也不声明白板能力标签。宿主从实际定义识别静态贡献,作者只声明 desktop,安装兼容性统一由平台和最低客户端版本决定。
|
|
8
8
|
|
|
9
9
|
## 作者清单
|
|
10
10
|
|
|
11
|
-
作者维护 manifest.json
|
|
11
|
+
作者维护 manifest.json 的身份、目标平台、最低版本和数据权限。包格式、入口、摘要由构建器生成。
|
|
12
12
|
|
|
13
13
|
```json
|
|
14
14
|
{
|
|
@@ -18,20 +18,18 @@
|
|
|
18
18
|
"version": "1.0.0",
|
|
19
19
|
"categories": ["page"],
|
|
20
20
|
"targets": {
|
|
21
|
-
"desktop": { "minAppVersion": "0.59.
|
|
22
|
-
"android": { "minAppVersion": "0.2.
|
|
23
|
-
"ios": { "minAppVersion": "0.2.
|
|
21
|
+
"desktop": { "minAppVersion": "0.59.4" },
|
|
22
|
+
"android": { "minAppVersion": "0.2.4" },
|
|
23
|
+
"ios": { "minAppVersion": "0.2.4" }
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
版本填写实际验证过的下限。声明平台不代表已在该平台通过设备验收,也不控制生产中心的分发开关。
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
命令、页面、设置、网络、媒体、源码编辑、样式编译、同步和上传均直接使用统一 API,不填写 requires/optional/required。正文节点只在 editorExtensions 中注册一次,Markdown 转换在 editorCodecs 中注册,白板元素在 whiteboardExtensions 中注册;不在清单重复列节点、支持等级或贡献标记。声明某个平台表示该插件完整功能已适配该平台;不完整的平台暂不声明。
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
根级 requires、optional、editor.elements 为公共声明。目标平台不写时继承;写了就整组替换,空数组清空该组额外需求,不能取消公共基础要求。节点映射也是完整替换,不深合并。必需与可选不能重叠,未知名称在构建时拒绝;省略平台表示不允许该平台应用安装。
|
|
32
|
+
permissions 是用户数据授权上限,与宿主功能装配分开。资源字段、数据校验、样式源码字段和 AI 功能定义描述实际数据或行为,仍按 API 要求填写。
|
|
35
33
|
|
|
36
34
|
## 页面和入口
|
|
37
35
|
|
|
@@ -77,26 +75,15 @@ coarsePointer 对应 (any-pointer: coarse),finePointer 对应 (any-pointer: fi
|
|
|
77
75
|
|
|
78
76
|
图册排序、绘图等专有交互仍由作者实现。基础操作保留可点击/可聚焦按钮,拖拽与悬停只作增强;布局按实际容器调整,共享编辑状态和提交函数,方向或输入变化不能丢失草稿。不能为手机另建一套节点类型。
|
|
79
77
|
|
|
80
|
-
##
|
|
81
|
-
|
|
82
|
-
只有具备具体可选访问器和完整替代流程的功能才能标记 optional。当前作者 optional 词表仅允许 runtimeStyles,且 requires 必须包含 sourceEditor:
|
|
83
|
-
|
|
84
|
-
```json
|
|
85
|
-
{
|
|
86
|
-
"requires": ["sourceEditor"],
|
|
87
|
-
"optional": ["runtimeStyles"]
|
|
88
|
-
}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
通过 useSourceBlock(element).compiler(行内源码为 useInlineSource)读取编译器,宿主未提供时得到 undefined;作者使用随包基础样式完成降级。若动态样式是内容正确呈现的必要条件,就必须放在 requires。调用异常仍应显示错误,不能以可选为由吞掉失败。
|
|
78
|
+
## 宿主服务与当前作用域
|
|
92
79
|
|
|
93
|
-
|
|
80
|
+
源码编辑和样式编译直接通过 SourceBlockEditor/useSourceBlock/useInlineSource 使用,宿主负责注入实现,不再检查字符串声明。只读、取消、编译失败仍遵循接口语义。博客只读环境可以显示已保存内容或源码,不启动应用插件生命周期。
|
|
94
81
|
|
|
95
|
-
|
|
82
|
+
useResourceUpload() 在只读或没有资源存储的作用域返回 undefined,表示当前不能上传。白板服务直接通过 getService 获取必需服务、tryGetService 获取允许缺省的服务,不另列 requires/optional;宿主仍按扩展绑定服务注册表,插件私有存储按插件和工作区隔离。服务缺失与调用失败按实际 API 返回值或异常处理。
|
|
96
83
|
|
|
97
84
|
## 同步与资源上传
|
|
98
85
|
|
|
99
|
-
桌面、Android 和 iOS 使用同一套 context.sync、context.upload、context.fetch 和 settings.register API
|
|
86
|
+
桌面、Android 和 iOS 使用同一套 context.sync、context.upload、context.fetch 和 settings.register API。提供方直接注册服务与配置表单,无需再在清单声明这些 API。任务调度、持久化与选用由宿主负责。
|
|
100
87
|
|
|
101
88
|
领域表单仍接收 syncConfig/uploadConfig 的 value 与 save(value)。save 表达保存配置的意图:持久化、选用、测试和切换确认由宿主编排。当前桌面显式保存并选用,移动字段失焦保存后在服务页显式选用;作者不调用原生存储或宿主路由。保存失败保留输入,不把调用成功等同于网络测试通过。
|
|
102
89
|
|
|
@@ -108,13 +95,13 @@ coarsePointer 对应 (any-pointer: coarse),finePointer 对应 (any-pointer: fi
|
|
|
108
95
|
|
|
109
96
|
## 构建和分发
|
|
110
97
|
|
|
111
|
-
buildPortablePluginManifest(authorManifest, output) 接收作者清单和构建器提供的 main/styles/integrity/skills,输出格式 3、apiVersion 1、profile web-v1、CJS 单入口的发行清单。targets
|
|
98
|
+
buildPortablePluginManifest(authorManifest, output) 接收作者清单和构建器提供的 main/styles/integrity/skills,输出格式 3、apiVersion 1、profile web-v1、CJS 单入口的发行清单。targets 仅记录各平台 minAppVersion,插件中心只消费规范化结果,不执行作者源码。
|
|
112
99
|
|
|
113
|
-
|
|
100
|
+
客户端按平台、最低版本、格式与运行配置检查兼容性,插件中心再检查分发开关。宿主装配时读取实际注册的静态贡献,不依赖重复的能力词表或推测任意 JavaScript 的全部依赖。新发行要求桌面至少 0.59.4、移动至少 0.2.4;客户端安装包单独发行。
|
|
114
101
|
|
|
115
102
|
纯 Markdown Skill 由目录收集,桌面读取,移动校验保存但不执行;脚本与后台不因此成为移动能力。现有桌面领域插件保持其真实支持范围。移动业务数据权限未接时,不允许发行声明这些权限的移动目标。
|
|
116
103
|
|
|
117
|
-
React、SDK 与公共 UI 由宿主提供,其他浏览器依赖随包构建;不引用宿主 src,不导入 host/environment-host 等内部装配入口。可信插件与宿主共享 JS
|
|
104
|
+
React、SDK 与公共 UI 由宿主提供,其他浏览器依赖随包构建;不引用宿主 src,不导入 host/environment-host 等内部装配入口。可信插件与宿主共享 JS 环境,平台兼容检查、完整性摘要和用户权限不构成恶意代码沙箱。
|
|
118
105
|
|
|
119
106
|
## 验证
|
|
120
107
|
|
package/docs/release.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 发布与更新
|
|
2
2
|
|
|
3
|
-
模板使用 SDK 0.
|
|
3
|
+
模板使用 SDK 0.41.0 与 UI 0.5.0,当前清单要求桌面至少 0.59.4、Android/iOS 至少 0.2.4。格式 3 可经工作流发布;OIDC 推送者与插件所有者一致、本人有审核权限且仓库已绑定时自动批准,其他提交进入人工审核。作者负责声明平台的适配和测试;审核者只做上架审核,不要求平台测试或验证记录。实际安装还须通过中心兼容选版和平台分发开关。install:local 不把格式 3 写入旧正式目录,不要改格式号绕过限制。
|
|
4
4
|
|
|
5
5
|
插件写好之后,发布到[插件中心](https://plugins.taunote.app),用户就能在 Tau 中搜索、安装和更新它。这一篇介绍发布前的准备、第一次发布、之后的版本更新,以及如何升级 SDK。
|
|
6
6
|
|
package/docs/whiteboard.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
```json
|
|
13
13
|
{
|
|
14
|
-
"targets": { "desktop": { "minAppVersion": "0.59.
|
|
14
|
+
"targets": { "desktop": { "minAppVersion": "0.59.4" } }
|
|
15
15
|
}
|
|
16
16
|
```
|
|
17
17
|
|
|
@@ -266,7 +266,6 @@ import { IPluginStorage, defineWhiteboardExtension } from "@tau/plugins/whiteboa
|
|
|
266
266
|
|
|
267
267
|
defineWhiteboardExtension({
|
|
268
268
|
id: __PLUGIN_META__.id,
|
|
269
|
-
requires: [IPluginStorage],
|
|
270
269
|
elements: [/* ... */],
|
|
271
270
|
create: api => {
|
|
272
271
|
const storage = api.getService(IPluginStorage);
|
package/package.json
CHANGED
package/portable.js
CHANGED
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
-
PLUGIN_BASE_REQUIREMENTS,
|
|
3
2
|
PORTABLE_PLATFORMS,
|
|
4
3
|
PORTABLE_SHARED_MODULES,
|
|
5
|
-
assertPortableElementDeclarations,
|
|
6
4
|
assertPortablePluginCompatibility,
|
|
7
5
|
buildPortablePluginManifest,
|
|
8
|
-
getPortableElementSupport,
|
|
9
|
-
isPluginCapability,
|
|
10
6
|
readPortablePluginManifest,
|
|
11
7
|
validatePortableDistributionManifest,
|
|
12
8
|
validatePortablePluginManifest
|
|
13
|
-
} from "./client/chunk-
|
|
9
|
+
} from "./client/chunk-TOYS6GBE.js";
|
|
14
10
|
import "./client/chunk-FZTR4KOY.js";
|
|
15
11
|
export {
|
|
16
|
-
PLUGIN_BASE_REQUIREMENTS,
|
|
17
12
|
PORTABLE_PLATFORMS,
|
|
18
13
|
PORTABLE_SHARED_MODULES,
|
|
19
|
-
assertPortableElementDeclarations,
|
|
20
14
|
assertPortablePluginCompatibility,
|
|
21
15
|
buildPortablePluginManifest,
|
|
22
|
-
getPortableElementSupport,
|
|
23
|
-
isPluginCapability,
|
|
24
16
|
readPortablePluginManifest,
|
|
25
17
|
validatePortableDistributionManifest,
|
|
26
18
|
validatePortablePluginManifest
|
package/publish-artifacts.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PORTABLE_SHARED_MODULES,
|
|
3
|
-
assertPortableElementDeclarations,
|
|
4
|
-
getPortableElementSupport,
|
|
5
3
|
readPortablePluginManifest
|
|
6
|
-
} from "./client/chunk-
|
|
4
|
+
} from "./client/chunk-TOYS6GBE.js";
|
|
7
5
|
import {
|
|
8
6
|
PLUGIN_SHARED_MODULES,
|
|
9
7
|
validatePluginManifest
|
|
@@ -75,9 +73,8 @@ function evaluatePublishedPluginPackage(artifact, modules) {
|
|
|
75
73
|
const manifest = readPublishedPluginManifest(artifact.manifest);
|
|
76
74
|
if (manifest.formatVersion !== 3)
|
|
77
75
|
return evaluatePluginPackage({ ...artifact, manifest }, modules);
|
|
78
|
-
if (!manifest.
|
|
76
|
+
if (!manifest.targets.desktop) throw new Error("\u535A\u5BA2\u6E32\u67D3\u9700\u8981\u684C\u9762\u76EE\u6807");
|
|
79
77
|
const definition = evaluateModule(manifest, artifact.code, modules, PORTABLE_SHARED_MODULES);
|
|
80
|
-
assertPortableElementDeclarations(manifest, getPluginNodeTypes(definition));
|
|
81
78
|
return adaptPortablePluginDefinition(definition, manifest, "desktop").definition;
|
|
82
79
|
}
|
|
83
80
|
function evaluatePluginPackage(artifact, modules) {
|
|
@@ -85,46 +82,12 @@ function evaluatePluginPackage(artifact, modules) {
|
|
|
85
82
|
return evaluateModule(manifest, artifact.code, modules, PLUGIN_SHARED_MODULES);
|
|
86
83
|
}
|
|
87
84
|
function adaptPortablePluginDefinition(definition, manifest, platform) {
|
|
88
|
-
|
|
89
|
-
Object.fromEntries(
|
|
90
|
-
getPluginNodeTypes(definition).map((type) => [
|
|
91
|
-
type,
|
|
92
|
-
getPortableElementSupport(manifest, platform, type)
|
|
93
|
-
])
|
|
94
|
-
)
|
|
95
|
-
);
|
|
96
|
-
const extensions = definition.editorExtensions?.flatMap((extension) => {
|
|
97
|
-
const elements = extension.elements?.filter((element) => support[element.type] !== "none").map(
|
|
98
|
-
(element) => support[element.type] === "edit" ? element : { ...element, behaviors: void 0 }
|
|
99
|
-
);
|
|
100
|
-
if (!elements?.length) return [];
|
|
101
|
-
const types = new Set(elements.map((element) => element.type));
|
|
102
|
-
const editable = elements.every((element) => support[element.type] === "edit");
|
|
103
|
-
return [
|
|
104
|
-
{
|
|
105
|
-
...extension,
|
|
106
|
-
elements,
|
|
107
|
-
styleSources: extension.styleSources?.filter((source) => types.has(source.type)),
|
|
108
|
-
htmlSerializers: extension.htmlSerializers?.filter(
|
|
109
|
-
(serializer) => types.has(serializer.type)
|
|
110
|
-
),
|
|
111
|
-
...editable ? {} : {
|
|
112
|
-
blockPanel: void 0,
|
|
113
|
-
commands: void 0,
|
|
114
|
-
hotkeys: void 0,
|
|
115
|
-
menu: void 0,
|
|
116
|
-
behaviorsFor: void 0
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
];
|
|
120
|
-
});
|
|
85
|
+
if (!manifest.targets[platform]) throw new Error("\u63D2\u4EF6\u4E0D\u652F\u6301\u5F53\u524D\u5E73\u53F0");
|
|
121
86
|
return {
|
|
122
|
-
support
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
editorCodecs: definition.editorCodecs?.filter((codec) => support[codec.type] !== "none")
|
|
127
|
-
}
|
|
87
|
+
support: Object.freeze(
|
|
88
|
+
Object.fromEntries(getPluginNodeTypes(definition).map((type) => [type, "edit"]))
|
|
89
|
+
),
|
|
90
|
+
definition
|
|
128
91
|
};
|
|
129
92
|
}
|
|
130
93
|
function evaluateModule(manifest, code, modules, allowed) {
|
|
@@ -149,14 +112,14 @@ function evaluateModule(manifest, code, modules, allowed) {
|
|
|
149
112
|
function validatePluginDefinition(manifest, definition) {
|
|
150
113
|
if (!definition || typeof definition.create !== "function" || definition.id !== manifest.id || definition.name !== manifest.name || definition.version !== manifest.version || definition.apiVersion !== manifest.apiVersion)
|
|
151
114
|
throw new Error("\u63D2\u4EF6\u5165\u53E3\u5B9A\u4E49\u4E0E\u6E05\u5355\u4E0D\u4E00\u81F4");
|
|
152
|
-
if (Boolean(definition.editorExtensions?.length) !== Boolean(manifest.editor))
|
|
115
|
+
if (manifest.formatVersion !== 3 && Boolean(definition.editorExtensions?.length) !== Boolean(manifest.editor))
|
|
153
116
|
throw new Error("\u7F16\u8F91\u5668\u8D21\u732E\u5FC5\u987B\u4E0E manifest.editor \u58F0\u660E\u4E00\u81F4");
|
|
154
|
-
if (Boolean(definition.whiteboardExtensions?.length) !== Boolean(manifest.whiteboard))
|
|
117
|
+
if (manifest.formatVersion !== 3 && Boolean(definition.whiteboardExtensions?.length) !== Boolean(manifest.whiteboard))
|
|
155
118
|
throw new Error("\u767D\u677F\u8D21\u732E\u5FC5\u987B\u4E0E manifest.whiteboard \u58F0\u660E\u4E00\u81F4");
|
|
156
119
|
getPluginWhiteboardTypes(definition);
|
|
157
|
-
if (definition.editorCodecs?.length && !
|
|
120
|
+
if (definition.editorCodecs?.length && !definition.editorExtensions?.length)
|
|
158
121
|
throw new Error("Markdown codec \u5FC5\u987B\u968F\u7F16\u8F91\u5668\u8D21\u732E\u58F0\u660E");
|
|
159
|
-
|
|
122
|
+
{
|
|
160
123
|
const types = getPluginNodeTypes(definition);
|
|
161
124
|
if (definition.editorCodecs?.some((codec) => !types.includes(codec.type)))
|
|
162
125
|
throw new Error("\u63D2\u4EF6 codec \u53EA\u80FD\u58F0\u660E\u672C\u63D2\u4EF6\u63D0\u4F9B\u7684\u8282\u70B9\u7C7B\u578B");
|
|
@@ -1,44 +1,25 @@
|
|
|
1
1
|
import { type PluginManifest } from "./package";
|
|
2
|
-
import { type PluginCapability } from "./capabilities";
|
|
3
2
|
import type { PluginEnvironment } from "./environment";
|
|
4
|
-
export { isPluginCapability } from "./capabilities";
|
|
5
|
-
export type { PluginCapability } from "./capabilities";
|
|
6
3
|
export declare const PORTABLE_PLATFORMS: readonly ["desktop", "android", "ios"];
|
|
7
4
|
export type PortablePlatform = (typeof PORTABLE_PLATFORMS)[number];
|
|
8
5
|
export type PluginElementSupport = "none" | "render" | "edit";
|
|
9
6
|
export declare const PORTABLE_SHARED_MODULES: readonly ["@tau/plugins", "@tau/plugins/whiteboard", "@tau/ui", "react", "react-dom", "react-dom/client", "react/jsx-runtime", "react/jsx-dev-runtime"];
|
|
10
|
-
export interface PortablePluginTarget
|
|
7
|
+
export interface PortablePluginTarget {
|
|
11
8
|
readonly minAppVersion: string;
|
|
12
|
-
readonly required: readonly Capability[];
|
|
13
|
-
readonly optional: readonly Capability[];
|
|
14
|
-
readonly elements?: Readonly<Record<string, PluginElementSupport>>;
|
|
15
9
|
}
|
|
16
|
-
export interface PortablePluginManifest
|
|
10
|
+
export interface PortablePluginManifest extends Omit<PluginManifest, "formatVersion" | "platform" | "backend" | "minAppVersion" | "editor" | "whiteboard"> {
|
|
17
11
|
readonly formatVersion: 3;
|
|
18
12
|
readonly platform: "portable";
|
|
19
13
|
readonly profile: "web-v1";
|
|
20
14
|
readonly description?: string;
|
|
21
|
-
readonly targets: Readonly<Partial<Record<PortablePlatform, PortablePluginTarget
|
|
15
|
+
readonly targets: Readonly<Partial<Record<PortablePlatform, PortablePluginTarget>>>;
|
|
22
16
|
}
|
|
23
|
-
export type ReadablePortablePluginManifest = PortablePluginManifest
|
|
24
|
-
export declare const PLUGIN_BASE_REQUIREMENTS: readonly ["commands", "storage", "pages", "navigation", "settings", "dialogs"];
|
|
25
|
-
export type PluginRequirement = "sourceEditor" | "runtimeStyles" | "media" | "fetch" | "sync" | "upload";
|
|
26
|
-
export type OptionalPluginRequirement = "runtimeStyles";
|
|
17
|
+
export type ReadablePortablePluginManifest = PortablePluginManifest;
|
|
27
18
|
export interface PluginAuthorTarget {
|
|
28
19
|
readonly minAppVersion: string;
|
|
29
|
-
readonly requires?: readonly PluginRequirement[];
|
|
30
|
-
readonly optional?: readonly OptionalPluginRequirement[];
|
|
31
|
-
readonly editor?: {
|
|
32
|
-
readonly elements: Readonly<Record<string, PluginElementSupport>>;
|
|
33
|
-
};
|
|
34
20
|
}
|
|
35
21
|
export interface PluginAuthorManifest extends Pick<PluginManifest, "id" | "name" | "version" | "categories" | "keywords" | "permissions"> {
|
|
36
22
|
readonly description?: string;
|
|
37
|
-
readonly requires?: readonly PluginRequirement[];
|
|
38
|
-
readonly optional?: readonly OptionalPluginRequirement[];
|
|
39
|
-
readonly editor?: {
|
|
40
|
-
readonly elements: Readonly<Record<string, PluginElementSupport>>;
|
|
41
|
-
};
|
|
42
23
|
readonly targets: Readonly<Partial<Record<PortablePlatform, PluginAuthorTarget>>>;
|
|
43
24
|
}
|
|
44
25
|
export interface PluginBuildOutput {
|
|
@@ -48,21 +29,16 @@ export interface PluginBuildOutput {
|
|
|
48
29
|
readonly skills?: readonly string[];
|
|
49
30
|
readonly imports?: readonly string[];
|
|
50
31
|
}
|
|
51
|
-
/**
|
|
32
|
+
/** 作者声明身份与支持平台,宿主功能通过统一 API 注册。 */
|
|
52
33
|
export declare function buildPortablePluginManifest(value: unknown, output: PluginBuildOutput): PortablePluginManifest;
|
|
53
34
|
export interface PortablePluginHost {
|
|
54
35
|
readonly environment: PluginEnvironment;
|
|
55
|
-
readonly capabilities: readonly PluginCapability[];
|
|
56
36
|
readonly appVersion: string;
|
|
57
37
|
readonly profiles: readonly string[];
|
|
58
38
|
}
|
|
59
|
-
/**
|
|
39
|
+
/** 作者、中心和宿主读取同一份平台与版本契约。 */
|
|
60
40
|
export declare function validatePortablePluginManifest(value: unknown): PortablePluginManifest;
|
|
61
|
-
|
|
62
|
-
export declare function readPortablePluginManifest(value: unknown): ReadablePortablePluginManifest;
|
|
41
|
+
export declare const readPortablePluginManifest: typeof validatePortablePluginManifest;
|
|
63
42
|
/** 构建器与中心共用发行范围;不代表中心已开放批准发布。 */
|
|
64
43
|
export declare function validatePortableDistributionManifest(value: unknown): PortablePluginManifest;
|
|
65
|
-
export declare function assertPortablePluginCompatibility(manifest: ReadablePortablePluginManifest, host: PortablePluginHost): PortablePluginTarget
|
|
66
|
-
export declare function getPortableElementSupport(manifest: ReadablePortablePluginManifest, platform: PortablePlatform, type: string): PluginElementSupport;
|
|
67
|
-
/** 定义求值后对账节点归属;调用方仍须按支持等级装配渲染与提交保护。 */
|
|
68
|
-
export declare function assertPortableElementDeclarations(manifest: ReadablePortablePluginManifest, nodeTypes: readonly string[]): void;
|
|
44
|
+
export declare function assertPortablePluginCompatibility(manifest: ReadablePortablePluginManifest, host: PortablePluginHost): PortablePluginTarget;
|
|
@@ -7,7 +7,7 @@ export type { PublishedPluginRender } from "./render-artifact";
|
|
|
7
7
|
export declare function assertUniqueEditorCodecs(codecs: readonly MarkdownCodec[]): void;
|
|
8
8
|
export declare const PLUGIN_RENDER_VERSION = 1;
|
|
9
9
|
/** 发布站只读取静态贡献;清单保持原格式,不启动应用插件生命周期。 */
|
|
10
|
-
export declare function readPublishedPluginManifest(value: unknown): PluginManifest |
|
|
10
|
+
export declare function readPublishedPluginManifest(value: unknown): PluginManifest | import("./portable").PortablePluginManifest;
|
|
11
11
|
export declare function evaluatePublishedPluginPackage(artifact: {
|
|
12
12
|
manifest: PluginManifest | ReadablePortablePluginManifest;
|
|
13
13
|
code: string;
|
|
@@ -36,42 +36,16 @@ export declare function evaluatePortablePluginPackage(artifact: {
|
|
|
36
36
|
/** 各宿主共用支持等级投影;原始数据与节点身份不改写。 */
|
|
37
37
|
export declare function adaptPortablePluginDefinition(definition: PluginDefinition, manifest: ReadablePortablePluginManifest, platform: PortablePlatform): {
|
|
38
38
|
support: Readonly<{
|
|
39
|
-
[k: string]:
|
|
39
|
+
[k: string]: "edit";
|
|
40
40
|
}>;
|
|
41
|
-
definition:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
elements: import("../../editor/api").ElementSpec<import("../../editor/api").ParagraphElement>[];
|
|
49
|
-
styleSources: {
|
|
50
|
-
type: string;
|
|
51
|
-
field: string;
|
|
52
|
-
language: "html" | "tsx";
|
|
53
|
-
}[] | undefined;
|
|
54
|
-
htmlSerializers: {
|
|
55
|
-
type: string;
|
|
56
|
-
toHtml(element: Record<string, unknown>): string;
|
|
57
|
-
}[] | undefined;
|
|
58
|
-
id: string;
|
|
59
|
-
apiVersion: typeof import("../../editor/api").EXTENSION_API_VERSION;
|
|
60
|
-
plugins?: never;
|
|
61
|
-
}[] | undefined;
|
|
62
|
-
editorCodecs: MarkdownCodec[] | undefined;
|
|
63
|
-
id: string;
|
|
64
|
-
name: string;
|
|
65
|
-
version: string;
|
|
66
|
-
apiVersion: 1;
|
|
67
|
-
whiteboardExtensions?: readonly import("../../whiteboard/src/author").WhiteboardExtension[];
|
|
68
|
-
ai?: {
|
|
69
|
-
readonly features: readonly import("./ai").PluginAIFeature[];
|
|
70
|
-
};
|
|
71
|
-
create(): import("./contract").PluginInstance;
|
|
72
|
-
};
|
|
41
|
+
definition: PluginDefinition;
|
|
42
|
+
};
|
|
43
|
+
export declare const hasPluginContent: (definition: PluginDefinition) => boolean;
|
|
44
|
+
type DefinitionManifest = Pick<PluginManifest, "id" | "name" | "version" | "apiVersion"> & {
|
|
45
|
+
readonly formatVersion?: number;
|
|
46
|
+
readonly editor?: boolean;
|
|
47
|
+
readonly whiteboard?: boolean;
|
|
73
48
|
};
|
|
74
|
-
type DefinitionManifest = Pick<PluginManifest, "id" | "name" | "version" | "apiVersion" | "editor" | "whiteboard">;
|
|
75
49
|
export declare function validatePluginDefinition(manifest: DefinitionManifest, definition: PluginDefinition | undefined): PluginDefinition;
|
|
76
50
|
export declare function getPluginNodeTypes(definition: PluginDefinition): string[];
|
|
77
51
|
export declare function getPluginWhiteboardTypes(definition: PluginDefinition): string[];
|
|
@@ -3,5 +3,5 @@ export type { SketchPath, Vec } from "../../whiteboard/src/author";
|
|
|
3
3
|
export type { SchematicShape, SchematicFill, ResolvedSketch, ElementSketch, PageSketch, SketchLevel, } from "../../whiteboard/src/author";
|
|
4
4
|
export type { WhiteboardAPI, WhiteboardExtension, WhiteboardElementDefinition, WhiteboardContributions, TypedBoardElement, ElementCreateSpec, WhiteboardSnapshot, BoardElement, WhiteboardToolProps, } from "../../whiteboard/src/author";
|
|
5
5
|
import type { PluginStorage } from "./contract";
|
|
6
|
-
/** 由宿主按插件和工作区绑定,交互扩展通过
|
|
6
|
+
/** 由宿主按插件和工作区绑定,交互扩展通过 getService 获取。 */
|
|
7
7
|
export declare const IPluginStorage: import("../../shared/service-contract").ServiceIdentifier<PluginStorage>;
|
|
@@ -77,16 +77,9 @@ export interface WhiteboardAPI {
|
|
|
77
77
|
getShortcut(commandId: string): string | null;
|
|
78
78
|
/** 让指定元素闪烁提示(内核事件 element:flash 的公开触发入口) */
|
|
79
79
|
flashElement(id: string): void;
|
|
80
|
-
/**
|
|
81
|
-
* 获取必选宿主服务:只能取扩展 requires 声明过的 id;
|
|
82
|
-
* 取未声明的 id 或对 optional 声明的 id 调用均抛错(编程错误)。
|
|
83
|
-
* 仅扩展作用域的 api 提供,主 api 调用即抛错。
|
|
84
|
-
*/
|
|
80
|
+
/** 获取宿主为当前扩展提供的服务,缺失时抛错;主 API 不提供服务访问。 */
|
|
85
81
|
getService<T>(id: ServiceIdentifier<T>): T;
|
|
86
|
-
/**
|
|
87
|
-
* 获取可选宿主服务:只能取扩展 requires/optional 声明过的 id,
|
|
88
|
-
* 未注册返回 undefined;取未声明的 id 抛错(编程错误)。
|
|
89
|
-
*/
|
|
82
|
+
/** 获取宿主为当前扩展提供的可缺省服务,缺失时返回 undefined。 */
|
|
90
83
|
tryGetService<T>(id: ServiceIdentifier<T>): T | undefined;
|
|
91
84
|
/** 订阅内核事件(按 WhiteboardKernelEvents 推断参数)或扩展事件(<命名空间>.<名称>) */
|
|
92
85
|
on<K extends keyof WhiteboardKernelEvents>(event: K, listener: (...args: WhiteboardKernelEvents[K]) => void): void;
|
|
@@ -319,16 +312,6 @@ export interface WhiteboardExtension {
|
|
|
319
312
|
/** 展示名(UI 显示"来自 xxx"用);内置扩展可不填 */
|
|
320
313
|
readonly name?: string;
|
|
321
314
|
readonly apiVersion: 1;
|
|
322
|
-
/**
|
|
323
|
-
* 必选宿主服务:任一服务在宿主注册表中不存在时扩展被拒(reason "missing-service")。
|
|
324
|
-
* 声明过的 id 才能经 api.getService / api.tryGetService 获取。
|
|
325
|
-
*/
|
|
326
|
-
readonly requires?: readonly ServiceIdentifier<unknown>[];
|
|
327
|
-
/**
|
|
328
|
-
* 可选宿主服务:缺失不影响装配,经 api.tryGetService 获取(返回 undefined 表示未提供)。
|
|
329
|
-
* 对 optional 中的 id 调用 getService 会抛错。
|
|
330
|
-
*/
|
|
331
|
-
readonly optional?: readonly ServiceIdentifier<unknown>[];
|
|
332
315
|
create(api: WhiteboardAPI): WhiteboardContributions;
|
|
333
316
|
}
|
|
334
317
|
/** 扩展被禁用的原因:除编程错误外一律降级禁用单个扩展,不中断画布装配。 */
|
package/client/chunk-PRPTZJX2.js
DELETED
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
assertLocalId,
|
|
3
|
-
comparePluginVersions,
|
|
4
|
-
validatePluginManifest
|
|
5
|
-
} from "./chunk-FZTR4KOY.js";
|
|
6
|
-
|
|
7
|
-
// packages/plugins/src/capabilities.ts
|
|
8
|
-
var PLUGIN_CAPABILITIES = [
|
|
9
|
-
"commands",
|
|
10
|
-
"storage",
|
|
11
|
-
"pages",
|
|
12
|
-
"navigation",
|
|
13
|
-
"settings",
|
|
14
|
-
"dialogs",
|
|
15
|
-
"editor",
|
|
16
|
-
"editorCodecs",
|
|
17
|
-
"sourceEditor",
|
|
18
|
-
"runtimeStyles",
|
|
19
|
-
"fetch",
|
|
20
|
-
"sync",
|
|
21
|
-
"upload",
|
|
22
|
-
"media"
|
|
23
|
-
];
|
|
24
|
-
function readPluginCapabilityNames(value) {
|
|
25
|
-
if (!Array.isArray(value) || value.length > 128 || [...value].some(
|
|
26
|
-
(item) => typeof item !== "string" || item.length > 128 || !/^[a-z][a-zA-Z0-9]*$/.test(item)
|
|
27
|
-
) || new Set(value).size !== value.length)
|
|
28
|
-
throw new Error("\u80FD\u529B\u5217\u8868\u5305\u542B\u65E0\u6548\u540D\u79F0\u3001\u91CD\u590D\u9879\u6216\u8D85\u51FA\u6570\u91CF\u9650\u5236");
|
|
29
|
-
return Object.freeze([...value]);
|
|
30
|
-
}
|
|
31
|
-
function isPluginCapability(value) {
|
|
32
|
-
return typeof value === "string" && PLUGIN_CAPABILITIES.some((capability) => capability === value);
|
|
33
|
-
}
|
|
34
|
-
function readPluginCapabilities(value) {
|
|
35
|
-
const names = readPluginCapabilityNames(value);
|
|
36
|
-
if (!names.every(isPluginCapability)) throw new Error("\u80FD\u529B\u5217\u8868\u5305\u542B\u672A\u77E5\u80FD\u529B");
|
|
37
|
-
return names;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// packages/plugins/src/portable.ts
|
|
41
|
-
var PORTABLE_PLATFORMS = ["desktop", "android", "ios"];
|
|
42
|
-
var PORTABLE_SHARED_MODULES = [
|
|
43
|
-
"@tau/plugins",
|
|
44
|
-
"@tau/plugins/whiteboard",
|
|
45
|
-
"@tau/ui",
|
|
46
|
-
"react",
|
|
47
|
-
"react-dom",
|
|
48
|
-
"react-dom/client",
|
|
49
|
-
"react/jsx-runtime",
|
|
50
|
-
"react/jsx-dev-runtime"
|
|
51
|
-
];
|
|
52
|
-
var PLUGIN_BASE_REQUIREMENTS = [
|
|
53
|
-
"commands",
|
|
54
|
-
"storage",
|
|
55
|
-
"pages",
|
|
56
|
-
"navigation",
|
|
57
|
-
"settings",
|
|
58
|
-
"dialogs"
|
|
59
|
-
];
|
|
60
|
-
function assertKeys(item, keys, label) {
|
|
61
|
-
if (Object.keys(item).some((key) => !keys.includes(key))) throw new Error(`${label}\u5305\u542B\u672A\u77E5\u5B57\u6BB5`);
|
|
62
|
-
}
|
|
63
|
-
function buildPortablePluginManifest(value, output) {
|
|
64
|
-
const item = record(value, "\u4F5C\u8005\u6E05\u5355");
|
|
65
|
-
const files = record(output, "\u6784\u5EFA\u6587\u4EF6\u4FE1\u606F");
|
|
66
|
-
assertKeys(files, ["main", "styles", "integrity", "skills", "imports"], "\u6784\u5EFA\u6587\u4EF6\u4FE1\u606F");
|
|
67
|
-
const imports = files.imports ?? [];
|
|
68
|
-
if (!Array.isArray(imports) || imports.some((name) => !PORTABLE_SHARED_MODULES.includes(name)))
|
|
69
|
-
throw new Error("\u6784\u5EFA\u6A21\u5757\u4F9D\u8D56\u65E0\u6548");
|
|
70
|
-
const whiteboard = imports.includes("@tau/plugins/whiteboard");
|
|
71
|
-
const { imports: _imports, ...buildFiles } = files;
|
|
72
|
-
assertKeys(
|
|
73
|
-
item,
|
|
74
|
-
[
|
|
75
|
-
"id",
|
|
76
|
-
"name",
|
|
77
|
-
"version",
|
|
78
|
-
"description",
|
|
79
|
-
"categories",
|
|
80
|
-
"keywords",
|
|
81
|
-
"permissions",
|
|
82
|
-
"requires",
|
|
83
|
-
"optional",
|
|
84
|
-
"editor",
|
|
85
|
-
"targets"
|
|
86
|
-
],
|
|
87
|
-
"\u4F5C\u8005\u6E05\u5355"
|
|
88
|
-
);
|
|
89
|
-
const targets = record(item.targets, "\u76EE\u6807\u5E73\u53F0");
|
|
90
|
-
const requirements = (input, optional) => {
|
|
91
|
-
const names = readPluginCapabilities(input ?? []);
|
|
92
|
-
const allowed = optional ? ["runtimeStyles"] : ["sourceEditor", "runtimeStyles", "media", "fetch", "sync", "upload"];
|
|
93
|
-
if (names.some((name) => !allowed.includes(name)))
|
|
94
|
-
throw new Error(optional ? "\u529F\u80FD\u4E0D\u652F\u6301\u53EF\u9009\u8BBF\u95EE" : "\u4F5C\u8005\u53EA\u80FD\u58F0\u660E\u989D\u5916\u529F\u80FD\u9700\u6C42");
|
|
95
|
-
return names;
|
|
96
|
-
};
|
|
97
|
-
const elements = (input) => {
|
|
98
|
-
if (input === void 0) return void 0;
|
|
99
|
-
const editor = record(input, "\u7F16\u8F91\u5668\u58F0\u660E");
|
|
100
|
-
assertKeys(editor, ["elements"], "\u7F16\u8F91\u5668\u58F0\u660E");
|
|
101
|
-
return record(editor.elements, "\u8282\u70B9\u652F\u6301\u58F0\u660E");
|
|
102
|
-
};
|
|
103
|
-
const commonRequired = requirements(item.requires, false);
|
|
104
|
-
const commonOptional = requirements(item.optional, true);
|
|
105
|
-
if (commonOptional.some((name) => commonRequired.includes(name)))
|
|
106
|
-
throw new Error("\u5FC5\u9700\u4E0E\u53EF\u9009\u80FD\u529B\u4E0D\u80FD\u91CD\u53E0");
|
|
107
|
-
const commonElements = elements(item.editor);
|
|
108
|
-
const normalized = Object.fromEntries(
|
|
109
|
-
Object.entries(targets).map(([platform, input]) => {
|
|
110
|
-
const target = record(input, "\u5E73\u53F0\u914D\u7F6E");
|
|
111
|
-
assertKeys(target, ["minAppVersion", "requires", "optional", "editor"], "\u5E73\u53F0\u914D\u7F6E");
|
|
112
|
-
const extra = target.requires === void 0 ? commonRequired : requirements(target.requires, false);
|
|
113
|
-
const optional = target.optional === void 0 ? commonOptional : requirements(target.optional, true);
|
|
114
|
-
if (optional.some((name) => extra.includes(name))) throw new Error("\u5FC5\u9700\u4E0E\u53EF\u9009\u80FD\u529B\u4E0D\u80FD\u91CD\u53E0");
|
|
115
|
-
if (optional.includes("runtimeStyles") && !extra.includes("sourceEditor"))
|
|
116
|
-
throw new Error("\u53EF\u9009\u6837\u5F0F\u7F16\u8BD1\u9700\u8981 sourceEditor \u8BBF\u95EE\u5668");
|
|
117
|
-
const support = target.editor === void 0 ? commonElements : elements(target.editor);
|
|
118
|
-
const required = [...PLUGIN_BASE_REQUIREMENTS, ...extra];
|
|
119
|
-
if (support) required.push("editor", "editorCodecs");
|
|
120
|
-
return [
|
|
121
|
-
platform,
|
|
122
|
-
{
|
|
123
|
-
minAppVersion: target.minAppVersion,
|
|
124
|
-
required,
|
|
125
|
-
optional,
|
|
126
|
-
...support ? { elements: support } : {}
|
|
127
|
-
}
|
|
128
|
-
];
|
|
129
|
-
})
|
|
130
|
-
);
|
|
131
|
-
const {
|
|
132
|
-
requires: _requires,
|
|
133
|
-
optional: _optional,
|
|
134
|
-
editor: _editor,
|
|
135
|
-
targets: _targets,
|
|
136
|
-
...metadata
|
|
137
|
-
} = item;
|
|
138
|
-
return validatePortableDistributionManifest({
|
|
139
|
-
...metadata,
|
|
140
|
-
formatVersion: 3,
|
|
141
|
-
apiVersion: 1,
|
|
142
|
-
platform: "portable",
|
|
143
|
-
profile: "web-v1",
|
|
144
|
-
format: "cjs",
|
|
145
|
-
...buildFiles,
|
|
146
|
-
...whiteboard ? { whiteboard: true } : {},
|
|
147
|
-
...Object.values(normalized).some((target) => target.elements) ? { editor: true } : {},
|
|
148
|
-
targets: normalized
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
function record(value, label) {
|
|
152
|
-
if (!value || typeof value !== "object" || Array.isArray(value) || Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null)
|
|
153
|
-
throw new Error(`${label}\u5FC5\u987B\u662F\u666E\u901A\u5BF9\u8C61`);
|
|
154
|
-
return value;
|
|
155
|
-
}
|
|
156
|
-
function validatePortablePluginManifest(value) {
|
|
157
|
-
return parsePortablePluginManifest(value, readPluginCapabilities);
|
|
158
|
-
}
|
|
159
|
-
function readPortablePluginManifest(value) {
|
|
160
|
-
return parsePortablePluginManifest(value, readPluginCapabilityNames);
|
|
161
|
-
}
|
|
162
|
-
function validatePortableDistributionManifest(value) {
|
|
163
|
-
const manifest = validatePortablePluginManifest(value);
|
|
164
|
-
if (/[-+]/.test(manifest.version)) throw new Error("\u6B63\u5F0F\u8DE8\u7AEF\u5305\u7248\u672C\u4E0D\u80FD\u542B\u9884\u53D1\u5E03\u6216\u6784\u5EFA\u6807\u8BC6");
|
|
165
|
-
if ((manifest.targets.android || manifest.targets.ios) && manifest.permissions?.length)
|
|
166
|
-
throw new Error("\u79FB\u52A8\u7AEF\u5C1A\u672A\u63A5\u5165\u4E1A\u52A1\u6570\u636E\u6388\u6743\uFF0C\u4E0D\u80FD\u53D1\u5E03\u58F0\u660E\u8FD9\u4E9B\u6743\u9650\u7684\u79FB\u52A8\u76EE\u6807");
|
|
167
|
-
return manifest;
|
|
168
|
-
}
|
|
169
|
-
function parsePortablePluginManifest(value, readCapabilities) {
|
|
170
|
-
const item = record(value, "\u8DE8\u7AEF\u6E05\u5355");
|
|
171
|
-
const keys = /* @__PURE__ */ new Set([
|
|
172
|
-
"formatVersion",
|
|
173
|
-
"apiVersion",
|
|
174
|
-
"id",
|
|
175
|
-
"name",
|
|
176
|
-
"description",
|
|
177
|
-
"version",
|
|
178
|
-
"platform",
|
|
179
|
-
"profile",
|
|
180
|
-
"targets",
|
|
181
|
-
"format",
|
|
182
|
-
"main",
|
|
183
|
-
"styles",
|
|
184
|
-
"editor",
|
|
185
|
-
"whiteboard",
|
|
186
|
-
"categories",
|
|
187
|
-
"keywords",
|
|
188
|
-
"permissions",
|
|
189
|
-
"integrity",
|
|
190
|
-
"skills"
|
|
191
|
-
]);
|
|
192
|
-
if (Object.keys(item).some((key) => !keys.has(key))) throw new Error("\u8DE8\u7AEF\u6E05\u5355\u5305\u542B\u672A\u652F\u6301\u5B57\u6BB5");
|
|
193
|
-
if (item.formatVersion !== 3 || item.platform !== "portable" || item.profile !== "web-v1")
|
|
194
|
-
throw new Error("\u8DE8\u7AEF\u5305\u683C\u5F0F\u6216\u8FD0\u884C\u914D\u7F6E\u4E0D\u517C\u5BB9");
|
|
195
|
-
if (item.description !== void 0 && (typeof item.description !== "string" || !item.description.trim() || item.description.length > 160))
|
|
196
|
-
throw new Error("\u63D2\u4EF6\u7B80\u4ECB\u5FC5\u987B\u4E3A 1 \u81F3 160 \u5B57");
|
|
197
|
-
const base = validatePluginManifest(
|
|
198
|
-
{ ...item, formatVersion: 1, platform: "desktop" },
|
|
199
|
-
{ strict: true }
|
|
200
|
-
);
|
|
201
|
-
const rawTargets = record(item.targets, "\u76EE\u6807\u5E73\u53F0");
|
|
202
|
-
if (!Object.keys(rawTargets).length || Object.keys(rawTargets).some((key) => !PORTABLE_PLATFORMS.some((platform) => platform === key)))
|
|
203
|
-
throw new Error("\u76EE\u6807\u5E73\u53F0\u4E3A\u7A7A\u6216\u5305\u542B\u672A\u77E5\u5E73\u53F0");
|
|
204
|
-
const targets = {};
|
|
205
|
-
for (const platform of PORTABLE_PLATFORMS) {
|
|
206
|
-
if (!Object.hasOwn(rawTargets, platform)) continue;
|
|
207
|
-
const target = record(rawTargets[platform], "\u5E73\u53F0\u914D\u7F6E");
|
|
208
|
-
if (Object.keys(target).some(
|
|
209
|
-
(key) => !["minAppVersion", "required", "optional", "elements"].includes(key)
|
|
210
|
-
))
|
|
211
|
-
throw new Error("\u5E73\u53F0\u914D\u7F6E\u5305\u542B\u672A\u77E5\u5B57\u6BB5");
|
|
212
|
-
if (typeof target.minAppVersion !== "string") throw new Error("\u5E73\u53F0\u7F3A\u5C11\u6700\u4F4E\u5BA2\u6237\u7AEF\u7248\u672C");
|
|
213
|
-
comparePluginVersions(target.minAppVersion, target.minAppVersion);
|
|
214
|
-
const required = readCapabilities(target.required);
|
|
215
|
-
const optional = readCapabilities(target.optional ?? []);
|
|
216
|
-
if (base.whiteboard && platform !== "desktop") throw new Error("\u767D\u677F\u6269\u5C55\u53EA\u652F\u6301\u684C\u9762\u76EE\u6807");
|
|
217
|
-
if (optional.some((capability) => required.includes(capability)))
|
|
218
|
-
throw new Error("\u5FC5\u9700\u4E0E\u53EF\u9009\u80FD\u529B\u4E0D\u80FD\u91CD\u53E0");
|
|
219
|
-
let elements;
|
|
220
|
-
if (target.elements !== void 0) {
|
|
221
|
-
const entries = Object.entries(record(target.elements, "\u8282\u70B9\u652F\u6301\u58F0\u660E"));
|
|
222
|
-
if (!base.editor || !entries.length || entries.length > 128)
|
|
223
|
-
throw new Error("\u8282\u70B9\u652F\u6301\u58F0\u660E\u9700\u8981\u7F16\u8F91\u5668\u8D21\u732E\u4E14\u6570\u91CF\u6709\u6548");
|
|
224
|
-
elements = /* @__PURE__ */ Object.create(null);
|
|
225
|
-
for (const [type, support] of entries) {
|
|
226
|
-
assertLocalId(type);
|
|
227
|
-
if (type === "__proto__" || !["none", "render", "edit"].includes(support))
|
|
228
|
-
throw new Error("\u8282\u70B9\u652F\u6301\u7B49\u7EA7\u65E0\u6548");
|
|
229
|
-
if (support !== "none" && !required.some((capability) => capability === "editor"))
|
|
230
|
-
throw new Error("\u5C55\u793A\u6216\u7F16\u8F91\u8282\u70B9\u9700\u8981\u58F0\u660E\u7F16\u8F91\u5668\u80FD\u529B");
|
|
231
|
-
elements[type] = support;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
if (base.editor && !elements) throw new Error("\u6BCF\u4E2A\u76EE\u6807\u5E73\u53F0\u5FC5\u987B\u660E\u786E\u58F0\u660E\u8282\u70B9\u652F\u6301\u7B49\u7EA7");
|
|
235
|
-
targets[platform] = Object.freeze({
|
|
236
|
-
minAppVersion: target.minAppVersion,
|
|
237
|
-
required,
|
|
238
|
-
optional,
|
|
239
|
-
...elements ? { elements: Object.freeze(elements) } : {}
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
const files = record(item.integrity, "\u6587\u4EF6\u6458\u8981");
|
|
243
|
-
if (Object.keys(files).some((file) => !Object.hasOwn(base.integrity, file)))
|
|
244
|
-
throw new Error("\u8DE8\u7AEF\u5305\u5305\u542B\u672A\u58F0\u660E\u6587\u4EF6");
|
|
245
|
-
for (const file of Object.keys(files)) {
|
|
246
|
-
if (file === base.main || file === base.styles) continue;
|
|
247
|
-
if (!file.endsWith(".md") || file.split("/").includes("scripts") || file.includes("\\"))
|
|
248
|
-
throw new Error("\u8DE8\u7AEF Skill \u4EC5\u652F\u6301\u7EAF Markdown \u6587\u6863\uFF0C\u4E0D\u652F\u6301\u811A\u672C\u6216\u9644\u4EF6");
|
|
249
|
-
}
|
|
250
|
-
return Object.freeze({
|
|
251
|
-
...base,
|
|
252
|
-
formatVersion: 3,
|
|
253
|
-
platform: "portable",
|
|
254
|
-
profile: "web-v1",
|
|
255
|
-
...typeof item.description === "string" ? { description: item.description } : {},
|
|
256
|
-
targets: Object.freeze(targets)
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
function assertPortablePluginCompatibility(manifest, host) {
|
|
260
|
-
if (!host.profiles.includes(manifest.profile)) throw new Error("\u5BBF\u4E3B\u672A\u63A5\u5165\u8DE8\u7AEF\u8FD0\u884C\u914D\u7F6E");
|
|
261
|
-
const platform = host.environment.platform;
|
|
262
|
-
if (!PORTABLE_PLATFORMS.some((value) => value === platform))
|
|
263
|
-
throw new Error("\u5F53\u524D\u5E73\u53F0\u4E0D\u80FD\u6FC0\u6D3B\u8DE8\u7AEF\u5E94\u7528\u63D2\u4EF6");
|
|
264
|
-
const target = manifest.targets[platform];
|
|
265
|
-
if (!target) throw new Error("\u63D2\u4EF6\u4E0D\u652F\u6301\u5F53\u524D\u5E73\u53F0");
|
|
266
|
-
if ((platform === "android" || platform === "ios") && manifest.permissions?.length)
|
|
267
|
-
throw new Error("\u79FB\u52A8\u5BBF\u4E3B\u5C1A\u672A\u63A5\u5165\u4E1A\u52A1\u6570\u636E\u6388\u6743");
|
|
268
|
-
if (comparePluginVersions(host.appVersion, target.minAppVersion) < 0)
|
|
269
|
-
throw new Error("\u5BA2\u6237\u7AEF\u7248\u672C\u4F4E\u4E8E\u63D2\u4EF6\u8981\u6C42");
|
|
270
|
-
const missing = target.required.filter(
|
|
271
|
-
(capability) => !host.capabilities.some((available) => available === capability)
|
|
272
|
-
);
|
|
273
|
-
if (missing.length) throw new Error(`\u5BBF\u4E3B\u7F3A\u5C11\u5FC5\u9700\u80FD\u529B\uFF1A${missing.join("\u3001")}`);
|
|
274
|
-
return target;
|
|
275
|
-
}
|
|
276
|
-
function getPortableElementSupport(manifest, platform, type) {
|
|
277
|
-
const elements = manifest.targets[platform]?.elements;
|
|
278
|
-
return elements && Object.hasOwn(elements, type) ? elements[type] : "none";
|
|
279
|
-
}
|
|
280
|
-
function assertPortableElementDeclarations(manifest, nodeTypes) {
|
|
281
|
-
const actual = new Set(nodeTypes);
|
|
282
|
-
for (const target of Object.values(manifest.targets)) {
|
|
283
|
-
const declared = Object.keys(target.elements ?? {});
|
|
284
|
-
if (declared.length !== actual.size || declared.some((type) => !actual.has(type)))
|
|
285
|
-
throw new Error("\u5E73\u53F0\u8282\u70B9\u58F0\u660E\u4E0E\u63D2\u4EF6\u5B9E\u9645\u8D21\u732E\u4E0D\u4E00\u81F4");
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
export {
|
|
290
|
-
isPluginCapability,
|
|
291
|
-
PORTABLE_PLATFORMS,
|
|
292
|
-
PORTABLE_SHARED_MODULES,
|
|
293
|
-
PLUGIN_BASE_REQUIREMENTS,
|
|
294
|
-
buildPortablePluginManifest,
|
|
295
|
-
validatePortablePluginManifest,
|
|
296
|
-
readPortablePluginManifest,
|
|
297
|
-
validatePortableDistributionManifest,
|
|
298
|
-
assertPortablePluginCompatibility,
|
|
299
|
-
getPortableElementSupport,
|
|
300
|
-
assertPortableElementDeclarations
|
|
301
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/** 功能名只表示是否可用;接口升级由 SDK 和最低客户端版本管理。 */
|
|
2
|
-
export declare const PLUGIN_CAPABILITIES: readonly ["commands", "storage", "pages", "navigation", "settings", "dialogs", "editor", "editorCodecs", "sourceEditor", "runtimeStyles", "fetch", "sync", "upload", "media"];
|
|
3
|
-
export type PluginCapability = (typeof PLUGIN_CAPABILITIES)[number];
|
|
4
|
-
/** 保留分发清单原值,未知可选功能可读取但不能当作已实现功能。 */
|
|
5
|
-
export declare function readPluginCapabilityNames(value: unknown): readonly string[];
|
|
6
|
-
export declare function isPluginCapability(value: unknown): value is PluginCapability;
|
|
7
|
-
export declare function readPluginCapabilities(value: unknown): readonly PluginCapability[];
|