@heybox/hb-sdk 0.5.9 → 0.5.11
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 +94 -51
- package/dist/cli-chunks/{create-zJEmBOvP.cjs → create-BaqN3jeW.cjs} +1 -1
- package/dist/cli-chunks/{dev-DsqPSgeJ.cjs → dev-DUZgcgYE.cjs} +1 -1
- package/dist/cli-chunks/{doctor-DZkEwLT9.cjs → doctor-DUjQij7b.cjs} +1 -1
- package/dist/cli-chunks/{index-CU-8dVKo.cjs → index-6W5M4MLF.cjs} +2 -2
- package/dist/cli-chunks/{index-BpVGoWHu.cjs → index-BROIiSNN.cjs} +57 -13
- package/dist/cli-chunks/{login-DhKNZpl4.cjs → login-BejyA1mX.cjs} +2 -2
- package/dist/cli-chunks/{remote-D0izsd5c.cjs → remote-ChGmIJC1.cjs} +117 -3
- package/dist/cli-chunks/{session-O_NdH1Z2.cjs → session-jHF9KWBo.cjs} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/devtools/mock-host/main.js +590 -0
- package/dist/index.cjs.js +37 -0
- package/dist/index.esm.js +37 -1
- package/dist/miniapp-publish.cjs.js +8 -0
- package/dist/miniapp-publish.esm.js +5 -1
- package/dist/protocol.cjs.js +50 -0
- package/dist/protocol.esm.js +46 -1
- package/package.json +3 -1
- package/skill/SKILL.md +5 -3
- package/skill/references/api-protocol.md +20 -0
- package/skill/references/api-root.md +63 -3
- package/skill/references/llms-index.md +1 -0
- package/skill/scripts/sync-agent-skills-payload.mjs +359 -0
- package/skill/skill.json +4 -4
- package/types/core/client.d.ts +1 -1
- package/types/core/sdk.d.ts +3 -0
- package/types/core/singleton.d.ts +3 -0
- package/types/index.d.ts +3 -1
- package/types/miniapp-publish/index.d.ts +4 -0
- package/types/modules/cloud/index.d.ts +100 -0
- package/types/protocol/capabilities.d.ts +55 -2
- package/types/protocol.d.ts +3 -2
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Buffer } from 'node:buffer';
|
|
3
|
+
import { promises as fs } from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
6
|
+
import { HB_SDK_PACKAGE_NAME } from './skill-metadata.mjs';
|
|
7
|
+
|
|
8
|
+
const SCRIPT_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const HB_SDK_ROOT = path.resolve(SCRIPT_DIR, '../..');
|
|
10
|
+
const REPO_ROOT = path.resolve(HB_SDK_ROOT, '../..');
|
|
11
|
+
const WELL_KNOWN_ROOT = path.join('.well-known', 'agent-skills');
|
|
12
|
+
const AGENT_SKILL_PACKAGES = [
|
|
13
|
+
{
|
|
14
|
+
packageName: HB_SDK_PACKAGE_NAME,
|
|
15
|
+
skillDir: 'skill',
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const FRONTMATTER_RE = /^---\n([\s\S]*?)\n---\n?/;
|
|
20
|
+
const TEXT_FILE_RE = /\.(?:md|mjs|js|cjs|ts|tsx|json|txt|sh|yaml|yml)$/i;
|
|
21
|
+
const PREFERRED_ORDER = new Map([
|
|
22
|
+
['SKILL.md', 0],
|
|
23
|
+
['skill.json', 1],
|
|
24
|
+
['references/api-root.md', 100],
|
|
25
|
+
['references/api-protocol.md', 101],
|
|
26
|
+
['references/cli.md', 102],
|
|
27
|
+
['references/recipes.md', 103],
|
|
28
|
+
['references/safety-boundaries.md', 104],
|
|
29
|
+
['references/llms-index.md', 105],
|
|
30
|
+
['references/examples.md', 106],
|
|
31
|
+
['references/smoke-evaluation.md', 107],
|
|
32
|
+
['scripts/sync-references.mjs', 200],
|
|
33
|
+
['scripts/check-references.mjs', 201],
|
|
34
|
+
['scripts/validate-skill.mjs', 202],
|
|
35
|
+
['scripts/package-skill.mjs', 203],
|
|
36
|
+
['scripts/package-skill.sh', 204],
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
function parseCliArgs(argv) {
|
|
40
|
+
const args = argv.slice(2);
|
|
41
|
+
let outDir = path.resolve(process.cwd(), '.agent-skills-payload');
|
|
42
|
+
let check = false;
|
|
43
|
+
|
|
44
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
45
|
+
const arg = args[index];
|
|
46
|
+
if (arg === '--check') {
|
|
47
|
+
check = true;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (arg === '--out-dir') {
|
|
51
|
+
const value = args[index + 1];
|
|
52
|
+
if (!value) {
|
|
53
|
+
throw new Error('--out-dir requires a path argument');
|
|
54
|
+
}
|
|
55
|
+
outDir = path.resolve(process.cwd(), value);
|
|
56
|
+
index += 1;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return { outDir, check };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function toPosixPath(value) {
|
|
64
|
+
return value.split(path.sep).join('/');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function assertSafeRelativePath(relativePath, context) {
|
|
68
|
+
const normalized = path.posix.normalize(relativePath);
|
|
69
|
+
|
|
70
|
+
if (path.isAbsolute(relativePath) || normalized.startsWith('../') || normalized === '..') {
|
|
71
|
+
throw new Error(`${context} has unsafe path: ${relativePath}`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (normalized !== relativePath) {
|
|
75
|
+
throw new Error(`${context} must be normalized: ${relativePath}`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (relativePath.includes('/../') || relativePath.endsWith('/..')) {
|
|
79
|
+
throw new Error(`${context} cannot contain parent traversal: ${relativePath}`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (/\.zip$/i.test(relativePath)) {
|
|
83
|
+
throw new Error(`${context} must not include zip archives: ${relativePath}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function parseFrontmatter(skillText, skillPath) {
|
|
88
|
+
const match = skillText.match(FRONTMATTER_RE);
|
|
89
|
+
if (!match) {
|
|
90
|
+
throw new Error(`${skillPath} is missing YAML frontmatter`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const metadata = {};
|
|
94
|
+
for (const rawLine of match[1].split('\n')) {
|
|
95
|
+
const line = rawLine.trim();
|
|
96
|
+
if (!line || line.startsWith('#') || line.startsWith('metadata:')) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const keyValue = line.match(/^([A-Za-z0-9_-]+):\s*(.*)$/);
|
|
101
|
+
if (!keyValue) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const [, key, rawValue] = keyValue;
|
|
106
|
+
metadata[key] = rawValue.replace(/^['"]|['"]$/g, '').trim();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return metadata;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async function exists(filePath) {
|
|
113
|
+
try {
|
|
114
|
+
await fs.access(filePath);
|
|
115
|
+
return true;
|
|
116
|
+
} catch {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function readJsonFile(filePath) {
|
|
122
|
+
return JSON.parse(await fs.readFile(filePath, 'utf8'));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async function resolvePackageRoot(packageSource) {
|
|
126
|
+
if (packageSource.packageName !== HB_SDK_PACKAGE_NAME) {
|
|
127
|
+
throw new Error(`Unsupported agent skill package: ${packageSource.packageName}`);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (!(await exists(path.join(HB_SDK_ROOT, 'package.json')))) {
|
|
131
|
+
throw new Error(`Cannot resolve ${packageSource.packageName}: missing package root at ${toPosixPath(HB_SDK_ROOT)}`);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return HB_SDK_ROOT;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function listFilesRecursive(rootDir, relativeBase = '', options = {}) {
|
|
138
|
+
if (!(await exists(rootDir))) {
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const entries = await fs.readdir(rootDir, { withFileTypes: true });
|
|
143
|
+
const files = [];
|
|
144
|
+
|
|
145
|
+
for (const entry of entries) {
|
|
146
|
+
if (!options.includeHidden && entry.name.startsWith('.')) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const absolutePath = path.join(rootDir, entry.name);
|
|
151
|
+
const relativePath = path.posix.join(relativeBase, entry.name);
|
|
152
|
+
|
|
153
|
+
if (entry.isDirectory()) {
|
|
154
|
+
files.push(...(await listFilesRecursive(absolutePath, relativePath, options)));
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (entry.isFile()) {
|
|
159
|
+
files.push(relativePath);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return files;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function sortSkillFiles(files) {
|
|
167
|
+
return [...files].sort((left, right) => {
|
|
168
|
+
const leftOrder = PREFERRED_ORDER.get(left) ?? 10_000;
|
|
169
|
+
const rightOrder = PREFERRED_ORDER.get(right) ?? 10_000;
|
|
170
|
+
return leftOrder - rightOrder || left.localeCompare(right);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async function discoverSkill(packageSource) {
|
|
175
|
+
const packageRoot = await resolvePackageRoot(packageSource);
|
|
176
|
+
const skillDir = path.join(packageRoot, packageSource.skillDir);
|
|
177
|
+
const skillMarkdownPath = path.join(skillDir, 'SKILL.md');
|
|
178
|
+
|
|
179
|
+
if (!(await exists(skillMarkdownPath))) {
|
|
180
|
+
throw new Error(`${packageSource.packageName} must provide ${packageSource.skillDir}/SKILL.md.`);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const skillMarkdown = await fs.readFile(skillMarkdownPath, 'utf8');
|
|
184
|
+
const frontmatter = parseFrontmatter(skillMarkdown, skillMarkdownPath);
|
|
185
|
+
const skillName = frontmatter.name;
|
|
186
|
+
|
|
187
|
+
if (!skillName) {
|
|
188
|
+
throw new Error(`${skillMarkdownPath} frontmatter must include name`);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (!frontmatter.description) {
|
|
192
|
+
throw new Error(`${skillMarkdownPath} frontmatter must include description`);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const files = ['SKILL.md'];
|
|
196
|
+
const skillJsonPath = path.join(skillDir, 'skill.json');
|
|
197
|
+
let metadata = null;
|
|
198
|
+
|
|
199
|
+
if (await exists(skillJsonPath)) {
|
|
200
|
+
const relativeFile = 'skill.json';
|
|
201
|
+
assertSafeRelativePath(relativeFile, `${skillName} source file`);
|
|
202
|
+
files.push(relativeFile);
|
|
203
|
+
metadata = await readJsonFile(skillJsonPath);
|
|
204
|
+
if (metadata.name !== skillName) {
|
|
205
|
+
throw new Error(`${skillJsonPath} name (${metadata.name}) must match SKILL.md frontmatter (${skillName})`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
for (const topLevelDir of ['references', 'scripts', 'assets']) {
|
|
210
|
+
const nestedFiles = await listFilesRecursive(path.join(skillDir, topLevelDir), topLevelDir);
|
|
211
|
+
for (const relativeFile of nestedFiles) {
|
|
212
|
+
if (!TEXT_FILE_RE.test(relativeFile)) {
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
assertSafeRelativePath(relativeFile, `${skillName} source file`);
|
|
216
|
+
files.push(relativeFile);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return {
|
|
221
|
+
sourceDir: skillDir,
|
|
222
|
+
name: skillName,
|
|
223
|
+
description: frontmatter.description,
|
|
224
|
+
files: sortSkillFiles(files),
|
|
225
|
+
metadata,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
async function discoverSkills() {
|
|
230
|
+
const skills = [];
|
|
231
|
+
|
|
232
|
+
for (const packageSource of AGENT_SKILL_PACKAGES) {
|
|
233
|
+
skills.push(await discoverSkill(packageSource));
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (skills.length === 0) {
|
|
237
|
+
throw new Error('No configured agent skills found.');
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return skills;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export function createSkillIndex(skills) {
|
|
244
|
+
return {
|
|
245
|
+
skills: skills.map((skill) => ({
|
|
246
|
+
name: skill.name,
|
|
247
|
+
description: skill.description,
|
|
248
|
+
...(skill.metadata
|
|
249
|
+
? {
|
|
250
|
+
version: skill.metadata.skillVersion,
|
|
251
|
+
sdk: skill.metadata.sdk,
|
|
252
|
+
source: skill.metadata.source,
|
|
253
|
+
integrity: skill.metadata.integrity,
|
|
254
|
+
}
|
|
255
|
+
: {}),
|
|
256
|
+
files: skill.files,
|
|
257
|
+
})),
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
async function addIndexFile(outputFiles, baseDir, skills) {
|
|
262
|
+
const indexPath = path.join(baseDir, WELL_KNOWN_ROOT, 'index.json');
|
|
263
|
+
const index = createSkillIndex(skills);
|
|
264
|
+
|
|
265
|
+
outputFiles.set(indexPath, Buffer.from(`${JSON.stringify(index, null, 2)}\n`, 'utf8'));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
async function addSkillFiles(outputFiles, baseDir, skills) {
|
|
269
|
+
for (const skill of skills) {
|
|
270
|
+
for (const relativeFile of skill.files) {
|
|
271
|
+
assertSafeRelativePath(relativeFile, `${skill.name} generated file`);
|
|
272
|
+
const sourcePath = path.join(skill.sourceDir, ...relativeFile.split('/'));
|
|
273
|
+
const targetPath = path.join(baseDir, WELL_KNOWN_ROOT, skill.name, ...relativeFile.split('/'));
|
|
274
|
+
outputFiles.set(targetPath, await fs.readFile(sourcePath));
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
async function buildExpectedOutput(skills, targetRoot) {
|
|
280
|
+
const outputFiles = new Map();
|
|
281
|
+
|
|
282
|
+
await addIndexFile(outputFiles, targetRoot, skills);
|
|
283
|
+
await addSkillFiles(outputFiles, targetRoot, skills);
|
|
284
|
+
|
|
285
|
+
return outputFiles;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
async function listExistingGeneratedFiles(targetRoot) {
|
|
289
|
+
if (!(await exists(targetRoot))) {
|
|
290
|
+
return [];
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const relativeFiles = await listFilesRecursive(targetRoot, '', { includeHidden: true });
|
|
294
|
+
return relativeFiles.map((relativeFile) => path.join(targetRoot, ...relativeFile.split('/')));
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
async function syncFiles(expectedOutput, targetRoot) {
|
|
298
|
+
await fs.rm(targetRoot, { recursive: true, force: true });
|
|
299
|
+
|
|
300
|
+
for (const [targetPath, content] of [...expectedOutput.entries()].sort(([left], [right]) => left.localeCompare(right))) {
|
|
301
|
+
await fs.mkdir(path.dirname(targetPath), { recursive: true });
|
|
302
|
+
await fs.writeFile(targetPath, content);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
async function checkFiles(expectedOutput, targetRoot) {
|
|
307
|
+
const expectedPaths = new Set(expectedOutput.keys());
|
|
308
|
+
const existingPaths = new Set(await listExistingGeneratedFiles(targetRoot));
|
|
309
|
+
const problems = [];
|
|
310
|
+
|
|
311
|
+
for (const expectedPath of [...expectedPaths].sort()) {
|
|
312
|
+
if (!existingPaths.has(expectedPath)) {
|
|
313
|
+
problems.push(`missing ${path.relative(REPO_ROOT, expectedPath)}`);
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const actual = await fs.readFile(expectedPath);
|
|
318
|
+
const expected = expectedOutput.get(expectedPath);
|
|
319
|
+
if (!actual.equals(expected)) {
|
|
320
|
+
problems.push(`stale ${path.relative(REPO_ROOT, expectedPath)}`);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
for (const existingPath of [...existingPaths].sort()) {
|
|
325
|
+
if (!expectedPaths.has(existingPath)) {
|
|
326
|
+
problems.push(`extra ${path.relative(REPO_ROOT, existingPath)}`);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (problems.length > 0) {
|
|
331
|
+
throw new Error(`Agent skills payload is out of sync:\n${problems.map((problem) => `- ${problem}`).join('\n')}`);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
async function main() {
|
|
336
|
+
const { outDir, check } = parseCliArgs(process.argv);
|
|
337
|
+
const skills = await discoverSkills();
|
|
338
|
+
const expectedOutput = await buildExpectedOutput(skills, outDir);
|
|
339
|
+
|
|
340
|
+
if (check) {
|
|
341
|
+
await checkFiles(expectedOutput, outDir);
|
|
342
|
+
console.log(
|
|
343
|
+
`Agent skills payload is in sync at ${toPosixPath(path.relative(REPO_ROOT, outDir))} (${expectedOutput.size} files, ${skills.length} skills).`,
|
|
344
|
+
);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
await syncFiles(expectedOutput, outDir);
|
|
349
|
+
console.log(
|
|
350
|
+
`Synced ${skills.length} skills to ${toPosixPath(path.relative(REPO_ROOT, outDir))} (${expectedOutput.size} files).`,
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
355
|
+
main().catch((error) => {
|
|
356
|
+
console.error(error.message);
|
|
357
|
+
process.exitCode = 1;
|
|
358
|
+
});
|
|
359
|
+
}
|
package/skill/skill.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hb-sdk",
|
|
3
|
-
"skillVersion": "0.5.
|
|
3
|
+
"skillVersion": "0.5.11+skill.20c209340580",
|
|
4
4
|
"sdk": {
|
|
5
5
|
"package": "@heybox/hb-sdk",
|
|
6
|
-
"version": "0.5.
|
|
7
|
-
"compatibility": "0.5.
|
|
6
|
+
"version": "0.5.11",
|
|
7
|
+
"compatibility": "0.5.11"
|
|
8
8
|
},
|
|
9
9
|
"source": "https://open.xiaoheihe.cn/agent-skills/hb-sdk",
|
|
10
|
-
"integrity": "sha256-
|
|
10
|
+
"integrity": "sha256-20c209340580ee5507bb72eb8cd044693b29e109472e93fc3d8302a53b4770d2"
|
|
11
11
|
}
|
package/types/core/client.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface MiniProgramSDKOptions {
|
|
|
18
18
|
/** 精准 postMessage 目标 origin;未传时尝试推断,失败则回退为 `*`。 */
|
|
19
19
|
targetOrigin?: string;
|
|
20
20
|
}
|
|
21
|
-
type MiniProgramRequesterArgs<Method extends MiniProgramBridgeMethod> = MiniProgramCapabilityPayload<Method> extends void ? [payload?: MiniProgramCapabilityPayload<Method>] : [payload: MiniProgramCapabilityPayload<Method>];
|
|
21
|
+
type MiniProgramRequesterArgs<Method extends MiniProgramBridgeMethod> = MiniProgramCapabilityPayload<Method> extends void ? [payload?: MiniProgramCapabilityPayload<Method>] : undefined extends MiniProgramCapabilityPayload<Method> ? [payload?: MiniProgramCapabilityPayload<Method>] : [payload: MiniProgramCapabilityPayload<Method>];
|
|
22
22
|
/** 模块 API 发起请求所需的最小能力。 */
|
|
23
23
|
export interface MiniProgramRequester {
|
|
24
24
|
/** 向父容器调用指定开放能力。 */
|
package/types/core/sdk.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type MiniProgramSDKOptions } from './client';
|
|
2
2
|
import { type MiniProgramAuthModule } from '../modules/auth';
|
|
3
|
+
import { type MiniProgramCloudModule } from '../modules/cloud';
|
|
3
4
|
import { type MiniProgramShareModule } from '../modules/share';
|
|
4
5
|
import { type MiniProgramStorageModule } from '../modules/storage';
|
|
5
6
|
import { type MiniProgramNetworkModule } from '../modules/network';
|
|
@@ -50,6 +51,8 @@ export declare class MiniProgramSDK {
|
|
|
50
51
|
readonly device: MiniProgramDeviceModule;
|
|
51
52
|
/** 导航与容器控制相关开放能力。 */
|
|
52
53
|
readonly navigation: MiniProgramNavigationModule;
|
|
54
|
+
/** 云端数据相关开放能力。 */
|
|
55
|
+
readonly cloud: MiniProgramCloudModule;
|
|
53
56
|
constructor(options?: MiniProgramSDKOptions);
|
|
54
57
|
/**
|
|
55
58
|
* 等待 SDK 与父容器完成握手。
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MiniProgramAuthModule } from '../modules/auth';
|
|
2
|
+
import type { MiniProgramCloudModule } from '../modules/cloud';
|
|
2
3
|
import type { MiniProgramShareModule } from '../modules/share';
|
|
3
4
|
import type { MiniProgramStorageModule } from '../modules/storage';
|
|
4
5
|
import type { MiniProgramNetworkModule } from '../modules/network';
|
|
@@ -49,5 +50,7 @@ export declare const ui: MiniProgramUiModule;
|
|
|
49
50
|
export declare const device: MiniProgramDeviceModule;
|
|
50
51
|
/** 默认 SDK 实例的 navigation 模块。 */
|
|
51
52
|
export declare const navigation: MiniProgramNavigationModule;
|
|
53
|
+
/** 默认 SDK 实例的 cloud 模块。 */
|
|
54
|
+
export declare const cloud: MiniProgramCloudModule;
|
|
52
55
|
/** 重置默认 SDK 实例,仅用于测试。 */
|
|
53
56
|
export declare function resetDefaultSDKForTest(): void;
|
package/types/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { createMiniProgramSDK, MiniProgramSDK } from './core/sdk';
|
|
2
2
|
export { HbMiniProgramSDKError, HbMiniProgramNetworkError } from './core/errors';
|
|
3
3
|
export type { MiniProgramSDKOptions } from './core/client';
|
|
4
|
-
export { ready, on, off, auth, user, share, viewport, storage, network, ui, device, navigation } from './core/singleton';
|
|
4
|
+
export { ready, on, off, auth, user, share, viewport, storage, network, ui, device, navigation, cloud } from './core/singleton';
|
|
5
5
|
export type { MiniProgramEventHandler, MiniProgramEventName, MiniProgramEventPayloadMap, } from './protocol/types';
|
|
6
6
|
export type { LoginPayload, LoginResult, MiniProgramAuthModule } from './modules/auth';
|
|
7
|
+
export type { DeleteCurrentUserLeaderboardEntryPayload, DeleteCurrentUserLeaderboardEntryResult, GetCurrentUserLeaderboardEntryPayload, GetCurrentUserLeaderboardEntryResult, GetLeaderboardInfoPayload, GetLeaderboardInfoResult, GetLeaderboardListPayload, GetLeaderboardListResult, LeaderboardEntry, LeaderboardOrder, MiniProgramCloudLeaderboardModule, MiniProgramCloudModule, SubmitLeaderboardEntryPayload, SubmitLeaderboardEntryResult, } from './modules/cloud';
|
|
7
8
|
export type { BasePlatformAccountInfo, CurrentUserAvatarConfig, CurrentUserAvatarDecoration, CurrentUserBbsInfo, CurrentUserDetail, CurrentUserLevelInfo, CurrentUserMedal, CurrentUserProfile, EpicPlatformAccountInfo, GetCurrentUserDetailPayload, GetCurrentUserDetailResult, GetCurrentUserProfilePayload, GetCurrentUserProfileResult, GetPlatformAccountInfoPayload, GetPlatformAccountInfoResult, GetPlatformAccountOverviewPayload, GetPlatformAccountOverviewResult, GetSteamGameListOptions, GetSteamGameListPayload, GetSteamGameListResult, GetUserInfoPayload, GetUserInfoResult, MiniProgramUserInfo, MiniProgramUserInfoResult, MiniProgramUserModule, MobilePlatformAccountInfo, PcHardwareAccountInfo, PlatformAccountInfoMap, PlatformAccountOverview, PlatformAccountResult, PlatformAccountType, PlatformStatItem, PsnPlatformAccountInfo, SteamGameListData, SteamGameListItem, SteamGameListSort, SteamGamePrice, SteamPlatformAccountInfo, SwitchPlatformAccountInfo, UserScopedResult, XboxPlatformAccountInfo, } from './modules/user';
|
|
8
9
|
export type { MiniProgramScreenshotOptions, MiniProgramScreenshotRect, MiniProgramShareChannel, MiniProgramShareModule, MiniProgramShowShareMenuOptions, ScreenshotPayload, ScreenshotResult, ShowShareMenuPayload, ShowShareMenuResult, } from './modules/share';
|
|
9
10
|
export type { GetWindowInfoPayload, GetWindowInfoResult, MiniProgramNavigationBarForegroundStyle, MiniProgramSafeArea, MiniProgramSetNavigationBarStyleOptions, MiniProgramViewportModule, MiniProgramWindowInfoResult, SetNavigationBarStylePayload, SetNavigationBarStyleResult, } from './modules/viewport';
|
|
@@ -26,5 +27,6 @@ declare const hbSDK: {
|
|
|
26
27
|
ui: import(".").MiniProgramUiModule;
|
|
27
28
|
device: import(".").MiniProgramDeviceModule;
|
|
28
29
|
navigation: import(".").MiniProgramNavigationModule;
|
|
30
|
+
cloud: import(".").MiniProgramCloudModule;
|
|
29
31
|
};
|
|
30
32
|
export default hbSDK;
|
|
@@ -10,6 +10,10 @@ export declare const CREATE_USER_MINIPROGRAM_API_PATH = "/mall/developer/user_mi
|
|
|
10
10
|
export declare const DETAIL_USER_MINIPROGRAM_API_PATH = "/mall/developer/user_miniprogram/detail";
|
|
11
11
|
export declare const USER_MINIPROGRAM_PREVIEW_ALLOWLIST_API_PATH = "/mall/developer/user_miniprogram/preview_allowlist";
|
|
12
12
|
export declare const UPDATE_USER_MINIPROGRAM_PREVIEW_ALLOWLIST_API_PATH = "/mall/developer/user_miniprogram/preview_allowlist/update";
|
|
13
|
+
export declare const CREATE_USER_MINIPROGRAM_LEADERBOARD_API_PATH = "/mall/developer/user_miniprogram/leaderboard/create";
|
|
14
|
+
export declare const DETAIL_USER_MINIPROGRAM_LEADERBOARD_API_PATH = "/mall/developer/user_miniprogram/leaderboard/detail";
|
|
15
|
+
export declare const LIST_USER_MINIPROGRAM_LEADERBOARD_API_PATH = "/mall/developer/user_miniprogram/leaderboard/list";
|
|
16
|
+
export declare const DELETE_USER_MINIPROGRAM_LEADERBOARD_API_PATH = "/mall/developer/user_miniprogram/leaderboard/delete";
|
|
13
17
|
export declare const PRECHECK_USER_MINIPROGRAM_VERSION_API_PATH = "/mall/developer/user_miniprogram/version/precheck";
|
|
14
18
|
export declare const SUBMIT_USER_MINIPROGRAM_AUDIT_API_PATH = "/mall/developer/user_miniprogram/version/submit_audit";
|
|
15
19
|
export declare const USER_MINIPROGRAM_VERSION_PREVIEW_INFO_API_PATH = "/mall/developer/user_miniprogram/version/preview_info";
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { MiniProgramRequester } from '../../core/client';
|
|
2
|
+
export { CLOUD_LEADERBOARD_DELETE_CURRENT_USER_ENTRY_METHOD, CLOUD_LEADERBOARD_GET_CURRENT_USER_ENTRY_METHOD, CLOUD_LEADERBOARD_GET_INFO_METHOD, CLOUD_LEADERBOARD_GET_LIST_METHOD, CLOUD_LEADERBOARD_SUBMIT_METHOD, } from '../../protocol/capabilities';
|
|
3
|
+
/** 排行榜排序方向。 */
|
|
4
|
+
export type LeaderboardOrder = 'asc' | 'desc';
|
|
5
|
+
/** 排行榜记录。 */
|
|
6
|
+
export interface LeaderboardEntry {
|
|
7
|
+
/** 排名;未进入展示范围或超出当前用户排名计算上限时为 0。 */
|
|
8
|
+
rank: number;
|
|
9
|
+
/** 是否进入展示范围并位于当前用户排名计算上限内。 */
|
|
10
|
+
ranked: boolean;
|
|
11
|
+
/** 当前记录所属用户 ID,由平台注入,前端不能传入。 */
|
|
12
|
+
userId: string;
|
|
13
|
+
/** 分数,排行榜唯一排序字段。 */
|
|
14
|
+
score: number;
|
|
15
|
+
/** 展示附加信息,不参与排序和查询。 */
|
|
16
|
+
extra: Record<string, unknown>;
|
|
17
|
+
/** 记录创建时间,秒级时间戳。 */
|
|
18
|
+
createdAt: number;
|
|
19
|
+
/** 记录更新时间,秒级时间戳。 */
|
|
20
|
+
updatedAt: number;
|
|
21
|
+
}
|
|
22
|
+
/** 提交当前用户排行榜分数。 */
|
|
23
|
+
export interface SubmitLeaderboardEntryPayload {
|
|
24
|
+
/** 排行榜 key;不传时由服务端使用当前小程序已创建的 default 榜单。 */
|
|
25
|
+
key?: string;
|
|
26
|
+
/** 本次提交分数,必须是有限安全数字,范围不超过 JavaScript safe number。 */
|
|
27
|
+
score: number;
|
|
28
|
+
/** 展示附加信息,不参与排序和查询;已有记录更新为更优分数时不传则保留旧值,序列化后不超过 2048 字节。 */
|
|
29
|
+
extra?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
/** 提交排行榜分数后返回的当前用户最终记录。 */
|
|
32
|
+
export type SubmitLeaderboardEntryResult = LeaderboardEntry;
|
|
33
|
+
/** 读取排行榜列表。 */
|
|
34
|
+
export interface GetLeaderboardListPayload {
|
|
35
|
+
/** 排行榜 key;不传时由服务端使用当前小程序已创建的 default 榜单。 */
|
|
36
|
+
key?: string;
|
|
37
|
+
/** 每页数量,默认 20,最大 100。 */
|
|
38
|
+
limit?: number;
|
|
39
|
+
/** 服务端返回的不透明分页游标;只能原样传回下一页,不能自行构造或解析。 */
|
|
40
|
+
cursor?: string;
|
|
41
|
+
}
|
|
42
|
+
/** 读取排行榜列表的分页结果。 */
|
|
43
|
+
export interface GetLeaderboardListResult {
|
|
44
|
+
/** 当前页排行榜记录。 */
|
|
45
|
+
entries: LeaderboardEntry[];
|
|
46
|
+
/** 下一页不透明分页游标;仅当 hasMore 为 true 时可能返回。 */
|
|
47
|
+
cursor?: string;
|
|
48
|
+
/** 是否还有下一页。 */
|
|
49
|
+
hasMore: boolean;
|
|
50
|
+
}
|
|
51
|
+
/** 读取当前用户在排行榜中的记录。 */
|
|
52
|
+
export interface GetCurrentUserLeaderboardEntryPayload {
|
|
53
|
+
/** 排行榜 key;不传时由服务端使用当前小程序已创建的 default 榜单。 */
|
|
54
|
+
key?: string;
|
|
55
|
+
}
|
|
56
|
+
/** 当前用户排行榜记录;不存在时返回 undefined。 */
|
|
57
|
+
export type GetCurrentUserLeaderboardEntryResult = LeaderboardEntry | undefined;
|
|
58
|
+
/** 删除当前用户在排行榜中的记录。 */
|
|
59
|
+
export interface DeleteCurrentUserLeaderboardEntryPayload {
|
|
60
|
+
/** 排行榜 key;不传时由服务端使用当前小程序已创建的 default 榜单。 */
|
|
61
|
+
key?: string;
|
|
62
|
+
}
|
|
63
|
+
/** 删除当前用户排行榜记录的结果。 */
|
|
64
|
+
export interface DeleteCurrentUserLeaderboardEntryResult {
|
|
65
|
+
/** 是否实际删除了已有记录。 */
|
|
66
|
+
deleted: boolean;
|
|
67
|
+
}
|
|
68
|
+
/** 读取排行榜基础信息。 */
|
|
69
|
+
export interface GetLeaderboardInfoPayload {
|
|
70
|
+
/** 排行榜 key;不传时由服务端使用当前小程序已创建的 default 榜单。 */
|
|
71
|
+
key?: string;
|
|
72
|
+
}
|
|
73
|
+
/** 排行榜基础配置。 */
|
|
74
|
+
export interface GetLeaderboardInfoResult {
|
|
75
|
+
/** 排行榜 key。 */
|
|
76
|
+
key: string;
|
|
77
|
+
/** 排行榜排序方向。 */
|
|
78
|
+
order: LeaderboardOrder;
|
|
79
|
+
/** 列表展示名次上限;0 表示不限制。当前用户记录仍最多精确计算前 5000 名。 */
|
|
80
|
+
rankLimit: number;
|
|
81
|
+
}
|
|
82
|
+
/** 外部小程序可调用的云端排行榜模块。 */
|
|
83
|
+
export interface MiniProgramCloudLeaderboardModule {
|
|
84
|
+
/** 提交当前用户分数。 */
|
|
85
|
+
submit(options: SubmitLeaderboardEntryPayload): Promise<SubmitLeaderboardEntryResult>;
|
|
86
|
+
/** 读取排行榜列表。 */
|
|
87
|
+
getList(options?: GetLeaderboardListPayload): Promise<GetLeaderboardListResult>;
|
|
88
|
+
/** 读取当前用户记录。 */
|
|
89
|
+
getCurrentUserEntry(options?: GetCurrentUserLeaderboardEntryPayload): Promise<GetCurrentUserLeaderboardEntryResult>;
|
|
90
|
+
/** 删除当前用户记录。 */
|
|
91
|
+
deleteCurrentUserEntry(options?: DeleteCurrentUserLeaderboardEntryPayload): Promise<DeleteCurrentUserLeaderboardEntryResult>;
|
|
92
|
+
/** 读取排行榜基础信息。 */
|
|
93
|
+
getInfo(options?: GetLeaderboardInfoPayload): Promise<GetLeaderboardInfoResult>;
|
|
94
|
+
}
|
|
95
|
+
/** 外部小程序可调用的云端能力模块。 */
|
|
96
|
+
export interface MiniProgramCloudModule {
|
|
97
|
+
leaderboard: MiniProgramCloudLeaderboardModule;
|
|
98
|
+
}
|
|
99
|
+
export type { MiniProgramCloudMethod } from '../../protocol/capabilities';
|
|
100
|
+
export declare function createCloudModule(requester: MiniProgramRequester): MiniProgramCloudModule;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { LoginPayload, LoginResult } from '../modules/auth';
|
|
2
|
+
import type { DeleteCurrentUserLeaderboardEntryPayload, DeleteCurrentUserLeaderboardEntryResult, GetCurrentUserLeaderboardEntryPayload, GetCurrentUserLeaderboardEntryResult, GetLeaderboardInfoPayload, GetLeaderboardInfoResult, GetLeaderboardListPayload, GetLeaderboardListResult, SubmitLeaderboardEntryPayload, SubmitLeaderboardEntryResult } from '../modules/cloud';
|
|
2
3
|
import type { SetClipboardPayload, SetClipboardResult, VibratePayload, VibrateResult } from '../modules/device';
|
|
3
4
|
import type { ClosePayload, CloseResult, OpenAppPagePayload, OpenAppPageResult, ReloadPayload, ReloadResult } from '../modules/navigation';
|
|
4
5
|
import type { NetworkRequestPayload, NetworkResponsePayload } from '../modules/network';
|
|
@@ -96,6 +97,16 @@ export declare const NAVIGATION_CLOSE_METHOD: "navigation.close";
|
|
|
96
97
|
export declare const NAVIGATION_RELOAD_METHOD: "navigation.reload";
|
|
97
98
|
/** 打开黑盒 App 页面能力方法名。 */
|
|
98
99
|
export declare const NAVIGATION_OPEN_APP_PAGE_METHOD: "navigation.openAppPage";
|
|
100
|
+
/** 提交当前用户排行榜分数能力方法名。 */
|
|
101
|
+
export declare const CLOUD_LEADERBOARD_SUBMIT_METHOD: "cloud.leaderboard.submit";
|
|
102
|
+
/** 读取排行榜列表能力方法名。 */
|
|
103
|
+
export declare const CLOUD_LEADERBOARD_GET_LIST_METHOD: "cloud.leaderboard.getList";
|
|
104
|
+
/** 读取当前用户排行榜记录能力方法名。 */
|
|
105
|
+
export declare const CLOUD_LEADERBOARD_GET_CURRENT_USER_ENTRY_METHOD: "cloud.leaderboard.getCurrentUserEntry";
|
|
106
|
+
/** 删除当前用户排行榜记录能力方法名。 */
|
|
107
|
+
export declare const CLOUD_LEADERBOARD_DELETE_CURRENT_USER_ENTRY_METHOD: "cloud.leaderboard.deleteCurrentUserEntry";
|
|
108
|
+
/** 读取排行榜基础信息能力方法名。 */
|
|
109
|
+
export declare const CLOUD_LEADERBOARD_GET_INFO_METHOD: "cloud.leaderboard.getInfo";
|
|
99
110
|
/** 授权模块开放的方法名。 */
|
|
100
111
|
export type MiniProgramAuthMethod = typeof AUTH_LOGIN_METHOD;
|
|
101
112
|
/** 用户模块开放的方法名。 */
|
|
@@ -114,10 +125,12 @@ export type MiniProgramUiMethod = typeof UI_SHOW_TOAST_METHOD | typeof UI_SHOW_L
|
|
|
114
125
|
export type MiniProgramDeviceMethod = typeof DEVICE_VIBRATE_METHOD | typeof DEVICE_SET_CLIPBOARD_METHOD;
|
|
115
126
|
/** Navigation 模块开放的方法名。 */
|
|
116
127
|
export type MiniProgramNavigationMethod = typeof NAVIGATION_CLOSE_METHOD | typeof NAVIGATION_RELOAD_METHOD | typeof NAVIGATION_OPEN_APP_PAGE_METHOD;
|
|
128
|
+
/** Cloud 模块开放的方法名。 */
|
|
129
|
+
export type MiniProgramCloudMethod = typeof CLOUD_LEADERBOARD_SUBMIT_METHOD | typeof CLOUD_LEADERBOARD_GET_LIST_METHOD | typeof CLOUD_LEADERBOARD_GET_CURRENT_USER_ENTRY_METHOD | typeof CLOUD_LEADERBOARD_DELETE_CURRENT_USER_ENTRY_METHOD | typeof CLOUD_LEADERBOARD_GET_INFO_METHOD;
|
|
117
130
|
/** 父容器开放给小程序调用的 bridge method。 */
|
|
118
|
-
export type MiniProgramBridgeMethod = MiniProgramAuthMethod | MiniProgramUserMethod | MiniProgramShareMethod | MiniProgramViewportMethod | MiniProgramStorageMethod | MiniProgramNetworkMethod | MiniProgramUiMethod | MiniProgramDeviceMethod | MiniProgramNavigationMethod;
|
|
131
|
+
export type MiniProgramBridgeMethod = MiniProgramAuthMethod | MiniProgramUserMethod | MiniProgramShareMethod | MiniProgramViewportMethod | MiniProgramStorageMethod | MiniProgramNetworkMethod | MiniProgramUiMethod | MiniProgramDeviceMethod | MiniProgramNavigationMethod | MiniProgramCloudMethod;
|
|
119
132
|
/** 小程序开放能力所属模块。 */
|
|
120
|
-
export type MiniProgramCapabilityModule = 'auth' | 'user' | 'share' | 'viewport' | 'storage' | 'network' | 'ui' | 'device' | 'navigation';
|
|
133
|
+
export type MiniProgramCapabilityModule = 'auth' | 'user' | 'share' | 'viewport' | 'storage' | 'network' | 'ui' | 'device' | 'navigation' | 'cloud';
|
|
121
134
|
/** 小程序开放能力风险级别,用于权限、审计和灰度策略。 */
|
|
122
135
|
export type MiniProgramCapabilityRisk = 'low' | 'medium' | 'high';
|
|
123
136
|
/**
|
|
@@ -277,6 +290,36 @@ export declare const MINI_PROGRAM_PROTOCOL_CAPABILITIES: readonly [{
|
|
|
277
290
|
readonly capability: "navigation.openAppPage";
|
|
278
291
|
readonly permission: "navigation.openAppPage";
|
|
279
292
|
readonly risk: "medium";
|
|
293
|
+
}, {
|
|
294
|
+
readonly method: "cloud.leaderboard.submit";
|
|
295
|
+
readonly module: "cloud";
|
|
296
|
+
readonly capability: "cloud.leaderboard.submit";
|
|
297
|
+
readonly permission: "cloud.leaderboard.write";
|
|
298
|
+
readonly risk: "medium";
|
|
299
|
+
}, {
|
|
300
|
+
readonly method: "cloud.leaderboard.getList";
|
|
301
|
+
readonly module: "cloud";
|
|
302
|
+
readonly capability: "cloud.leaderboard.getList";
|
|
303
|
+
readonly permission: "cloud.leaderboard.read";
|
|
304
|
+
readonly risk: "low";
|
|
305
|
+
}, {
|
|
306
|
+
readonly method: "cloud.leaderboard.getCurrentUserEntry";
|
|
307
|
+
readonly module: "cloud";
|
|
308
|
+
readonly capability: "cloud.leaderboard.getCurrentUserEntry";
|
|
309
|
+
readonly permission: "cloud.leaderboard.currentUserEntry.read";
|
|
310
|
+
readonly risk: "medium";
|
|
311
|
+
}, {
|
|
312
|
+
readonly method: "cloud.leaderboard.deleteCurrentUserEntry";
|
|
313
|
+
readonly module: "cloud";
|
|
314
|
+
readonly capability: "cloud.leaderboard.deleteCurrentUserEntry";
|
|
315
|
+
readonly permission: "cloud.leaderboard.currentUserEntry.delete";
|
|
316
|
+
readonly risk: "medium";
|
|
317
|
+
}, {
|
|
318
|
+
readonly method: "cloud.leaderboard.getInfo";
|
|
319
|
+
readonly module: "cloud";
|
|
320
|
+
readonly capability: "cloud.leaderboard.getInfo";
|
|
321
|
+
readonly permission: "cloud.leaderboard.info.read";
|
|
322
|
+
readonly risk: "low";
|
|
280
323
|
}];
|
|
281
324
|
/** bridge method 到请求 payload 的映射。 */
|
|
282
325
|
export interface MiniProgramCapabilityPayloadMap {
|
|
@@ -302,6 +345,11 @@ export interface MiniProgramCapabilityPayloadMap {
|
|
|
302
345
|
[NAVIGATION_CLOSE_METHOD]: ClosePayload;
|
|
303
346
|
[NAVIGATION_RELOAD_METHOD]: ReloadPayload;
|
|
304
347
|
[NAVIGATION_OPEN_APP_PAGE_METHOD]: OpenAppPagePayload;
|
|
348
|
+
[CLOUD_LEADERBOARD_SUBMIT_METHOD]: SubmitLeaderboardEntryPayload;
|
|
349
|
+
[CLOUD_LEADERBOARD_GET_LIST_METHOD]: GetLeaderboardListPayload | undefined;
|
|
350
|
+
[CLOUD_LEADERBOARD_GET_CURRENT_USER_ENTRY_METHOD]: GetCurrentUserLeaderboardEntryPayload | undefined;
|
|
351
|
+
[CLOUD_LEADERBOARD_DELETE_CURRENT_USER_ENTRY_METHOD]: DeleteCurrentUserLeaderboardEntryPayload | undefined;
|
|
352
|
+
[CLOUD_LEADERBOARD_GET_INFO_METHOD]: GetLeaderboardInfoPayload | undefined;
|
|
305
353
|
}
|
|
306
354
|
/** bridge method 到标准化响应 payload 的映射。 */
|
|
307
355
|
export interface MiniProgramCapabilityResultMap {
|
|
@@ -327,6 +375,11 @@ export interface MiniProgramCapabilityResultMap {
|
|
|
327
375
|
[NAVIGATION_CLOSE_METHOD]: CloseResult;
|
|
328
376
|
[NAVIGATION_RELOAD_METHOD]: ReloadResult;
|
|
329
377
|
[NAVIGATION_OPEN_APP_PAGE_METHOD]: OpenAppPageResult;
|
|
378
|
+
[CLOUD_LEADERBOARD_SUBMIT_METHOD]: SubmitLeaderboardEntryResult;
|
|
379
|
+
[CLOUD_LEADERBOARD_GET_LIST_METHOD]: GetLeaderboardListResult;
|
|
380
|
+
[CLOUD_LEADERBOARD_GET_CURRENT_USER_ENTRY_METHOD]: GetCurrentUserLeaderboardEntryResult;
|
|
381
|
+
[CLOUD_LEADERBOARD_DELETE_CURRENT_USER_ENTRY_METHOD]: DeleteCurrentUserLeaderboardEntryResult;
|
|
382
|
+
[CLOUD_LEADERBOARD_GET_INFO_METHOD]: GetLeaderboardInfoResult;
|
|
330
383
|
}
|
|
331
384
|
/** 指定 bridge method 的请求 payload。 */
|
|
332
385
|
export type MiniProgramCapabilityPayload<T extends MiniProgramBridgeMethod> = MiniProgramCapabilityPayloadMap[T];
|
package/types/protocol.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { MINI_PROGRAM_BRIDGE_NONCE_PARAM, MINI_PROGRAM_MESSAGE_NAMESPACE, MINI_PROGRAM_MESSAGE_VERSION, SDK_HANDSHAKE_METHOD, } from './protocol/constants';
|
|
2
2
|
export { isMiniProgramBridgeMessage } from './protocol/guards';
|
|
3
3
|
export type { MiniProgramBridgeError, MiniProgramBridgeMessage, MiniProgramBridgeMessageType, MiniProgramEventHandler, MiniProgramEventName, MiniProgramEventPayloadMap, } from './protocol/types';
|
|
4
|
-
export { AUTH_LOGIN_METHOD, DEVICE_SET_CLIPBOARD_METHOD, DEVICE_VIBRATE_METHOD, MINI_PROGRAM_PROTOCOL_CAPABILITIES, NAVIGATION_CLOSE_METHOD, NAVIGATION_OPEN_APP_PAGE_METHOD, NAVIGATION_RELOAD_METHOD, NETWORK_REQUEST_METHOD, SHARE_SCREENSHOT_METHOD, SHARE_SHOW_SHARE_MENU_METHOD, STORAGE_GET_STORAGE_METHOD, STORAGE_SET_STORAGE_METHOD, UI_HIDE_LOADING_METHOD, UI_SHOW_LOADING_METHOD, UI_SHOW_TOAST_METHOD, USER_GET_CURRENT_USER_DETAIL_METHOD, USER_GET_CURRENT_USER_PROFILE_METHOD, USER_GET_INFO_METHOD, USER_GET_PLATFORM_ACCOUNT_INFO_METHOD, USER_GET_PLATFORM_ACCOUNT_OVERVIEW_METHOD, USER_GET_STEAM_GAME_LIST_METHOD, VIEWPORT_GET_WINDOW_INFO_METHOD, VIEWPORT_SET_NAVIGATION_BAR_STYLE_METHOD, } from './protocol/capabilities';
|
|
5
|
-
export type { MiniProgramDeviceMethod, MiniProgramAuthMethod, MiniProgramBridgeMethod, MiniProgramCapabilityDefinition, MiniProgramCapabilityModule, MiniProgramCapabilityPayload, MiniProgramCapabilityPayloadMap, MiniProgramCapabilityResult, MiniProgramCapabilityResultMap, MiniProgramCapabilityRisk, MiniProgramNavigationMethod, MiniProgramNetworkMethod, MiniProgramShareMethod, MiniProgramStorageMethod, MiniProgramUiMethod, MiniProgramUserMethod, MiniProgramViewportMethod, } from './protocol/capabilities';
|
|
4
|
+
export { AUTH_LOGIN_METHOD, CLOUD_LEADERBOARD_DELETE_CURRENT_USER_ENTRY_METHOD, CLOUD_LEADERBOARD_GET_CURRENT_USER_ENTRY_METHOD, CLOUD_LEADERBOARD_GET_INFO_METHOD, CLOUD_LEADERBOARD_GET_LIST_METHOD, CLOUD_LEADERBOARD_SUBMIT_METHOD, DEVICE_SET_CLIPBOARD_METHOD, DEVICE_VIBRATE_METHOD, MINI_PROGRAM_PROTOCOL_CAPABILITIES, NAVIGATION_CLOSE_METHOD, NAVIGATION_OPEN_APP_PAGE_METHOD, NAVIGATION_RELOAD_METHOD, NETWORK_REQUEST_METHOD, SHARE_SCREENSHOT_METHOD, SHARE_SHOW_SHARE_MENU_METHOD, STORAGE_GET_STORAGE_METHOD, STORAGE_SET_STORAGE_METHOD, UI_HIDE_LOADING_METHOD, UI_SHOW_LOADING_METHOD, UI_SHOW_TOAST_METHOD, USER_GET_CURRENT_USER_DETAIL_METHOD, USER_GET_CURRENT_USER_PROFILE_METHOD, USER_GET_INFO_METHOD, USER_GET_PLATFORM_ACCOUNT_INFO_METHOD, USER_GET_PLATFORM_ACCOUNT_OVERVIEW_METHOD, USER_GET_STEAM_GAME_LIST_METHOD, VIEWPORT_GET_WINDOW_INFO_METHOD, VIEWPORT_SET_NAVIGATION_BAR_STYLE_METHOD, } from './protocol/capabilities';
|
|
5
|
+
export type { MiniProgramDeviceMethod, MiniProgramAuthMethod, MiniProgramBridgeMethod, MiniProgramCapabilityDefinition, MiniProgramCapabilityModule, MiniProgramCapabilityPayload, MiniProgramCapabilityPayloadMap, MiniProgramCapabilityResult, MiniProgramCapabilityResultMap, MiniProgramCapabilityRisk, MiniProgramCloudMethod, MiniProgramNavigationMethod, MiniProgramNetworkMethod, MiniProgramShareMethod, MiniProgramStorageMethod, MiniProgramUiMethod, MiniProgramUserMethod, MiniProgramViewportMethod, } from './protocol/capabilities';
|
|
6
6
|
export type { LoginPayload, LoginResult } from './modules/auth';
|
|
7
|
+
export type { DeleteCurrentUserLeaderboardEntryPayload, DeleteCurrentUserLeaderboardEntryResult, GetCurrentUserLeaderboardEntryPayload, GetCurrentUserLeaderboardEntryResult, GetLeaderboardInfoPayload, GetLeaderboardInfoResult, GetLeaderboardListPayload, GetLeaderboardListResult, LeaderboardEntry, LeaderboardOrder, SubmitLeaderboardEntryPayload, SubmitLeaderboardEntryResult, } from './modules/cloud';
|
|
7
8
|
export type { GetCurrentUserDetailPayload, GetCurrentUserDetailResult, GetCurrentUserProfilePayload, GetCurrentUserProfileResult, GetPlatformAccountInfoPayload, GetPlatformAccountInfoResult, GetPlatformAccountOverviewPayload, GetPlatformAccountOverviewResult, GetSteamGameListOptions, GetSteamGameListPayload, GetSteamGameListResult, GetUserInfoPayload, GetUserInfoResult, MiniProgramUserInfo, MiniProgramUserInfoResult, SteamGameListData, SteamGameListItem, SteamGameListSort, SteamGamePrice, } from './modules/user';
|
|
8
9
|
export type { ScreenshotPayload, ScreenshotResult } from './modules/share/screenshot';
|
|
9
10
|
export type { ShowShareMenuPayload, ShowShareMenuResult } from './modules/share/show-share-menu';
|