@heybox/hb-sdk 0.2.0-alpha.0 → 0.2.0-alpha.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 +193 -452
- package/bin/hb-sdk.cjs +1 -1
- package/dist/cli.cjs +71660 -3903
- package/dist/devtools/mock-host/index.html +13 -387
- package/dist/devtools/mock-host/main.js +975 -0
- package/dist/index.cjs.js +50 -63
- package/dist/index.esm.js +51 -50
- package/dist/miniapp-publish.cjs.js +77 -0
- package/dist/miniapp-publish.esm.js +66 -0
- package/dist/protocol.cjs.js +72 -13
- package/dist/protocol.esm.js +72 -14
- package/dist/templates/vue3-vite-ts/README.md.ejs +1 -5
- package/dist/templates/vue3-vite-ts/package.json.ejs +0 -1
- package/dist/templates/vue3-vite-ts/vite.config.ts +2 -1
- package/dist/vite.cjs.js +62 -0
- package/dist/vite.esm.js +60 -0
- package/package.json +30 -1
- package/skill/SKILL.md +106 -0
- package/skill/references/api-protocol.md +135 -0
- package/skill/references/api-root.md +474 -0
- package/skill/references/cli.md +376 -0
- package/skill/references/examples.md +119 -0
- package/skill/references/llms-index.md +44 -0
- package/skill/references/recipes.md +374 -0
- package/skill/references/safety-boundaries.md +30 -0
- package/skill/references/smoke-evaluation.md +24 -0
- package/skill/scripts/check-references.mjs +14 -0
- package/skill/scripts/package-skill.mjs +60 -0
- package/skill/scripts/package-skill.sh +6 -0
- package/skill/scripts/skill-metadata.mjs +74 -0
- package/skill/scripts/sync-references.mjs +565 -0
- package/skill/scripts/validate-skill.mjs +235 -0
- package/skill/skill.json +11 -0
- package/types/index.d.ts +8 -6
- package/types/miniapp-publish/index.d.ts +23 -0
- package/types/modules/auth/index.d.ts +2 -9
- package/types/modules/network/index.d.ts +6 -11
- package/types/modules/share/index.d.ts +3 -9
- package/types/modules/share/screenshot.d.ts +1 -7
- package/types/modules/share/show-share-menu.d.ts +1 -7
- package/types/modules/storage/index.d.ts +2 -16
- package/types/modules/user/get-info.d.ts +1 -7
- package/types/modules/user/index.d.ts +2 -8
- package/types/modules/viewport/index.d.ts +2 -9
- package/types/protocol/capabilities.d.ts +180 -0
- package/types/protocol.d.ts +8 -13
- package/types/vite/index.d.ts +17 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import process from 'node:process';
|
|
6
|
+
import {
|
|
7
|
+
HB_SDK_PACKAGE_NAME,
|
|
8
|
+
HB_SDK_SKILL_NAME,
|
|
9
|
+
validateSkillManifest,
|
|
10
|
+
} from './skill-metadata.mjs';
|
|
11
|
+
|
|
12
|
+
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
const skillRoot = path.resolve(scriptDir, '..');
|
|
14
|
+
const packageRoot = path.resolve(skillRoot, '..');
|
|
15
|
+
const repoRoot = findRepoRoot(process.cwd()) ?? findRepoRoot(skillRoot) ?? process.cwd();
|
|
16
|
+
const errors = [];
|
|
17
|
+
const warnings = [];
|
|
18
|
+
|
|
19
|
+
function findRepoRoot(startDir) {
|
|
20
|
+
let dir = path.resolve(startDir);
|
|
21
|
+
while (true) {
|
|
22
|
+
if (existsSync(path.join(dir, 'package.json')) && existsSync(path.join(dir, 'packages/hb-sdk/package.json'))) {
|
|
23
|
+
return dir;
|
|
24
|
+
}
|
|
25
|
+
const parent = path.dirname(dir);
|
|
26
|
+
if (parent === dir) return null;
|
|
27
|
+
dir = parent;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function rel(filePath) {
|
|
32
|
+
return path.relative(repoRoot, filePath).split(path.sep).join('/');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function skillRel(filePath) {
|
|
36
|
+
return path.relative(skillRoot, filePath).split(path.sep).join('/');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function fail(message) {
|
|
40
|
+
errors.push(message);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function warn(message) {
|
|
44
|
+
warnings.push(message);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function read(filePath) {
|
|
48
|
+
return readFileSync(filePath, 'utf8');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function walk(dir) {
|
|
52
|
+
const out = [];
|
|
53
|
+
for (const entry of readdirSync(dir)) {
|
|
54
|
+
const fullPath = path.join(dir, entry);
|
|
55
|
+
const stat = statSync(fullPath);
|
|
56
|
+
if (stat.isDirectory()) out.push(...walk(fullPath));
|
|
57
|
+
else out.push(fullPath);
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function parseFrontmatter(markdown) {
|
|
63
|
+
const match = markdown.match(/^---\n([\s\S]*?)\n---\n/);
|
|
64
|
+
if (!match) return null;
|
|
65
|
+
const fields = new Map();
|
|
66
|
+
for (const line of match[1].split('\n')) {
|
|
67
|
+
const field = line.match(/^([A-Za-z0-9_-]+):\s*(.*)$/);
|
|
68
|
+
if (field) fields.set(field[1], field[2].replace(/^['"]|['"]$/g, ''));
|
|
69
|
+
}
|
|
70
|
+
return fields;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const requiredFiles = [
|
|
74
|
+
'SKILL.md',
|
|
75
|
+
'skill.json',
|
|
76
|
+
'references/api-root.md',
|
|
77
|
+
'references/api-protocol.md',
|
|
78
|
+
'references/cli.md',
|
|
79
|
+
'references/recipes.md',
|
|
80
|
+
'references/safety-boundaries.md',
|
|
81
|
+
'references/llms-index.md',
|
|
82
|
+
'references/examples.md',
|
|
83
|
+
'references/smoke-evaluation.md',
|
|
84
|
+
'scripts/sync-references.mjs',
|
|
85
|
+
'scripts/check-references.mjs',
|
|
86
|
+
'scripts/skill-metadata.mjs',
|
|
87
|
+
'scripts/validate-skill.mjs',
|
|
88
|
+
'scripts/package-skill.mjs',
|
|
89
|
+
'scripts/package-skill.sh',
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
for (const file of requiredFiles) {
|
|
93
|
+
const absolutePath = path.join(skillRoot, file);
|
|
94
|
+
if (!existsSync(absolutePath)) fail(`Missing required file: ${rel(absolutePath)}`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const skillMdPath = path.join(skillRoot, 'SKILL.md');
|
|
98
|
+
const packageJsonPath = path.join(repoRoot, 'packages/hb-sdk/package.json');
|
|
99
|
+
const skillJsonPath = path.join(skillRoot, 'skill.json');
|
|
100
|
+
|
|
101
|
+
if (existsSync(skillJsonPath) && existsSync(packageJsonPath)) {
|
|
102
|
+
try {
|
|
103
|
+
const skillJson = JSON.parse(read(skillJsonPath));
|
|
104
|
+
const packageJson = JSON.parse(read(packageJsonPath));
|
|
105
|
+
|
|
106
|
+
for (const error of validateSkillManifest({ manifest: skillJson, sdkVersion: packageJson.version })) {
|
|
107
|
+
fail(error);
|
|
108
|
+
}
|
|
109
|
+
} catch (error) {
|
|
110
|
+
fail(`skill.json must be valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (existsSync(skillMdPath)) {
|
|
115
|
+
const skillMd = read(skillMdPath);
|
|
116
|
+
const frontmatter = parseFrontmatter(skillMd);
|
|
117
|
+
if (!frontmatter) {
|
|
118
|
+
fail('SKILL.md must start with YAML frontmatter.');
|
|
119
|
+
} else {
|
|
120
|
+
const allowedFrontmatter = new Set(['name', 'description']);
|
|
121
|
+
for (const key of frontmatter.keys()) {
|
|
122
|
+
if (!allowedFrontmatter.has(key)) fail(`SKILL.md frontmatter must only include name and description; found ${key}.`);
|
|
123
|
+
}
|
|
124
|
+
const name = frontmatter.get('name');
|
|
125
|
+
const description = frontmatter.get('description');
|
|
126
|
+
if (name !== HB_SDK_SKILL_NAME) fail('SKILL.md frontmatter name must be `hb-sdk`.');
|
|
127
|
+
if (!description) fail('SKILL.md frontmatter description is required.');
|
|
128
|
+
if (description && description.length > 1024) fail('SKILL.md description must be <= 1024 characters.');
|
|
129
|
+
if (description && !description.includes("Don't use")) warn('Description should include negative triggers for discoverability.');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const lineCount = skillMd.split('\n').length;
|
|
133
|
+
if (lineCount > 500) fail(`SKILL.md must stay under 500 lines; found ${lineCount}.`);
|
|
134
|
+
if (!skillMd.includes('references/api-root.md')) fail('SKILL.md must point agents to references/api-root.md.');
|
|
135
|
+
if (!skillMd.includes('references/api-protocol.md')) fail('SKILL.md must point agents to references/api-protocol.md.');
|
|
136
|
+
if (!skillMd.includes('references/cli.md')) fail('SKILL.md must point agents to references/cli.md.');
|
|
137
|
+
if (!skillMd.includes('references/smoke-evaluation.md')) fail('SKILL.md must point evaluators to references/smoke-evaluation.md.');
|
|
138
|
+
if (!skillMd.includes('host/runtime') && !skillMd.includes('Host/runtime')) fail('SKILL.md must gate protocol usage to host/runtime tasks.');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const nestedReferenceFiles = existsSync(path.join(skillRoot, 'references'))
|
|
142
|
+
? walk(path.join(skillRoot, 'references')).filter(file => path.dirname(path.relative(path.join(skillRoot, 'references'), file)).includes(path.sep))
|
|
143
|
+
: [];
|
|
144
|
+
for (const file of nestedReferenceFiles) fail(`References must be one level deep: ${skillRel(file)}`);
|
|
145
|
+
|
|
146
|
+
if (existsSync(path.join(skillRoot, 'README.md'))) fail('Do not create README.md inside hb-sdk skill; keep human distribution docs outside the skill folder.');
|
|
147
|
+
if (existsSync(path.join(skillRoot, 'CHANGELOG.md'))) fail('Do not create CHANGELOG.md inside hb-sdk skill.');
|
|
148
|
+
if (existsSync(path.join(skillRoot, 'INSTALLATION_GUIDE.md'))) fail('Do not create INSTALLATION_GUIDE.md inside hb-sdk skill.');
|
|
149
|
+
|
|
150
|
+
const textFiles = existsSync(skillRoot)
|
|
151
|
+
? walk(skillRoot).filter(file => /\.(md|yaml|yml|json|txt)$/.test(file))
|
|
152
|
+
: [];
|
|
153
|
+
|
|
154
|
+
const negativeMarkers = [
|
|
155
|
+
'do not',
|
|
156
|
+
"don't",
|
|
157
|
+
'does not',
|
|
158
|
+
'must not',
|
|
159
|
+
'never',
|
|
160
|
+
'no ',
|
|
161
|
+
'without',
|
|
162
|
+
'forbidden',
|
|
163
|
+
'refuse',
|
|
164
|
+
'block',
|
|
165
|
+
'fail',
|
|
166
|
+
'negative',
|
|
167
|
+
'不会',
|
|
168
|
+
'不应',
|
|
169
|
+
'不要',
|
|
170
|
+
'不能',
|
|
171
|
+
'不开放',
|
|
172
|
+
'无',
|
|
173
|
+
'禁止',
|
|
174
|
+
];
|
|
175
|
+
const positiveCredentialPattern = /\b(read|extract|forward|store|persist|depend on|use|request|expose|get|parse|send)\b.*\b(token|cookie|credentials?|phone number|login state)\b/i;
|
|
176
|
+
const unsupportedStoragePattern = /\b(removeStorage|clearStorage|getStorageInfo|getStorageV2|delete storage|clear storage)\b/i;
|
|
177
|
+
const rawProtocolPattern = /\b(raw postMessage|construct bridge|bridge envelope|nonce handling|mutate bridge|sdk\.handshake)\b/i;
|
|
178
|
+
const removedUserLoginPattern = /\b(?:hbSDK\.)?user\.login\s*\(/;
|
|
179
|
+
|
|
180
|
+
for (const file of textFiles) {
|
|
181
|
+
const relative = skillRel(file);
|
|
182
|
+
const content = read(file);
|
|
183
|
+
if (removedUserLoginPattern.test(content)) {
|
|
184
|
+
fail(`Removed API guidance found in ${relative}: use auth.login() instead of user.login().`);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (new RegExp(`${HB_SDK_PACKAGE_NAME.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\/(?!(?:protocol|vite|miniapp-publish)\\b)[A-Za-z0-9_./-]+`).test(content)) {
|
|
188
|
+
fail(
|
|
189
|
+
`Deep/internal hb-sdk import guidance found in ${relative}. Only @heybox/hb-sdk, @heybox/hb-sdk/protocol, @heybox/hb-sdk/vite, and @heybox/hb-sdk/miniapp-publish are allowed.`,
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const lines = content.split('\n');
|
|
194
|
+
lines.forEach((line, index) => {
|
|
195
|
+
const lower = line.toLowerCase();
|
|
196
|
+
const isNegative = negativeMarkers.some(marker => lower.includes(marker));
|
|
197
|
+
if (positiveCredentialPattern.test(line) && !isNegative) {
|
|
198
|
+
fail(`Unsafe positive credential guidance in ${relative}:${index + 1}: ${line.trim()}`);
|
|
199
|
+
}
|
|
200
|
+
if (unsupportedStoragePattern.test(line) && !isNegative) {
|
|
201
|
+
fail(`Unsupported storage capability guidance in ${relative}:${index + 1}: ${line.trim()}`);
|
|
202
|
+
}
|
|
203
|
+
if (rawProtocolPattern.test(line) && !isNegative && !/host\/runtime|runtime|protocol|parent-container|parent container|父容器/i.test(line)) {
|
|
204
|
+
fail(`Raw protocol guidance without host/runtime context in ${relative}:${index + 1}: ${line.trim()}`);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const recipesPath = path.join(skillRoot, 'references/recipes.md');
|
|
210
|
+
if (existsSync(recipesPath)) {
|
|
211
|
+
const recipes = read(recipesPath);
|
|
212
|
+
if (/api-protocol\.md/.test(recipes) && !/host\/runtime-only|host\/runtime|runtime only/i.test(recipes)) {
|
|
213
|
+
fail('references/recipes.md references api-protocol.md without a nearby host/runtime-only warning.');
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const protocolPath = path.join(skillRoot, 'references/api-protocol.md');
|
|
218
|
+
if (existsSync(protocolPath)) {
|
|
219
|
+
const protocol = read(protocolPath);
|
|
220
|
+
if (!/Host\/runtime-only warning/i.test(protocol)) fail('references/api-protocol.md must include a Host/runtime-only warning section.');
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const zipPath = path.join(packageRoot, 'hb-sdk.zip');
|
|
224
|
+
if (existsSync(zipPath)) {
|
|
225
|
+
const size = statSync(zipPath).size;
|
|
226
|
+
if (size <= 0) fail('packages/hb-sdk/hb-sdk.zip exists but is empty.');
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
for (const warning of warnings) console.error(`warning: ${warning}`);
|
|
230
|
+
if (errors.length > 0) {
|
|
231
|
+
for (const error of errors) console.error(`error: ${error}`);
|
|
232
|
+
process.exit(1);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
console.log(JSON.stringify({ ok: true, skillRoot: rel(skillRoot), checkedFiles: textFiles.length, warnings: warnings.length }));
|
package/skill/skill.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hb-sdk",
|
|
3
|
+
"skillVersion": "0.2.0-alpha.2+skill.57e0cec11058",
|
|
4
|
+
"sdk": {
|
|
5
|
+
"package": "@heybox/hb-sdk",
|
|
6
|
+
"version": "0.2.0-alpha.2",
|
|
7
|
+
"compatibility": "0.2.0-alpha.2"
|
|
8
|
+
},
|
|
9
|
+
"source": "https://open.xiaoheihe.cn/agent-skills/hb-sdk",
|
|
10
|
+
"integrity": "sha256-57e0cec1105894712e82600045659d9f08fedc9e0e4c3159445168eaec6675e7"
|
|
11
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -5,12 +5,14 @@ export { ready, on, off, auth, user, share, viewport, storage, network } from '.
|
|
|
5
5
|
export { MINI_PROGRAM_BRIDGE_NONCE_PARAM, MINI_PROGRAM_MESSAGE_NAMESPACE, MINI_PROGRAM_MESSAGE_VERSION, SDK_HANDSHAKE_METHOD, } from './protocol/constants';
|
|
6
6
|
export { isMiniProgramBridgeMessage } from './protocol/guards';
|
|
7
7
|
export type { MiniProgramBridgeError, MiniProgramBridgeMessage, MiniProgramBridgeMessageType, MiniProgramEventHandler, MiniProgramEventName, MiniProgramEventPayloadMap, } from './protocol/types';
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
8
|
+
export { AUTH_LOGIN_METHOD, NETWORK_REQUEST_METHOD, SHARE_SCREENSHOT_METHOD, SHARE_SHOW_SHARE_MENU_METHOD, STORAGE_GET_STORAGE_METHOD, STORAGE_SET_STORAGE_METHOD, USER_GET_INFO_METHOD, VIEWPORT_GET_WINDOW_INFO_METHOD, } from './protocol/capabilities';
|
|
9
|
+
export type { MiniProgramAuthMethod, MiniProgramBridgeMethod, MiniProgramCapabilityDefinition, MiniProgramCapabilityModule, MiniProgramCapabilityPayload, MiniProgramCapabilityPayloadMap, MiniProgramCapabilityResult, MiniProgramCapabilityResultMap, MiniProgramCapabilityRisk, MiniProgramNetworkMethod, MiniProgramShareMethod, MiniProgramStorageMethod, MiniProgramUserMethod, MiniProgramViewportMethod, } from './protocol/capabilities';
|
|
10
|
+
export type { LoginPayload, LoginResult, MiniProgramAuthModule } from './modules/auth';
|
|
11
|
+
export type { GetUserInfoPayload, GetUserInfoResult, MiniProgramUserInfo, MiniProgramUserInfoResult, MiniProgramUserModule, } from './modules/user';
|
|
12
|
+
export type { MiniProgramScreenshotOptions, MiniProgramScreenshotRect, MiniProgramShareChannel, MiniProgramShareModule, MiniProgramShowShareMenuOptions, ScreenshotPayload, ScreenshotResult, ShowShareMenuPayload, ShowShareMenuResult, } from './modules/share';
|
|
13
|
+
export type { GetWindowInfoPayload, GetWindowInfoResult, MiniProgramSafeArea, MiniProgramViewportModule, MiniProgramWindowInfoResult, } from './modules/viewport';
|
|
14
|
+
export type { GetStoragePayload, GetStorageResult, MiniProgramStorageModule, SetStoragePayload, } from './modules/storage';
|
|
15
|
+
export type { MiniProgramNetworkHeaders, MiniProgramNetworkModule, MiniProgramNetworkParams, MiniProgramNetworkRequestConfig, MiniProgramNetworkRequestMethod, MiniProgramNetworkResponse, MiniProgramNetworkValidateStatus, NetworkRequestPayload, NetworkResponsePayload, } from './modules/network';
|
|
14
16
|
import { off, on, ready } from './core/singleton';
|
|
15
17
|
declare const hbSDK: {
|
|
16
18
|
ready: typeof ready;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const MINIAPP_UPLOAD_SCOPE = "activity";
|
|
2
|
+
export declare const ACTIVITY_UPLOAD_KEY_MAX_LENGTH = 64;
|
|
3
|
+
export declare const PUBLISH_USER_MINIPROGRAM_API_PATH = "/mall/developer/user_miniprogram/publish";
|
|
4
|
+
export declare function isValidVersion(version: string): boolean;
|
|
5
|
+
export declare function normalizeRelativePath(relativePath: string): string;
|
|
6
|
+
export declare function relativePathContainsNodeModulesSegment(relativePath: string): boolean;
|
|
7
|
+
export declare function getMiniProgramUploadAlias(miniProgramId: string): string;
|
|
8
|
+
export interface MiniappUploadKeyInput {
|
|
9
|
+
miniProgramId: string;
|
|
10
|
+
version: string;
|
|
11
|
+
relativePath: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function getMiniappUploadKey(input: MiniappUploadKeyInput): string;
|
|
14
|
+
export interface UploadPathItem {
|
|
15
|
+
relativePath: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ValidateUploadPathsOptions {
|
|
18
|
+
miniProgramId: string;
|
|
19
|
+
version: string;
|
|
20
|
+
maxLength?: number;
|
|
21
|
+
}
|
|
22
|
+
export declare function validateUploadPaths(items: UploadPathItem[], options: ValidateUploadPathsOptions): string | undefined;
|
|
23
|
+
export declare function shouldUploadDistFile(relativePath: string): boolean;
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import type { MiniProgramRequester } from '../../core/client';
|
|
2
2
|
import type { MiniProgramUserInfoResult } from '../user';
|
|
3
|
-
|
|
4
|
-
* 登录授权能力方法名。
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* 供 SDK 与父容器 runtime 共享同一 bridge method 标识。
|
|
8
|
-
*/
|
|
9
|
-
export declare const AUTH_LOGIN_METHOD: "auth.login";
|
|
3
|
+
export { AUTH_LOGIN_METHOD } from '../../protocol/capabilities';
|
|
10
4
|
/** `auth.login` 不需要入参。 */
|
|
11
5
|
export type LoginPayload = void;
|
|
12
6
|
/** `auth.login` 返回登录流程结束后的最新用户登录态与公开基础资料。 */
|
|
13
7
|
export type LoginResult = MiniProgramUserInfoResult;
|
|
14
|
-
|
|
15
|
-
export type MiniProgramAuthMethod = typeof AUTH_LOGIN_METHOD;
|
|
8
|
+
export type { MiniProgramAuthMethod } from '../../protocol/capabilities';
|
|
16
9
|
/** 外部小程序可调用的授权模块。 */
|
|
17
10
|
export interface MiniProgramAuthModule {
|
|
18
11
|
/**
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import type { MiniProgramRequester } from '../../core/client';
|
|
2
|
-
|
|
3
|
-
* 发起网络请求能力方法名。
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* 供 SDK 与父容器 runtime 共享同一 bridge method 标识。
|
|
7
|
-
*/
|
|
8
|
-
export declare const NETWORK_REQUEST_METHOD: "network.request";
|
|
2
|
+
export { NETWORK_REQUEST_METHOD } from '../../protocol/capabilities';
|
|
9
3
|
/** `network.request` 请求头。 */
|
|
10
4
|
export type MiniProgramNetworkHeaders = Record<string, string>;
|
|
11
5
|
/** `network.request` 查询参数。 */
|
|
12
6
|
export type MiniProgramNetworkParams = Record<string, unknown>;
|
|
7
|
+
/** `network.request` 支持的 HTTP 方法。 */
|
|
8
|
+
export type MiniProgramNetworkRequestMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
13
9
|
/**
|
|
14
10
|
* SDK 侧可配置的状态校验函数。
|
|
15
11
|
*
|
|
@@ -31,7 +27,7 @@ export interface MiniProgramNetworkRequestConfig {
|
|
|
31
27
|
/** 请求地址。 */
|
|
32
28
|
url: string;
|
|
33
29
|
/** HTTP 方法,默认 `GET`。 */
|
|
34
|
-
method?:
|
|
30
|
+
method?: MiniProgramNetworkRequestMethod;
|
|
35
31
|
/** 查询参数,会被编码到请求 URL。 */
|
|
36
32
|
params?: MiniProgramNetworkParams;
|
|
37
33
|
/** 请求体。 */
|
|
@@ -53,7 +49,7 @@ export interface MiniProgramNetworkRequestConfig {
|
|
|
53
49
|
*/
|
|
54
50
|
export interface NetworkRequestPayload {
|
|
55
51
|
url: string;
|
|
56
|
-
method?:
|
|
52
|
+
method?: MiniProgramNetworkRequestMethod;
|
|
57
53
|
params?: MiniProgramNetworkParams;
|
|
58
54
|
data?: unknown;
|
|
59
55
|
headers?: MiniProgramNetworkHeaders;
|
|
@@ -80,8 +76,7 @@ export interface MiniProgramNetworkResponse<T = unknown> extends NetworkResponse
|
|
|
80
76
|
/** 发起请求时的 SDK 公共配置快照。 */
|
|
81
77
|
config: MiniProgramNetworkRequestConfig;
|
|
82
78
|
}
|
|
83
|
-
|
|
84
|
-
export type MiniProgramNetworkMethod = typeof NETWORK_REQUEST_METHOD;
|
|
79
|
+
export type { MiniProgramNetworkMethod } from '../../protocol/capabilities';
|
|
85
80
|
/** 外部小程序可调用的网络模块。 */
|
|
86
81
|
export interface MiniProgramNetworkModule {
|
|
87
82
|
/**
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import type { MiniProgramRequester } from '../../core/client';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { type ScreenshotResult } from './screenshot';
|
|
3
|
+
import { type ShowShareMenuPayload, type ShowShareMenuResult } from './show-share-menu';
|
|
4
4
|
import type { MiniProgramScreenshotOptions } from './types';
|
|
5
5
|
export * from './screenshot';
|
|
6
6
|
export * from './show-share-menu';
|
|
7
7
|
export * from './types';
|
|
8
|
-
|
|
9
|
-
* 分享模块开放的方法名。
|
|
10
|
-
*
|
|
11
|
-
* @remarks
|
|
12
|
-
* 该联合类型用于约束分享模块向父容器发起的 bridge method 集合。
|
|
13
|
-
*/
|
|
14
|
-
export type MiniProgramShareMethod = typeof SHARE_SHOW_SHARE_MENU_METHOD | typeof SHARE_SCREENSHOT_METHOD;
|
|
8
|
+
export type { MiniProgramShareMethod } from '../../protocol/capabilities';
|
|
15
9
|
/** 外部小程序可调用的分享模块。 */
|
|
16
10
|
export interface MiniProgramShareModule {
|
|
17
11
|
/** 展示基础分享面板。 */
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import type { MiniProgramRequester } from '../../core/client';
|
|
2
2
|
import type { MiniProgramScreenshotOptions } from './types';
|
|
3
|
-
|
|
4
|
-
* 截图分享能力方法名。
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* 供 SDK 与父容器 runtime 共享同一 bridge method 标识。
|
|
8
|
-
*/
|
|
9
|
-
export declare const SHARE_SCREENSHOT_METHOD: "share.screenshot";
|
|
3
|
+
export { SHARE_SCREENSHOT_METHOD } from '../../protocol/capabilities';
|
|
10
4
|
/** `share.screenshot` 入参。 */
|
|
11
5
|
export type ScreenshotPayload = MiniProgramScreenshotOptions | undefined;
|
|
12
6
|
/** `share.screenshot` 返回值由客户端协议决定。 */
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import type { MiniProgramRequester } from '../../core/client';
|
|
2
2
|
import type { MiniProgramShowShareMenuOptions } from './types';
|
|
3
|
-
|
|
4
|
-
* 展示分享面板能力方法名。
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* 供 SDK 与父容器 runtime 共享同一 bridge method 标识。
|
|
8
|
-
*/
|
|
9
|
-
export declare const SHARE_SHOW_SHARE_MENU_METHOD: "share.showShareMenu";
|
|
3
|
+
export { SHARE_SHOW_SHARE_MENU_METHOD } from '../../protocol/capabilities';
|
|
10
4
|
/** `share.showShareMenu` 入参。 */
|
|
11
5
|
export type ShowShareMenuPayload = MiniProgramShowShareMenuOptions;
|
|
12
6
|
/** `share.showShareMenu` 返回值由客户端协议决定。 */
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
import type { MiniProgramRequester } from '../../core/client';
|
|
2
|
-
|
|
3
|
-
* 读取小程序隔离 storage 能力方法名。
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* 供 SDK 与父容器 runtime 共享同一 bridge method 标识。
|
|
7
|
-
*/
|
|
8
|
-
export declare const STORAGE_GET_STORAGE_METHOD: "storage.getStorage";
|
|
9
|
-
/**
|
|
10
|
-
* 写入小程序隔离 storage 能力方法名。
|
|
11
|
-
*
|
|
12
|
-
* @remarks
|
|
13
|
-
* 供 SDK 与父容器 runtime 共享同一 bridge method 标识。
|
|
14
|
-
*/
|
|
15
|
-
export declare const STORAGE_SET_STORAGE_METHOD: "storage.setStorage";
|
|
2
|
+
export { STORAGE_GET_STORAGE_METHOD, STORAGE_SET_STORAGE_METHOD } from '../../protocol/capabilities';
|
|
16
3
|
/** `storage.getStorage` 入参。 */
|
|
17
4
|
export interface GetStoragePayload {
|
|
18
5
|
/** storage key。 */
|
|
@@ -34,8 +21,7 @@ export interface SetStoragePayload {
|
|
|
34
21
|
/** 需要写入的数据。 */
|
|
35
22
|
data: unknown;
|
|
36
23
|
}
|
|
37
|
-
|
|
38
|
-
export type MiniProgramStorageMethod = typeof STORAGE_GET_STORAGE_METHOD | typeof STORAGE_SET_STORAGE_METHOD;
|
|
24
|
+
export type { MiniProgramStorageMethod } from '../../protocol/capabilities';
|
|
39
25
|
/** 外部小程序可调用的 storage 模块。 */
|
|
40
26
|
export interface MiniProgramStorageModule {
|
|
41
27
|
/** 获取小程序隔离 storage。 */
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import type { MiniProgramRequester } from '../../core/client';
|
|
2
2
|
import type { MiniProgramUserInfoResult } from './types';
|
|
3
|
-
|
|
4
|
-
* 用户信息能力方法名。
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* 供 SDK 与父容器 runtime 共享同一 bridge method 标识。
|
|
8
|
-
*/
|
|
9
|
-
export declare const USER_GET_INFO_METHOD: "user.getInfo";
|
|
3
|
+
export { USER_GET_INFO_METHOD } from '../../protocol/capabilities';
|
|
10
4
|
/**
|
|
11
5
|
* `user.getInfo` 不需要入参。
|
|
12
6
|
*/
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import type { MiniProgramRequester } from '../../core/client';
|
|
2
|
-
import {
|
|
2
|
+
import { type GetUserInfoResult } from './get-info';
|
|
3
3
|
export * from './get-info';
|
|
4
4
|
export * from './types';
|
|
5
|
-
|
|
6
|
-
* 用户模块开放的方法名。
|
|
7
|
-
*
|
|
8
|
-
* @remarks
|
|
9
|
-
* 该联合类型用于约束用户模块向父容器发起的 bridge method 集合。
|
|
10
|
-
*/
|
|
11
|
-
export type MiniProgramUserMethod = typeof USER_GET_INFO_METHOD;
|
|
5
|
+
export type { MiniProgramUserMethod } from '../../protocol/capabilities';
|
|
12
6
|
/** 外部小程序可调用的用户模块。 */
|
|
13
7
|
export interface MiniProgramUserModule {
|
|
14
8
|
/**
|
|
@@ -43,19 +43,12 @@ export interface MiniProgramWindowInfoResult {
|
|
|
43
43
|
/** 窗口上边缘的 y 值。 */
|
|
44
44
|
screenTop: number;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
* 视口窗口信息能力方法名。
|
|
48
|
-
*
|
|
49
|
-
* @remarks
|
|
50
|
-
* 供 SDK 与父容器 runtime 共享同一 bridge method 标识。
|
|
51
|
-
*/
|
|
52
|
-
export declare const VIEWPORT_GET_WINDOW_INFO_METHOD: "viewport.getWindowInfo";
|
|
46
|
+
export { VIEWPORT_GET_WINDOW_INFO_METHOD } from '../../protocol/capabilities';
|
|
53
47
|
/** `viewport.getWindowInfo` 不需要入参。 */
|
|
54
48
|
export type GetWindowInfoPayload = void;
|
|
55
49
|
/** `viewport.getWindowInfo` 返回当前小程序可用窗口信息。 */
|
|
56
50
|
export type GetWindowInfoResult = MiniProgramWindowInfoResult;
|
|
57
|
-
|
|
58
|
-
export type MiniProgramViewportMethod = typeof VIEWPORT_GET_WINDOW_INFO_METHOD;
|
|
51
|
+
export type { MiniProgramViewportMethod } from '../../protocol/capabilities';
|
|
59
52
|
/** 外部小程序可调用的 Viewport 模块。 */
|
|
60
53
|
export interface MiniProgramViewportModule {
|
|
61
54
|
/** 获取当前小程序窗口信息。 */
|