@heybox/hb-sdk 0.7.5-alpha.0 → 0.8.0-alpha
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 +51 -0
- package/README.md +14 -14
- package/dist/cli-chunks/{build-V1YBdpzY.cjs → build-DJWFSM1B.cjs} +6 -5
- package/dist/cli-chunks/{context-Ba1Je-wT.cjs → context-DV2UK1Nz.cjs} +2 -2
- package/dist/cli-chunks/{create-CKGjqo9E.cjs → create-2HfoB48V.cjs} +1 -1
- package/dist/cli-chunks/{dev-XopYKLYZ.cjs → dev-Dgt2zS9k.cjs} +8 -8
- package/dist/cli-chunks/{doctor-BHbrYQqT.cjs → doctor-C95gIao_.cjs} +1 -1
- package/dist/cli-chunks/{index-DKWfX6Ut.cjs → index-BjoSXl8C.cjs} +2 -2
- package/dist/cli-chunks/{index-C9mpajVG.cjs → index-D62ANeBv.cjs} +14 -14
- package/dist/cli-chunks/{index.esm-SXAQ3WVR.cjs → index.esm-CigcxJ2B.cjs} +6 -6
- package/dist/cli-chunks/{login-BVWicWqe.cjs → login-Cumknwdx.cjs} +2 -2
- package/dist/cli-chunks/{project-vite-CBb38HJ3.cjs → project-vite-CcE-HMmd.cjs} +1 -1
- package/dist/cli-chunks/{remote-BG1u0NKT.cjs → remote-DDdP3xcE.cjs} +10 -8
- package/dist/cli-chunks/{runtime-gate-CtV7rWyX.cjs → runtime-gate-DFjw66kF.cjs} +20 -1
- package/dist/cli-chunks/{runtime-permission-env-D-8_jPG3.cjs → runtime-permission-env-CjsCe5bp.cjs} +13 -13
- package/dist/cli-chunks/{session-CJS_SEp9.cjs → session-BDi_AZSv.cjs} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/devtools/browser-dev-host/main.js +173 -68
- package/dist/index.cjs.js +113 -63
- package/dist/index.esm.js +113 -63
- package/dist/miniapp-publish.cjs.js +13 -13
- package/dist/miniapp-publish.esm.js +13 -13
- package/dist/templates/vue3-vite-ts/README.md.ejs +2 -0
- package/dist/templates/vue3-vite-ts/vite.config.ts +1 -1
- package/dist/vite.cjs.js +31 -4
- package/dist/vite.esm.js +31 -5
- package/package.json +10 -7
- package/skill/references/api-protocol.md +14 -2
- package/skill/references/api-root.md +42 -21
- package/skill/references/examples.md +1 -1
- package/skill/references/safety-boundaries.md +1 -1
- package/skill/scripts/sync-references.mjs +3 -1
- package/skill/skill.json +4 -4
- package/types/core/errors.d.ts +5 -5
- package/types/core/sdk.d.ts +5 -5
- package/types/core/singleton.d.ts +56 -6
- package/types/miniapp-manifest/schema.d.ts +5 -0
- package/types/miniapp-publish/index.d.ts +8 -8
- package/types/modules/auth/index.d.ts +15 -1
- package/types/modules/cloud/index.d.ts +75 -5
- package/types/modules/device/index.d.ts +31 -3
- package/types/modules/navigation/index.d.ts +46 -4
- package/types/modules/network/index.d.ts +22 -11
- package/types/modules/share/copy-link.d.ts +3 -3
- package/types/modules/share/index.d.ts +61 -5
- package/types/modules/share/screenshot.d.ts +3 -3
- package/types/modules/share/show-share-menu.d.ts +3 -3
- package/types/modules/storage/index.d.ts +38 -10
- package/types/modules/ui/index.d.ts +46 -4
- package/types/modules/user/get-info.d.ts +1 -1
- package/types/modules/user/index.d.ts +46 -4
- package/types/modules/user/steam-game-list.d.ts +2 -2
- package/types/modules/viewport/index.d.ts +36 -8
- package/types/vite/index.d.ts +15 -7
package/dist/vite.cjs.js
CHANGED
|
@@ -8,7 +8,7 @@ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentS
|
|
|
8
8
|
/** 构建时替换为当前发布包的实际版本。 */
|
|
9
9
|
const HB_SDK_VERSION = typeof undefined === 'string'
|
|
10
10
|
? undefined
|
|
11
|
-
: '0.
|
|
11
|
+
: '0.8.0-alpha';
|
|
12
12
|
|
|
13
13
|
var re = {exports: {}};
|
|
14
14
|
|
|
@@ -2795,6 +2795,7 @@ function requireSemver () {
|
|
|
2795
2795
|
|
|
2796
2796
|
var semverExports = requireSemver();
|
|
2797
2797
|
|
|
2798
|
+
const MINIAPP_PLATFORM_VALUES = ['android', 'ios', 'ohos', 'windows', 'macos', 'linux'];
|
|
2798
2799
|
function validateMiniappPackageVersionForBuild(version) {
|
|
2799
2800
|
return validateMiniappManifestVersion(version, 'package.json.version');
|
|
2800
2801
|
}
|
|
@@ -2806,7 +2807,25 @@ function validateMiniappManifestVersion(version, sourceLabel = 'manifest.version
|
|
|
2806
2807
|
return String(version).trim();
|
|
2807
2808
|
}
|
|
2808
2809
|
function renderMiniappManifest(manifest) {
|
|
2809
|
-
|
|
2810
|
+
const platforms = validateMiniappPlatforms(manifest.platforms, 'manifest.platforms');
|
|
2811
|
+
return `${JSON.stringify({ version: manifest.version, sdkVersion: manifest.sdkVersion, platforms }, null, 2)}\n`;
|
|
2812
|
+
}
|
|
2813
|
+
function validateMiniappPlatforms(platforms, sourceLabel = 'platforms') {
|
|
2814
|
+
if (!Array.isArray(platforms) || platforms.length === 0) {
|
|
2815
|
+
throw new Error(`${sourceLabel} 必须是非空平台数组`);
|
|
2816
|
+
}
|
|
2817
|
+
const allowedPlatforms = new Set(MINIAPP_PLATFORM_VALUES);
|
|
2818
|
+
const seen = new Set();
|
|
2819
|
+
for (const platform of platforms) {
|
|
2820
|
+
if (typeof platform !== 'string' || !allowedPlatforms.has(platform)) {
|
|
2821
|
+
throw new Error(`${sourceLabel} 包含不支持的平台:${String(platform)}`);
|
|
2822
|
+
}
|
|
2823
|
+
if (seen.has(platform)) {
|
|
2824
|
+
throw new Error(`${sourceLabel} 包含重复平台:${platform}`);
|
|
2825
|
+
}
|
|
2826
|
+
seen.add(platform);
|
|
2827
|
+
}
|
|
2828
|
+
return Object.freeze(MINIAPP_PLATFORM_VALUES.filter((platform) => seen.has(platform)));
|
|
2810
2829
|
}
|
|
2811
2830
|
function getMiniappManifestVersionError(version) {
|
|
2812
2831
|
if (typeof version !== 'string' || version.trim() === '') {
|
|
@@ -11629,7 +11648,8 @@ function shouldSkipMiniappPlatformCspFromEnv(env = process.env) {
|
|
|
11629
11648
|
|
|
11630
11649
|
const sdkVersionPlaceholder = ['__HB_SDK', 'VERSION__'].join('_');
|
|
11631
11650
|
const sdkVersionBuildConstant = ['__HB_SDK_BUILD', 'VERSION__'].join('_');
|
|
11632
|
-
function miniappManifest() {
|
|
11651
|
+
function miniappManifest(options) {
|
|
11652
|
+
const platforms = validateMiniappPlatforms(options?.platforms, 'miniappManifest().platforms');
|
|
11633
11653
|
const skipPlatformCsp = shouldSkipMiniappPlatformCspFromEnv();
|
|
11634
11654
|
let root = process.cwd();
|
|
11635
11655
|
let outDir = 'dist';
|
|
@@ -11649,6 +11669,12 @@ function miniappManifest() {
|
|
|
11649
11669
|
};
|
|
11650
11670
|
},
|
|
11651
11671
|
configResolved(resolved) {
|
|
11672
|
+
if (resolved.plugins) {
|
|
11673
|
+
const manifestPluginCount = resolved.plugins.filter((plugin) => plugin.name === 'heybox-miniapp-manifest').length;
|
|
11674
|
+
if (manifestPluginCount !== 1) {
|
|
11675
|
+
throw new Error(`Vite 配置必须且只能包含一个 miniappManifest() 插件,当前数量:${manifestPluginCount}`);
|
|
11676
|
+
}
|
|
11677
|
+
}
|
|
11652
11678
|
root = resolved.root;
|
|
11653
11679
|
outDir = resolved.build.outDir;
|
|
11654
11680
|
command = resolved.command;
|
|
@@ -11688,7 +11714,7 @@ function miniappManifest() {
|
|
|
11688
11714
|
node_fs.writeFileSync(indexHtmlPath, enforceMiniappHtmlPolicy(node_fs.readFileSync(indexHtmlPath, 'utf8'), { skipPlatformCsp }));
|
|
11689
11715
|
const manifestPath = path.join(outputRoot, 'manifest.json');
|
|
11690
11716
|
node_fs.mkdirSync(path.dirname(manifestPath), { recursive: true });
|
|
11691
|
-
node_fs.writeFileSync(manifestPath, renderMiniappManifest({ version, sdkVersion }));
|
|
11717
|
+
node_fs.writeFileSync(manifestPath, renderMiniappManifest({ version, sdkVersion, platforms }));
|
|
11692
11718
|
},
|
|
11693
11719
|
};
|
|
11694
11720
|
}
|
|
@@ -11734,4 +11760,5 @@ function resolveHmrWebSocketUrl(resolved) {
|
|
|
11734
11760
|
return `${protocol}://${host}${port ? `:${port}` : ''}`;
|
|
11735
11761
|
}
|
|
11736
11762
|
|
|
11763
|
+
exports.MINIAPP_PLATFORM_VALUES = MINIAPP_PLATFORM_VALUES;
|
|
11737
11764
|
exports.miniappManifest = miniappManifest;
|
package/dist/vite.esm.js
CHANGED
|
@@ -5,7 +5,7 @@ import { AsyncLocalStorage } from 'node:async_hooks';
|
|
|
5
5
|
/** 构建时替换为当前发布包的实际版本。 */
|
|
6
6
|
const HB_SDK_VERSION = typeof undefined === 'string'
|
|
7
7
|
? undefined
|
|
8
|
-
: '0.
|
|
8
|
+
: '0.8.0-alpha';
|
|
9
9
|
|
|
10
10
|
var re = {exports: {}};
|
|
11
11
|
|
|
@@ -2792,6 +2792,7 @@ function requireSemver () {
|
|
|
2792
2792
|
|
|
2793
2793
|
var semverExports = requireSemver();
|
|
2794
2794
|
|
|
2795
|
+
const MINIAPP_PLATFORM_VALUES = ['android', 'ios', 'ohos', 'windows', 'macos', 'linux'];
|
|
2795
2796
|
function validateMiniappPackageVersionForBuild(version) {
|
|
2796
2797
|
return validateMiniappManifestVersion(version, 'package.json.version');
|
|
2797
2798
|
}
|
|
@@ -2803,7 +2804,25 @@ function validateMiniappManifestVersion(version, sourceLabel = 'manifest.version
|
|
|
2803
2804
|
return String(version).trim();
|
|
2804
2805
|
}
|
|
2805
2806
|
function renderMiniappManifest(manifest) {
|
|
2806
|
-
|
|
2807
|
+
const platforms = validateMiniappPlatforms(manifest.platforms, 'manifest.platforms');
|
|
2808
|
+
return `${JSON.stringify({ version: manifest.version, sdkVersion: manifest.sdkVersion, platforms }, null, 2)}\n`;
|
|
2809
|
+
}
|
|
2810
|
+
function validateMiniappPlatforms(platforms, sourceLabel = 'platforms') {
|
|
2811
|
+
if (!Array.isArray(platforms) || platforms.length === 0) {
|
|
2812
|
+
throw new Error(`${sourceLabel} 必须是非空平台数组`);
|
|
2813
|
+
}
|
|
2814
|
+
const allowedPlatforms = new Set(MINIAPP_PLATFORM_VALUES);
|
|
2815
|
+
const seen = new Set();
|
|
2816
|
+
for (const platform of platforms) {
|
|
2817
|
+
if (typeof platform !== 'string' || !allowedPlatforms.has(platform)) {
|
|
2818
|
+
throw new Error(`${sourceLabel} 包含不支持的平台:${String(platform)}`);
|
|
2819
|
+
}
|
|
2820
|
+
if (seen.has(platform)) {
|
|
2821
|
+
throw new Error(`${sourceLabel} 包含重复平台:${platform}`);
|
|
2822
|
+
}
|
|
2823
|
+
seen.add(platform);
|
|
2824
|
+
}
|
|
2825
|
+
return Object.freeze(MINIAPP_PLATFORM_VALUES.filter((platform) => seen.has(platform)));
|
|
2807
2826
|
}
|
|
2808
2827
|
function getMiniappManifestVersionError(version) {
|
|
2809
2828
|
if (typeof version !== 'string' || version.trim() === '') {
|
|
@@ -11626,7 +11645,8 @@ function shouldSkipMiniappPlatformCspFromEnv(env = process.env) {
|
|
|
11626
11645
|
|
|
11627
11646
|
const sdkVersionPlaceholder = ['__HB_SDK', 'VERSION__'].join('_');
|
|
11628
11647
|
const sdkVersionBuildConstant = ['__HB_SDK_BUILD', 'VERSION__'].join('_');
|
|
11629
|
-
function miniappManifest() {
|
|
11648
|
+
function miniappManifest(options) {
|
|
11649
|
+
const platforms = validateMiniappPlatforms(options?.platforms, 'miniappManifest().platforms');
|
|
11630
11650
|
const skipPlatformCsp = shouldSkipMiniappPlatformCspFromEnv();
|
|
11631
11651
|
let root = process.cwd();
|
|
11632
11652
|
let outDir = 'dist';
|
|
@@ -11646,6 +11666,12 @@ function miniappManifest() {
|
|
|
11646
11666
|
};
|
|
11647
11667
|
},
|
|
11648
11668
|
configResolved(resolved) {
|
|
11669
|
+
if (resolved.plugins) {
|
|
11670
|
+
const manifestPluginCount = resolved.plugins.filter((plugin) => plugin.name === 'heybox-miniapp-manifest').length;
|
|
11671
|
+
if (manifestPluginCount !== 1) {
|
|
11672
|
+
throw new Error(`Vite 配置必须且只能包含一个 miniappManifest() 插件,当前数量:${manifestPluginCount}`);
|
|
11673
|
+
}
|
|
11674
|
+
}
|
|
11649
11675
|
root = resolved.root;
|
|
11650
11676
|
outDir = resolved.build.outDir;
|
|
11651
11677
|
command = resolved.command;
|
|
@@ -11685,7 +11711,7 @@ function miniappManifest() {
|
|
|
11685
11711
|
writeFileSync(indexHtmlPath, enforceMiniappHtmlPolicy(readFileSync(indexHtmlPath, 'utf8'), { skipPlatformCsp }));
|
|
11686
11712
|
const manifestPath = path.join(outputRoot, 'manifest.json');
|
|
11687
11713
|
mkdirSync(path.dirname(manifestPath), { recursive: true });
|
|
11688
|
-
writeFileSync(manifestPath, renderMiniappManifest({ version, sdkVersion }));
|
|
11714
|
+
writeFileSync(manifestPath, renderMiniappManifest({ version, sdkVersion, platforms }));
|
|
11689
11715
|
},
|
|
11690
11716
|
};
|
|
11691
11717
|
}
|
|
@@ -11731,4 +11757,4 @@ function resolveHmrWebSocketUrl(resolved) {
|
|
|
11731
11757
|
return `${protocol}://${host}${port ? `:${port}` : ''}`;
|
|
11732
11758
|
}
|
|
11733
11759
|
|
|
11734
|
-
export { miniappManifest };
|
|
11760
|
+
export { MINIAPP_PLATFORM_VALUES, miniappManifest };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heybox/hb-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-alpha",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"./src/index.ts",
|
|
6
6
|
"./src/core/singleton.ts",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"parse5": "^7.3.0",
|
|
58
58
|
"undici": "^7.28.0",
|
|
59
59
|
"ws": "^8.18.0",
|
|
60
|
-
"@heybox/hb-sdk-protocol": "0.
|
|
60
|
+
"@heybox/hb-sdk-protocol": "0.8.0-alpha"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"vite": ">=5"
|
|
@@ -100,11 +100,11 @@
|
|
|
100
100
|
"vue": "^2.7.16",
|
|
101
101
|
"vite": "^8.0.12",
|
|
102
102
|
"vitest": "^3.2.4",
|
|
103
|
-
"@heybox/hb-api": "~1.25.
|
|
103
|
+
"@heybox/hb-api": "~1.25.23",
|
|
104
|
+
"@heybox/hb-sdk-runtime": "~0.8.0-alpha",
|
|
104
105
|
"@heybox/runtime": "~0.2.0",
|
|
105
|
-
"@heybox/runtime-
|
|
106
|
-
"@heybox/
|
|
107
|
-
"@heybox/runtime-policy": "~0.2.0"
|
|
106
|
+
"@heybox/runtime-policy": "~0.2.0",
|
|
107
|
+
"@heybox/runtime-transport-fetch": "~0.2.0"
|
|
108
108
|
},
|
|
109
109
|
"publishConfig": {
|
|
110
110
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -149,6 +149,8 @@
|
|
|
149
149
|
"build:types": "tsc -p tsconfig.dts.json",
|
|
150
150
|
"check:boundary": "node scripts/check-boundary.cjs",
|
|
151
151
|
"check:docs-sync": "pnpm -w exec hbexec hb-sdk check",
|
|
152
|
+
"check:compatibility-evidence": "node scripts/validate-compatibility-evidence.mjs",
|
|
153
|
+
"check:api-semver": "node ../../ops/jobs/hb-sdk-docs-contract/semantic-diff.cjs",
|
|
152
154
|
"clean": "rimraf ./dist && rimraf ./types",
|
|
153
155
|
"test:unit": "NODE_OPTIONS='--conditions=heybox' vitest run",
|
|
154
156
|
"test:types:characterization": "tsc -p tsconfig.characterization.json --noEmit --pretty false",
|
|
@@ -160,7 +162,8 @@
|
|
|
160
162
|
"test:watch": "NODE_OPTIONS='--conditions=heybox' vitest",
|
|
161
163
|
"changelog:draft": "node scripts/changelog-draft.cjs",
|
|
162
164
|
"check:changelog": "node scripts/check-changelog.cjs",
|
|
163
|
-
"test:release": "node --test scripts/release-family.test.cjs ../../ops/jobs/publish-changed-packages/publish.test.cjs",
|
|
165
|
+
"test:release": "node --test scripts/release-family.test.cjs ../../ops/jobs/publish-changed-packages/publish.test.cjs ../../ops/jobs/release-hb-sdk/docs-release-contract.test.cjs",
|
|
166
|
+
"test:compatibility-evidence": "node --test scripts/validate-compatibility-evidence.test.mjs",
|
|
164
167
|
"release:prepare": "node scripts/release-prepare.cjs",
|
|
165
168
|
"release:tag": "node scripts/release-tag.cjs",
|
|
166
169
|
"release:family:dry-run": "node ../../ops/jobs/publish-changed-packages/publish.cjs --dry-run",
|
|
@@ -202,6 +202,18 @@ Reference 由 `@heybox/hb-sdk` 的公开导出与源码注释自动生成,不
|
|
|
202
202
|
| 导出面 | Classes | Functions | Interfaces | Types | Constants |
|
|
203
203
|
| --- | ---: | ---: | ---: | ---: | ---: |
|
|
204
204
|
| Root API | 2 | 4 | 51 | 57 | 1 |
|
|
205
|
-
| Protocol API | 0 | 3 |
|
|
205
|
+
| Protocol API | 0 | 3 | 34 | 62 | 30 |
|
|
206
206
|
| Miniapp Publish API | 0 | 5 | 2 | 0 | 0 |
|
|
207
|
-
| Vite API | 0 | 1 |
|
|
207
|
+
| Vite API | 0 | 1 | 5 | 1 | 1 |
|
|
208
|
+
|
|
209
|
+
<!-- Generated by apps/docs/hb-sdk/scripts/generate-api-docs.ts; schemaVersion=2; fingerprint=d54639a086217e53edf8a85d2e11e0f0263aa0fd3dc88183fe2b3f3f07b4f4a1 -->
|
|
210
|
+
|
|
211
|
+
## SDK API
|
|
212
|
+
|
|
213
|
+
- [兼容性总览](https://docs.xiaoheihe.cn/hb_sdk/reference/compatibility)
|
|
214
|
+
|
|
215
|
+
## 常用 API
|
|
216
|
+
|
|
217
|
+
- [`user.getInfo`](https://docs.xiaoheihe.cn/hb_sdk/reference/sdk/user/getInfo)
|
|
218
|
+
- [`auth.login`](https://docs.xiaoheihe.cn/hb_sdk/reference/sdk/auth/login)
|
|
219
|
+
- [`cloud.leaderboard.submit`](https://docs.xiaoheihe.cn/hb_sdk/reference/sdk/cloud/leaderboard/submit)
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
## Package metadata
|
|
25
25
|
|
|
26
26
|
- Package: `@heybox/hb-sdk`
|
|
27
|
-
- Version at generation time: `0.
|
|
27
|
+
- Version at generation time: `0.8.0-alpha`
|
|
28
28
|
- Public root export: `@heybox/hb-sdk`
|
|
29
29
|
- Protocol export: `@heybox/hb-sdk/protocol`
|
|
30
30
|
- Vite plugin export: `@heybox/hb-sdk/vite`
|
|
@@ -210,12 +210,18 @@ Use `@heybox/hb-sdk/vite` only in `vite.config.ts`. Do not import it from iframe
|
|
|
210
210
|
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
211
211
|
import path from 'node:path';
|
|
212
212
|
import { HB_SDK_VERSION } from '../core/version';
|
|
213
|
-
import {
|
|
213
|
+
import {
|
|
214
|
+
MINIAPP_PLATFORM_VALUES,
|
|
215
|
+
renderMiniappManifest,
|
|
216
|
+
validateMiniappPackageVersionForBuild,
|
|
217
|
+
validateMiniappPlatforms,
|
|
218
|
+
type MiniappPlatform,
|
|
219
|
+
} from '../miniapp-manifest/schema';
|
|
214
220
|
import { readMiniappVersionFromPackageJson } from '../miniapp-manifest/node';
|
|
215
221
|
import { enforceMiniappHtmlPolicy } from './html-policy';
|
|
216
222
|
import { shouldSkipMiniappPlatformCspFromEnv } from './runtime-permission-env';
|
|
217
223
|
|
|
218
|
-
|
|
224
|
+
export interface MiniappManifestPlugin {
|
|
219
225
|
name: string;
|
|
220
226
|
config: (config: MiniappManifestUserConfig) => MiniappManifestUserConfig | void;
|
|
221
227
|
configResolved: (resolved: MiniappManifestResolvedConfig) => void;
|
|
@@ -223,18 +229,18 @@ type MiniappManifestPlugin = {
|
|
|
223
229
|
buildEnd: (error?: Error) => void;
|
|
224
230
|
transformIndexHtml: (html: string) => string;
|
|
225
231
|
closeBundle: (this: MiniappManifestPluginContext) => Promise<void>;
|
|
226
|
-
}
|
|
232
|
+
}
|
|
227
233
|
|
|
228
|
-
interface MiniappManifestUserConfig {
|
|
234
|
+
export interface MiniappManifestUserConfig {
|
|
229
235
|
base?: string;
|
|
230
236
|
define?: Record<string, string>;
|
|
231
237
|
}
|
|
232
238
|
|
|
233
|
-
interface MiniappManifestPluginContext {
|
|
239
|
+
export interface MiniappManifestPluginContext {
|
|
234
240
|
warn: (message: string) => void;
|
|
235
241
|
}
|
|
236
242
|
|
|
237
|
-
interface MiniappManifestResolvedConfig {
|
|
243
|
+
export interface MiniappManifestResolvedConfig {
|
|
238
244
|
root: string;
|
|
239
245
|
command: 'build' | 'serve';
|
|
240
246
|
build: {
|
|
@@ -253,12 +259,21 @@ interface MiniappManifestResolvedConfig {
|
|
|
253
259
|
protocol?: 'ws' | 'wss';
|
|
254
260
|
};
|
|
255
261
|
};
|
|
262
|
+
plugins?: readonly { name?: string }[];
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export { MINIAPP_PLATFORM_VALUES };
|
|
266
|
+
export type { MiniappPlatform };
|
|
267
|
+
|
|
268
|
+
export interface MiniappManifestOptions {
|
|
269
|
+
platforms: readonly MiniappPlatform[];
|
|
256
270
|
}
|
|
257
271
|
|
|
258
272
|
const sdkVersionPlaceholder = ['__HB_SDK', 'VERSION__'].join('_');
|
|
259
273
|
const sdkVersionBuildConstant = ['__HB_SDK_BUILD', 'VERSION__'].join('_');
|
|
260
274
|
|
|
261
|
-
export function miniappManifest(): MiniappManifestPlugin {
|
|
275
|
+
export function miniappManifest(options: MiniappManifestOptions): MiniappManifestPlugin {
|
|
276
|
+
const platforms = validateMiniappPlatforms(options?.platforms, 'miniappManifest().platforms');
|
|
262
277
|
const skipPlatformCsp = shouldSkipMiniappPlatformCspFromEnv();
|
|
263
278
|
let root = process.cwd();
|
|
264
279
|
let outDir = 'dist';
|
|
@@ -279,6 +294,12 @@ export function miniappManifest(): MiniappManifestPlugin {
|
|
|
279
294
|
};
|
|
280
295
|
},
|
|
281
296
|
configResolved(resolved) {
|
|
297
|
+
if (resolved.plugins) {
|
|
298
|
+
const manifestPluginCount = resolved.plugins.filter((plugin) => plugin.name === 'heybox-miniapp-manifest').length;
|
|
299
|
+
if (manifestPluginCount !== 1) {
|
|
300
|
+
throw new Error(`Vite 配置必须且只能包含一个 miniappManifest() 插件,当前数量:${manifestPluginCount}`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
282
303
|
root = resolved.root;
|
|
283
304
|
outDir = resolved.build.outDir;
|
|
284
305
|
command = resolved.command;
|
|
@@ -322,7 +343,7 @@ export function miniappManifest(): MiniappManifestPlugin {
|
|
|
322
343
|
|
|
323
344
|
const manifestPath = path.join(outputRoot, 'manifest.json');
|
|
324
345
|
mkdirSync(path.dirname(manifestPath), { recursive: true });
|
|
325
|
-
writeFileSync(manifestPath, renderMiniappManifest({ version, sdkVersion }));
|
|
346
|
+
writeFileSync(manifestPath, renderMiniappManifest({ version, sdkVersion, platforms }));
|
|
326
347
|
},
|
|
327
348
|
};
|
|
328
349
|
}
|
|
@@ -556,18 +577,18 @@ function reportSDKError(errorCode: string, message: string, data?: unknown) {
|
|
|
556
577
|
|
|
557
578
|
SDK 还提供 `getHandshakeState()` / `onHandshakeStateChange()` 管理持久握手状态,并通过 `on()` / `off()` 处理前后台、登录态等生命周期事件。
|
|
558
579
|
|
|
559
|
-
| 模块 | 用途
|
|
560
|
-
| ------------ |
|
|
561
|
-
| `auth` | 获取交给开发者服务端交换的短期授权码
|
|
562
|
-
| `user` | 读取 Host 当前用户资料、隔离身份或撤销授权
|
|
563
|
-
| `share` | 打开分享、复制链接或截图分享流程
|
|
564
|
-
| `ui` | 展示 Toast 和 Loading
|
|
565
|
-
| `device` | 调用振动和剪贴板能力
|
|
566
|
-
| `navigation` | 关闭、刷新页面或打开小黑盒页面
|
|
567
|
-
| `viewport` | 读取窗口信息和设置导航栏样式
|
|
568
|
-
| `storage` | 读写当前小程序的隔离存储
|
|
569
|
-
| `cloud` | 使用小程序云端排行榜
|
|
570
|
-
| `network` | 发起经过平台授权的网络请求
|
|
580
|
+
| 模块 | 用途 |
|
|
581
|
+
| ------------ | ------------------------------------------ |
|
|
582
|
+
| `auth` | 获取交给开发者服务端交换的短期授权码 |
|
|
583
|
+
| `user` | 读取 Host 当前用户资料、隔离身份或撤销授权 |
|
|
584
|
+
| `share` | 打开分享、复制链接或截图分享流程 |
|
|
585
|
+
| `ui` | 展示 Toast 和 Loading |
|
|
586
|
+
| `device` | 调用振动和剪贴板能力 |
|
|
587
|
+
| `navigation` | 关闭、刷新页面或打开小黑盒页面 |
|
|
588
|
+
| `viewport` | 读取窗口信息和设置导航栏样式 |
|
|
589
|
+
| `storage` | 读写当前小程序的隔离存储 |
|
|
590
|
+
| `cloud` | 使用小程序云端排行榜 |
|
|
591
|
+
| `network` | 发起经过平台授权的网络请求 |
|
|
571
592
|
|
|
572
593
|
具体方法、参数和返回值以 [API Reference](https://docs.xiaoheihe.cn/hb_sdk/reference/) 为准,常见组合写法见 [Recipes](https://docs.xiaoheihe.cn/hb_sdk/recipes/)。
|
|
573
594
|
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
- `network.request()` 不能访问平台保留的 runtime auth 与 OpenAPI 内部路径;页面不得持有或交换服务端应用凭据。
|
|
25
25
|
- `network.request` 不支持 `multipart/form-data`;App Host 仅支持 form(`application/x-www-form-urlencoded`)与 JSON。表单请用 `URLSearchParams#toString()` 作为 `data`,文件上传请走专用上传能力。
|
|
26
26
|
- 仅当远端已启用 `network.request` 时,`hb-sdk dev` 与 `hb-sdk remote deploy` 构建才会跳过平台 CSP;其他构建继续注入平台 CSP。`useOfficialDomain` 不参与 CSP 跳过判定。
|
|
27
|
-
- 构建必须启用 `miniappManifest()
|
|
27
|
+
- 构建必须启用 `miniappManifest({ platforms })` 并显式声明实际承诺适配的平台,推荐统一使用 `hb-sdk build`。新项目模板中的 `['android', 'ios', 'ohos']` 只是初始配置,不代表已经完成真机验收。
|
|
28
28
|
|
|
29
29
|
## Agent rules
|
|
30
30
|
|
|
@@ -78,6 +78,8 @@ function rewriteBundledProtocolIndexLinks(markdown) {
|
|
|
78
78
|
return markdown
|
|
79
79
|
.replaceAll('(./root/)', '(api-root.md)')
|
|
80
80
|
.replaceAll('(./protocol/)', '(#public-protocol-entrypoint)')
|
|
81
|
+
.replaceAll('(./compatibility)', '(https://docs.xiaoheihe.cn/hb_sdk/reference/compatibility)')
|
|
82
|
+
.replaceAll('](/reference/', '](https://docs.xiaoheihe.cn/hb_sdk/reference/')
|
|
81
83
|
.replaceAll('(./miniapp-publish/)', '(https://open.xiaoheihe.cn/docs/hb_sdk/reference/miniapp-publish/)')
|
|
82
84
|
.replaceAll('(./vite/)', '(https://open.xiaoheihe.cn/docs/hb_sdk/reference/vite/)')
|
|
83
85
|
.replaceAll('(./runtime/)', '(https://docs.xiaoheihe.cn/hb_sdk/reference/runtime/)')
|
|
@@ -735,7 +737,7 @@ import { defineConfig } from 'vite';
|
|
|
735
737
|
|
|
736
738
|
export default defineConfig({
|
|
737
739
|
base: './',
|
|
738
|
-
plugins: [miniappManifest()],
|
|
740
|
+
plugins: [miniappManifest({ platforms: ['android', 'ios', 'ohos'] })],
|
|
739
741
|
});`,
|
|
740
742
|
)}
|
|
741
743
|
|
package/skill/skill.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hb-sdk",
|
|
3
|
-
"skillVersion": "0.
|
|
3
|
+
"skillVersion": "0.8.0-alpha+skill.e73cb0ba5184",
|
|
4
4
|
"sdk": {
|
|
5
5
|
"package": "@heybox/hb-sdk",
|
|
6
|
-
"version": "0.
|
|
7
|
-
"compatibility": "0.
|
|
6
|
+
"version": "0.8.0-alpha",
|
|
7
|
+
"compatibility": "0.8.0-alpha"
|
|
8
8
|
},
|
|
9
9
|
"source": "https://open.xiaoheihe.cn/agent-skills/hb-sdk",
|
|
10
|
-
"integrity": "sha256-
|
|
10
|
+
"integrity": "sha256-e73cb0ba518459e1b262d09fb0ead87a7163c8e5358430184a9dd4f085049357"
|
|
11
11
|
}
|
package/types/core/errors.d.ts
CHANGED
|
@@ -18,9 +18,9 @@ export declare class HbMiniProgramSDKError extends Error {
|
|
|
18
18
|
/**
|
|
19
19
|
* 创建 SDK 标准错误。
|
|
20
20
|
*
|
|
21
|
-
* @param code 稳定错误码。
|
|
22
|
-
* @param message 面向开发者的错误说明。
|
|
23
|
-
* @param data 可选调试数据。
|
|
21
|
+
* @param code - 稳定错误码。
|
|
22
|
+
* @param message - 面向开发者的错误说明。
|
|
23
|
+
* @param data - 可选调试数据。
|
|
24
24
|
* @returns 标准化 `HbMiniProgramSDKError` 实例。
|
|
25
25
|
*
|
|
26
26
|
* @remarks
|
|
@@ -34,7 +34,7 @@ export declare function createSDKError(code: string, message: string, data?: unk
|
|
|
34
34
|
* 仅在请求已经成功走完 bridge / runtime / 宿主调用链、但最终 HTTP 状态不满足
|
|
35
35
|
* `validateStatus` 时抛出。它不表示握手失败或 bridge 级错误。
|
|
36
36
|
*
|
|
37
|
-
* @typeParam T 标准化响应数据的类型。
|
|
37
|
+
* @typeParam T - 标准化响应数据的类型。
|
|
38
38
|
*/
|
|
39
39
|
export declare class HbMiniProgramNetworkError<T = unknown> extends Error {
|
|
40
40
|
/** HTTP 状态码。 */
|
|
@@ -48,7 +48,7 @@ export declare class HbMiniProgramNetworkError<T = unknown> extends Error {
|
|
|
48
48
|
/** 完整标准化响应。 */
|
|
49
49
|
response: MiniProgramNetworkResponse<T>;
|
|
50
50
|
/**
|
|
51
|
-
* @param response 已完成请求的标准化网络响应。
|
|
51
|
+
* @param response - 已完成请求的标准化网络响应。
|
|
52
52
|
*/
|
|
53
53
|
constructor(response: MiniProgramNetworkResponse<T>);
|
|
54
54
|
}
|
package/types/core/sdk.d.ts
CHANGED
|
@@ -53,16 +53,16 @@ export declare class MiniProgramSDK {
|
|
|
53
53
|
/**
|
|
54
54
|
* 注册小程序生命周期或业务事件。
|
|
55
55
|
*
|
|
56
|
-
* @param eventName 要监听的事件名。
|
|
57
|
-
* @param handler 事件处理函数。
|
|
56
|
+
* @param eventName - 要监听的事件名。
|
|
57
|
+
* @param handler - 事件处理函数。
|
|
58
58
|
* @returns 事件解绑函数。
|
|
59
59
|
*/
|
|
60
60
|
on<T extends MiniProgramEventName>(eventName: T, handler: MiniProgramEventHandler<T>): () => void;
|
|
61
61
|
/**
|
|
62
62
|
* 移除小程序生命周期或业务事件。
|
|
63
63
|
*
|
|
64
|
-
* @param eventName 要移除的事件名。
|
|
65
|
-
* @param handler 对应的事件处理函数。
|
|
64
|
+
* @param eventName - 要移除的事件名。
|
|
65
|
+
* @param handler - 对应的事件处理函数。
|
|
66
66
|
*/
|
|
67
67
|
off<T extends MiniProgramEventName>(eventName: T, handler: MiniProgramEventHandler<T>): void;
|
|
68
68
|
/**
|
|
@@ -77,7 +77,7 @@ export declare class MiniProgramSDK {
|
|
|
77
77
|
/**
|
|
78
78
|
* 创建独立 SDK 实例。
|
|
79
79
|
*
|
|
80
|
-
* @param options SDK 运行配置,例如超时时间、nonce 或测试环境注入的 window。
|
|
80
|
+
* @param options - SDK 运行配置,例如超时时间、nonce 或测试环境注入的 window。
|
|
81
81
|
* @returns 可独立管理生命周期的 `MiniProgramSDK` 实例。
|
|
82
82
|
*
|
|
83
83
|
* @remarks
|
|
@@ -10,24 +10,74 @@ import type { MiniProgramDeviceModule } from '../modules/device';
|
|
|
10
10
|
import type { MiniProgramNavigationModule } from '../modules/navigation';
|
|
11
11
|
import type { MiniProgramEventHandler, MiniProgramEventName } from '../protocol/types';
|
|
12
12
|
import type { MiniProgramSDKHandshakeState, MiniProgramSDKHandshakeStateHandler } from './handshake-state';
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* 获取默认 SDK 实例的当前握手状态。
|
|
15
|
+
*
|
|
16
|
+
* @since 0.7.0-alpha.9
|
|
17
|
+
* @hbPlatform android
|
|
18
|
+
* @hbPlatform ios
|
|
19
|
+
* @hbPlatform ohos
|
|
20
|
+
* @hbPlatform windows
|
|
21
|
+
* @hbPlatform macos
|
|
22
|
+
* @hbClient android none
|
|
23
|
+
* @hbClient ios none
|
|
24
|
+
* @hbClient ohos none
|
|
25
|
+
* @hbClient windows none
|
|
26
|
+
* @hbClient macos none
|
|
27
|
+
*/
|
|
14
28
|
export declare function getHandshakeState(): MiniProgramSDKHandshakeState;
|
|
15
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* 订阅默认 SDK 实例的握手状态,并立即接收当前状态。
|
|
31
|
+
*
|
|
32
|
+
* @since 0.7.0-alpha.9
|
|
33
|
+
* @hbPlatform android
|
|
34
|
+
* @hbPlatform ios
|
|
35
|
+
* @hbPlatform ohos
|
|
36
|
+
* @hbPlatform windows
|
|
37
|
+
* @hbPlatform macos
|
|
38
|
+
* @hbClient android none
|
|
39
|
+
* @hbClient ios none
|
|
40
|
+
* @hbClient ohos none
|
|
41
|
+
* @hbClient windows none
|
|
42
|
+
* @hbClient macos none
|
|
43
|
+
*/
|
|
16
44
|
export declare function onHandshakeStateChange(handler: MiniProgramSDKHandshakeStateHandler): () => void;
|
|
17
45
|
/**
|
|
18
46
|
* 注册默认 SDK 实例的事件监听。
|
|
19
47
|
*
|
|
20
|
-
* @param eventName 要监听的事件名。
|
|
21
|
-
* @param handler 事件处理函数。
|
|
48
|
+
* @param eventName - 要监听的事件名。
|
|
49
|
+
* @param handler - 事件处理函数。
|
|
22
50
|
* @returns 事件解绑函数。
|
|
51
|
+
* @since 0.2.0-alpha.0
|
|
52
|
+
* @hbPlatform android
|
|
53
|
+
* @hbPlatform ios
|
|
54
|
+
* @hbPlatform ohos
|
|
55
|
+
* @hbPlatform windows
|
|
56
|
+
* @hbPlatform macos
|
|
57
|
+
* @hbClient android none
|
|
58
|
+
* @hbClient ios none
|
|
59
|
+
* @hbClient ohos none
|
|
60
|
+
* @hbClient windows none
|
|
61
|
+
* @hbClient macos none
|
|
23
62
|
*/
|
|
24
63
|
export declare function on<T extends MiniProgramEventName>(eventName: T, handler: MiniProgramEventHandler<T>): () => void;
|
|
25
64
|
/**
|
|
26
65
|
* 移除默认 SDK 实例的事件监听。
|
|
27
66
|
*
|
|
28
|
-
* @param eventName 要移除的事件名。
|
|
29
|
-
* @param handler 对应的事件处理函数。
|
|
67
|
+
* @param eventName - 要移除的事件名。
|
|
68
|
+
* @param handler - 对应的事件处理函数。
|
|
30
69
|
* @returns 无返回值。
|
|
70
|
+
* @since 0.2.0-alpha.0
|
|
71
|
+
* @hbPlatform android
|
|
72
|
+
* @hbPlatform ios
|
|
73
|
+
* @hbPlatform ohos
|
|
74
|
+
* @hbPlatform windows
|
|
75
|
+
* @hbPlatform macos
|
|
76
|
+
* @hbClient android none
|
|
77
|
+
* @hbClient ios none
|
|
78
|
+
* @hbClient ohos none
|
|
79
|
+
* @hbClient windows none
|
|
80
|
+
* @hbClient macos none
|
|
31
81
|
*/
|
|
32
82
|
export declare function off<T extends MiniProgramEventName>(eventName: T, handler: MiniProgramEventHandler<T>): void;
|
|
33
83
|
/** 默认 SDK 实例的授权模块。 */
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export declare const MINIAPP_TEMPLATE_VERSION = "0.0.0";
|
|
2
|
+
export declare const MINIAPP_PLATFORM_VALUES: readonly ["android", "ios", "ohos", "windows", "macos", "linux"];
|
|
3
|
+
export type MiniappPlatform = (typeof MINIAPP_PLATFORM_VALUES)[number];
|
|
2
4
|
export interface MiniappManifest {
|
|
3
5
|
[key: string]: unknown;
|
|
4
6
|
sdkVersion: string;
|
|
5
7
|
version: string;
|
|
8
|
+
platforms: readonly MiniappPlatform[];
|
|
6
9
|
}
|
|
7
10
|
export interface ParseMiniappManifestResult {
|
|
8
11
|
manifest: MiniappManifest;
|
|
@@ -16,5 +19,7 @@ export declare function parseMiniappManifestJson(raw: string, sourceLabel?: stri
|
|
|
16
19
|
export declare function validateMiniappManifestForDeploy(manifest: MiniappManifest): {
|
|
17
20
|
version: string;
|
|
18
21
|
sdkVersion: string;
|
|
22
|
+
platforms: readonly ("android" | "ios" | "ohos" | "windows" | "macos" | "linux")[];
|
|
19
23
|
};
|
|
24
|
+
export declare function validateMiniappPlatforms(platforms: unknown, sourceLabel?: string): readonly MiniappPlatform[];
|
|
20
25
|
export declare function validateSdkVersion(version: unknown, sourceLabel?: string): string;
|
|
@@ -71,7 +71,7 @@ export interface MiniappUploadSessionFile {
|
|
|
71
71
|
/**
|
|
72
72
|
* 校验构建产物路径和大小,并按路径 UTF-8 字节序排序。
|
|
73
73
|
*
|
|
74
|
-
* @param files 待处理的构建产物文件。
|
|
74
|
+
* @param files - 待处理的构建产物文件。
|
|
75
75
|
* @returns 保留输入附加字段的有序文件列表。
|
|
76
76
|
* @throws 路径不规范、路径重复或文件大小非法时抛出错误。
|
|
77
77
|
*/
|
|
@@ -81,8 +81,8 @@ export declare function prepareMiniappArtifactFiles<T extends MiniappArtifactFil
|
|
|
81
81
|
/**
|
|
82
82
|
* 按服务端 session key 前缀校验最终上传路径的 UTF-8 字节长度。
|
|
83
83
|
*
|
|
84
|
-
* @param files 待上传的构建产物文件。
|
|
85
|
-
* @param options 小程序和长度限制配置。
|
|
84
|
+
* @param files - 待上传的构建产物文件。
|
|
85
|
+
* @param options - 小程序和长度限制配置。
|
|
86
86
|
* @returns 第一个超长路径的错误提示;全部合法时返回 `undefined`。
|
|
87
87
|
*/
|
|
88
88
|
export declare function validateMiniappUploadPathLengths(files: readonly Pick<MiniappArtifactFile, 'relativePath'>[], options: {
|
|
@@ -92,7 +92,7 @@ export declare function validateMiniappUploadPathLengths(files: readonly Pick<Mi
|
|
|
92
92
|
/**
|
|
93
93
|
* 创建 v1 整包签名头。
|
|
94
94
|
*
|
|
95
|
-
* @param fileCount 参与签名的文件数量。
|
|
95
|
+
* @param fileCount - 参与签名的文件数量。
|
|
96
96
|
* @returns 包含协议标识和文件数量的字节数组。
|
|
97
97
|
* @throws 文件数量超出协议范围时抛出错误。
|
|
98
98
|
*/
|
|
@@ -100,7 +100,7 @@ export declare function createMiniappArtifactSignatureHeader(fileCount: number):
|
|
|
100
100
|
/**
|
|
101
101
|
* 创建单个文件的 v1 framing header。
|
|
102
102
|
*
|
|
103
|
-
* @param file 已规范化或待校验的构建产物文件。
|
|
103
|
+
* @param file - 已规范化或待校验的构建产物文件。
|
|
104
104
|
* @returns 包含路径长度、路径和文件大小的字节数组。
|
|
105
105
|
* @throws 文件路径或大小非法时抛出错误。
|
|
106
106
|
*/
|
|
@@ -108,9 +108,9 @@ export declare function createMiniappArtifactFileHeader(file: MiniappArtifactFil
|
|
|
108
108
|
/**
|
|
109
109
|
* 校验服务端 session 文件映射,并计算仍需上传的文件。
|
|
110
110
|
*
|
|
111
|
-
* @param localFiles 本地构建产物文件。
|
|
112
|
-
* @param serverFiles 服务端签发的文件映射。
|
|
113
|
-
* @param uploadedKeys 服务端已确认上传成功的 key。
|
|
111
|
+
* @param localFiles - 本地构建产物文件。
|
|
112
|
+
* @param serverFiles - 服务端签发的文件映射。
|
|
113
|
+
* @param uploadedKeys - 服务端已确认上传成功的 key。
|
|
114
114
|
* @returns 完整映射、待上传文件和已确认 key。
|
|
115
115
|
* @throws 服务端映射与本地产物不一致时抛出错误。
|
|
116
116
|
*/
|
|
@@ -16,7 +16,21 @@ export interface LoginResult {
|
|
|
16
16
|
export type { MiniProgramAuthMethod } from '../../protocol/capabilities';
|
|
17
17
|
/** 外部小程序可调用的授权模块。 */
|
|
18
18
|
export interface MiniProgramAuthModule {
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* 获取短期授权码;不会向小程序暴露 token、cookie 或黑盒用户资料。
|
|
21
|
+
*
|
|
22
|
+
* @since 0.2.0-alpha.0
|
|
23
|
+
* @hbPlatform android
|
|
24
|
+
* @hbPlatform ios
|
|
25
|
+
* @hbPlatform ohos
|
|
26
|
+
* @hbPlatform windows
|
|
27
|
+
* @hbPlatform macos
|
|
28
|
+
* @hbClient android none
|
|
29
|
+
* @hbClient ios none
|
|
30
|
+
* @hbClient ohos none
|
|
31
|
+
* @hbClient windows none
|
|
32
|
+
* @hbClient macos none
|
|
33
|
+
*/
|
|
20
34
|
login(options?: LoginOptions): Promise<LoginResult>;
|
|
21
35
|
}
|
|
22
36
|
/** 获取短期授权码。 */
|