@arcadia-eternity/content-sdk 4.15.7 → 4.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/author-reference.d.ts +181 -2
- package/dist/author-reference.js +69 -2
- package/dist/creator-docs.d.ts +20 -0
- package/dist/creator-docs.js +89 -0
- package/dist/mcp-contracts.d.ts +12 -0
- package/dist/mcp-contracts.js +20 -1
- package/dist/mcp.js +5 -2
- package/dist/sdk-reference.d.ts +53 -0
- package/dist/sdk-reference.js +99 -0
- package/dist/sdk-reference.json +1 -0
- package/dist/template/package.json +2 -2
- package/dist/template/src/effects/slow.effect.ts +5 -0
- package/package.json +5 -5
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import { readFile } from 'node:fs/promises';
|
|
10
|
+
export const sdkGroups = {
|
|
11
|
+
triggers: '触发器',
|
|
12
|
+
objects: '战斗对象与上下文',
|
|
13
|
+
functions: '创作函数与装饰器',
|
|
14
|
+
values: 'SDK 对象与常量',
|
|
15
|
+
enums: '枚举',
|
|
16
|
+
types: '类型声明',
|
|
17
|
+
host: '宿主专用函数',
|
|
18
|
+
};
|
|
19
|
+
export function sdkPath(item) {
|
|
20
|
+
if (item.group === 'triggers')
|
|
21
|
+
return '/sdk/triggers/' + item.symbol.split('.')[1];
|
|
22
|
+
const base = '/sdk/' + item.group + '/' + (item.owner ?? item.symbol);
|
|
23
|
+
if (!item.owner)
|
|
24
|
+
return base;
|
|
25
|
+
const name = item.symbol.slice(item.owner.length + 1);
|
|
26
|
+
if (item.owner === 'ops')
|
|
27
|
+
return base + '/' + name;
|
|
28
|
+
if (item.owner === 'BattleMessageData' || item.owner === 'Events') {
|
|
29
|
+
const [event, ...field] = name.split('.');
|
|
30
|
+
return base + '/' + event + (field.length ? '#member-' + field.join('.') : '');
|
|
31
|
+
}
|
|
32
|
+
return base + '#member-' + name;
|
|
33
|
+
}
|
|
34
|
+
function code(text) {
|
|
35
|
+
return ['```typescript', text, '```'].join('\n');
|
|
36
|
+
}
|
|
37
|
+
export function sdkCatalog(records) {
|
|
38
|
+
const byName = new Map(records.map(item => [item.symbol, item]));
|
|
39
|
+
const children = new Map();
|
|
40
|
+
for (const item of records) {
|
|
41
|
+
if (!item.owner)
|
|
42
|
+
continue;
|
|
43
|
+
const siblings = children.get(item.owner) ?? [];
|
|
44
|
+
siblings.push(item);
|
|
45
|
+
children.set(item.owner, siblings);
|
|
46
|
+
}
|
|
47
|
+
const link = (name) => {
|
|
48
|
+
const item = byName.get(name);
|
|
49
|
+
return item ? '[`' + name + '`](' + sdkPath(item) + ')' : '`' + name + '`';
|
|
50
|
+
};
|
|
51
|
+
function body(item) {
|
|
52
|
+
const lines = [item.kind, '', code(item.context ?? item.signature)];
|
|
53
|
+
if (item.description)
|
|
54
|
+
lines.push('', item.description.replace(/[<>{}]/g, c => '&#' + c.charCodeAt(0) + ';'));
|
|
55
|
+
if (item.group === 'host')
|
|
56
|
+
lines.push('', '此函数供宿主进程使用。');
|
|
57
|
+
if (item.group === 'types' && !item.owner)
|
|
58
|
+
lines.push('', 'TypeScript 声明。具体战斗实例可访问的成员见[战斗对象与上下文](/sdk/objects/)。');
|
|
59
|
+
if (item.parent) {
|
|
60
|
+
lines.push('', '## 回调上下文', '', '回调接收 ' + link('EffectContext') + '。本次事件的 `ctx.parent` 类型为 ' + link(item.parent) + '。');
|
|
61
|
+
if (item.variants?.length)
|
|
62
|
+
lines.push('', '先用 `instanceof` 判断父对象类型,再访问具体事件:' + item.variants.map(link).join('、') + '。');
|
|
63
|
+
if (item.fields?.length)
|
|
64
|
+
lines.push('', '| 父上下文字段 | 类型 |', '| --- | --- |', ...item.fields.map(name => '| ' + link(name) + ' | `' + byName.get(name).signature.replaceAll('|', '\\|') + '` |'));
|
|
65
|
+
if (item.methods?.length) {
|
|
66
|
+
const receivers = Map.groupBy(item.methods, method => method.receiver);
|
|
67
|
+
lines.push('', '## 可调用的方法', '', '可选字段需先判空。伤害结算期间,修改操作还受当前伤害提案和触发阶段约束。', '', '| 调用对象 | 方法签名 |', '| --- | --- |');
|
|
68
|
+
for (const [receiver, methods] of receivers)
|
|
69
|
+
lines.push('| `' + receiver + '` | ' + methods.map(method => link(method.symbol)).join('、') + ' |');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (item.example) {
|
|
73
|
+
lines.push('', '## ' + (item.exampleSource ? '霜击模板示例' : '读取事件示例'), '', code(item.example));
|
|
74
|
+
if (item.exampleSource)
|
|
75
|
+
lines.push('', '模板文件 `' + item.exampleSource + '`。参见[霜击创作教程](/frost-strike)。');
|
|
76
|
+
}
|
|
77
|
+
if (item.dispatches?.length)
|
|
78
|
+
lines.push('', '派发位置 ' + item.dispatches.map(site => '`' + site.path + ':' + site.line + '`').join('、'));
|
|
79
|
+
if (item.related.length)
|
|
80
|
+
lines.push('', '相关符号 ' + item.related.map(link).join('、'));
|
|
81
|
+
return lines.join('\n');
|
|
82
|
+
}
|
|
83
|
+
function markdown(item) {
|
|
84
|
+
return '# ' + item.symbol + '\n\n' + body(item) + '\n';
|
|
85
|
+
}
|
|
86
|
+
return { records, byName, children, link, body, markdown };
|
|
87
|
+
}
|
|
88
|
+
async function loadRecords() {
|
|
89
|
+
if (import.meta.url.endsWith('.ts')) {
|
|
90
|
+
const { generateSdkReference } = await import(__rewriteRelativeImportExtension(new URL('../generate-sdk-reference.mjs', import.meta.url).href));
|
|
91
|
+
const ts = (await import('typescript')).default;
|
|
92
|
+
return generateSdkReference(ts, import.meta.filename);
|
|
93
|
+
}
|
|
94
|
+
return JSON.parse(await readFile(new URL('./sdk-reference.json', import.meta.url), 'utf8'));
|
|
95
|
+
}
|
|
96
|
+
let installed;
|
|
97
|
+
export function installedSdkCatalog() {
|
|
98
|
+
return (installed ??= loadRecords().then(sdkCatalog));
|
|
99
|
+
}
|