@supersdk/supercli 0.1.1-staging.2 → 0.1.1-staging.4

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.
Files changed (34) hide show
  1. package/dist/commands/createApp.js +14 -58
  2. package/dist/commands/createApp.js.map +1 -1
  3. package/dist/commands/publishSite.js +286 -209
  4. package/dist/commands/publishSite.js.map +1 -1
  5. package/dist/createApp/copyTemplate.js +38 -53
  6. package/dist/createApp/copyTemplate.js.map +1 -1
  7. package/dist/publish/offlineVersion.js +33 -0
  8. package/dist/publish/offlineVersion.js.map +1 -0
  9. package/dist/publish/orgResolve.js +16 -17
  10. package/dist/publish/orgResolve.js.map +1 -1
  11. package/dist/publish/responseClassifier.js +17 -7
  12. package/dist/publish/responseClassifier.js.map +1 -1
  13. package/dist/publish/siteClient.js +19 -10
  14. package/dist/publish/siteClient.js.map +1 -1
  15. package/dist/publish/siteConfig.js +166 -124
  16. package/dist/publish/siteConfig.js.map +1 -1
  17. package/dist/template/README.md +11 -1
  18. package/dist/template/android/app/build.gradle.kts +6 -3
  19. package/dist/template/android/app/src/main/java/com/supersdk/simple/SimpleApplication.java +1 -1
  20. package/dist/template/android/gradle/supersdk-config-reader.gradle +2 -1
  21. package/dist/template/android/supersdk-default.config.json +3 -2
  22. package/dist/template/ios/MockSuperSDKPackage/Sources/SuperSDK/SuperSDK.swift +20 -4
  23. package/dist/template/ios/Sources/App/AppDelegate.swift +5 -1
  24. package/dist/template/ios/Sources/App/SimpleSDKBootstrap.swift +6 -2
  25. package/dist/template/ios/Sources/App/SimpleSDKProbe.swift +7 -4
  26. package/dist/template/ios/Tests/SimpleAppTests/SimpleSDKInitializationTests.swift +2 -1
  27. package/dist/template/scripts/build_ios.sh +13 -9
  28. package/dist/template/scripts/supersdk_template.py +15 -8
  29. package/dist/template/supersdk.yaml +3 -2
  30. package/dist/template/web/src/index.html +6 -2
  31. package/dist/template/web/src/js/app.js +6 -3
  32. package/dist/template/web/src/js/supersdk.js +229 -91
  33. package/dist/template/web/src/js/supersdk.provenance.json +3 -3
  34. package/package.json +1 -1
@@ -16,11 +16,11 @@ from web_host_validator import HostValidationError, normalize_host
16
16
  MANAGED_BY = "supersdk-template"
17
17
  MANAGED_CONFIG_SCHEMA_VERSION = 2
18
18
  MANAGED_SCHEMA_VERSION = MANAGED_CONFIG_SCHEMA_VERSION
19
- MANAGED_CONFIG_KEYS = ("managed_by", "schema_version", "app_id", "name", "platform", "version", "sdk", "platform_config")
19
+ MANAGED_CONFIG_KEYS = ("managed_by", "schema_version", "spid", "environment", "name", "platform", "version", "sdk", "platform_config")
20
20
  ANDROID_NAMESPACE = "com.supersdk.simple"
21
21
  ANDROID_VERSION_RE = r"^[0-9]+\.[0-9]+\.[0-9]+(?:[-.][A-Za-z0-9]+)*$"
22
22
  PLATFORMS = ("android", "ios", "web")
23
- ROOT_KEYS = {"schema_version", "app_id", "name", "android", "ios", "web", "version", "sdk"}
23
+ ROOT_KEYS = {"schema_version", "spid", "environment", "name", "android", "ios", "web", "version", "sdk"}
24
24
  NAMESPACE_KEYS = {
25
25
  "android": {"package"},
26
26
  "ios": {"bundleId", "spmMode"},
@@ -29,7 +29,8 @@ NAMESPACE_KEYS = {
29
29
  }
30
30
  SDK_KEYS = {"androidVersion", "iosPackageUrl", "iosVersion"}
31
31
  IOS_VERSION_PATTERN = r"^[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z.-]+)?$"
32
- APP_ID_PATTERN = r"[A-Za-z][A-Za-z0-9_-]{2,63}"
32
+ SPID_PATTERN = r"[a-z0-9]{8}"
33
+ ENVIRONMENT_PATTERN = r"[a-z0-9]{1,10}"
33
34
  BUNDLE_ID_PATTERN = r"[A-Za-z0-9][A-Za-z0-9-]*(\.[A-Za-z0-9][A-Za-z0-9-]*)+"
34
35
  SDK_PROJECTION = {
35
36
  "android": {"mock": ("androidVersion",), "real": ("androidVersion",)},
@@ -272,9 +273,13 @@ def validate_config(raw, selected=None):
272
273
 
273
274
  if type(raw.get("schema_version")) is not int or raw.get("schema_version") != 1:
274
275
  raise ConfigError("schema_version", "must be 1")
275
- app_id = require_string(raw.get("app_id"), "app_id")
276
- if not re.fullmatch(APP_ID_PATTERN, app_id):
277
- raise ConfigError("app_id", f"must match ^{APP_ID_PATTERN}$")
276
+ spid = require_string(raw.get("spid"), "spid")
277
+ if not re.fullmatch(SPID_PATTERN, spid):
278
+ raise ConfigError("spid", f"must match ^{SPID_PATTERN}$")
279
+ environment = raw.get("environment", "prod")
280
+ environment = require_string(environment, "environment")
281
+ if not re.fullmatch(ENVIRONMENT_PATTERN, environment):
282
+ raise ConfigError("environment", f"must match ^{ENVIRONMENT_PATTERN}$")
278
283
 
279
284
  name = raw.get("name", "SuperSDK Simple")
280
285
  name = require_string(name, "name")
@@ -330,7 +335,8 @@ def validate_config(raw, selected=None):
330
335
 
331
336
  return {
332
337
  "schema_version": 1,
333
- "app_id": app_id,
338
+ "spid": spid,
339
+ "environment": environment,
334
340
  "name": name,
335
341
  "platforms": {
336
342
  "android": {"package": android_package},
@@ -415,7 +421,8 @@ def target_content(normalized, platform):
415
421
  return {
416
422
  "managed_by": MANAGED_BY,
417
423
  "schema_version": MANAGED_CONFIG_SCHEMA_VERSION,
418
- "app_id": normalized["app_id"],
424
+ "spid": normalized["spid"],
425
+ "environment": normalized["environment"],
419
426
  "name": normalized["name"],
420
427
  "platform": platform,
421
428
  "version": normalized["version"],
@@ -1,5 +1,6 @@
1
1
  schema_version: 1
2
- app_id: Demo_App-01
2
+ spid: demo0001
3
+ environment: prod
3
4
  name: SuperSDK Simple
4
5
  android:
5
6
  package: com.supersdk.simple.host
@@ -12,4 +13,4 @@ version:
12
13
  name: "1.0.0"
13
14
  code: 1
14
15
  sdk:
15
- androidVersion: 1.0.0.43-SNAPSHOT
16
+ androidVersion: 1.0.0.54-SNAPSHOT
@@ -14,8 +14,12 @@
14
14
  <h1>SuperSDK Web</h1>
15
15
  <dl class="summary">
16
16
  <div>
17
- <dt>App ID</dt>
18
- <dd id="appId">-</dd>
17
+ <dt>SPID</dt>
18
+ <dd id="spid">-</dd>
19
+ </div>
20
+ <div>
21
+ <dt>Environment</dt>
22
+ <dd id="environment">-</dd>
19
23
  </div>
20
24
  <div>
21
25
  <dt>App Name</dt>
@@ -29,14 +29,16 @@
29
29
  function renderConfig(config) {
30
30
  var version = config && config.version ? config.version : {};
31
31
  var platformConfig = config && config.platform_config ? config.platform_config : {};
32
- text("appId", config && config.app_id);
32
+ text("spid", config && config.spid);
33
+ text("environment", config && config.environment);
33
34
  text("appName", config && config.name);
34
35
  text("host", platformConfig.host);
35
36
  text("version", version.name);
36
37
  }
37
38
 
38
39
  function renderEnv(env) {
39
- text("appId", env && env.aid);
40
+ text("spid", env && env.spid);
41
+ text("environment", env && env.environment);
40
42
  text("appName", env && env.appName);
41
43
  text("host", "-");
42
44
  text("version", env && env.appVersion);
@@ -69,7 +71,8 @@
69
71
  function runFallback() {
70
72
  return loadConfig().then(function(config) {
71
73
  window.SuperSDK.initFallback({
72
- aid: config.app_id,
74
+ spid: config.spid,
75
+ environment: config.environment,
73
76
  appName: config.name
74
77
  });
75
78
  clearDiagnostic();
@@ -14,6 +14,10 @@
14
14
  let _backPressedCallback = null;
15
15
 
16
16
  // 降级配置(initFallback 写入)
17
+ const DEFAULT_API_BASE_URL = 'https://api.supersdk.com/superapi';
18
+ const LAST_SUCCESS_BASE_URL_KEY = 'supersdk_last_success_base_url';
19
+ const SPID_PATTERN = /^[a-z0-9]{8}$/;
20
+ const ENVIRONMENT_PATTERN = /^[a-z0-9]{1,10}$/;
17
21
  let _fallbackConfig = null;
18
22
  let _deviceId = null;
19
23
 
@@ -71,43 +75,220 @@
71
75
  return _deviceId;
72
76
  }
73
77
 
78
+ function _normalizeBaseUrl(baseUrl) {
79
+ if (typeof baseUrl !== 'string') return '';
80
+ return baseUrl.trim().replace(/\/+$/, '');
81
+ }
82
+
83
+ function _normalizeLegacyBaseUrl(baseUrl) {
84
+ var normalized = _normalizeBaseUrl(baseUrl);
85
+ if (normalized && !/\/superapi$/.test(normalized)) {
86
+ return normalized + '/superapi';
87
+ }
88
+ return normalized;
89
+ }
90
+
91
+ function _dedupe(values) {
92
+ var seen = {};
93
+ var result = [];
94
+ values.forEach(function(value) {
95
+ if (!seen[value]) {
96
+ seen[value] = true;
97
+ result.push(value);
98
+ }
99
+ });
100
+ return result;
101
+ }
102
+
103
+ function _collectFallbackBaseUrls(fc) {
104
+ if (!fc) return [DEFAULT_API_BASE_URL];
105
+
106
+ var source;
107
+ var legacyBaseUrl = false;
108
+ if (Object.prototype.hasOwnProperty.call(fc, 'baseUrls')) {
109
+ source = fc.baseUrls;
110
+ } else if (Object.prototype.hasOwnProperty.call(fc, 'baseApi')) {
111
+ source = fc.baseApi;
112
+ } else if (Object.prototype.hasOwnProperty.call(fc, 'baseAPI')) {
113
+ source = fc.baseAPI;
114
+ } else if (Object.prototype.hasOwnProperty.call(fc, 'baseUrl')) {
115
+ source = fc.baseUrl;
116
+ legacyBaseUrl = true;
117
+ } else {
118
+ source = DEFAULT_API_BASE_URL;
119
+ }
120
+
121
+ var rawUrls = Array.isArray(source) ? source : [source];
122
+ var normalizer = legacyBaseUrl ? _normalizeLegacyBaseUrl : _normalizeBaseUrl;
123
+ return _dedupe(rawUrls.map(normalizer).filter(function(url) { return !!url; }));
124
+ }
125
+
126
+ function _readLastSuccessfulBaseUrl() {
127
+ try {
128
+ return localStorage.getItem(LAST_SUCCESS_BASE_URL_KEY) || '';
129
+ } catch (e) {
130
+ return '';
131
+ }
132
+ }
133
+
134
+ function _recordSuccessfulBaseUrl(baseUrl) {
135
+ var normalized = _normalizeBaseUrl(baseUrl);
136
+ if (!normalized) return;
137
+ try {
138
+ localStorage.setItem(LAST_SUCCESS_BASE_URL_KEY, normalized);
139
+ } catch (e) {
140
+ // localStorage 不可用时仅退化为本次随机/fallback。
141
+ }
142
+ }
143
+
144
+ function _shuffle(values) {
145
+ var result = values.slice();
146
+ for (var i = result.length - 1; i > 0; i--) {
147
+ var j = Math.floor(Math.random() * (i + 1));
148
+ var tmp = result[i];
149
+ result[i] = result[j];
150
+ result[j] = tmp;
151
+ }
152
+ return result;
153
+ }
154
+
155
+ function _getOrderedFallbackBaseUrls(fc) {
156
+ var candidates = _collectFallbackBaseUrls(fc);
157
+ var last = _normalizeBaseUrl(_readLastSuccessfulBaseUrl());
158
+ var index = candidates.indexOf(last);
159
+ if (index >= 0) {
160
+ candidates.splice(index, 1);
161
+ return [last].concat(_shuffle(candidates));
162
+ }
163
+ return _shuffle(candidates);
164
+ }
165
+
166
+ function _buildApiUrl(baseUrl, path) {
167
+ var normalizedBaseUrl = _normalizeBaseUrl(baseUrl);
168
+ var normalizedPath = path.charAt(0) === '/' ? path : '/' + path;
169
+ if (/\/superapi$/.test(normalizedBaseUrl) && normalizedPath.indexOf('/superapi') === 0) {
170
+ normalizedPath = normalizedPath.substring('/superapi'.length);
171
+ }
172
+ return normalizedBaseUrl + normalizedPath;
173
+ }
174
+
175
+ function _isPlainObject(value) {
176
+ return Object.prototype.toString.call(value) === '[object Object]';
177
+ }
178
+
179
+ function _throwFallbackConfigError(ErrorType, field, rule) {
180
+ console.error('[SuperSDK] initFallback invalid ' + field + ': ' + rule);
181
+ throw new ErrorType('initFallback ' + field + ' ' + rule);
182
+ }
183
+
184
+ function _buildValidatedFallbackConfig(config) {
185
+ if (!_isPlainObject(config)) {
186
+ _throwFallbackConfigError(TypeError, 'config', 'must be a plain object');
187
+ }
188
+ if (Object.prototype.hasOwnProperty.call(config, 'aid')) {
189
+ _throwFallbackConfigError(TypeError, 'aid', 'is unsupported; use spid');
190
+ }
191
+ if (!Object.prototype.hasOwnProperty.call(config, 'spid')) {
192
+ _throwFallbackConfigError(TypeError, 'spid', 'is required');
193
+ }
194
+
195
+ var candidate = Object.assign({
196
+ baseUrl: DEFAULT_API_BASE_URL,
197
+ spid: '',
198
+ environment: 'prod',
199
+ appName: '',
200
+ appIcon: '',
201
+ deviceId: ''
202
+ }, _fallbackConfig || {}, config);
203
+
204
+ if (typeof candidate.spid !== 'string' || !SPID_PATTERN.test(candidate.spid)) {
205
+ _throwFallbackConfigError(RangeError, 'spid', 'must match ^[a-z0-9]{8}$');
206
+ }
207
+ if (typeof candidate.environment !== 'string' || !ENVIRONMENT_PATTERN.test(candidate.environment)) {
208
+ _throwFallbackConfigError(RangeError, 'environment', 'must match ^[a-z0-9]{1,10}$');
209
+ }
210
+ return candidate;
211
+ }
212
+
213
+ function _sanitizedReportRoute(url) {
214
+ try {
215
+ var parsed = new URL(url);
216
+ return parsed.host + parsed.pathname;
217
+ } catch (e) {
218
+ return 'invalid-route';
219
+ }
220
+ }
221
+
222
+ function _logReportFailure(level, url, attempt, total, outcome) {
223
+ var message = '[SuperSDK] reportEvent ' + level
224
+ + ' request=reportEvent attempt=' + attempt + '/' + total
225
+ + ' route=' + _sanitizedReportRoute(url)
226
+ + ' outcome=' + outcome;
227
+ if (level === 'WARN') {
228
+ console.warn(message);
229
+ } else {
230
+ console.error(message);
231
+ }
232
+ }
233
+
74
234
  // 通过 fetch 直接上报事件到服务端
75
235
  function _reportEventViaFetch(eventName, params) {
76
236
  var fc = _fallbackConfig || {};
77
- if (!fc.baseUrl || !fc.aid) {
78
- return Promise.reject(new Error('reportEvent requires SuperSDK.initFallback() with baseUrl and aid'));
237
+ var baseUrls = _getOrderedFallbackBaseUrls(fc);
238
+ if (baseUrls.length === 0 || !fc.spid) {
239
+ return Promise.reject(new Error('reportEvent requires SuperSDK.initFallback() with baseUrl/baseUrls and spid'));
79
240
  }
80
241
 
81
242
  var payload = {
82
243
  basic_data: {
83
244
  device_id: fc.deviceId || _getOrCreateDeviceId(),
84
- app_id: fc.aid || '',
85
245
  os_type: 'web',
86
- host_aid: fc.aid || '',
246
+ host_spid: fc.spid,
247
+ env: fc.environment,
87
248
  source: 'web_fallback'
88
249
  },
89
250
  events: [{
90
251
  event_name: eventName,
91
- event_param: params ? JSON.stringify(params) : '',
252
+ // 自建 super-ea-collector 要求 event_param 为 JSON 对象(非字符串/数组/Date)。
253
+ // plain-object guard:排除 Array/Date/null/字符串/数字 等 → 一律落 {}(与 Android/iOS 对齐)。
254
+ event_param: (Object.prototype.toString.call(params) === '[object Object]') ? params : {},
92
255
  client_ts_ms: Date.now()
93
256
  }]
94
257
  };
95
258
 
96
- var baseUrl = fc.baseUrl.replace(/\/+$/, '');
97
- var apiBase = /\/superapi$/.test(baseUrl) ? baseUrl : baseUrl + '/superapi';
98
- var url = apiBase + '/rptEvent';
99
-
100
- return fetch(url, {
101
- method: 'POST',
102
- headers: { 'Content-Type': 'application/json' },
103
- body: JSON.stringify(payload)
104
- }).then(function(resp) {
105
- if (!resp.ok) {
106
- console.warn('[SuperSDK] reportEvent fallback HTTP error:', resp.status);
107
- }
108
- }).catch(function(e) {
109
- console.warn('[SuperSDK] reportEvent fallback failed:', e.message);
110
- });
259
+ function send(index) {
260
+ var baseUrl = baseUrls[index];
261
+ var url = _buildApiUrl(baseUrl, '/v2/reportEvent');
262
+ var attempt = index + 1;
263
+ var total = baseUrls.length;
264
+ return fetch(url, {
265
+ method: 'POST',
266
+ headers: {
267
+ 'Content-Type': 'application/json',
268
+ 'X-Aid': fc.spid,
269
+ 'X-Super-API-ENV': fc.environment
270
+ },
271
+ body: JSON.stringify(payload)
272
+ }).then(function(resp) {
273
+ if (resp.ok) {
274
+ _recordSuccessfulBaseUrl(baseUrl);
275
+ return;
276
+ }
277
+ if (index + 1 < baseUrls.length) {
278
+ _logReportFailure('WARN', url, attempt, total, 'http_' + resp.status);
279
+ return send(index + 1);
280
+ }
281
+ _logReportFailure('ERROR', url, attempt, total, 'http_' + resp.status);
282
+ }, function() {
283
+ if (index + 1 < baseUrls.length) {
284
+ _logReportFailure('WARN', url, attempt, total, 'network_error');
285
+ return send(index + 1);
286
+ }
287
+ _logReportFailure('ERROR', url, attempt, total, 'network_error');
288
+ });
289
+ }
290
+
291
+ return send(0);
111
292
  }
112
293
 
113
294
  // 生成唯一回调 ID
@@ -191,36 +372,27 @@
191
372
  const SDK = {
192
373
  /**
193
374
  * 初始化非端环境降级配置
194
- * 端内(有 appbridge)时调用被忽略
375
+ * 配置总是先校验;端内(有 appbridge)时合法配置随后被忽略
195
376
  * 多次调用采用 merge 语义,只更新本次传入的字段
196
377
  * @param {Object} config
197
- * @param {string} [config.baseUrl] - 服务端地址
198
- * @param {string} [config.aid] - 应用标识
378
+ * @param {string} [config.baseUrl] - 服务端地址(兼容旧字段)
379
+ * @param {string[]} [config.baseUrls] - 服务端地址列表,优先于 baseUrl
380
+ * @param {string|string[]} [config.baseApi] - 服务端地址或地址列表,优先级同 baseUrls
381
+ * @param {string} config.spid - 控制台签发的 8 位项目标识
382
+ * @param {string} [config.environment='prod'] - 项目环境
199
383
  * @param {string} [config.appName] - 应用名称
200
384
  * @param {string} [config.appIcon] - 应用图标 Base64
201
385
  * @param {string} [config.deviceId] - 设备标识,不传则自动生成
202
386
  */
203
387
  initFallback: function(config) {
388
+ var candidate = _buildValidatedFallbackConfig(config);
204
389
  if (global.appbridge) {
205
390
  return;
206
391
  }
207
392
 
208
- if (!_fallbackConfig) {
209
- _fallbackConfig = {
210
- baseUrl: 'https://api.supersdk.com/superapi',
211
- aid: '',
212
- appName: '',
213
- appIcon: '',
214
- deviceId: ''
215
- };
216
- }
217
-
218
- if (config) {
219
- Object.assign(_fallbackConfig, config);
220
- }
221
-
222
- if (_fallbackConfig.deviceId) {
223
- _deviceId = _fallbackConfig.deviceId;
393
+ _fallbackConfig = candidate;
394
+ if (candidate.deviceId) {
395
+ _deviceId = candidate.deviceId;
224
396
  }
225
397
  },
226
398
 
@@ -241,7 +413,8 @@
241
413
  if (!global.appbridge) {
242
414
  if (_fallbackConfig) {
243
415
  resolve({
244
- aid: _fallbackConfig.aid,
416
+ spid: _fallbackConfig.spid,
417
+ environment: _fallbackConfig.environment,
245
418
  appName: _fallbackConfig.appName,
246
419
  deviceId: _fallbackConfig.deviceId || _getOrCreateDeviceId(),
247
420
  os: 'web',
@@ -321,10 +494,11 @@
321
494
  },
322
495
 
323
496
  /**
324
- * 获取 SDK 配置(namespace=supersdk)
497
+ * 获取宿主配置
498
+ * @param {string} [configName] - 配置名称,不传则请求不带 configName
325
499
  * @returns {Promise<Object>}
326
500
  */
327
- getSDKSettings: function() {
501
+ getHostSettings: function(configName) {
328
502
  return new Promise((resolve, reject) => {
329
503
  if (!global.appbridge) {
330
504
  resolve({});
@@ -339,63 +513,22 @@
339
513
  reject(new Error(result.message || result.code));
340
514
  }
341
515
  }, 5000);
342
- global.appbridge.getSDKSettingsAsync(callbackId);
343
- });
344
- },
345
-
346
- /**
347
- * 根据 key 获取 SDK 配置
348
- * @param {string} key
349
- * @returns {Promise<Object>}
350
- */
351
- getSDKSettingsByKey: function(key) {
352
- return new Promise((resolve, reject) => {
353
- if (!global.appbridge) {
354
- resolve(null);
355
- return;
516
+ var normalizedConfigName = (typeof configName === 'string' && configName.trim()) ? configName.trim() : '';
517
+ if (normalizedConfigName && typeof global.appbridge.getHostSettingsByConfigNameAsync === 'function') {
518
+ global.appbridge.getHostSettingsByConfigNameAsync(normalizedConfigName, callbackId);
519
+ } else {
520
+ global.appbridge.getHostSettingsAsync(callbackId);
356
521
  }
357
- const callbackId = generateCallbackId();
358
- registerCallback(callbackId, (result) => {
359
- delete callbackMap[callbackId];
360
- if (result.code === 'SUCCESS') {
361
- resolve(result.data);
362
- } else {
363
- reject(new Error(result.message || result.code));
364
- }
365
- }, 5000);
366
- global.appbridge.getSDKSettingsByKeyAsync(key, callbackId);
367
- });
368
- },
369
-
370
- /**
371
- * 获取宿主配置(namespace=aid)
372
- * @returns {Promise<Object>}
373
- */
374
- getHostSettings: function() {
375
- return new Promise((resolve, reject) => {
376
- if (!global.appbridge) {
377
- resolve({});
378
- return;
379
- }
380
- const callbackId = generateCallbackId();
381
- registerCallback(callbackId, (result) => {
382
- delete callbackMap[callbackId];
383
- if (result.code === 'SUCCESS') {
384
- resolve(result.data);
385
- } else {
386
- reject(new Error(result.message || result.code));
387
- }
388
- }, 5000);
389
- global.appbridge.getHostSettingsAsync(callbackId);
390
522
  });
391
523
  },
392
524
 
393
525
  /**
394
526
  * 根据 key 获取宿主配置
395
527
  * @param {string} key
528
+ * @param {string} [configName] - 配置名称,不传则请求不带 configName
396
529
  * @returns {Promise<Object>}
397
530
  */
398
- getHostSettingsByKey: function(key) {
531
+ getHostSettingsByKey: function(key, configName) {
399
532
  return new Promise((resolve, reject) => {
400
533
  if (!global.appbridge) {
401
534
  resolve(null);
@@ -410,7 +543,12 @@
410
543
  reject(new Error(result.message || result.code));
411
544
  }
412
545
  }, 5000);
413
- global.appbridge.getHostSettingsByKeyAsync(key, callbackId);
546
+ var normalizedConfigName = (typeof configName === 'string' && configName.trim()) ? configName.trim() : '';
547
+ if (normalizedConfigName && typeof global.appbridge.getHostSettingsByConfigNameAndKeyAsync === 'function') {
548
+ global.appbridge.getHostSettingsByConfigNameAndKeyAsync(normalizedConfigName, key, callbackId);
549
+ } else {
550
+ global.appbridge.getHostSettingsByKeyAsync(key, callbackId);
551
+ }
414
552
  });
415
553
  },
416
554
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "source_path": "jssdk:supersdk.js",
3
- "source_sha256": "5a07b36511a7b3b003448c62b0e9a62233d42112be5aa0e607431458e326bf72",
4
- "source_version": "vendored-from-monorepo-2026-06-20",
5
- "vendored_sha256": "5a07b36511a7b3b003448c62b0e9a62233d42112be5aa0e607431458e326bf72"
3
+ "source_sha256": "ffbac25b6cd83f888ae55630044ecfaf9c7641a83472d007bfb1367cfffa1419",
4
+ "source_version": "vendored-from-monorepo-2026-07-30",
5
+ "vendored_sha256": "ffbac25b6cd83f888ae55630044ecfaf9c7641a83472d007bfb1367cfffa1419"
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supersdk/supercli",
3
- "version": "0.1.1-staging.2",
3
+ "version": "0.1.1-staging.4",
4
4
  "description": "SuperSDK official command-line tool: browser-authorized login and multi-account context for supercli commands.",
5
5
  "license": "UNLICENSED",
6
6
  "bin": {