@bittersmilezzz/dsh-asr-voice 0.4.0 → 0.4.1

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/lib/client.js CHANGED
@@ -1219,8 +1219,23 @@ window.__ModuleLoader__.load({
1219
1219
  listeners.delete(fn);
1220
1220
  };
1221
1221
  }
1222
- /** settings namespace(host schema 注册与 client 绑定共用同一个名字)。 */
1223
- const ASR_VOICE_NS = "asr-voice";
1222
+ /**
1223
+ * settings namespace = host 半区 `cordis.patch.yml` 的 entry `id`(DSH 0.1.7 起
1224
+ * `SettingsForms.update/describe` 与 `ConfigForms.get` 都用这个字符串定位 entry,
1225
+ * 官方实现是 `entries().find(row => row.options.id === ns)`)。
1226
+ *
1227
+ * ⚠ 它**不是** npm 包名(本插件 npm 包名是 `@bittersmilezzz/dsh-asr-voice`),也不
1228
+ * 是文件里其它地方的插件短名。拿错字符串不会抛错:host 侧 update 抛
1229
+ * `No configurable plugin entry`(migrateLegacyKeys 只落一句 warn),client 侧
1230
+ * configForms.get 拿到 unavailable 快照 → 设置卡能渲染但**所有读写静默失效**。
1231
+ * 一致性由 test/entry-id-parity.test.mjs 钉住(读 cordis.patch.yml 的 id,并与
1232
+ * host 侧 `src/settings.ts` 的 `ASR_VOICE_SETTINGS_NAMESPACE` 三方比对)。
1233
+ *
1234
+ * 这里刻意**不再 import** host 侧的常量:client bundle 由 tsdown 打包,把
1235
+ * `src/settings.ts`(整棵 schemastery schema)拖进浏览器产物没有意义;用一个字面量
1236
+ * 加一条三方比对测试守住等价性,比共享导入更轻。
1237
+ */
1238
+ const ASR_VOICE_NS = "dsh-asr-voice";
1224
1239
  /** 把旧版凭据通道适配成新版形状(alpha.3 前的老运行时仍暴露旧面时兜底)。 */
1225
1240
  function adaptLegacyCredentials(legacy) {
1226
1241
  if (legacy === void 0) return void 0;
@@ -1509,6 +1524,10 @@ window.__ModuleLoader__.load({
1509
1524
  /** 保存草稿:只把真正改过的顶层段写回 host,然后**读回校验**。
1510
1525
  * `SettingsScope.set` 会把失败吞掉并重载宿主状态(promise 成功不代表落盘),所以
1511
1526
  * 判定标准只能是写完之后宿主那边到底剩什么——这也正是官方设置卡的做法。
1527
+ *
1528
+ * 两道防线:① `set` 返回 `false` = 宿主拒写/跳过,直接计入失败集合并提前返回段名,
1529
+ * 不等读回——因为拒写时宿主刚触发过一次状态重载,重载值恰好等于草稿时读回会算出
1530
+ * 「零变更」→ 静默报成功;② 读回校验兜住「set 说成功但宿主没留住」这一类。
1512
1531
  * @returns 未落盘的段名,undefined 表示全部落定。
1513
1532
  */
1514
1533
  async function writeDraft(draft) {
@@ -1526,7 +1545,17 @@ window.__ModuleLoader__.load({
1526
1545
  announce();
1527
1546
  return;
1528
1547
  }
1529
- for (const key of changed) await scope.set(key, draft[key]);
1548
+ const refused = [];
1549
+ for (const key of changed) {
1550
+ let accepted = false;
1551
+ try {
1552
+ accepted = await scope.set(key, draft[key]);
1553
+ } catch {
1554
+ accepted = false;
1555
+ }
1556
+ if (!accepted) refused.push(key);
1557
+ }
1558
+ if (refused.length > 0) return refused[0];
1530
1559
  mergeHostValue(draft);
1531
1560
  announce();
1532
1561
  const resolved = scope.getSnapshot().value;