@heybox/hb-sdk 0.6.1 → 0.6.3
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 +4 -17
- package/dist/cli-chunks/{context-D0BowvGu.cjs → context-Bu0Zusj_.cjs} +1 -37
- package/dist/cli-chunks/{create-C0afRvs9.cjs → create-CgAGcRtZ.cjs} +1 -1
- package/dist/cli-chunks/{dev-CN307p_G.cjs → dev-g35-QcIa.cjs} +4 -96
- package/dist/cli-chunks/{doctor-VW0nKg5q.cjs → doctor-klsQg82G.cjs} +1 -1
- package/dist/cli-chunks/{index-BnCDW-BB.cjs → index--P321c8v.cjs} +13 -13
- package/dist/cli-chunks/{index-DcZLSI_y.cjs → index-CbsbCgtf.cjs} +2 -2
- package/dist/cli-chunks/{login-BsyENL1d.cjs → login-DEoReXOe.cjs} +2 -2
- package/dist/cli-chunks/{remote-BSvvxvVv.cjs → remote-CZ-G3RSH.cjs} +9 -52
- package/dist/cli-chunks/{session-0XuUaVOO.cjs → session-vlPGi1Z8.cjs} +1 -2
- package/dist/cli.cjs +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/miniapp-publish.cjs.js +0 -4
- package/dist/miniapp-publish.esm.js +1 -4
- package/dist/templates/vue3-vite-ts/README.md.ejs +1 -1
- package/dist/templates/vue3-vite-ts/package.json.ejs +1 -6
- package/dist/vite.cjs.js +2 -344
- package/dist/vite.esm.js +2 -344
- package/package.json +1 -1
- package/skill/SKILL.md +2 -2
- package/skill/references/api-root.md +3 -25
- package/skill/references/cli.md +5 -18
- package/skill/scripts/sync-references.mjs +1 -1
- package/skill/skill.json +4 -4
- package/types/miniapp-publish/index.d.ts +0 -1
- package/types/vite/index.d.ts +1 -7
- package/types/cli/auth/base-url.d.ts +0 -20
- package/types/cli/config.d.ts +0 -11
- package/types/miniapp-manifest/sdk-version-policy.d.ts +0 -9
- package/types/vite/sdk-version-gate.d.ts +0 -8
package/dist/vite.esm.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import { readFileSync, existsSync, writeFileSync, mkdirSync, readdirSync } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import require$$0 from 'path';
|
|
4
|
-
import require$$1 from 'os';
|
|
5
|
-
import { readFile, mkdir, writeFile, rename } from 'node:fs/promises';
|
|
6
3
|
|
|
7
4
|
/** 构建时替换为当前发布包的实际版本。 */
|
|
8
5
|
const HB_SDK_VERSION = typeof undefined === 'string'
|
|
9
6
|
? undefined
|
|
10
|
-
: '0.6.
|
|
11
|
-
|
|
12
|
-
function getDefaultExportFromCjs (x) {
|
|
13
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
14
|
-
}
|
|
7
|
+
: '0.6.3';
|
|
15
8
|
|
|
16
9
|
var re = {exports: {}};
|
|
17
10
|
|
|
@@ -11584,328 +11577,9 @@ function walk(node, visit) {
|
|
|
11584
11577
|
walk(node.content, visit);
|
|
11585
11578
|
}
|
|
11586
11579
|
|
|
11587
|
-
var envPaths$1 = {exports: {}};
|
|
11588
|
-
|
|
11589
|
-
var hasRequiredEnvPaths;
|
|
11590
|
-
|
|
11591
|
-
function requireEnvPaths () {
|
|
11592
|
-
if (hasRequiredEnvPaths) return envPaths$1.exports;
|
|
11593
|
-
hasRequiredEnvPaths = 1;
|
|
11594
|
-
const path = require$$0;
|
|
11595
|
-
const os = require$$1;
|
|
11596
|
-
|
|
11597
|
-
const homedir = os.homedir();
|
|
11598
|
-
const tmpdir = os.tmpdir();
|
|
11599
|
-
const {env} = process;
|
|
11600
|
-
|
|
11601
|
-
const macos = name => {
|
|
11602
|
-
const library = path.join(homedir, 'Library');
|
|
11603
|
-
|
|
11604
|
-
return {
|
|
11605
|
-
data: path.join(library, 'Application Support', name),
|
|
11606
|
-
config: path.join(library, 'Preferences', name),
|
|
11607
|
-
cache: path.join(library, 'Caches', name),
|
|
11608
|
-
log: path.join(library, 'Logs', name),
|
|
11609
|
-
temp: path.join(tmpdir, name)
|
|
11610
|
-
};
|
|
11611
|
-
};
|
|
11612
|
-
|
|
11613
|
-
const windows = name => {
|
|
11614
|
-
const appData = env.APPDATA || path.join(homedir, 'AppData', 'Roaming');
|
|
11615
|
-
const localAppData = env.LOCALAPPDATA || path.join(homedir, 'AppData', 'Local');
|
|
11616
|
-
|
|
11617
|
-
return {
|
|
11618
|
-
// Data/config/cache/log are invented by me as Windows isn't opinionated about this
|
|
11619
|
-
data: path.join(localAppData, name, 'Data'),
|
|
11620
|
-
config: path.join(appData, name, 'Config'),
|
|
11621
|
-
cache: path.join(localAppData, name, 'Cache'),
|
|
11622
|
-
log: path.join(localAppData, name, 'Log'),
|
|
11623
|
-
temp: path.join(tmpdir, name)
|
|
11624
|
-
};
|
|
11625
|
-
};
|
|
11626
|
-
|
|
11627
|
-
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
|
11628
|
-
const linux = name => {
|
|
11629
|
-
const username = path.basename(homedir);
|
|
11630
|
-
|
|
11631
|
-
return {
|
|
11632
|
-
data: path.join(env.XDG_DATA_HOME || path.join(homedir, '.local', 'share'), name),
|
|
11633
|
-
config: path.join(env.XDG_CONFIG_HOME || path.join(homedir, '.config'), name),
|
|
11634
|
-
cache: path.join(env.XDG_CACHE_HOME || path.join(homedir, '.cache'), name),
|
|
11635
|
-
// https://wiki.debian.org/XDGBaseDirectorySpecification#state
|
|
11636
|
-
log: path.join(env.XDG_STATE_HOME || path.join(homedir, '.local', 'state'), name),
|
|
11637
|
-
temp: path.join(tmpdir, username, name)
|
|
11638
|
-
};
|
|
11639
|
-
};
|
|
11640
|
-
|
|
11641
|
-
const envPaths = (name, options) => {
|
|
11642
|
-
if (typeof name !== 'string') {
|
|
11643
|
-
throw new TypeError(`Expected string, got ${typeof name}`);
|
|
11644
|
-
}
|
|
11645
|
-
|
|
11646
|
-
options = Object.assign({suffix: 'nodejs'}, options);
|
|
11647
|
-
|
|
11648
|
-
if (options.suffix) {
|
|
11649
|
-
// Add suffix to prevent possible conflict with native apps
|
|
11650
|
-
name += `-${options.suffix}`;
|
|
11651
|
-
}
|
|
11652
|
-
|
|
11653
|
-
if (process.platform === 'darwin') {
|
|
11654
|
-
return macos(name);
|
|
11655
|
-
}
|
|
11656
|
-
|
|
11657
|
-
if (process.platform === 'win32') {
|
|
11658
|
-
return windows(name);
|
|
11659
|
-
}
|
|
11660
|
-
|
|
11661
|
-
return linux(name);
|
|
11662
|
-
};
|
|
11663
|
-
|
|
11664
|
-
envPaths$1.exports = envPaths;
|
|
11665
|
-
// TODO: Remove this for the next major release
|
|
11666
|
-
envPaths$1.exports.default = envPaths;
|
|
11667
|
-
return envPaths$1.exports;
|
|
11668
|
-
}
|
|
11669
|
-
|
|
11670
|
-
var envPathsExports = requireEnvPaths();
|
|
11671
|
-
var envPaths = /*@__PURE__*/getDefaultExportFromCjs(envPathsExports);
|
|
11672
|
-
|
|
11673
|
-
const APIUserMiniprogramPublicSdkConfigPath = '/user_miniprogram/public/sdk_config';
|
|
11674
|
-
function createUserMiniprogramPublicSdkConfigRequest(serviceTag) {
|
|
11675
|
-
return {
|
|
11676
|
-
path: APIUserMiniprogramPublicSdkConfigPath,
|
|
11677
|
-
searchParams: serviceTag ? { special_tag: serviceTag } : {},
|
|
11678
|
-
headers: serviceTag ? { 'x-rylai-service-tag': serviceTag } : {},
|
|
11679
|
-
};
|
|
11680
|
-
}
|
|
11681
|
-
function parseUserMiniprogramPublicSdkConfigResult(value) {
|
|
11682
|
-
if (!isRecord(value) ||
|
|
11683
|
-
typeof value.minimum_sdk_version !== 'string') {
|
|
11684
|
-
throw new Error('公共 SDK 配置响应无效');
|
|
11685
|
-
}
|
|
11686
|
-
return value;
|
|
11687
|
-
}
|
|
11688
|
-
function parseUserMiniprogramPublicSdkConfigEnvelope(value) {
|
|
11689
|
-
if (!isRecord(value) || value.status !== 'ok') {
|
|
11690
|
-
throw new Error('公共 SDK 配置响应无效');
|
|
11691
|
-
}
|
|
11692
|
-
return parseUserMiniprogramPublicSdkConfigResult(value.result);
|
|
11693
|
-
}
|
|
11694
|
-
function isRecord(value) {
|
|
11695
|
-
return typeof value === 'object' && value !== null;
|
|
11696
|
-
}
|
|
11697
|
-
|
|
11698
|
-
const PUBLIC_USER_MINIPROGRAM_SDK_CONFIG_API_PATH = APIUserMiniprogramPublicSdkConfigPath;
|
|
11699
|
-
|
|
11700
|
-
const CACHE_MAX_AGE_MS = 24 * 60 * 60 * 1_000;
|
|
11701
|
-
const CACHE_FILE_NAME = 'minimum-sdk-versions.json';
|
|
11702
|
-
async function resolveMinimumSdkVersion(options) {
|
|
11703
|
-
const now = options.now ?? Date.now();
|
|
11704
|
-
const cachePath = path.join(options.cacheDir, CACHE_FILE_NAME);
|
|
11705
|
-
const cache = await readCache(cachePath);
|
|
11706
|
-
let minimumSdkVersion;
|
|
11707
|
-
try {
|
|
11708
|
-
minimumSdkVersion = validateStableSdkVersion(await options.fetchMinimumSdkVersion(), 'minimumSdkVersion');
|
|
11709
|
-
}
|
|
11710
|
-
catch {
|
|
11711
|
-
const cached = cache.environments[options.environment];
|
|
11712
|
-
const cacheAge = cached ? now - cached.fetchedAt : Number.NaN;
|
|
11713
|
-
if (cached && Number.isFinite(cached.fetchedAt) && cacheAge >= 0 && cacheAge <= CACHE_MAX_AGE_MS) {
|
|
11714
|
-
try {
|
|
11715
|
-
return validateStableSdkVersion(cached.minimumSdkVersion, 'cached minimumSdkVersion');
|
|
11716
|
-
}
|
|
11717
|
-
catch {
|
|
11718
|
-
// 非法缓存按不存在处理。
|
|
11719
|
-
}
|
|
11720
|
-
}
|
|
11721
|
-
throw new Error('MINIMUM_SDK_VERSION_UNAVAILABLE:无法获取最低 SDK 版本,且没有 24 小时内的有效缓存');
|
|
11722
|
-
}
|
|
11723
|
-
cache.environments[options.environment] = { fetchedAt: now, minimumSdkVersion };
|
|
11724
|
-
try {
|
|
11725
|
-
await writeCache(cachePath, cache);
|
|
11726
|
-
}
|
|
11727
|
-
catch {
|
|
11728
|
-
// 已校验的远端策略仍然可信;缓存只是离线回退优化。
|
|
11729
|
-
}
|
|
11730
|
-
return minimumSdkVersion;
|
|
11731
|
-
}
|
|
11732
|
-
function validateCurrentSdkVersion(currentSdkVersion, minimumSdkVersion, options) {
|
|
11733
|
-
const current = validateSdkVersion(currentSdkVersion, '当前 SDK 版本');
|
|
11734
|
-
const minimum = validateStableSdkVersion(minimumSdkVersion, 'minimumSdkVersion');
|
|
11735
|
-
if (!options.allowPrerelease && semverExports.prerelease(current) !== null) {
|
|
11736
|
-
throw new Error('正式发布不允许使用预发布 SDK,请运行 pnpm add @heybox/hb-sdk@latest 后重新构建');
|
|
11737
|
-
}
|
|
11738
|
-
if (!semverExports.satisfies(current, `>=${minimum}`, { includePrerelease: options.allowPrerelease })) {
|
|
11739
|
-
throw new Error(`SDK_VERSION_TOO_LOW:当前 @heybox/hb-sdk@${current} 低于最低版本 ${minimum},请运行 pnpm add @heybox/hb-sdk@latest`);
|
|
11740
|
-
}
|
|
11741
|
-
return current;
|
|
11742
|
-
}
|
|
11743
|
-
function validateSdkVersion(value, label) {
|
|
11744
|
-
const normalized = String(value).trim();
|
|
11745
|
-
const parsed = semverExports.parse(normalized);
|
|
11746
|
-
if (!parsed || parsed.version !== normalized || parsed.build.length > 0) {
|
|
11747
|
-
throw new Error(`${label} 必须是合法 SemVer:${normalized}`);
|
|
11748
|
-
}
|
|
11749
|
-
return normalized;
|
|
11750
|
-
}
|
|
11751
|
-
function validateStableSdkVersion(value, label) {
|
|
11752
|
-
const normalized = validateSdkVersion(value, label);
|
|
11753
|
-
if (semverExports.prerelease(normalized) !== null)
|
|
11754
|
-
throw new Error(`${label} 必须是稳定 SemVer:${normalized}`);
|
|
11755
|
-
return normalized;
|
|
11756
|
-
}
|
|
11757
|
-
async function readCache(cachePath) {
|
|
11758
|
-
try {
|
|
11759
|
-
const parsed = JSON.parse(await readFile(cachePath, 'utf8'));
|
|
11760
|
-
if (parsed && typeof parsed === 'object' && parsed.environments && typeof parsed.environments === 'object')
|
|
11761
|
-
return parsed;
|
|
11762
|
-
}
|
|
11763
|
-
catch {
|
|
11764
|
-
// 缓存缺失或损坏时继续请求最新配置。
|
|
11765
|
-
}
|
|
11766
|
-
return { environments: {} };
|
|
11767
|
-
}
|
|
11768
|
-
async function writeCache(cachePath, cache) {
|
|
11769
|
-
await mkdir(path.dirname(cachePath), { recursive: true });
|
|
11770
|
-
const temporaryPath = `${cachePath}.${process.pid}.tmp`;
|
|
11771
|
-
await writeFile(temporaryPath, `${JSON.stringify(cache, null, 2)}\n`, { mode: 0o600 });
|
|
11772
|
-
await rename(temporaryPath, cachePath);
|
|
11773
|
-
}
|
|
11774
|
-
|
|
11775
|
-
const globalHeyboxCliRequestConfig = {};
|
|
11776
|
-
function readHeyboxCliRequestConfig() {
|
|
11777
|
-
return normalizeHeyboxRylaiServiceTagConfig(globalHeyboxCliRequestConfig);
|
|
11778
|
-
}
|
|
11779
|
-
function resolveHeyboxRylaiServiceTag(pathWithQuery, config = readHeyboxCliRequestConfig()) {
|
|
11780
|
-
const normalized = normalizeHeyboxRylaiServiceTagConfig(config);
|
|
11781
|
-
const pathname = getPathname(pathWithQuery) ;
|
|
11782
|
-
const specialTag = normalized.special_tag;
|
|
11783
|
-
if (pathname && specialTag?.path_prefix_list.some((prefix) => pathname.startsWith(prefix))) {
|
|
11784
|
-
return specialTag.tag_name;
|
|
11785
|
-
}
|
|
11786
|
-
return normalized.default_tag;
|
|
11787
|
-
}
|
|
11788
|
-
function normalizeHeyboxRylaiServiceTagConfig(config) {
|
|
11789
|
-
const defaultTag = normalizeHeyboxRylaiServiceTag(config.default_tag);
|
|
11790
|
-
const specialTagName = normalizeHeyboxRylaiServiceTag(config.special_tag?.tag_name);
|
|
11791
|
-
const pathPrefixList = config.special_tag?.path_prefix_list?.filter(isValidPathPrefix) || [];
|
|
11792
|
-
return {
|
|
11793
|
-
...(defaultTag ? { default_tag: defaultTag } : {}),
|
|
11794
|
-
...(specialTagName && pathPrefixList.length
|
|
11795
|
-
? {
|
|
11796
|
-
special_tag: {
|
|
11797
|
-
tag_name: specialTagName,
|
|
11798
|
-
path_prefix_list: pathPrefixList,
|
|
11799
|
-
},
|
|
11800
|
-
}
|
|
11801
|
-
: {}),
|
|
11802
|
-
};
|
|
11803
|
-
}
|
|
11804
|
-
function normalizeHeyboxRylaiServiceTag(value) {
|
|
11805
|
-
const tag = String(value ?? '').trim();
|
|
11806
|
-
if (!tag) {
|
|
11807
|
-
return undefined;
|
|
11808
|
-
}
|
|
11809
|
-
if (/[\r\n]/.test(tag)) {
|
|
11810
|
-
throw new Error('x-rylai-service-tag 不允许包含换行符');
|
|
11811
|
-
}
|
|
11812
|
-
return tag;
|
|
11813
|
-
}
|
|
11814
|
-
function isValidPathPrefix(value) {
|
|
11815
|
-
return typeof value === 'string' && value.startsWith('/') && !/[\r\n]/.test(value);
|
|
11816
|
-
}
|
|
11817
|
-
function getPathname(pathWithQuery) {
|
|
11818
|
-
try {
|
|
11819
|
-
return new URL(pathWithQuery, 'https://api.xiaoheihe.cn').pathname;
|
|
11820
|
-
}
|
|
11821
|
-
catch {
|
|
11822
|
-
return '';
|
|
11823
|
-
}
|
|
11824
|
-
}
|
|
11825
|
-
|
|
11826
|
-
const paths = envPaths('hb-sdk');
|
|
11827
|
-
async function enforceViteSdkVersion(options) {
|
|
11828
|
-
const fetchImpl = options.fetchImpl ?? fetch;
|
|
11829
|
-
const serviceTag = resolveHeyboxRylaiServiceTag(PUBLIC_USER_MINIPROGRAM_SDK_CONFIG_API_PATH, {
|
|
11830
|
-
default_tag: options.serviceTag,
|
|
11831
|
-
});
|
|
11832
|
-
const minimumSdkVersion = await resolveMinimumSdkVersion({
|
|
11833
|
-
cacheDir: options.cacheDir ?? paths.cache,
|
|
11834
|
-
environment: options.environment,
|
|
11835
|
-
fetchMinimumSdkVersion: async () => {
|
|
11836
|
-
const request = createUserMiniprogramPublicSdkConfigRequest(serviceTag);
|
|
11837
|
-
const url = new URL(request.path, options.environment);
|
|
11838
|
-
for (const [key, value] of Object.entries(request.searchParams)) {
|
|
11839
|
-
url.searchParams.set(key, value);
|
|
11840
|
-
}
|
|
11841
|
-
const response = await fetchImpl(url, {
|
|
11842
|
-
headers: request.headers,
|
|
11843
|
-
});
|
|
11844
|
-
if (!response.ok) {
|
|
11845
|
-
throw new Error('公共 SDK 配置响应无效');
|
|
11846
|
-
}
|
|
11847
|
-
return parseUserMiniprogramPublicSdkConfigEnvelope(await response.json())
|
|
11848
|
-
.minimum_sdk_version;
|
|
11849
|
-
},
|
|
11850
|
-
});
|
|
11851
|
-
return validateCurrentSdkVersion(options.sdkVersion, minimumSdkVersion, { allowPrerelease: options.allowPrerelease });
|
|
11852
|
-
}
|
|
11853
|
-
|
|
11854
|
-
const HEYBOX_API_BASE_URL = 'https://api.xiaoheihe.cn';
|
|
11855
|
-
const TRUSTED_HEYBOX_API_HOST_SUFFIXES = ['.xiaoheihe.cn', '.debugmode.cn'];
|
|
11856
|
-
function resolveHeyboxApiBaseUrl(options = {}) {
|
|
11857
|
-
const env = options.env;
|
|
11858
|
-
const baseUrl = normalizeHeyboxOriginUrl(options.apiBaseUrl ?? env?.HB_SDK_API_BASE_URL ?? HEYBOX_API_BASE_URL, 'Heybox API baseUrl');
|
|
11859
|
-
assertSafeHeyboxApiBaseUrl(baseUrl, {
|
|
11860
|
-
allowUnsafeApiBaseUrl: options.allowUnsafeApiBaseUrl === true || isTruthyEnvFlag(env?.HB_SDK_ALLOW_UNSAFE_API_BASE_URL),
|
|
11861
|
-
});
|
|
11862
|
-
return baseUrl;
|
|
11863
|
-
}
|
|
11864
|
-
function normalizeHeyboxOriginUrl(value, label) {
|
|
11865
|
-
const raw = String(value ?? '').trim();
|
|
11866
|
-
if (!raw) {
|
|
11867
|
-
throw new Error(`${label} 不能为空`);
|
|
11868
|
-
}
|
|
11869
|
-
let url;
|
|
11870
|
-
try {
|
|
11871
|
-
url = new URL(raw);
|
|
11872
|
-
}
|
|
11873
|
-
catch {
|
|
11874
|
-
throw new Error(`${label} 必须是合法的 http(s) origin:${raw}`);
|
|
11875
|
-
}
|
|
11876
|
-
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
11877
|
-
throw new Error(`${label} 只支持 http(s) 协议:${raw}`);
|
|
11878
|
-
}
|
|
11879
|
-
if (url.username || url.password) {
|
|
11880
|
-
throw new Error(`${label} 不允许包含用户名或密码:${raw}`);
|
|
11881
|
-
}
|
|
11882
|
-
const rawSuffix = raw.match(/^[a-z][a-z\d+.-]*:\/\/[^/?#]+(.*)$/i)?.[1] ?? '';
|
|
11883
|
-
if ((rawSuffix && rawSuffix !== '/') || url.search || url.hash) {
|
|
11884
|
-
throw new Error(`${label} 只支持 origin,不允许包含 path、query 或 hash:${raw}`);
|
|
11885
|
-
}
|
|
11886
|
-
return url.origin;
|
|
11887
|
-
}
|
|
11888
|
-
function assertSafeHeyboxApiBaseUrl(origin, options) {
|
|
11889
|
-
if (options.allowUnsafeApiBaseUrl) {
|
|
11890
|
-
return;
|
|
11891
|
-
}
|
|
11892
|
-
const url = new URL(origin);
|
|
11893
|
-
if (url.protocol !== 'https:' || !isTrustedHeyboxApiHost(url.hostname)) {
|
|
11894
|
-
throw new Error('Heybox API baseUrl 默认只允许 Heybox 受信 HTTPS origin;本地调试请显式使用 --allow-unsafe-api-base-url 或 HB_SDK_ALLOW_UNSAFE_API_BASE_URL=1');
|
|
11895
|
-
}
|
|
11896
|
-
}
|
|
11897
|
-
function isTrustedHeyboxApiHost(hostname) {
|
|
11898
|
-
return TRUSTED_HEYBOX_API_HOST_SUFFIXES.some((suffix) => hostname === suffix.slice(1) || hostname.endsWith(suffix));
|
|
11899
|
-
}
|
|
11900
|
-
function isTruthyEnvFlag(value) {
|
|
11901
|
-
return ['1', 'true', 'yes', 'on'].includes(String(value ?? '')
|
|
11902
|
-
.trim()
|
|
11903
|
-
.toLowerCase());
|
|
11904
|
-
}
|
|
11905
|
-
|
|
11906
11580
|
const sdkVersionPlaceholder = ['__HB_SDK', 'VERSION__'].join('_');
|
|
11907
11581
|
const sdkVersionBuildConstant = ['__HB_SDK_BUILD', 'VERSION__'].join('_');
|
|
11908
|
-
function miniappManifest(
|
|
11582
|
+
function miniappManifest() {
|
|
11909
11583
|
let root = process.cwd();
|
|
11910
11584
|
let outDir = 'dist';
|
|
11911
11585
|
let command = 'build';
|
|
@@ -11929,22 +11603,6 @@ function miniappManifest(options = {}) {
|
|
|
11929
11603
|
command = resolved.command;
|
|
11930
11604
|
hmrWebSocketUrl = resolveHmrWebSocketUrl(resolved);
|
|
11931
11605
|
},
|
|
11932
|
-
async buildStart() {
|
|
11933
|
-
if (command !== 'build' || process.env.HB_SDK_DEPLOY_BUILD === '1')
|
|
11934
|
-
return;
|
|
11935
|
-
try {
|
|
11936
|
-
await (options.enforceSdkVersion ?? enforceViteSdkVersion)({
|
|
11937
|
-
sdkVersion: resolveSdkVersion(),
|
|
11938
|
-
environment: resolveHeyboxApiBaseUrl({ env: process.env }),
|
|
11939
|
-
serviceTag: process.env.HB_SDK_SERVICE_TAG,
|
|
11940
|
-
allowPrerelease: true,
|
|
11941
|
-
});
|
|
11942
|
-
}
|
|
11943
|
-
catch (error) {
|
|
11944
|
-
priorBuildError = toError(error);
|
|
11945
|
-
throw priorBuildError;
|
|
11946
|
-
}
|
|
11947
|
-
},
|
|
11948
11606
|
buildEnd(error) {
|
|
11949
11607
|
if (error) {
|
|
11950
11608
|
priorBuildError = priorBuildError ?? toError(error);
|
package/package.json
CHANGED
package/skill/SKILL.md
CHANGED
|
@@ -52,14 +52,14 @@ Apply these instructions when writing, reviewing, or debugging code that consume
|
|
|
52
52
|
2. Use `hb-sdk dev` for local browser debugging through the built-in mock runtime host. The project must bind `package.json.heybox.miniProgramId` and the CLI must be logged in so dev can load the real Runtime permission snapshot before starting Vite.
|
|
53
53
|
3. Use `hb-sdk remote ...` for developer-owned remote mini-program management. Top-level `hb-sdk deploy` has been hard-cut and must not be recommended as a compatibility alias.
|
|
54
54
|
4. Use `hb-sdk remote entity list`, `hb-sdk remote entity current`, and `hb-sdk remote entity switch <entity-id>` to inspect or change the developer platform server-side current entity before remote management commands.
|
|
55
|
-
5. Use `hb-sdk remote create` to create a remote mini-program under the server-side current entity and bind the returned id into `package.json.heybox.miniProgramId`; use `hb-sdk remote bind <mini-program-id>` to bind an existing remote mini-program after current-entity manageability is verified.
|
|
55
|
+
5. Use `hb-sdk remote create` to create a remote mini-program under the server-side current entity and bind the returned id into `package.json.heybox.miniProgramId`; use `hb-sdk remote bind <mini-program-id>` to bind an existing remote mini-program after current-entity manageability is verified. CLI project configuration contains only `package.json.heybox.miniProgramId`; mini-program name, icon, and cover images are maintained on the Open platform version-publish flow. On first submit without prior approved profile, the server injects a default name and default images.
|
|
56
56
|
6. Use `hb-sdk remote info`, `hb-sdk remote list`, `hb-sdk remote access`, `hb-sdk remote versions`, `hb-sdk remote preview <version>`, and `hb-sdk remote allowlist ...` for read/basic/preview management workflows. Mini-program name and image changes must go through version audit, so the CLI must not expose a basic-info update command.
|
|
57
57
|
7. Use `hb-sdk remote deploy --release-note <text>` to build, upload, and submit the current project for audit. It reads `package.json.heybox.miniProgramId`, validates that the bound mini-program belongs to the server-side current entity before precheck/build/upload, prechecks `package.json.version` before build, runs the project's `build` script via the package manager auto-detected by lockfile, uploads `dist/` to CDN (skipping `manifest.json`, `.DS_Store`, `.map`), then calls the submit-audit API. Deploy and `--from-version` do not fetch or compare the client-side `minimumSdkVersion`; Manifest validation and server-side precheck / submit-audit policy still apply. When `--env <name>` or `HB_SDK_ENV=<name>` selects an environment preset, deploy also passes the same name to the project build as its Vite mode. The deploy upload pipeline rejects actual upload artifacts over 100MiB before any upload request, processes CDN upload metadata and callback confirmation at 50 files per batch, keeps 4-way upload concurrency within each batch, and validates CDN-returned keys exactly against the local expected upload keys.
|
|
58
58
|
8. Use `hb-sdk remote deploy --from-version <version> --release-note <text>` to reuse a previously uploaded remote version artifact and submit a new audit version without reading local `dist`, building, or uploading.
|
|
59
59
|
9. Always provide a concise release note before deploy. Non-interactive environments must pass `--release-note`; interactive terminals may prompt for it. The default is manual release after approval with `hb-sdk remote release <version>`; use `--auto-publish` when the audited version should automatically release after approval.
|
|
60
60
|
10. Use `hb-sdk remote release <version>`, `hb-sdk remote withdraw <version>`, `hb-sdk remote take-down`, and `hb-sdk remote reopen` for dangerous remote changes. Interactive terminals should confirm after showing enough context; non-interactive environments must pass `--yes`.
|
|
61
61
|
11. For internal test/staging backend operations, use origin-only custom URLs: `HB_SDK_API_BASE_URL` or `hb-sdk remote ... --api-base-url <url>` for remote platform APIs, and `HB_SDK_LOGIN_BASE_URL` or `hb-sdk login --login-base-url <url>` for browser login. CLI flags override env vars. API base URLs must be Heybox trusted HTTPS origins by default; use `--allow-unsafe-api-base-url` or `HB_SDK_ALLOW_UNSAFE_API_BASE_URL=1` only for local backend debugging. Do not include path, query, or hash in these URLs.
|
|
62
|
-
12. For development routing or gray validation, use `HB_SDK_SERVICE_TAG` to attach `x-rylai-service-tag` and the matching `special_tag` query parameter to CLI backend requests
|
|
62
|
+
12. For development routing or gray validation, use `HB_SDK_SERVICE_TAG` to attach `x-rylai-service-tag` and the matching `special_tag` query parameter to CLI backend requests. Repository-local path-specific routing can still be configured in `packages/hb-sdk/src/cli/config.ts` with `@heybox/hb-types` `RylaiServiceTagConfig` (`default_tag` / path-specific `special_tag`).
|
|
63
63
|
13. If a remote command targets a custom login environment, pass the same `--login-base-url` or `HB_SDK_LOGIN_BASE_URL` used for `hb-sdk login`; remote commands reject cached CLI login state from a different login origin.
|
|
64
64
|
14. Add `--verbose` / `-v` only when diagnosing failures; default CLI errors are intentionally concise, while verbose output includes backend envelope, HTTP status, trace fields, raw body, or original submit-audit failure details.
|
|
65
65
|
15. Use `--json` for script consumption of `hb-sdk remote` commands. With `--json`, stdout must contain exactly one JSON object; progress, warnings, update reminders, and verbose diagnostics must not pollute stdout.
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
## Package metadata
|
|
20
20
|
|
|
21
21
|
- Package: `@heybox/hb-sdk`
|
|
22
|
-
- Version at generation time: `0.6.
|
|
22
|
+
- Version at generation time: `0.6.3`
|
|
23
23
|
- Public root export: `@heybox/hb-sdk`
|
|
24
24
|
- Protocol export: `@heybox/hb-sdk/protocol`
|
|
25
25
|
- Vite plugin export: `@heybox/hb-sdk/vite`
|
|
@@ -203,25 +203,17 @@ import { HB_SDK_VERSION } from '../core/version';
|
|
|
203
203
|
import { renderMiniappManifest, validateMiniappPackageVersionForBuild } from '../miniapp-manifest/schema';
|
|
204
204
|
import { readMiniappVersionFromPackageJson } from '../miniapp-manifest/node';
|
|
205
205
|
import { enforceMiniappHtmlPolicy } from './html-policy';
|
|
206
|
-
import { enforceViteSdkVersion as defaultEnforceRemoteSdkVersion } from './sdk-version-gate';
|
|
207
|
-
import { resolveHeyboxApiBaseUrl } from '../cli/auth/base-url';
|
|
208
206
|
|
|
209
207
|
type MiniappManifestPlugin = {
|
|
210
208
|
name: string;
|
|
211
209
|
config: (config: MiniappManifestUserConfig) => MiniappManifestUserConfig | void;
|
|
212
210
|
configResolved: (resolved: MiniappManifestResolvedConfig) => void;
|
|
213
|
-
buildStart: () => Promise<void>;
|
|
214
211
|
/** Rollup 在构建失败后仍会跑 closeBundle;用 buildEnd 记录真实错误,避免二次校验掩盖原因。 */
|
|
215
212
|
buildEnd: (error?: Error) => void;
|
|
216
213
|
transformIndexHtml: (html: string) => string;
|
|
217
214
|
closeBundle: (this: MiniappManifestPluginContext) => Promise<void>;
|
|
218
215
|
};
|
|
219
216
|
|
|
220
|
-
export interface MiniappManifestOptions {
|
|
221
|
-
/** 仅供平台测试和自托管 Remote Environment adapter 使用。 */
|
|
222
|
-
enforceSdkVersion?: typeof defaultEnforceRemoteSdkVersion;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
217
|
interface MiniappManifestUserConfig {
|
|
226
218
|
base?: string;
|
|
227
219
|
define?: Record<string, string>;
|
|
@@ -254,7 +246,7 @@ interface MiniappManifestResolvedConfig {
|
|
|
254
246
|
const sdkVersionPlaceholder = ['__HB_SDK', 'VERSION__'].join('_');
|
|
255
247
|
const sdkVersionBuildConstant = ['__HB_SDK_BUILD', 'VERSION__'].join('_');
|
|
256
248
|
|
|
257
|
-
export function miniappManifest(
|
|
249
|
+
export function miniappManifest(): MiniappManifestPlugin {
|
|
258
250
|
let root = process.cwd();
|
|
259
251
|
let outDir = 'dist';
|
|
260
252
|
let command: 'build' | 'serve' = 'build';
|
|
@@ -279,20 +271,6 @@ export function miniappManifest(options: MiniappManifestOptions = {}): MiniappMa
|
|
|
279
271
|
command = resolved.command;
|
|
280
272
|
hmrWebSocketUrl = resolveHmrWebSocketUrl(resolved);
|
|
281
273
|
},
|
|
282
|
-
async buildStart() {
|
|
283
|
-
if (command !== 'build' || process.env.HB_SDK_DEPLOY_BUILD === '1') return;
|
|
284
|
-
try {
|
|
285
|
-
await (options.enforceSdkVersion ?? defaultEnforceRemoteSdkVersion)({
|
|
286
|
-
sdkVersion: resolveSdkVersion(),
|
|
287
|
-
environment: resolveHeyboxApiBaseUrl({ env: process.env }),
|
|
288
|
-
serviceTag: process.env.HB_SDK_SERVICE_TAG,
|
|
289
|
-
allowPrerelease: true,
|
|
290
|
-
});
|
|
291
|
-
} catch (error) {
|
|
292
|
-
priorBuildError = toError(error);
|
|
293
|
-
throw priorBuildError;
|
|
294
|
-
}
|
|
295
|
-
},
|
|
296
274
|
buildEnd(error) {
|
|
297
275
|
if (error) {
|
|
298
276
|
priorBuildError = priorBuildError ?? toError(error);
|
|
@@ -404,7 +382,7 @@ export default defineConfig({
|
|
|
404
382
|
|
|
405
383
|
插件只接受单页应用:输出目录只能存在入口 `index.html`。build 会用结构化 HTML parser 校验入口,并把平台 CSP 插入 `<head>` 首位;已有 CSP 会原样保留,两份策略按浏览器交集生效。正式策略禁止 `fetch`、XHR、WebSocket、EventSource、Beacon、Worker、iframe、表单和对象加载等浏览器原生出口;业务网络请求应使用 `network.request()`。dev 使用相同策略,只额外放行当前 Vite 的精确 HMR WebSocket 地址。
|
|
406
384
|
|
|
407
|
-
meta refresh、外部 anchor、`dns-prefetch`、`preconnect`、`prerender`、外部资源 URL 和额外 HTML 会使 build 失败。内联 script/style 允许,但 `unsafe-eval` 不允许。`dev` 和手动 Vite build
|
|
385
|
+
meta refresh、外部 anchor、`dns-prefetch`、`preconnect`、`prerender`、外部资源 URL 和额外 HTML 会使 build 失败。内联 script/style 允许,但 `unsafe-eval` 不允许。`dev` 和手动 Vite build 不再请求远端最低 SDK 版本;构建仍会把当前 `sdkVersion` 写入 Manifest,`hb-sdk remote deploy` 仍校验 Manifest 结构并经过服务端 precheck / submit-audit 策略。
|
|
408
386
|
|
|
409
387
|
失败与警告语义:
|
|
410
388
|
|
package/skill/references/cli.md
CHANGED
|
@@ -165,11 +165,11 @@ HB_SDK_ALLOW_UNSAFE_API_BASE_URL=1 hb-sdk remote deploy --api-base-url http://12
|
|
|
165
165
|
|
|
166
166
|
`manifest.json` 仅作为提交审核接口的 `manifest` 字段提交,不会上传到 CDN。Vite 项目通过 `miniappManifest()` 插件生成;CLI 不会自动注入插件,请在 `vite.config.ts` 中显式挂载。小程序构建产物需要使用相对资源路径;`hb-sdk create` 模板会显式配置 `base: './'`,未配置 `base` 的项目也会由 `miniappManifest()` 在 build 时默认补成 `./`。构建产物只能在兼容的小黑盒 Runtime 中启动,普通浏览器直接打开时不会执行标准业务脚本。
|
|
167
167
|
|
|
168
|
-
`remote deploy` 的本地构建和 `--from-version` 路径都不执行客户端 `minimumSdkVersion` 查询或比较;Manifest 结构校验、版本 precheck 和服务端 submit-audit
|
|
168
|
+
`dev`、手动 Vite build、`remote deploy` 的本地构建和 `--from-version` 路径都不执行客户端 `minimumSdkVersion` 查询或比较;Manifest 结构校验、版本 precheck 和服务端 submit-audit 策略仍然生效。
|
|
169
169
|
|
|
170
170
|
默认发布策略是 `auto_publish=false`:运营审核通过后使用 `hb-sdk remote versions` 查看版本状态,再用 `hb-sdk remote release <version>` 发布。需要审核通过后自动发布并下架旧线上版本时,使用 `--auto-publish`。如需让指定用户预览未发布候选版本,使用 `hb-sdk remote allowlist add <heybox_id>` 管理预览白名单。
|
|
171
171
|
|
|
172
|
-
内部测试或预发环境可通过 `HB_SDK_API_BASE_URL` / `HB_SDK_LOGIN_BASE_URL` 设置默认后台环境,也可以用 `--api-base-url` / `--login-base-url` 覆盖单次命令。自定义地址只接受 origin,不允许包含 path、query 或 hash;API origin 默认还必须是 Heybox 受信 HTTPS 域名,只有本地联调等场景可显式使用 `--allow-unsafe-api-base-url` 或 `HB_SDK_ALLOW_UNSAFE_API_BASE_URL=1` 放开。`apiBaseUrl` 影响 `hb-sdk remote` 里的远端平台后台 API,包括预检、CDN 上传凭证/回调、提交审核、版本、发布、撤回、下架、重新上架、详情和白名单等调用;`loginBaseUrl` 用于 `hb-sdk login` 的登录入口,以及 remote 命令前校验当前 CLI 登录态是否属于同一个登录环境。开发环境如需给后台请求带 `x-rylai-service-tag` 和 `special_tag`,优先用 `--service-tag <tag>` 或 `HB_SDK_SERVICE_TAG
|
|
172
|
+
内部测试或预发环境可通过 `HB_SDK_API_BASE_URL` / `HB_SDK_LOGIN_BASE_URL` 设置默认后台环境,也可以用 `--api-base-url` / `--login-base-url` 覆盖单次命令。自定义地址只接受 origin,不允许包含 path、query 或 hash;API origin 默认还必须是 Heybox 受信 HTTPS 域名,只有本地联调等场景可显式使用 `--allow-unsafe-api-base-url` 或 `HB_SDK_ALLOW_UNSAFE_API_BASE_URL=1` 放开。`apiBaseUrl` 影响 `hb-sdk remote` 里的远端平台后台 API,包括预检、CDN 上传凭证/回调、提交审核、版本、发布、撤回、下架、重新上架、详情和白名单等调用;`loginBaseUrl` 用于 `hb-sdk login` 的登录入口,以及 remote 命令前校验当前 CLI 登录态是否属于同一个登录环境。开发环境如需给后台请求带 `x-rylai-service-tag` 和 `special_tag`,优先用 `--service-tag <tag>` 或 `HB_SDK_SERVICE_TAG`。path-prefix 级 `special_tag` 仍可在 `packages/hb-sdk/src/cli/config.ts` 里按 `@heybox/hb-types` 的 `RylaiServiceTagConfig` 配置。日志只输出 origin,不输出带身份和签名参数的完整请求 URL。
|
|
173
173
|
|
|
174
174
|
`hb-sdk doctor`、npm latest 检查、mock host 的 `network.request()` 不受这些配置影响。
|
|
175
175
|
|
|
@@ -256,20 +256,7 @@ hb-sdk remote square show
|
|
|
256
256
|
|
|
257
257
|
`hb-sdk remote create` 会创建远端工坊小程序并写入当前项目绑定;已有绑定时必须传 `--force-bind` 才能覆盖。`hb-sdk remote bind <mini-program-id>` 会先校验当前 CLI 用户可管理目标小程序,再写入本地配置;`--force` 只允许覆盖本地绑定,不跳过远端校验。
|
|
258
258
|
|
|
259
|
-
小程序名称、icon
|
|
260
|
-
|
|
261
|
-
```json
|
|
262
|
-
{
|
|
263
|
-
"heybox": {
|
|
264
|
-
"miniProgramId": "mp_xxxxxxxx",
|
|
265
|
-
"miniProgramProfile": {
|
|
266
|
-
"name": "我的小程序",
|
|
267
|
-
"iconUrl": "https://img.example.test/icon.png",
|
|
268
|
-
"coverImageUrls": ["https://img.example.test/cover.png"]
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
```
|
|
259
|
+
小程序名称、icon 和介绍图在开放平台「版本发布」中维护并随版本审核。CLI 项目配置只保留 `package.json.heybox.miniProgramId`;首次部署且没有历史审核资料时,服务端会使用默认名称「我的小程序」与平台默认图片。
|
|
273
260
|
|
|
274
261
|
`hb-sdk remote square hide` 会隐藏当前绑定小程序在普通用户侧的小程序工坊广场展示;白名单用户仍可在小程序工坊广场看到,直接链接访问已发布版本也不受影响。`hb-sdk remote square show` 会恢复普通用户侧的小程序工坊广场展示。
|
|
275
262
|
|
|
@@ -281,7 +268,7 @@ Agent rules:
|
|
|
281
268
|
|
|
282
269
|
- Use `hb-sdk remote entity list/current/switch` for developer entity inspection and switching.
|
|
283
270
|
- Use `hb-sdk remote create` for create-and-bind and `hb-sdk remote bind <mini-program-id>` for binding an existing manageable remote mini-program.
|
|
284
|
-
-
|
|
271
|
+
- Do not require or submit mini-program name/icon/cover from CLI; maintain them on Open version publish. CLI project configuration contains only `package.json.heybox.miniProgramId`.
|
|
285
272
|
- Explain that `remote create` creates under the current entity and that multi-entity non-TTY usage must confirm with `--yes`; `--yes` confirms current-entity usage but does not switch entities.
|
|
286
273
|
- Explain that `remote bind` verifies the mini-program is manageable by the current entity and does not write `package.json.heybox.miniProgramId` on entity mismatch.
|
|
287
274
|
- Use `hb-sdk remote info`, `hb-sdk remote access`, `hb-sdk remote list`, `hb-sdk remote versions`, `hb-sdk remote preview <version>`, `hb-sdk remote square show/hide`, and `hb-sdk remote allowlist ...` instead of sending users to Open when a matching CLI command exists.
|
|
@@ -398,7 +385,7 @@ npm run deploy
|
|
|
398
385
|
|
|
399
386
|
- `npm run dev`:启动本地 Vite 服务和 `hb-sdk` 内置 mock runtime host,适合本地调试 SDK 能力;调试页内可点击按钮在 Mac 版 APP 中启动同一页面,也可以选择局域网网卡后用手机小黑盒 APP 扫码调试。手机需要与电脑处在同一局域网,并使用支持小程序调试壳的新版小黑盒 APP。Codex、VSCode 等内嵌浏览器可能无法唤起系统 APP,需要时请在系统浏览器中打开同一个调试页后重试。
|
|
400
387
|
- `npm run build`:先执行 TypeScript 检查,再构建生产产物。
|
|
401
|
-
- `npm run deploy -- --release-note "..."`:运行 `hb-sdk remote deploy`,构建、上传并提交当前小程序版本审核。部署前需要先执行过 `npx hb-sdk login`;多主体账号还应通过 `npx hb-sdk remote entity current` 确认服务端 current entity。远端小程序可通过 `npx hb-sdk remote create` 在 current entity 下创建并绑定,或用 `npx hb-sdk remote bind <mini-program-id>` 绑定 current entity 可管理的已有小程序。小程序名称、icon
|
|
388
|
+
- `npm run deploy -- --release-note "..."`:运行 `hb-sdk remote deploy`,构建、上传并提交当前小程序版本审核。部署前需要先执行过 `npx hb-sdk login`;多主体账号还应通过 `npx hb-sdk remote entity current` 确认服务端 current entity。远端小程序可通过 `npx hb-sdk remote create` 在 current entity 下创建并绑定,或用 `npx hb-sdk remote bind <mini-program-id>` 绑定 current entity 可管理的已有小程序。小程序名称、icon 和介绍图在开放平台版本发布中维护;CLI 项目配置只保留 `heybox.miniProgramId`,首次部署服务端会使用默认名与默认图。`selectedEntity` 只是 CLI 登录缓存中的提示快照,实际 deploy/create/bind 以服务端 current entity 为准。默认审核通过后用 `hb-sdk remote versions` 查看状态,再用 `hb-sdk remote release <version>` 发布,如需审核通过后自动发布可追加 `--auto-publish`。顶层 `hb-sdk deploy` 已删除,不再作为兼容别名保留。
|
|
402
389
|
|
|
403
390
|
## 更多能力
|
|
404
391
|
|
|
@@ -429,7 +429,7 @@ Agent rules:
|
|
|
429
429
|
|
|
430
430
|
- Use \`hb-sdk remote entity list/current/switch\` for developer entity inspection and switching.
|
|
431
431
|
- Use \`hb-sdk remote create\` for create-and-bind and \`hb-sdk remote bind <mini-program-id>\` for binding an existing manageable remote mini-program.
|
|
432
|
-
-
|
|
432
|
+
- Do not require or submit mini-program name/icon/cover from CLI; maintain them on Open version publish. CLI project configuration contains only \`package.json.heybox.miniProgramId\`.
|
|
433
433
|
- Explain that \`remote create\` creates under the current entity and that multi-entity non-TTY usage must confirm with \`--yes\`; \`--yes\` confirms current-entity usage but does not switch entities.
|
|
434
434
|
- Explain that \`remote bind\` verifies the mini-program is manageable by the current entity and does not write \`package.json.heybox.miniProgramId\` on entity mismatch.
|
|
435
435
|
- Use \`hb-sdk remote info\`, \`hb-sdk remote access\`, \`hb-sdk remote list\`, \`hb-sdk remote versions\`, \`hb-sdk remote preview <version>\`, \`hb-sdk remote square show/hide\`, and \`hb-sdk remote allowlist ...\` instead of sending users to Open when a matching CLI command exists.
|
package/skill/skill.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hb-sdk",
|
|
3
|
-
"skillVersion": "0.6.
|
|
3
|
+
"skillVersion": "0.6.3+skill.e46d946d0d66",
|
|
4
4
|
"sdk": {
|
|
5
5
|
"package": "@heybox/hb-sdk",
|
|
6
|
-
"version": "0.6.
|
|
7
|
-
"compatibility": "0.6.
|
|
6
|
+
"version": "0.6.3",
|
|
7
|
+
"compatibility": "0.6.3"
|
|
8
8
|
},
|
|
9
9
|
"source": "https://open.xiaoheihe.cn/agent-skills/hb-sdk",
|
|
10
|
-
"integrity": "sha256-
|
|
10
|
+
"integrity": "sha256-e46d946d0d668d1f9fc60d49d0552ff3f7d8c15d69823e979b20307cdcb42a36"
|
|
11
11
|
}
|
|
@@ -2,7 +2,6 @@ export declare const MINIAPP_UPLOAD_SCOPE = "activity";
|
|
|
2
2
|
export declare const ACTIVITY_UPLOAD_KEY_MAX_LENGTH = 64;
|
|
3
3
|
export declare const MINIAPP_UPLOAD_BATCH_SIZE = 50;
|
|
4
4
|
export declare const MINIAPP_UPLOAD_TOTAL_SIZE_LIMIT_BYTES: number;
|
|
5
|
-
export declare const PUBLIC_USER_MINIPROGRAM_SDK_CONFIG_API_PATH = "/user_miniprogram/public/sdk_config";
|
|
6
5
|
export declare const USER_MINIPROGRAM_ACCESS_STATUS_API_PATH = "/mall/developer/user_miniprogram/access_status";
|
|
7
6
|
export declare const DEVELOPER_ENTITY_LIST_API_PATH = "/mall/developer/entity/list";
|
|
8
7
|
export declare const DEVELOPER_ENTITY_SWITCH_API_PATH = "/mall/developer/entity/switch";
|
package/types/vite/index.d.ts
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import { enforceViteSdkVersion as defaultEnforceRemoteSdkVersion } from './sdk-version-gate';
|
|
2
1
|
type MiniappManifestPlugin = {
|
|
3
2
|
name: string;
|
|
4
3
|
config: (config: MiniappManifestUserConfig) => MiniappManifestUserConfig | void;
|
|
5
4
|
configResolved: (resolved: MiniappManifestResolvedConfig) => void;
|
|
6
|
-
buildStart: () => Promise<void>;
|
|
7
5
|
/** Rollup 在构建失败后仍会跑 closeBundle;用 buildEnd 记录真实错误,避免二次校验掩盖原因。 */
|
|
8
6
|
buildEnd: (error?: Error) => void;
|
|
9
7
|
transformIndexHtml: (html: string) => string;
|
|
10
8
|
closeBundle: (this: MiniappManifestPluginContext) => Promise<void>;
|
|
11
9
|
};
|
|
12
|
-
export interface MiniappManifestOptions {
|
|
13
|
-
/** 仅供平台测试和自托管 Remote Environment adapter 使用。 */
|
|
14
|
-
enforceSdkVersion?: typeof defaultEnforceRemoteSdkVersion;
|
|
15
|
-
}
|
|
16
10
|
interface MiniappManifestUserConfig {
|
|
17
11
|
base?: string;
|
|
18
12
|
define?: Record<string, string>;
|
|
@@ -37,5 +31,5 @@ interface MiniappManifestResolvedConfig {
|
|
|
37
31
|
};
|
|
38
32
|
};
|
|
39
33
|
}
|
|
40
|
-
export declare function miniappManifest(
|
|
34
|
+
export declare function miniappManifest(): MiniappManifestPlugin;
|
|
41
35
|
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export interface HeyboxBaseUrlEnv extends NodeJS.ProcessEnv {
|
|
2
|
-
HB_SDK_API_BASE_URL?: string;
|
|
3
|
-
HB_SDK_ALLOW_UNSAFE_API_BASE_URL?: string;
|
|
4
|
-
HB_SDK_LOGIN_BASE_URL?: string;
|
|
5
|
-
}
|
|
6
|
-
export interface HeyboxBaseUrlResolveOptions {
|
|
7
|
-
env?: HeyboxBaseUrlEnv;
|
|
8
|
-
}
|
|
9
|
-
export interface HeyboxApiBaseUrlResolveOptions extends HeyboxBaseUrlResolveOptions {
|
|
10
|
-
allowUnsafeApiBaseUrl?: boolean;
|
|
11
|
-
apiBaseUrl?: string;
|
|
12
|
-
}
|
|
13
|
-
export interface HeyboxLoginBaseUrlResolveOptions extends HeyboxBaseUrlResolveOptions {
|
|
14
|
-
loginBaseUrl?: string;
|
|
15
|
-
}
|
|
16
|
-
export declare const HEYBOX_API_BASE_URL = "https://api.xiaoheihe.cn";
|
|
17
|
-
export declare const HEYBOX_LOGIN_BASE_URL = "https://login.xiaoheihe.cn";
|
|
18
|
-
export declare function resolveHeyboxApiBaseUrl(options?: HeyboxApiBaseUrlResolveOptions): string;
|
|
19
|
-
export declare function resolveHeyboxLoginBaseUrl(options?: HeyboxLoginBaseUrlResolveOptions): string;
|
|
20
|
-
export declare function normalizeHeyboxOriginUrl(value: string, label: string): string;
|
package/types/cli/config.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { RylaiServiceTagConfig } from '@heybox/hb-types';
|
|
2
|
-
export type HeyboxCliRequestConfig = RylaiServiceTagConfig;
|
|
3
|
-
export declare function configureHeyboxCliRequestConfig(config: HeyboxCliRequestConfig): void;
|
|
4
|
-
export declare function readHeyboxCliRequestConfig(): HeyboxCliRequestConfig;
|
|
5
|
-
/**
|
|
6
|
-
* 当 tag 为非空字符串时,把它设为 CLI 全局 default_tag;为空时不改动现有配置,
|
|
7
|
-
* 避免清掉 env 预设阶段已注入的值。
|
|
8
|
-
*/
|
|
9
|
-
export declare function applyServiceTagIfNeeded(tag: unknown): void;
|
|
10
|
-
export declare function resolveHeyboxRylaiServiceTag(pathWithQuery?: string, config?: RylaiServiceTagConfig): string | undefined;
|
|
11
|
-
export declare function normalizeHeyboxRylaiServiceTagConfig(config: HeyboxCliRequestConfig): RylaiServiceTagConfig;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare function resolveMinimumSdkVersion(options: {
|
|
2
|
-
cacheDir: string;
|
|
3
|
-
environment: string;
|
|
4
|
-
fetchMinimumSdkVersion: () => Promise<string>;
|
|
5
|
-
now?: number;
|
|
6
|
-
}): Promise<string>;
|
|
7
|
-
export declare function validateCurrentSdkVersion(currentSdkVersion: string, minimumSdkVersion: string, options: {
|
|
8
|
-
allowPrerelease: boolean;
|
|
9
|
-
}): string;
|