@xiongtao.xt/tau-plugins 0.41.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 +7 -0
- package/client/{chunk-TOYS6GBE.js → chunk-666OM7IO.js} +34 -64
- package/client/{chunk-FZTR4KOY.js → chunk-XCKDPTLI.js} +117 -138
- package/docs/README.md +1 -1
- package/docs/api-support.md +1 -1
- package/docs/backend.md +2 -2
- package/docs/getting-started.md +1 -1
- package/docs/plugin-basics.md +2 -2
- package/docs/portability.md +3 -1
- package/docs/release.md +1 -1
- package/docs/site-data.md +1 -1
- package/docs/skills.md +0 -1
- package/package.js +1 -5
- package/package.json +1 -1
- package/portable.js +2 -2
- package/publish-artifacts.js +16 -24
- package/types/packages/plugins/src/categories.d.ts +2 -8
- package/types/packages/plugins/src/editor-fields.d.ts +2 -5
- package/types/packages/plugins/src/package.d.ts +5 -7
- package/types/packages/plugins/src/permissions.d.ts +2 -2
- package/types/packages/plugins/src/portable.d.ts +0 -1
- package/types/packages/plugins/src/rendering.d.ts +1 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
comparePluginVersions,
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
readPluginFilePath,
|
|
4
|
+
readPluginFiles,
|
|
5
|
+
readPluginMetadata
|
|
6
|
+
} from "./chunk-XCKDPTLI.js";
|
|
5
7
|
|
|
6
8
|
// packages/plugins/src/portable.ts
|
|
7
9
|
var PORTABLE_PLATFORMS = ["desktop", "android", "ios"];
|
|
@@ -15,45 +17,32 @@ var PORTABLE_SHARED_MODULES = [
|
|
|
15
17
|
"react/jsx-runtime",
|
|
16
18
|
"react/jsx-dev-runtime"
|
|
17
19
|
];
|
|
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
20
|
function buildPortablePluginManifest(value, output) {
|
|
22
21
|
const item = record(value, "\u4F5C\u8005\u6E05\u5355");
|
|
23
22
|
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
23
|
return validatePortableDistributionManifest({
|
|
44
|
-
|
|
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,
|
|
45
31
|
formatVersion: 3,
|
|
46
32
|
apiVersion: 1,
|
|
47
33
|
platform: "portable",
|
|
48
34
|
profile: "web-v1",
|
|
49
35
|
format: "cjs",
|
|
50
|
-
|
|
51
|
-
|
|
36
|
+
main: files.main,
|
|
37
|
+
styles: files.styles,
|
|
38
|
+
skills: files.skills,
|
|
39
|
+
integrity: files.integrity,
|
|
40
|
+
targets: item.targets
|
|
52
41
|
});
|
|
53
42
|
}
|
|
54
43
|
function record(value, label) {
|
|
55
|
-
if (!value || typeof value !== "object" || Array.isArray(value)
|
|
56
|
-
throw new Error(`${label}\u5FC5\u987B\u662F\
|
|
44
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
45
|
+
throw new Error(`${label}\u5FC5\u987B\u662F\u5BF9\u8C61`);
|
|
57
46
|
return value;
|
|
58
47
|
}
|
|
59
48
|
function validatePortablePluginManifest(value) {
|
|
@@ -62,63 +51,44 @@ function validatePortablePluginManifest(value) {
|
|
|
62
51
|
var readPortablePluginManifest = validatePortablePluginManifest;
|
|
63
52
|
function validatePortableDistributionManifest(value) {
|
|
64
53
|
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
54
|
if ((manifest.targets.android || manifest.targets.ios) && manifest.permissions?.length)
|
|
67
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");
|
|
68
56
|
return manifest;
|
|
69
57
|
}
|
|
70
58
|
function parsePortablePluginManifest(value) {
|
|
71
59
|
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
60
|
if (item.formatVersion !== 3 || item.platform !== "portable" || item.profile !== "web-v1")
|
|
93
61
|
throw new Error("\u8DE8\u7AEF\u5305\u683C\u5F0F\u6216\u8FD0\u884C\u914D\u7F6E\u4E0D\u517C\u5BB9");
|
|
94
|
-
if (item.
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
);
|
|
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] : []]);
|
|
100
67
|
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
68
|
const targets = {};
|
|
104
69
|
for (const platform of PORTABLE_PLATFORMS) {
|
|
105
70
|
if (!Object.hasOwn(rawTargets, platform)) continue;
|
|
106
71
|
const target = record(rawTargets[platform], "\u5E73\u53F0\u914D\u7F6E");
|
|
107
|
-
assertKeys(target, ["minAppVersion"], "\u5E73\u53F0\u914D\u7F6E");
|
|
108
72
|
if (typeof target.minAppVersion !== "string") throw new Error("\u5E73\u53F0\u7F3A\u5C11\u6700\u4F4E\u5BA2\u6237\u7AEF\u7248\u672C");
|
|
109
73
|
comparePluginVersions(target.minAppVersion, target.minAppVersion);
|
|
110
74
|
targets[platform] = Object.freeze({ minAppVersion: target.minAppVersion });
|
|
111
75
|
}
|
|
112
|
-
|
|
113
|
-
|
|
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)))
|
|
114
79
|
throw new Error("\u8DE8\u7AEF\u5305\u5305\u542B\u672A\u58F0\u660E\u6587\u4EF6");
|
|
115
|
-
for (const file of Object.keys(files)) {
|
|
116
|
-
if (file ===
|
|
80
|
+
for (const file of Object.keys(files.integrity)) {
|
|
81
|
+
if (file === main || file === styles) continue;
|
|
117
82
|
if (!file.endsWith(".md") || file.split("/").includes("scripts") || file.includes("\\"))
|
|
118
83
|
throw new Error("\u8DE8\u7AEF Skill \u4EC5\u652F\u6301\u7EAF Markdown \u6587\u6863\uFF0C\u4E0D\u652F\u6301\u811A\u672C\u6216\u9644\u4EF6");
|
|
119
84
|
}
|
|
120
85
|
return Object.freeze({
|
|
121
|
-
...
|
|
86
|
+
...metadata,
|
|
87
|
+
apiVersion: 1,
|
|
88
|
+
format: "cjs",
|
|
89
|
+
main,
|
|
90
|
+
...styles ? { styles } : {},
|
|
91
|
+
...files,
|
|
122
92
|
formatVersion: 3,
|
|
123
93
|
platform: "portable",
|
|
124
94
|
profile: "web-v1",
|
|
@@ -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
|
|
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
|
-
|
|
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))
|
|
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
|
|
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
|
|
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
|
-
|
|
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))
|
|
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)
|
|
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
|
|
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
|
-
|
|
284
|
-
|
|
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 :
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
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
|
-
|
|
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
|
-
...
|
|
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
|
-
|
|
356
|
-
|
|
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.
|
|
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
|
|
package/docs/api-support.md
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
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
|
|
package/docs/backend.md
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
| `scope` | `application`:整个应用一个后台;`workspace`:每个工作区一个后台 |
|
|
38
38
|
| `activation` | 什么时候启动,见下表 |
|
|
39
39
|
| `lifetime` | `idle`:空闲一段时间后停止,有调用时再启动;`persistent`:一直运行到作用域结束,意外退出时自动重启 |
|
|
40
|
-
| `reason` |
|
|
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
|
-
|
|
138
|
+
声明工具后,在后台中调用:
|
|
139
139
|
|
|
140
140
|
```ts
|
|
141
141
|
const result = await ctx.process.run("git", ["status", "--short"], { signal: request.signal });
|
package/docs/getting-started.md
CHANGED
|
@@ -12,7 +12,7 @@ pnpm install --frozen-lockfile
|
|
|
12
12
|
pnpm build
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
SDK 0.
|
|
15
|
+
SDK 0.42.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
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
| ------------- | ----------------------------------------------------------------------------------------------- |
|
|
38
38
|
| `id` | 插件的唯一标识,由小写字母、数字组成,用点或连字符分段,例如 `yourname.counter`。发布后不要再改 |
|
|
39
39
|
| `name` | 插件名称,显示在插件页和插件中心 |
|
|
40
|
-
| `description` |
|
|
40
|
+
| `description` | 一句话简介,非空文本 |
|
|
41
41
|
| `version` | 插件版本,格式为 `主版本.次版本.修订号`,可带预发布后缀,如 `1.2.0-beta.1` |
|
|
42
42
|
| `targets` | 各平台最低应用版本;填写完整版本号,不写范围。省略平台表示不支持安装 |
|
|
43
43
|
| `categories` | 插件中心的分类,可多选,也可以不写,见下表 |
|
|
44
|
-
| `keywords` |
|
|
44
|
+
| `keywords` | 插件中心的搜索词,用于搜索的文本。例如 S3 插件可以写 `MinIO`、`R2` |
|
|
45
45
|
| `permissions` | 插件可能申请的用户数据权限,见[用户数据 · 权限](user-data.md#权限)和 [AI](ai.md) |
|
|
46
46
|
| `backend` | 需要本机后台时填写,同时把 `formatVersion` 改为 `2`,见[本机后台](backend.md) |
|
|
47
47
|
|
package/docs/portability.md
CHANGED
|
@@ -71,6 +71,8 @@ coarsePointer 对应 (any-pointer: coarse),finePointer 对应 (any-pointer: fi
|
|
|
71
71
|
|
|
72
72
|
节点结构、codec、校验和渲染共用;静态 editorExtensions/editorCodecs 直接交给 definePlugin,不依赖 activate 或缓存全局 context。博客由自己的宿主提供 web/只读环境,不能启动应用插件生命周期。
|
|
73
73
|
|
|
74
|
+
宿主只把公开的扩展字段交给编辑器内核,附加属性不会执行。
|
|
75
|
+
|
|
74
76
|
优先使用 SourceBlockEditor/useSourceBlock 与公开的节点 API。标准插入、选区、源码草稿保存/取消、只读和迟到提交保护由宿主负责;节点允许移动不等于所有平台都采用鼠标拖拽。
|
|
75
77
|
|
|
76
78
|
图册排序、绘图等专有交互仍由作者实现。基础操作保留可点击/可聚焦按钮,拖拽与悬停只作增强;布局按实际容器调整,共享编辑状态和提交函数,方向或输入变化不能丢失草稿。不能为手机另建一套节点类型。
|
|
@@ -95,7 +97,7 @@ useResourceUpload() 在只读或没有资源存储的作用域返回 undefined
|
|
|
95
97
|
|
|
96
98
|
## 构建和分发
|
|
97
99
|
|
|
98
|
-
buildPortablePluginManifest(authorManifest, output) 接收作者清单和构建器提供的 main/styles/integrity/skills,输出格式 3、apiVersion 1、profile web-v1、CJS 单入口的发行清单。targets 仅记录各平台 minAppVersion
|
|
100
|
+
buildPortablePluginManifest(authorManifest, output) 接收作者清单和构建器提供的 main/styles/integrity/skills,输出格式 3、apiVersion 1、profile web-v1、CJS 单入口的发行清单。targets 仅记录各平台 minAppVersion,插件中心只消费规范化结果,不执行作者源码。读取器提取协议字段,忽略附加元信息;只校验身份、协议、授权、文件完整性和实际数据约束,不限制简介、关键词或 Skill 数量。版本使用 SemVer,允许预发布和构建标识。
|
|
99
101
|
|
|
100
102
|
客户端按平台、最低版本、格式与运行配置检查兼容性,插件中心再检查分发开关。宿主装配时读取实际注册的静态贡献,不依赖重复的能力词表或推测任意 JavaScript 的全部依赖。新发行要求桌面至少 0.59.4、移动至少 0.2.4;客户端安装包单独发行。
|
|
101
103
|
|
package/docs/release.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 发布与更新
|
|
2
2
|
|
|
3
|
-
模板使用 SDK 0.
|
|
3
|
+
模板使用 SDK 0.42.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/site-data.md
CHANGED
|
@@ -44,7 +44,7 @@ if (item) {
|
|
|
44
44
|
|
|
45
45
|
站点的其他配置(描述、副标题、布局开关等)由**博客模板**自己声明:在模板的 manifest 中写 `template.siteFields`,用户在「站点设置 · 博客模板」中填写,发布时以 `site.fields[key]` 交给模板。
|
|
46
46
|
|
|
47
|
-
- 字段类型有 `text`、`textarea`、`url`、`select`、`switch
|
|
47
|
+
- 字段类型有 `text`、`textarea`、`url`、`select`、`switch`。
|
|
48
48
|
- `fields` 只包含已声明的字段。用户没填时取字段的 `default`;没有默认值时,文本类为空字符串,开关为 `false`,下拉为第一个选项。
|
|
49
49
|
- 首页数据只有时间线和统计,介绍区等由模板根据自己的字段渲染。
|
|
50
50
|
|
package/docs/skills.md
CHANGED
package/package.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PLUGIN_AI_CAPABILITIES,
|
|
3
3
|
PLUGIN_CATEGORIES,
|
|
4
|
-
PLUGIN_KEYWORD_LIMIT,
|
|
5
|
-
PLUGIN_KEYWORD_MAX_LENGTH,
|
|
6
4
|
PLUGIN_PERMISSIONS,
|
|
7
5
|
PLUGIN_SHARED_MODULES,
|
|
8
6
|
PLUGIN_SYSTEM_ACCESS,
|
|
@@ -14,12 +12,10 @@ import {
|
|
|
14
12
|
isPluginPermission,
|
|
15
13
|
validateBackendManifest,
|
|
16
14
|
validatePluginManifest
|
|
17
|
-
} from "./client/chunk-
|
|
15
|
+
} from "./client/chunk-XCKDPTLI.js";
|
|
18
16
|
export {
|
|
19
17
|
PLUGIN_AI_CAPABILITIES,
|
|
20
18
|
PLUGIN_CATEGORIES,
|
|
21
|
-
PLUGIN_KEYWORD_LIMIT,
|
|
22
|
-
PLUGIN_KEYWORD_MAX_LENGTH,
|
|
23
19
|
PLUGIN_PERMISSIONS,
|
|
24
20
|
PLUGIN_SHARED_MODULES,
|
|
25
21
|
PLUGIN_SYSTEM_ACCESS,
|
package/package.json
CHANGED
package/portable.js
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
readPortablePluginManifest,
|
|
7
7
|
validatePortableDistributionManifest,
|
|
8
8
|
validatePortablePluginManifest
|
|
9
|
-
} from "./client/chunk-
|
|
10
|
-
import "./client/chunk-
|
|
9
|
+
} from "./client/chunk-666OM7IO.js";
|
|
10
|
+
import "./client/chunk-XCKDPTLI.js";
|
|
11
11
|
export {
|
|
12
12
|
PORTABLE_PLATFORMS,
|
|
13
13
|
PORTABLE_SHARED_MODULES,
|
package/publish-artifacts.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PORTABLE_SHARED_MODULES,
|
|
3
3
|
readPortablePluginManifest
|
|
4
|
-
} from "./client/chunk-
|
|
4
|
+
} from "./client/chunk-666OM7IO.js";
|
|
5
5
|
import {
|
|
6
6
|
PLUGIN_SHARED_MODULES,
|
|
7
7
|
validatePluginManifest
|
|
8
|
-
} from "./client/chunk-
|
|
8
|
+
} from "./client/chunk-XCKDPTLI.js";
|
|
9
9
|
|
|
10
10
|
// packages/db-schema/content-resources.ts
|
|
11
11
|
var CONTENT_RESOURCE_KINDS = [
|
|
@@ -48,20 +48,18 @@ var OPEN_EXTENSION_FIELDS = [
|
|
|
48
48
|
"blockPanel",
|
|
49
49
|
"behaviorsFor"
|
|
50
50
|
];
|
|
51
|
-
var PLUGIN_EXTENSION_FIELDS =
|
|
51
|
+
var PLUGIN_EXTENSION_FIELDS = [
|
|
52
52
|
...OPEN_EXTENSION_FIELDS,
|
|
53
53
|
"styleSources",
|
|
54
54
|
"htmlSerializers"
|
|
55
|
-
]
|
|
56
|
-
function
|
|
57
|
-
if (typeof extension !== "object" || extension
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (closed.length)
|
|
64
|
-
throw new Error(`\u7F16\u8F91\u5668\u6269\u5C55\u542B\u672A\u5F00\u653E\u7684\u5B57\u6BB5\uFF1A${closed.map((key) => String(key)).join("\u3001")}`);
|
|
55
|
+
];
|
|
56
|
+
function normalizePluginEditorExtension(extension) {
|
|
57
|
+
if (!extension || typeof extension !== "object" || Array.isArray(extension))
|
|
58
|
+
throw new Error("\u7F16\u8F91\u5668\u6269\u5C55\u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
59
|
+
const source = extension;
|
|
60
|
+
return Object.fromEntries(
|
|
61
|
+
PLUGIN_EXTENSION_FIELDS.filter((key) => source[key] !== void 0).map((key) => [key, source[key]])
|
|
62
|
+
);
|
|
65
63
|
}
|
|
66
64
|
|
|
67
65
|
// packages/plugins/src/rendering.ts
|
|
@@ -75,21 +73,12 @@ function evaluatePublishedPluginPackage(artifact, modules) {
|
|
|
75
73
|
return evaluatePluginPackage({ ...artifact, manifest }, modules);
|
|
76
74
|
if (!manifest.targets.desktop) throw new Error("\u535A\u5BA2\u6E32\u67D3\u9700\u8981\u684C\u9762\u76EE\u6807");
|
|
77
75
|
const definition = evaluateModule(manifest, artifact.code, modules, PORTABLE_SHARED_MODULES);
|
|
78
|
-
return
|
|
76
|
+
return definition;
|
|
79
77
|
}
|
|
80
78
|
function evaluatePluginPackage(artifact, modules) {
|
|
81
79
|
const manifest = validatePluginManifest(artifact.manifest);
|
|
82
80
|
return evaluateModule(manifest, artifact.code, modules, PLUGIN_SHARED_MODULES);
|
|
83
81
|
}
|
|
84
|
-
function adaptPortablePluginDefinition(definition, manifest, platform) {
|
|
85
|
-
if (!manifest.targets[platform]) throw new Error("\u63D2\u4EF6\u4E0D\u652F\u6301\u5F53\u524D\u5E73\u53F0");
|
|
86
|
-
return {
|
|
87
|
-
support: Object.freeze(
|
|
88
|
-
Object.fromEntries(getPluginNodeTypes(definition).map((type) => [type, "edit"]))
|
|
89
|
-
),
|
|
90
|
-
definition
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
82
|
function evaluateModule(manifest, code, modules, allowed) {
|
|
94
83
|
const module = { exports: {} };
|
|
95
84
|
new Function(
|
|
@@ -116,6 +105,10 @@ function validatePluginDefinition(manifest, definition) {
|
|
|
116
105
|
throw new Error("\u7F16\u8F91\u5668\u8D21\u732E\u5FC5\u987B\u4E0E manifest.editor \u58F0\u660E\u4E00\u81F4");
|
|
117
106
|
if (manifest.formatVersion !== 3 && Boolean(definition.whiteboardExtensions?.length) !== Boolean(manifest.whiteboard))
|
|
118
107
|
throw new Error("\u767D\u677F\u8D21\u732E\u5FC5\u987B\u4E0E manifest.whiteboard \u58F0\u660E\u4E00\u81F4");
|
|
108
|
+
definition = {
|
|
109
|
+
...definition,
|
|
110
|
+
editorExtensions: definition.editorExtensions?.map(normalizePluginEditorExtension)
|
|
111
|
+
};
|
|
119
112
|
getPluginWhiteboardTypes(definition);
|
|
120
113
|
if (definition.editorCodecs?.length && !definition.editorExtensions?.length)
|
|
121
114
|
throw new Error("Markdown codec \u5FC5\u987B\u968F\u7F16\u8F91\u5668\u8D21\u732E\u58F0\u660E");
|
|
@@ -129,7 +122,6 @@ function validatePluginDefinition(manifest, definition) {
|
|
|
129
122
|
function getPluginNodeTypes(definition) {
|
|
130
123
|
const types = [];
|
|
131
124
|
for (const extension of definition.editorExtensions ?? []) {
|
|
132
|
-
assertPluginEditorExtension(extension);
|
|
133
125
|
for (const element of extension.elements ?? []) {
|
|
134
126
|
if (!element.type || types.includes(element.type))
|
|
135
127
|
throw new Error(`\u63D2\u4EF6\u8282\u70B9\u7C7B\u578B\u4E3A\u7A7A\u6216\u91CD\u590D\uFF1A${element.type}`);
|
|
@@ -34,16 +34,10 @@ export declare const PLUGIN_CATEGORIES: readonly [{
|
|
|
34
34
|
readonly label: "页面";
|
|
35
35
|
}];
|
|
36
36
|
export type PluginCategory = (typeof PLUGIN_CATEGORIES)[number]["id"];
|
|
37
|
-
export declare const PLUGIN_KEYWORD_LIMIT = 5;
|
|
38
|
-
export declare const PLUGIN_KEYWORD_MAX_LENGTH = 20;
|
|
39
37
|
export declare const isPluginCategory: (value: unknown) => value is PluginCategory;
|
|
40
38
|
export interface PluginCatalogFields {
|
|
41
39
|
categories?: readonly PluginCategory[];
|
|
42
40
|
keywords?: readonly string[];
|
|
43
41
|
}
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
* strict 用于门户上传,非法值直接报错;客户端用宽松模式静默丢弃,
|
|
47
|
-
* 使老客户端不会因词表新增或上限调整而拒收插件。
|
|
48
|
-
*/
|
|
49
|
-
export declare function readCatalogFields(item: Record<string, unknown>, strict: boolean): PluginCatalogFields;
|
|
42
|
+
/** 分类使用产品词表,关键词保留有效文本并去重。 */
|
|
43
|
+
export declare function readCatalogFields(item: Record<string, unknown>): PluginCatalogFields;
|
|
@@ -2,9 +2,6 @@ import type { PluginEditorExtension } from "./editor";
|
|
|
2
2
|
/** 向插件开放的编辑器扩展字段;类型与运行时校验共用这一份,新增开放须同时评估宿主隔离。 */
|
|
3
3
|
declare const OPEN_EXTENSION_FIELDS: readonly ["id", "apiVersion", "elements", "commands", "hotkeys", "menu", "blockPanel", "behaviorsFor"];
|
|
4
4
|
export type OpenEditorExtensionField = (typeof OPEN_EXTENSION_FIELDS)[number];
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
* 继承或不可枚举的属性同样会被读到,所以要求普通对象且自有键全部开放。
|
|
8
|
-
*/
|
|
9
|
-
export declare function assertPluginEditorExtension(extension: unknown): asserts extension is PluginEditorExtension;
|
|
5
|
+
/** 只把公开字段交给编辑器,避免私有内核钩子进入执行链路。 */
|
|
6
|
+
export declare function normalizePluginEditorExtension(extension: unknown): PluginEditorExtension;
|
|
10
7
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { assertLocalId } from "./ids";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { PluginCategory } from "./categories";
|
|
3
|
+
import type { PluginPermission } from "./permissions";
|
|
4
4
|
import { type PluginBackendManifest } from "./backend-manifest";
|
|
5
5
|
export { validateBackendManifest, PLUGIN_SYSTEM_ACCESS, type PluginBackendManifest, type PluginSystemAccess, } from "./backend-manifest";
|
|
6
6
|
export { comparePluginVersions } from "./version";
|
|
7
|
-
export { PLUGIN_CATEGORIES,
|
|
7
|
+
export { PLUGIN_CATEGORIES, isPluginCategory, type PluginCategory } from "./categories";
|
|
8
8
|
export { PLUGIN_PERMISSIONS, isPluginPermission, type PluginPermission } from "./permissions";
|
|
9
9
|
export { PLUGIN_AI_CAPABILITIES, isPluginAICapability } from "./ai";
|
|
10
10
|
export declare const PLUGIN_SHARED_MODULES: readonly ["@tau/plugins", "@tau/plugins/whiteboard", "@tau/plugins/sync", "@tau/ui", "react", "react-dom", "react-dom/client", "react/jsx-runtime", "react/jsx-dev-runtime"];
|
|
@@ -39,9 +39,7 @@ export interface DevelopmentPluginPackage {
|
|
|
39
39
|
code: string;
|
|
40
40
|
css?: string;
|
|
41
41
|
}
|
|
42
|
-
/**
|
|
43
|
-
export declare function validatePluginManifest(value: unknown
|
|
44
|
-
strict?: boolean;
|
|
45
|
-
}): PluginManifest;
|
|
42
|
+
/** 按实际使用的包字段解析身份、权限、入口和摘要。 */
|
|
43
|
+
export declare function validatePluginManifest(value: unknown): PluginManifest;
|
|
46
44
|
/** 静态内容贡献在启动时固定,启停与更新需要重启。 */
|
|
47
45
|
export declare const isContentPlugin: (manifest: Pick<PluginManifest, "editor" | "whiteboard">) => boolean;
|
|
@@ -19,7 +19,7 @@ export interface PluginPermissions {
|
|
|
19
19
|
/** 一次询问多项;全部获准时返回 true。已获准的不再询问。 */
|
|
20
20
|
request(permissions: readonly PluginPermission[]): Promise<boolean>;
|
|
21
21
|
}
|
|
22
|
-
/**
|
|
23
|
-
export declare function readPermissionsField(item: Record<string, unknown
|
|
22
|
+
/** 权限必须属于宿主已定义的授权范围。 */
|
|
23
|
+
export declare function readPermissionsField(item: Record<string, unknown>): {
|
|
24
24
|
permissions?: readonly PluginPermission[];
|
|
25
25
|
};
|
|
@@ -27,7 +27,6 @@ export interface PluginBuildOutput {
|
|
|
27
27
|
readonly styles?: string;
|
|
28
28
|
readonly integrity: Readonly<Record<string, string>>;
|
|
29
29
|
readonly skills?: readonly string[];
|
|
30
|
-
readonly imports?: readonly string[];
|
|
31
30
|
}
|
|
32
31
|
/** 作者声明身份与支持平台,宿主功能通过统一 API 注册。 */
|
|
33
32
|
export declare function buildPortablePluginManifest(value: unknown, output: PluginBuildOutput): PortablePluginManifest;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PluginDefinition } from "./contract";
|
|
2
2
|
import type { PluginEditorExtension } from "./editor";
|
|
3
3
|
import type { MarkdownCodec } from "../../markdown/src/index";
|
|
4
|
-
import { type
|
|
4
|
+
import { type ReadablePortablePluginManifest, type PortablePluginHost } from "./portable";
|
|
5
5
|
import { type DevelopmentPluginPackage, type PluginManifest } from "./package";
|
|
6
6
|
export type { PublishedPluginRender } from "./render-artifact";
|
|
7
7
|
export declare function assertUniqueEditorCodecs(codecs: readonly MarkdownCodec[]): void;
|
|
@@ -33,13 +33,6 @@ export declare function evaluatePortablePluginPackage(artifact: {
|
|
|
33
33
|
code: string;
|
|
34
34
|
css?: string;
|
|
35
35
|
}, modules: Readonly<Record<string, unknown>>, host: PortablePluginHost): PluginDefinition;
|
|
36
|
-
/** 各宿主共用支持等级投影;原始数据与节点身份不改写。 */
|
|
37
|
-
export declare function adaptPortablePluginDefinition(definition: PluginDefinition, manifest: ReadablePortablePluginManifest, platform: PortablePlatform): {
|
|
38
|
-
support: Readonly<{
|
|
39
|
-
[k: string]: "edit";
|
|
40
|
-
}>;
|
|
41
|
-
definition: PluginDefinition;
|
|
42
|
-
};
|
|
43
36
|
export declare const hasPluginContent: (definition: PluginDefinition) => boolean;
|
|
44
37
|
type DefinitionManifest = Pick<PluginManifest, "id" | "name" | "version" | "apiVersion"> & {
|
|
45
38
|
readonly formatVersion?: number;
|