@xiongtao.xt/tau-plugins 0.40.0 → 0.42.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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # 更新记录
2
2
 
3
+ ## 0.42.0
4
+
5
+ - 元数据按协议提取,多余属性不再阻止构建、安装或宿主请求。
6
+ - 编辑器只接收公开字段,保留权限、身份、文件与资源完整性检查。
7
+ - 共享身份、文件和元数据解析,移除重复校验、无用途的构建依赖声明与任意文案、列表限制。
8
+ - SDK、模板和官方插件共用同一规则,插件接口与业务数据保持。
9
+
10
+ ## 0.41.0
11
+
12
+ - 插件功能直接使用统一 API 或注册实际扩展,不再填写宿主能力列表、正文节点等级或贡献标记。
13
+ - 正文转换、源码编辑、样式编译、媒体、同步和上传沿用现有接口,宿主负责装配。
14
+ - 白板服务直接通过 getService/tryGetService 获取,不再重复填写服务依赖表;插件与工作区存储隔离保持。
15
+ - 作者清单只保留插件资料、支持平台、最低客户端版本和用户数据权限,新发行拒绝重复声明。
16
+
3
17
  ## 0.40.0
4
18
 
5
19
  - 白板装配信息从构建的实际宿主模块依赖自动生成,作者只保留现有扩展 API 与平台声明。
@@ -0,0 +1,121 @@
1
+ import {
2
+ comparePluginVersions,
3
+ readPluginFilePath,
4
+ readPluginFiles,
5
+ readPluginMetadata
6
+ } from "./chunk-XCKDPTLI.js";
7
+
8
+ // packages/plugins/src/portable.ts
9
+ var PORTABLE_PLATFORMS = ["desktop", "android", "ios"];
10
+ var PORTABLE_SHARED_MODULES = [
11
+ "@tau/plugins",
12
+ "@tau/plugins/whiteboard",
13
+ "@tau/ui",
14
+ "react",
15
+ "react-dom",
16
+ "react-dom/client",
17
+ "react/jsx-runtime",
18
+ "react/jsx-dev-runtime"
19
+ ];
20
+ function buildPortablePluginManifest(value, output) {
21
+ const item = record(value, "\u4F5C\u8005\u6E05\u5355");
22
+ const files = record(output, "\u6784\u5EFA\u6587\u4EF6\u4FE1\u606F");
23
+ return validatePortableDistributionManifest({
24
+ id: item.id,
25
+ name: item.name,
26
+ version: item.version,
27
+ description: item.description,
28
+ categories: item.categories,
29
+ keywords: item.keywords,
30
+ permissions: item.permissions,
31
+ formatVersion: 3,
32
+ apiVersion: 1,
33
+ platform: "portable",
34
+ profile: "web-v1",
35
+ format: "cjs",
36
+ main: files.main,
37
+ styles: files.styles,
38
+ skills: files.skills,
39
+ integrity: files.integrity,
40
+ targets: item.targets
41
+ });
42
+ }
43
+ function record(value, label) {
44
+ if (!value || typeof value !== "object" || Array.isArray(value))
45
+ throw new Error(`${label}\u5FC5\u987B\u662F\u5BF9\u8C61`);
46
+ return value;
47
+ }
48
+ function validatePortablePluginManifest(value) {
49
+ return parsePortablePluginManifest(value);
50
+ }
51
+ var readPortablePluginManifest = validatePortablePluginManifest;
52
+ function validatePortableDistributionManifest(value) {
53
+ const manifest = validatePortablePluginManifest(value);
54
+ if ((manifest.targets.android || manifest.targets.ios) && manifest.permissions?.length)
55
+ 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");
56
+ return manifest;
57
+ }
58
+ function parsePortablePluginManifest(value) {
59
+ const item = record(value, "\u8DE8\u7AEF\u6E05\u5355");
60
+ if (item.formatVersion !== 3 || item.platform !== "portable" || item.profile !== "web-v1")
61
+ throw new Error("\u8DE8\u7AEF\u5305\u683C\u5F0F\u6216\u8FD0\u884C\u914D\u7F6E\u4E0D\u517C\u5BB9");
62
+ if (item.apiVersion !== 1 || item.format !== "cjs") throw new Error("\u63D2\u4EF6 API \u6216\u5165\u53E3\u683C\u5F0F\u4E0D\u517C\u5BB9");
63
+ const metadata = readPluginMetadata(item);
64
+ const main = readPluginFilePath(item.main, ".js");
65
+ const styles = item.styles === void 0 ? void 0 : readPluginFilePath(item.styles, ".css");
66
+ const files = readPluginFiles(item, [main, ...styles ? [styles] : []]);
67
+ const rawTargets = record(item.targets, "\u76EE\u6807\u5E73\u53F0");
68
+ const targets = {};
69
+ for (const platform of PORTABLE_PLATFORMS) {
70
+ if (!Object.hasOwn(rawTargets, platform)) continue;
71
+ const target = record(rawTargets[platform], "\u5E73\u53F0\u914D\u7F6E");
72
+ if (typeof target.minAppVersion !== "string") throw new Error("\u5E73\u53F0\u7F3A\u5C11\u6700\u4F4E\u5BA2\u6237\u7AEF\u7248\u672C");
73
+ comparePluginVersions(target.minAppVersion, target.minAppVersion);
74
+ targets[platform] = Object.freeze({ minAppVersion: target.minAppVersion });
75
+ }
76
+ if (!Object.keys(targets).length) throw new Error("\u9700\u8981\u81F3\u5C11\u4E00\u4E2A\u652F\u6301\u7684\u76EE\u6807\u5E73\u53F0");
77
+ const declaredFiles = item.integrity;
78
+ if (Object.keys(declaredFiles).some((file) => !Object.hasOwn(files.integrity, file)))
79
+ throw new Error("\u8DE8\u7AEF\u5305\u5305\u542B\u672A\u58F0\u660E\u6587\u4EF6");
80
+ for (const file of Object.keys(files.integrity)) {
81
+ if (file === main || file === styles) continue;
82
+ if (!file.endsWith(".md") || file.split("/").includes("scripts") || file.includes("\\"))
83
+ throw new Error("\u8DE8\u7AEF Skill \u4EC5\u652F\u6301\u7EAF Markdown \u6587\u6863\uFF0C\u4E0D\u652F\u6301\u811A\u672C\u6216\u9644\u4EF6");
84
+ }
85
+ return Object.freeze({
86
+ ...metadata,
87
+ apiVersion: 1,
88
+ format: "cjs",
89
+ main,
90
+ ...styles ? { styles } : {},
91
+ ...files,
92
+ formatVersion: 3,
93
+ platform: "portable",
94
+ profile: "web-v1",
95
+ ...typeof item.description === "string" ? { description: item.description } : {},
96
+ targets: Object.freeze(targets)
97
+ });
98
+ }
99
+ function assertPortablePluginCompatibility(manifest, host) {
100
+ if (!host.profiles.includes(manifest.profile)) throw new Error("\u5BBF\u4E3B\u672A\u63A5\u5165\u8DE8\u7AEF\u8FD0\u884C\u914D\u7F6E");
101
+ const platform = host.environment.platform;
102
+ if (!PORTABLE_PLATFORMS.some((value) => value === platform))
103
+ throw new Error("\u5F53\u524D\u5E73\u53F0\u4E0D\u80FD\u6FC0\u6D3B\u8DE8\u7AEF\u5E94\u7528\u63D2\u4EF6");
104
+ const target = manifest.targets[platform];
105
+ if (!target) throw new Error("\u63D2\u4EF6\u4E0D\u652F\u6301\u5F53\u524D\u5E73\u53F0");
106
+ if ((platform === "android" || platform === "ios") && manifest.permissions?.length)
107
+ throw new Error("\u79FB\u52A8\u5BBF\u4E3B\u5C1A\u672A\u63A5\u5165\u4E1A\u52A1\u6570\u636E\u6388\u6743");
108
+ if (comparePluginVersions(host.appVersion, target.minAppVersion) < 0)
109
+ throw new Error("\u5BA2\u6237\u7AEF\u7248\u672C\u4F4E\u4E8E\u63D2\u4EF6\u8981\u6C42");
110
+ return target;
111
+ }
112
+
113
+ export {
114
+ PORTABLE_PLATFORMS,
115
+ PORTABLE_SHARED_MODULES,
116
+ buildPortablePluginManifest,
117
+ validatePortablePluginManifest,
118
+ readPortablePluginManifest,
119
+ validatePortableDistributionManifest,
120
+ assertPortablePluginCompatibility
121
+ };
@@ -36,6 +36,62 @@ function comparePluginVersions(left, right) {
36
36
  return 0;
37
37
  }
38
38
 
39
+ // packages/plugins/src/backend-manifest.ts
40
+ var PLUGIN_SYSTEM_ACCESS = ["filesystem", "network", "process"];
41
+ function validateBackendManifest(value) {
42
+ if (!value || typeof value !== "object" || Array.isArray(value))
43
+ throw new Error("\u540E\u53F0\u58F0\u660E\u5FC5\u987B\u662F\u5BF9\u8C61");
44
+ const item = value;
45
+ if (typeof item.entry !== "string" || !/^[\w./-]+\.js$/.test(item.entry) || item.entry.split("/").some((part) => !part || part === "." || part === ".."))
46
+ throw new Error("\u540E\u53F0\u5165\u53E3\u5FC5\u987B\u662F\u5305\u5185 JS \u6587\u4EF6");
47
+ if (item.runtime !== "node" || item.apiVersion !== 1)
48
+ throw new Error("\u540E\u53F0\u8FD0\u884C\u65F6\u6216\u534F\u8BAE\u7248\u672C\u4E0D\u517C\u5BB9");
49
+ if (item.scope !== "application" && item.scope !== "workspace") throw new Error("\u540E\u53F0\u4F5C\u7528\u57DF\u65E0\u6548");
50
+ if (item.activation !== "on-demand" && item.activation !== "app-ready" && item.activation !== "workspace-ready")
51
+ throw new Error("\u540E\u53F0\u6FC0\u6D3B\u65F6\u673A\u65E0\u6548");
52
+ if (item.activation !== "on-demand" && item.activation !== (item.scope === "application" ? "app-ready" : "workspace-ready"))
53
+ throw new Error("\u540E\u53F0\u6FC0\u6D3B\u65F6\u673A\u4E0E\u4F5C\u7528\u57DF\u4E0D\u5339\u914D");
54
+ if (item.lifetime !== "idle" && item.lifetime !== "persistent")
55
+ throw new Error("\u540E\u53F0\u751F\u547D\u5468\u671F\u65E0\u6548");
56
+ if (typeof item.reason !== "string" || !item.reason.trim()) throw new Error("\u540E\u53F0\u7528\u9014\u4E0D\u80FD\u4E3A\u7A7A");
57
+ if (!Array.isArray(item.systemAccess) || item.systemAccess.some((value2) => !PLUGIN_SYSTEM_ACCESS.includes(value2)))
58
+ throw new Error("\u540E\u53F0\u7CFB\u7EDF\u7528\u9014\u5206\u7C7B\u65E0\u6548");
59
+ let tools;
60
+ if (item.tools !== void 0) {
61
+ if (!Array.isArray(item.tools) || !item.systemAccess.includes("process"))
62
+ throw new Error("\u5916\u90E8\u5DE5\u5177\u987B\u58F0\u660E process \u7528\u9014");
63
+ const ids = /* @__PURE__ */ new Set();
64
+ tools = Object.freeze(
65
+ item.tools.map((tool) => {
66
+ if (!tool || typeof tool !== "object" || Array.isArray(tool))
67
+ throw new Error("\u5916\u90E8\u5DE5\u5177\u58F0\u660E\u65E0\u6548");
68
+ const value2 = tool;
69
+ if (typeof value2.id !== "string" || !/^[a-z][\w.-]*$/.test(value2.id) || ids.has(value2.id) || typeof value2.command !== "string" || !value2.command.trim() || value2.command.includes("\0"))
70
+ throw new Error("\u5916\u90E8\u5DE5\u5177\u8EAB\u4EFD\u6216\u547D\u4EE4\u65E0\u6548");
71
+ ids.add(value2.id);
72
+ if (value2.args !== void 0 && (!Array.isArray(value2.args) || value2.args.some((arg) => typeof arg !== "string" || arg.includes("\0"))))
73
+ throw new Error("\u5916\u90E8\u5DE5\u5177\u53C2\u6570\u65E0\u6548");
74
+ return Object.freeze({
75
+ id: value2.id,
76
+ command: value2.command,
77
+ ...value2.args ? { args: Object.freeze([...value2.args]) } : {}
78
+ });
79
+ })
80
+ );
81
+ }
82
+ return Object.freeze({
83
+ ...tools ? { tools } : {},
84
+ entry: item.entry,
85
+ runtime: "node",
86
+ apiVersion: 1,
87
+ scope: item.scope,
88
+ activation: item.activation,
89
+ lifetime: item.lifetime,
90
+ reason: item.reason.trim(),
91
+ systemAccess: Object.freeze([...new Set(item.systemAccess)])
92
+ });
93
+ }
94
+
39
95
  // packages/plugins/src/categories.ts
40
96
  var PLUGIN_CATEGORIES = [
41
97
  { id: "sync", label: "\u540C\u6B65" },
@@ -50,36 +106,25 @@ var PLUGIN_CATEGORIES = [
50
106
  { id: "video", label: "\u89C6\u9891" },
51
107
  { id: "page", label: "\u9875\u9762" }
52
108
  ];
53
- var PLUGIN_KEYWORD_LIMIT = 5;
54
- var PLUGIN_KEYWORD_MAX_LENGTH = 20;
55
109
  var categoryIds = new Set(PLUGIN_CATEGORIES.map((item) => item.id));
56
110
  var isPluginCategory = (value) => typeof value === "string" && categoryIds.has(value);
57
- function readCatalogFields(item, strict) {
58
- const fail = (message) => {
59
- if (strict) throw new Error(message);
60
- };
111
+ function readCatalogFields(item) {
61
112
  const list = (value, name) => {
62
113
  if (value === void 0) return [];
63
114
  if (Array.isArray(value)) return value;
64
- fail(`${name} \u5FC5\u987B\u662F\u6570\u7EC4`);
65
- return [];
115
+ throw new Error(`${name} \u5FC5\u987B\u662F\u6570\u7EC4`);
66
116
  };
67
117
  const categories = [];
68
118
  for (const value of list(item.categories, "categories")) {
69
- if (!isPluginCategory(value)) fail(`\u672A\u77E5\u63D2\u4EF6\u5206\u7C7B\uFF1A${String(value)}`);
119
+ if (!isPluginCategory(value)) throw new Error(`\u672A\u77E5\u63D2\u4EF6\u5206\u7C7B\uFF1A${String(value)}`);
70
120
  else if (!categories.includes(value)) categories.push(value);
71
121
  }
72
122
  const keywords = [];
73
123
  for (const value of list(item.keywords, "keywords")) {
74
124
  const keyword = typeof value === "string" ? value.trim() : "";
75
- if (!keyword || keyword.length > PLUGIN_KEYWORD_MAX_LENGTH)
76
- fail(`\u5173\u952E\u8BCD\u5FC5\u987B\u4E3A 1 \u81F3 ${PLUGIN_KEYWORD_MAX_LENGTH} \u5B57`);
125
+ if (!keyword) throw new Error("\u5173\u952E\u8BCD\u5FC5\u987B\u662F\u975E\u7A7A\u6587\u672C");
77
126
  else if (!keywords.includes(keyword)) keywords.push(keyword);
78
127
  }
79
- if (keywords.length > PLUGIN_KEYWORD_LIMIT) {
80
- fail(`\u5173\u952E\u8BCD\u6700\u591A ${PLUGIN_KEYWORD_LIMIT} \u4E2A`);
81
- keywords.length = PLUGIN_KEYWORD_LIMIT;
82
- }
83
128
  return {
84
129
  ...categories.length ? { categories: Object.freeze(categories) } : {},
85
130
  ...keywords.length ? { keywords: Object.freeze(keywords) } : {}
@@ -138,108 +183,30 @@ var PLUGIN_PERMISSIONS = [
138
183
  ];
139
184
  var permissionIds = new Set(PLUGIN_PERMISSIONS);
140
185
  var isPluginPermission = (value) => typeof value === "string" && permissionIds.has(value);
141
- function readPermissionsField(item, strict) {
142
- const fail = (message) => {
143
- if (strict) throw new Error(message);
144
- };
186
+ function readPermissionsField(item) {
145
187
  if (item.permissions === void 0) return {};
146
188
  if (!Array.isArray(item.permissions)) {
147
- fail("permissions \u5FC5\u987B\u662F\u6570\u7EC4");
148
- return {};
189
+ throw new Error("permissions \u5FC5\u987B\u662F\u6570\u7EC4");
149
190
  }
150
191
  const permissions = [];
151
192
  for (const value of item.permissions) {
152
- if (!isPluginPermission(value)) fail(`\u672A\u77E5\u63D2\u4EF6\u6743\u9650\uFF1A${String(value)}`);
193
+ if (!isPluginPermission(value)) throw new Error(`\u672A\u77E5\u63D2\u4EF6\u6743\u9650\uFF1A${String(value)}`);
153
194
  else if (!permissions.includes(value)) permissions.push(value);
154
195
  }
155
196
  return permissions.length ? { permissions: Object.freeze(permissions) } : {};
156
197
  }
157
198
 
158
- // packages/plugins/src/backend-manifest.ts
159
- var PLUGIN_SYSTEM_ACCESS = ["filesystem", "network", "process"];
160
- function validateBackendManifest(value) {
161
- if (!value || typeof value !== "object" || Array.isArray(value))
162
- throw new Error("\u540E\u53F0\u58F0\u660E\u5FC5\u987B\u662F\u5BF9\u8C61");
163
- const item = value;
164
- const keys = [
165
- "entry",
166
- "runtime",
167
- "apiVersion",
168
- "scope",
169
- "activation",
170
- "lifetime",
171
- "reason",
172
- "systemAccess",
173
- "tools"
174
- ];
175
- if (Object.keys(item).some((key) => !keys.includes(key))) throw new Error("\u540E\u53F0\u58F0\u660E\u5305\u542B\u672A\u77E5\u5B57\u6BB5");
176
- if (typeof item.entry !== "string" || !/^[\w./-]+\.js$/.test(item.entry) || item.entry.split("/").some((part) => !part || part === "." || part === ".."))
177
- throw new Error("\u540E\u53F0\u5165\u53E3\u5FC5\u987B\u662F\u5305\u5185 JS \u6587\u4EF6");
178
- if (item.runtime !== "node" || item.apiVersion !== 1)
179
- throw new Error("\u540E\u53F0\u8FD0\u884C\u65F6\u6216\u534F\u8BAE\u7248\u672C\u4E0D\u517C\u5BB9");
180
- if (item.scope !== "application" && item.scope !== "workspace") throw new Error("\u540E\u53F0\u4F5C\u7528\u57DF\u65E0\u6548");
181
- if (item.activation !== "on-demand" && item.activation !== "app-ready" && item.activation !== "workspace-ready")
182
- throw new Error("\u540E\u53F0\u6FC0\u6D3B\u65F6\u673A\u65E0\u6548");
183
- if (item.activation !== "on-demand" && item.activation !== (item.scope === "application" ? "app-ready" : "workspace-ready"))
184
- throw new Error("\u540E\u53F0\u6FC0\u6D3B\u65F6\u673A\u4E0E\u4F5C\u7528\u57DF\u4E0D\u5339\u914D");
185
- if (item.lifetime !== "idle" && item.lifetime !== "persistent")
186
- throw new Error("\u540E\u53F0\u751F\u547D\u5468\u671F\u65E0\u6548");
187
- if (typeof item.reason !== "string" || !item.reason.trim() || item.reason.length > 500)
188
- throw new Error("\u540E\u53F0\u7528\u9014\u5FC5\u987B\u4E3A 1 \u81F3 500 \u5B57");
189
- if (!Array.isArray(item.systemAccess) || new Set(item.systemAccess).size !== item.systemAccess.length || item.systemAccess.some((value2) => !PLUGIN_SYSTEM_ACCESS.includes(value2)))
190
- throw new Error("\u540E\u53F0\u7CFB\u7EDF\u7528\u9014\u5206\u7C7B\u65E0\u6548");
191
- let tools;
192
- if (item.tools !== void 0) {
193
- if (!Array.isArray(item.tools) || item.tools.length > 32 || !item.systemAccess.includes("process"))
194
- throw new Error("\u5916\u90E8\u5DE5\u5177\u987B\u58F0\u660E process \u7528\u9014\uFF0C\u6700\u591A 32 \u9879");
195
- const ids = /* @__PURE__ */ new Set();
196
- tools = Object.freeze(
197
- item.tools.map((tool) => {
198
- if (!tool || typeof tool !== "object" || Array.isArray(tool))
199
- throw new Error("\u5916\u90E8\u5DE5\u5177\u58F0\u660E\u65E0\u6548");
200
- const value2 = tool;
201
- if (Object.keys(value2).some((key) => !["id", "command", "args"].includes(key)) || typeof value2.id !== "string" || !/^[a-z][\w.-]{0,63}$/.test(value2.id) || ids.has(value2.id) || typeof value2.command !== "string" || !value2.command.trim() || value2.command.length > 1024 || /[\0\r\n]/.test(value2.command))
202
- throw new Error("\u5916\u90E8\u5DE5\u5177\u8EAB\u4EFD\u6216\u547D\u4EE4\u65E0\u6548");
203
- ids.add(value2.id);
204
- if (value2.args !== void 0 && (!Array.isArray(value2.args) || value2.args.length > 64 || value2.args.some(
205
- (arg) => typeof arg !== "string" || arg.length > 4096 || arg.includes("\0")
206
- )))
207
- throw new Error("\u5916\u90E8\u5DE5\u5177\u53C2\u6570\u65E0\u6548");
208
- return Object.freeze({
209
- id: value2.id,
210
- command: value2.command,
211
- ...value2.args ? { args: Object.freeze([...value2.args]) } : {}
212
- });
213
- })
214
- );
215
- }
216
- return Object.freeze({
217
- ...tools ? { tools } : {},
218
- entry: item.entry,
219
- runtime: "node",
220
- apiVersion: 1,
221
- scope: item.scope,
222
- activation: item.activation,
223
- lifetime: item.lifetime,
224
- reason: item.reason.trim(),
225
- systemAccess: Object.freeze([...item.systemAccess])
226
- });
227
- }
228
-
229
199
  // packages/plugins/src/skills.ts
230
200
  var SKILL_ROOT = "skills";
231
201
  var SKILL_README = "SKILL.md";
232
- var SKILL_LIMITS = { skills: 32 };
233
202
  var skillDirectory = (id) => `${SKILL_ROOT}/${id}`;
234
203
  function readSkillsField(value) {
235
204
  if (value === void 0) return void 0;
236
- if (!Array.isArray(value) || value.length > SKILL_LIMITS.skills)
237
- throw new Error(`skills \u5FC5\u987B\u662F\u6700\u591A ${SKILL_LIMITS.skills} \u9879\u7684\u6570\u7EC4`);
205
+ if (!Array.isArray(value)) throw new Error("skills \u5FC5\u987B\u662F\u6570\u7EC4");
238
206
  const ids = /* @__PURE__ */ new Set();
239
207
  for (const id of value) {
240
208
  if (typeof id !== "string") throw new Error("Skill ID \u65E0\u6548");
241
209
  assertLocalId(id);
242
- if (ids.has(id)) throw new Error(`Skill ID \u91CD\u590D\uFF1A${id}`);
243
210
  ids.add(id);
244
211
  }
245
212
  return ids.size ? Object.freeze([...ids]) : void 0;
@@ -262,6 +229,43 @@ function readSkillFiles(skills, integrity) {
262
229
  return files;
263
230
  }
264
231
 
232
+ // packages/plugins/src/package-fields.ts
233
+ function readPluginIdentity(item) {
234
+ const { id, name, version } = item;
235
+ if (typeof id !== "string") throw new Error("\u63D2\u4EF6 ID \u65E0\u6548");
236
+ assertLocalId(id);
237
+ if (typeof name !== "string" || !name.trim() || typeof version !== "string")
238
+ throw new Error("\u63D2\u4EF6\u540D\u79F0\u6216\u7248\u672C\u65E0\u6548");
239
+ comparePluginVersions(version, version);
240
+ return { id, name, version };
241
+ }
242
+ function readPluginMetadata(item) {
243
+ return { ...readPluginIdentity(item), ...readCatalogFields(item), ...readPermissionsField(item) };
244
+ }
245
+ function readPluginFilePath(input, extension) {
246
+ if (typeof input !== "string" || !/^[\w./-]+$/.test(input) || input.split("/").some((part) => !part || part === "." || part === "..") || !input.endsWith(extension))
247
+ throw new Error("\u63D2\u4EF6\u5165\u53E3\u6216\u6837\u5F0F\u8DEF\u5F84\u65E0\u6548");
248
+ return input;
249
+ }
250
+ function readPluginFiles(item, entries) {
251
+ if (!item.integrity || typeof item.integrity !== "object" || Array.isArray(item.integrity))
252
+ throw new Error("\u63D2\u4EF6\u4EA7\u7269\u7F3A\u5C11\u5B8C\u6574\u6027\u6458\u8981\u6E05\u5355");
253
+ const source = item.integrity;
254
+ const integrity = {};
255
+ for (const name of entries) {
256
+ const hash = source[name];
257
+ if (typeof hash !== "string" || !/^[a-f0-9]{64}$/.test(hash))
258
+ throw new Error("\u63D2\u4EF6\u4EA7\u7269\u7F3A\u5C11\u6709\u6548\u7684\u5B8C\u6574\u6027\u6458\u8981");
259
+ integrity[name] = hash;
260
+ }
261
+ const skills = readSkillsField(item.skills);
262
+ Object.assign(integrity, readSkillFiles(skills, source));
263
+ return {
264
+ ...skills ? { skills } : {},
265
+ integrity: Object.freeze(integrity)
266
+ };
267
+ }
268
+
265
269
  // packages/plugins/src/package.ts
266
270
  var PLUGIN_SHARED_MODULES = [
267
271
  "@tau/plugins",
@@ -274,22 +278,14 @@ var PLUGIN_SHARED_MODULES = [
274
278
  "react/jsx-runtime",
275
279
  "react/jsx-dev-runtime"
276
280
  ];
277
- function validatePluginManifest(value, options = {}) {
281
+ function validatePluginManifest(value) {
278
282
  if (!value || typeof value !== "object" || Array.isArray(value))
279
283
  throw new Error("\u63D2\u4EF6\u6E05\u5355\u5FC5\u987B\u662F\u5BF9\u8C61");
280
284
  const item = value;
281
285
  if (item.formatVersion !== 1 && item.formatVersion !== 2 || item.apiVersion !== 1 || item.platform !== "desktop" || item.format !== "cjs")
282
286
  throw new Error("\u63D2\u4EF6\u5305\u683C\u5F0F\u3001API \u7248\u672C\u6216\u5E73\u53F0\u4E0D\u517C\u5BB9");
283
- if (typeof item.id !== "string") throw new Error("\u63D2\u4EF6 ID \u65E0\u6548");
284
- assertLocalId(item.id);
285
- if (typeof item.name !== "string" || !item.name.trim() || typeof item.version !== "string" || !/^\d+\.\d+\.\d+(?:-[\w.-]+)?$/.test(item.version))
286
- throw new Error("\u63D2\u4EF6\u540D\u79F0\u6216\u7248\u672C\u65E0\u6548");
287
- const file = (input, extension) => {
288
- if (typeof input !== "string" || !/^[\w./-]+$/.test(input) || input.split("/").some((part) => !part || part === "." || part === "..") || !input.endsWith(extension))
289
- throw new Error("\u63D2\u4EF6\u5165\u53E3\u6216\u6837\u5F0F\u8DEF\u5F84\u65E0\u6548");
290
- return input;
291
- };
292
- const main = file(item.main, ".js");
287
+ const metadata = readPluginMetadata(item);
288
+ const main = readPluginFilePath(item.main, ".js");
293
289
  const backend = item.backend === void 0 ? void 0 : validateBackendManifest(item.backend);
294
290
  if (item.formatVersion === 2 !== Boolean(backend))
295
291
  throw new Error("\u540E\u53F0\u58F0\u660E\u5FC5\u987B\u4F7F\u7528\u5305\u683C\u5F0F 2\uFF0C\u666E\u901A\u63D2\u4EF6\u4F7F\u7528\u683C\u5F0F 1");
@@ -300,30 +296,15 @@ function validatePluginManifest(value, options = {}) {
300
296
  if (typeof item.minAppVersion !== "string") throw new Error("\u6700\u4F4E\u5BA2\u6237\u7AEF\u7248\u672C\u65E0\u6548");
301
297
  comparePluginVersions(item.minAppVersion, item.minAppVersion);
302
298
  }
303
- const styles = item.styles === void 0 ? void 0 : file(item.styles, ".css");
304
- if (item.editor !== void 0 && item.editor !== true) throw new Error("editor \u53EA\u80FD\u58F0\u660E\u4E3A true");
305
- if (item.whiteboard !== void 0 && item.whiteboard !== true)
306
- throw new Error("whiteboard \u53EA\u80FD\u58F0\u660E\u4E3A true");
307
- const catalog = readCatalogFields(item, options.strict === true);
308
- const permissions = readPermissionsField(item, options.strict === true);
309
- const integrity = {};
310
- for (const name of [main, ...styles ? [styles] : [], ...backend ? [backend.entry] : []]) {
311
- const hash = item.integrity && typeof item.integrity === "object" ? item.integrity[name] : void 0;
312
- if (typeof hash !== "string" || !/^[a-f0-9]{64}$/.test(hash))
313
- throw new Error("\u63D2\u4EF6\u4EA7\u7269\u7F3A\u5C11\u6709\u6548\u7684\u5B8C\u6574\u6027\u6458\u8981");
314
- integrity[name] = hash;
315
- }
316
- const skills = readSkillsField(item.skills);
317
- if (skills)
318
- Object.assign(
319
- integrity,
320
- readSkillFiles(skills, item.integrity ?? {})
321
- );
299
+ const styles = item.styles === void 0 ? void 0 : readPluginFilePath(item.styles, ".css");
300
+ const files = readPluginFiles(item, [
301
+ main,
302
+ ...styles ? [styles] : [],
303
+ ...backend ? [backend.entry] : []
304
+ ]);
322
305
  return Object.freeze({
323
306
  formatVersion: item.formatVersion,
324
- id: item.id,
325
- name: item.name,
326
- version: item.version,
307
+ ...metadata,
327
308
  ...typeof item.minAppVersion === "string" ? { minAppVersion: item.minAppVersion } : {},
328
309
  apiVersion: 1,
329
310
  platform: "desktop",
@@ -332,10 +313,7 @@ function validatePluginManifest(value, options = {}) {
332
313
  ...backend ? { backend } : {},
333
314
  ...item.editor === true ? { editor: true } : {},
334
315
  ...item.whiteboard === true ? { whiteboard: true } : {},
335
- ...catalog,
336
- ...permissions,
337
- ...skills ? { skills } : {},
338
- integrity: Object.freeze(integrity),
316
+ ...files,
339
317
  ...styles === void 0 ? {} : { styles }
340
318
  });
341
319
  }
@@ -344,16 +322,17 @@ var isContentPlugin = (manifest) => manifest.editor === true || manifest.whitebo
344
322
  export {
345
323
  assertLocalId,
346
324
  comparePluginVersions,
325
+ PLUGIN_SYSTEM_ACCESS,
326
+ validateBackendManifest,
347
327
  PLUGIN_CATEGORIES,
348
- PLUGIN_KEYWORD_LIMIT,
349
- PLUGIN_KEYWORD_MAX_LENGTH,
350
328
  isPluginCategory,
351
329
  PLUGIN_AI_CAPABILITIES,
352
330
  isPluginAICapability,
353
331
  PLUGIN_PERMISSIONS,
354
332
  isPluginPermission,
355
- PLUGIN_SYSTEM_ACCESS,
356
- validateBackendManifest,
333
+ readPluginMetadata,
334
+ readPluginFilePath,
335
+ readPluginFiles,
357
336
  PLUGIN_SHARED_MODULES,
358
337
  validatePluginManifest,
359
338
  isContentPlugin
package/docs/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Tau 插件开发文档
2
2
 
3
- 默认模板使用 SDK 0.40.0、UI 0.5.0,生成格式 3 的同一插件包。中心 v2 支持上传待审,格式 3 普通提交人工批准,具审核权限的作者本人经已绑定仓库 CI 发布可自动批准;平台测试由作者负责,不要求审核者测试或填写验证记录。Android/iOS 正式安装要求客户端至少 0.2.3,并通过中心兼容选版。先读 [API 支持矩阵](api-support.md)、[跨端契约](portability.md)与[快速开始](getting-started.md)。下文桌面领域接口不表示移动端可用。
3
+ 默认模板使用 SDK 0.42.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
 
@@ -2,9 +2,9 @@
2
2
 
3
3
  # 插件 API 支持矩阵
4
4
 
5
- 本表描述当前 SDK 与仓库宿主实现,不代表线上已发布客户端。统一功能名契约随 SDK、模板、中心和作者插件一起更新,不保留旧能力别名。桌面与移动均接入格式 3 的安装和内容装配,实际发行版本与设备验收独立记录。网页插件中心只浏览与分发,不执行插件;具体发行和设备验证见任务记录。
5
+ 本表描述当前 SDK 与仓库宿主实现,不代表线上已发布客户端。统一 API 契约随 SDK、模板、中心和作者插件一起更新,不保留旧能力别名。桌面与移动均接入格式 3 的安装和内容装配,实际发行版本与设备验收独立记录。网页插件中心只浏览与分发,不执行插件;具体发行和设备验证见任务记录。
6
6
 
7
- 一个 SDK 允许不同宿主实现不同子集。类型中有方法不代表该端可用;宿主内部 `capabilities` 只列实际实现,作者环境不暴露该列表,`permissions` 只声明业务授权上限,两者不能互代。不能通过删除 required、改格式号或伪报 edit 绕过限制。
7
+ 作者使用同一套 API,宿主负责具体实现和作用域。作者清单只声明支持平台、最低版本与用户数据权限,不填写能力列表;未接入移动端业务接口的插件暂不声明移动目标。调用失败、只读与用户授权继续遵循各 API 的明确语义。
8
8
 
9
9
  ## 上下文 API
10
10
 
@@ -35,38 +35,38 @@
35
35
  | `context.notifications` | 已接 | 未接 | 未接 | 不承诺移动系统通知或后台通知 |
36
36
  | `context.sync`、`context.upload` | 领域提供方已接 | 同一注册与配置 API 已接 | 同 Android | 宿主负责流程与选用,插件实现远端存储;账号独立,不做统一共享 |
37
37
  | `context.tts`、`context.images`、`context.video`、`context.publish` | 领域提供方已接 | 未接 | 未接 | 本轮不扩大其他业务领域 |
38
- | `context.backend` | 格式 2 独立后台与授权已接 | 格式 3 不支持 | 格式 3 不支持 | Node、子进程、本机程序继续留在旧桌面包;本轮不迁移 |
38
+ | `context.backend` | 格式 2 独立后台与授权已接 | 格式 3 不支持 | 格式 3 不支持 | Node、子进程、本机程序使用独立的桌面后台包 |
39
39
 
40
40
  ## 正文、UI 与交互
41
41
 
42
- | 能力 | 已实现范围 | 作者需要适配 | 宿主未接或待验收 |
43
- | -------------------------------------------------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------- | ----------------------------------------------------------------------------- |
44
- | 静态 editorExtensions/editorCodecs | 三端共用节点/codec;移动普通正文与预览装配;none/render/edit 同时约束界面和提交 | 为各平台如实声明全部节点,公共数据与节点 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 支持白板扩展与现有装配 | 与正文编辑器扩展分开声明 | 不纳入移动 web-v1 运行能力 |
52
- | runtimeStyles | 桌面使用原有编译服务,移动通过 Worker 解析 HTML/TSX 静态类并生成主题 CSS | 写完整类名,不拼接动态类名;处理编译失败 | 不执行作者源码;移动源码上限 1 MiB,设备资源预算仍需验证 |
53
- | media | 移动插件复用当前文档的资源上传/解析、媒体槽位和图片查看器 | 只读不上传;图册等自定义控件自行适配触摸 | media 与 upload 为独立功能;上传提供方另声明 upload |
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
- 当前词表为 `commands`、`storage`、`pages`、`navigation`、`settings`、`dialogs`、`editor`、`editorCodecs`、`sourceEditor`、`runtimeStyles`、`media`、`fetch`、`sync`、`upload`。功能名没有独立版本,接口兼容由 SDK 与各平台最低客户端版本表达。构建器从 editor 自动补齐正文与 codec 需求,Skill 文档直接从包结构读取,不另造能力。commands 不承诺手机命令面板,settings 的领域设置由对应 sync/upload 声明约束,editor 不代表动态 context.editor.register。
58
+ 宿主功能不再维护重复的字符串词表。context.fetch/sync/upload、源码编辑、媒体与样式编译直接使用现有 API;editorExtensions/editorCodecs/whiteboardExtensions 是实际注册内容。清单不再有 requires、required、optional、editor、whiteboard 或节点等级,新构建和上传严格拒绝这些字段。
59
59
 
60
- 没有登记能力名的桌面 API 不属于已承诺的移动可选能力,不能自行发明 data 等名称。当前移动目标的非空 permissions 会在模板构建、中心上传和移动求值前被拒绝。
60
+ 白板 getService 和 tryGetService 直接访问宿主按扩展绑定的服务注册表,不再重复填写依赖表。必需服务缺失抛错,可缺省服务通过 tryGetService 返回 undefined;插件存储隔离与资源回收继续由宿主控制。
61
61
 
62
- 作者/上传严格校验使用 validatePortablePluginManifest 或更严格的 validatePortableDistributionManifest,未知能力(包括 optional 拼错)均拒绝。客户端使用 readPortablePluginManifest 保留有界、合法的未来能力名称:未知 required 在兼容检查中作为缺能力拒绝,未知 optional 保留但不可用。optional 不是自动补实现;作者调用前仍检查实际环境并提供降级。未知字段、格式、profile、权限词表和节点等级仍拒绝。
62
+ 权限、节点数据校验、资源字段、样式源码字段以及 AI 功能定义继续保留,它们分别约束授权、数据或实际行为。移动目标的非空 permissions 仍在构建、上传和求值前拒绝。
63
63
 
64
64
  ## 作者选择与发行边界
65
65
 
66
66
  1. 先列出插件用到的 API;全部落在移动已接范围,才声明对应移动 target。
67
- 2. 若仅交互不同,共用数据/codec,按容器宽度与输入提供操作;适配未完成的节点填 render 或 none。
67
+ 2. 若仅交互不同,共用数据/codec,按容器宽度与输入提供操作;未完整适配的平台暂不声明。
68
68
  3. 若依赖宿主未接的业务能力,保留桌面版本,不用改清单假装兼容。计数器和 ABC 的结论不能外推到所有插件。
69
69
  4. 官方插件新发行统一使用格式 3;仅桌面插件也声明 desktop target。历史已发行记录不改写,历史客户端选版边界保留。增加平台需同一插件 ID 的更高版本,不覆盖已发布 ZIP、重命名节点或自动清数据。
70
- 5. SDK、模板、中心与宿主采用同一功能名契约;旧版本化能力名称直接拒绝,不保留映射或多套实现。普通提交人工批准,具审核权限的作者本人通过已绑定仓库 CI 发布可自动批准。平台适配与功能测试由作者负责,不要求审核者测试或填写验证记录。是否可安装由客户端版本、能力与中心开关共同决定,不能由 npm 版本推断。移动中心首次安装默认保存启用意图,下次打开生效;桌面新装默认停用,用户启用后重启内容插件;更新保留显式启停选择。任意开发 URL 安装仅限调试构建。
70
+ 5. SDK、模板、中心与宿主共用平台和版本契约;不保留重复能力声明或名称映射。普通提交人工批准,具审核权限的作者本人通过已绑定仓库 CI 发布可自动批准。平台适配与功能测试由作者负责,不要求审核者测试或填写验证记录。是否可安装由平台、客户端版本与中心开关共同决定,不能由 npm 版本推断。移动中心首次安装默认保存启用意图,下次打开生效;桌面新装默认停用,用户启用后重启内容插件;更新保留显式启停选择。任意开发 URL 安装仅限调试构建。
71
71
 
72
72
  已完成的自动测试与模拟器行为验证不替代真机、最低系统、完整 IPA、桌面原生安装包发行、未知旧作者迁移或应用商店验收。
package/docs/backend.md CHANGED
@@ -37,7 +37,7 @@
37
37
  | `scope` | `application`:整个应用一个后台;`workspace`:每个工作区一个后台 |
38
38
  | `activation` | 什么时候启动,见下表 |
39
39
  | `lifetime` | `idle`:空闲一段时间后停止,有调用时再启动;`persistent`:一直运行到作用域结束,意外退出时自动重启 |
40
- | `reason` | 向用户说明后台用来做什么,1 至 500 字。用户授权时会看到它 |
40
+ | `reason` | 向用户说明后台用来做什么,填写非空用途说明,用户授权时会看到它 |
41
41
  | `systemAccess` | 后台会用到的系统能力:`filesystem`(文件)、`network`(网络)、`process`(启动程序),用于告知用户和审核 |
42
42
  | `tools` | 需要启动外部程序时声明,见[调用外部程序](#调用外部程序) |
43
43
 
@@ -135,7 +135,7 @@ const os = await context.backend.call("system.platform", null, { signal });
135
135
  | `command` | 程序名或绝对路径 |
136
136
  | `args` | 可选。固定的前置参数,每次调用都会带上 |
137
137
 
138
- 最多声明 32 个工具。然后在后台中调用:
138
+ 声明工具后,在后台中调用:
139
139
 
140
140
  ```ts
141
141
  const result = await ctx.process.run("git", ["status", "--short"], { signal: request.signal });
package/docs/editor.md CHANGED
@@ -6,17 +6,9 @@
6
6
 
7
7
  ## 第一个块:计数器
8
8
 
9
- ### 1. 在 manifest 中声明
9
+ 正文节点在 editorExtensions 中注册,Markdown 转换在 editorCodecs 中注册。宿主据此装配正文、源码编辑和样式编译;manifest 不重复登记节点、等级或能力。targets 只声明已完整适配的平台及最低客户端版本。
10
10
 
11
- ```json
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
- ### 3. 构建、安装、重启
97
+ ### 2. 构建、安装、重启
106
98
 
107
99
  `pnpm build` 并安装后,**完全退出并重新打开 Tau**。编辑器扩展在启动时装配,启用、停用和更新都要重启才生效。之后在文档里输入 `/计数器`,就能插入这个块。
108
100