dsh-effort-mosaic 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +1 -0
- package/lib/client.js +255 -57
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
按版本倒序。每条按「新增 / 修复 / 质量」归类;没有的分类省略。
|
|
4
4
|
|
|
5
|
+
## 1.2.2 — 2026-11-20
|
|
6
|
+
|
|
7
|
+
### 修复
|
|
8
|
+
|
|
9
|
+
- **切换模型后推理轨道偶尔空白**:`current.reasoningEffort` 可能还留着上一个模型的 id,旧逻辑直接拿它找下标会得到 `-1`,轨道进入未就绪状态。现在会先用当前模型的 `efforts` 校验,失效时回落到 `defaultEffort`;`default` / `auto` / `none` 只有不在当前档位表里时才当作“跟随默认”的占位值,真实声明的 `none` 档不再被误吞。
|
|
10
|
+
- **模型切换后目录桥仍读旧 store**:`createAccess` 现在每次读取、订阅、选择都重新解析 `directoryFor`;目录包装对象换了、内部 store 换了、连接重置都会重新订阅,清空旧快照并主动通知 React。新目录加载不再沿用旧目录的 400ms 节流,避免刚打开菜单就切模型时新目录被跳过。
|
|
11
|
+
- **轨道索引解析失败仍占 30px 空白**:只要当前模型确实声明了 `reasoning.efforts`,轨道就不会因为 `liveIndex` / 行文案暂时解析不出而完全隐藏;最后会先落在第一档,等快照或官方行文本回来再纠正。未就绪轨道高度收为 0,空容器 `display:none`,不再留下空白占位。
|
|
12
|
+
- **官方行文本和档位对象格式兼容性**:行文本支持 `推理等级 Max`、`Effort: Default`、尾部箭头、大小写混用;不会把 `Maximum` 误判成 `Max`。`efforts` 支持 `{ id, name }`、`{ id, label }` 和字符串数组,`current.model` 兼容字符串与 `{ id }` 对象。
|
|
13
|
+
- **模型换代时旧乐观状态串台**:切换模型会清掉上一代留下的 `draft`、待写档位和超时计时器,避免旧档位短暂盖在新模型轨道上,或把旧档位写进新模型;`teardownEntry` 也会摘掉官方行重建后遗留的空容器。
|
|
14
|
+
- **切模型后非最高档字符被误染蓝**:最高档染色现在只作用于当前最高档那一段文字,不再给卡片里所有档位名统一上蓝;乐观染色索引会绑定模型 id,刚把模型 A 拉到最高档就切到模型 B 时,B 的首帧直接按自己的真实档位绘制,不会先沿用 A 的最高档索引。
|
|
15
|
+
|
|
16
|
+
### 质量
|
|
17
|
+
|
|
18
|
+
- `node --check lib/client.js` 通过;离线检查覆盖 `Default` 回落、旧模型档位失效、真实 `none` 档、字符串档位、provider 重挂、对象模型 id、菜单行标签/箭头解析、目录切换、加载节流和快照身份稳定性。
|
|
19
|
+
- 发布包仍只包含运行文件:`lib/`、`cordis.patch.yml`、`icon.svg`、`package.json`、`README.md`、`CHANGELOG.md`、`LICENSE`。
|
|
20
|
+
|
|
5
21
|
## 1.2.1 — 2026-11-20
|
|
6
22
|
|
|
7
23
|
### 修复
|
package/README.md
CHANGED
|
@@ -148,6 +148,7 @@ README.md / LICENSE 说明与许可
|
|
|
148
148
|
|
|
149
149
|
完整记录见 [CHANGELOG.md](./CHANGELOG.md)。
|
|
150
150
|
|
|
151
|
+
- **1.2.2** — 修复切换模型后推理滑轨偶尔空白:旧 `reasoningEffort` 先用新模型的档位表校验,失效时回落 `defaultEffort`;目录换代时重新解析并订阅新 store,新目录不再被旧加载节流跳过;只要模型声明了档位,轨道就有兜底落点,不再留下 30px 空占位。另修复拉到最高档后立即切模型、新模型非最高档字符被旧最高档索引误染蓝的问题。
|
|
151
152
|
- **1.2.1** — 修复详情页面板在未注入 DSH 令牌的宿主里选中块纯黑、文字看不清、预览黑底;色带与粒子层改用同一条右端收口,拖拽 `scale / skew` 时不会在滑块右缘露出色轨;粒子引擎的逐帧 `clip-path` 不再把右侧重新放开。
|
|
152
153
|
- **1.2.0** — 详情页预览接入真实三档轨道与「拖拽动效 / 玻璃材质」开关;无感档位引擎将字符切换提前到视觉落位帧;修复玻璃上缘过厚、旋钮浅色环、轨道底缘硬黑线;修复输入胶囊 Max 染色先蓝后灰再蓝;发布包只保留运行文件。
|
|
153
154
|
- **1.1.9** — 补充 `screenshots.json` 与 `engines.dsh`,修复插件市场介绍页无截图、宿主要求显示未知。
|
package/lib/client.js
CHANGED
|
@@ -745,6 +745,8 @@ window.__ModuleLoader__.load({
|
|
|
745
745
|
插件若在这里自己画白底,深色主题下就会露出一条白块。 */
|
|
746
746
|
".dem-inline{box-sizing:border-box;flex-basis:100%;width:100%;min-width:0;background:transparent;"
|
|
747
747
|
+ "clip-path:inset(-12px 0 -12px 0)}",
|
|
748
|
+
/* 组件返回 null / 档位从有到无时,容器里没有子节点;不要让它继续占一行高度。 */
|
|
749
|
+
".dem-inline:empty{display:none}",
|
|
748
750
|
".dem-track{--dem-slot-bg:var(--dsw-alias-border-l1,color-mix(in srgb,var(--dsw-alias-label-primary,#0f1115) 8%,transparent));"
|
|
749
751
|
+ "position:relative;box-sizing:border-box;height:" + TRACK_HEIGHT + "px;margin:2px " + TRACK_INSET + "px 0;"
|
|
750
752
|
+ "border-radius:999px;"
|
|
@@ -957,8 +959,10 @@ window.__ModuleLoader__.load({
|
|
|
957
959
|
不能被当成换档过渡播出来。等这一帧画完(data-measured 翻 1)才恢复缓动。 */
|
|
958
960
|
".dem-track[data-measured='0'] .dem-knob,.dem-track[data-measured='0'] .dem-fill{transition:none}",
|
|
959
961
|
/* 目录快照还没给出真实档位时,整条轨道先不显示。否则会先画在 0 档,
|
|
960
|
-
等快照回来再滑到正确档位 —— 就是"每次打开浮层从最左端起步"的另一半根因。
|
|
961
|
-
|
|
962
|
+
等快照回来再滑到正确档位 —— 就是"每次打开浮层从最左端起步"的另一半根因。
|
|
963
|
+
同时把高度收成 0:只设 opacity 会留下一块 30px 的空白占位,
|
|
964
|
+
模型切换 / 索引未解析时看起来就是"轨道消失但菜单多了一块洞"。 */
|
|
965
|
+
".dem-track[data-ready='0']{opacity:0;pointer-events:none;height:0;margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0}",
|
|
962
966
|
".dem-track[data-dragging='1'] .dem-knob,.dem-track[data-dragging='1'] .dem-fill{transition:none}",
|
|
963
967
|
/* 吸附阶段位置由 `beginSettle` 的 rAF 逐帧写,再叠一层 CSS transition 就是双重缓动,
|
|
964
968
|
滑块和填充的插值曲线不同会互相追不上 —— 这一段两边都直接跟数值走。 */
|
|
@@ -1237,20 +1241,37 @@ window.__ModuleLoader__.load({
|
|
|
1237
1241
|
error: null,
|
|
1238
1242
|
});
|
|
1239
1243
|
|
|
1244
|
+
/** 当前模型 id:目录正常给字符串;兼容少数把 current.model 给成对象的宿主。 */
|
|
1245
|
+
function modelIdOf(value) {
|
|
1246
|
+
if (typeof value === "string") return value.trim();
|
|
1247
|
+
if (value && typeof value === "object") {
|
|
1248
|
+
if (typeof value.id === "string") return value.id.trim();
|
|
1249
|
+
if (typeof value.value === "string") return value.value.trim();
|
|
1250
|
+
}
|
|
1251
|
+
return "";
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1240
1254
|
/** 在目录快照里找到当前模型条目(groups[].models[])。 */
|
|
1241
1255
|
function modelOf(state) {
|
|
1242
1256
|
var current = state && state.current;
|
|
1243
|
-
|
|
1257
|
+
var wanted = modelIdOf(current && current.model);
|
|
1258
|
+
if (!current || typeof current.provider !== "string" || wanted.length === 0) return null;
|
|
1244
1259
|
var groups = state && Array.isArray(state.groups) ? state.groups : [];
|
|
1260
|
+
var fallback = null;
|
|
1245
1261
|
for (var i = 0; i < groups.length; i += 1) {
|
|
1246
1262
|
var group = groups[i];
|
|
1247
|
-
if (!group || group.
|
|
1248
|
-
var models =
|
|
1263
|
+
if (!group || !Array.isArray(group.models)) continue;
|
|
1264
|
+
var models = group.models;
|
|
1249
1265
|
for (var j = 0; j < models.length; j += 1) {
|
|
1250
|
-
|
|
1266
|
+
var model = models[j];
|
|
1267
|
+
if (!model || model.id !== wanted) continue;
|
|
1268
|
+
/* provider 目录项正常时优先取同一分组;目录正在重建、
|
|
1269
|
+
分组 id 暂时对不上时,至少按模型 id 找到唯一候选。 */
|
|
1270
|
+
if (group.id === current.provider) return model;
|
|
1271
|
+
if (fallback === null) fallback = model;
|
|
1251
1272
|
}
|
|
1252
1273
|
}
|
|
1253
|
-
return
|
|
1274
|
+
return fallback;
|
|
1254
1275
|
}
|
|
1255
1276
|
|
|
1256
1277
|
/**
|
|
@@ -1263,29 +1284,68 @@ window.__ModuleLoader__.load({
|
|
|
1263
1284
|
var out = [];
|
|
1264
1285
|
for (var i = 0; i < efforts.length; i += 1) {
|
|
1265
1286
|
var effort = efforts[i];
|
|
1287
|
+
/* 目录里通常是 { id, name };少数适配器会直接给字符串。
|
|
1288
|
+
两种都归一成同一种档位对象,避免"有档位但读不出来"。 */
|
|
1289
|
+
if (typeof effort === "string" && effort.trim().length > 0) {
|
|
1290
|
+
out.push({ id: effort.trim(), name: effort.trim() });
|
|
1291
|
+
continue;
|
|
1292
|
+
}
|
|
1266
1293
|
if (!effort || typeof effort.id !== "string" || effort.id.length === 0) continue;
|
|
1267
1294
|
out.push({
|
|
1268
1295
|
id: effort.id,
|
|
1269
|
-
name: typeof effort.name === "string" && effort.name.length > 0
|
|
1296
|
+
name: typeof effort.name === "string" && effort.name.length > 0
|
|
1297
|
+
? effort.name
|
|
1298
|
+
: (typeof effort.label === "string" && effort.label.length > 0 ? effort.label : effort.id),
|
|
1270
1299
|
});
|
|
1271
1300
|
}
|
|
1272
1301
|
return out;
|
|
1273
1302
|
}
|
|
1274
1303
|
|
|
1275
|
-
|
|
1304
|
+
function effortValueOf(value) {
|
|
1305
|
+
if (typeof value === "string") return value.trim();
|
|
1306
|
+
if (value && typeof value === "object") {
|
|
1307
|
+
if (typeof value.id === "string") return value.id.trim();
|
|
1308
|
+
if (typeof value.value === "string") return value.value.trim();
|
|
1309
|
+
if (typeof value.name === "string") return value.name.trim();
|
|
1310
|
+
}
|
|
1311
|
+
return "";
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
/** 当前**生效**的档位 id:显式设置优先,否则回落到模型的 defaultEffort。
|
|
1315
|
+
DSH 会把"跟随模型默认"写成 `default` / `auto`,这不是一个真实档位 id;
|
|
1316
|
+
如果直接拿它去 levels 里找下标,就会得到 -1,轨道进入"未就绪"状态并留下
|
|
1317
|
+
一块空白占位。这里先把这类占位值当作"未显式设置",再落回 defaultEffort。 */
|
|
1276
1318
|
function effectiveEffortId(state) {
|
|
1277
1319
|
var current = state && state.current;
|
|
1278
|
-
|
|
1279
|
-
return current.reasoningEffort;
|
|
1280
|
-
}
|
|
1320
|
+
var explicit = effortValueOf(current && current.reasoningEffort);
|
|
1281
1321
|
var model = modelOf(state);
|
|
1282
|
-
var
|
|
1283
|
-
|
|
1322
|
+
var levels = levelsOf(state);
|
|
1323
|
+
var explicitIsLevel = indexOfLevel(levels, explicit) >= 0;
|
|
1324
|
+
/* `none` 也可能是模型真实声明的档位;只有它不在当前档位表里时,
|
|
1325
|
+
才把 default / auto / none 当成"跟随默认"的占位值。 */
|
|
1326
|
+
var placeholder = /^(default|auto|none)$/i.test(explicit) && !explicitIsLevel;
|
|
1327
|
+
var fallback = effortValueOf(model && model.reasoning && model.reasoning.defaultEffort);
|
|
1328
|
+
if (!placeholder && explicit.length > 0) {
|
|
1329
|
+
/* 切模型时 current.reasoningEffort 可能还留着上一个模型的 id。
|
|
1330
|
+
这个 id 在新模型的 efforts 里不存在时不能直接拿去定位,
|
|
1331
|
+
否则会得到 -1,轨道再次变成空白;优先回到新模型的默认档。 */
|
|
1332
|
+
if (levels.length === 0 || explicitIsLevel) return explicit;
|
|
1333
|
+
}
|
|
1334
|
+
if (fallback.length > 0) return fallback;
|
|
1335
|
+
return null;
|
|
1284
1336
|
}
|
|
1285
1337
|
|
|
1286
1338
|
function indexOfLevel(levels, id) {
|
|
1287
1339
|
if (typeof id !== "string") return -1;
|
|
1288
|
-
|
|
1340
|
+
var needle = id.trim().toLowerCase();
|
|
1341
|
+
if (!needle) return -1;
|
|
1342
|
+
for (var i = 0; i < levels.length; i += 1) {
|
|
1343
|
+
var level = levels[i];
|
|
1344
|
+
if (!level) continue;
|
|
1345
|
+
var levelId = typeof level.id === "string" ? level.id.trim().toLowerCase() : "";
|
|
1346
|
+
var levelName = typeof level.name === "string" ? level.name.trim().toLowerCase() : "";
|
|
1347
|
+
if (levelId === needle || levelName === needle) return i;
|
|
1348
|
+
}
|
|
1289
1349
|
return -1;
|
|
1290
1350
|
}
|
|
1291
1351
|
|
|
@@ -1296,12 +1356,42 @@ window.__ModuleLoader__.load({
|
|
|
1296
1356
|
if (!row || typeof document === "undefined" || typeof document.createTreeWalker !== "function") return -1;
|
|
1297
1357
|
var walker = document.createTreeWalker(row, NodeFilter.SHOW_TEXT, null);
|
|
1298
1358
|
var node;
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1359
|
+
function normalize(value) {
|
|
1360
|
+
return (value || "").replace(/[\s\u00a0\u200b]+/g, " ").trim().toLowerCase();
|
|
1361
|
+
}
|
|
1362
|
+
function matches(value) {
|
|
1363
|
+
var text = normalize(value);
|
|
1364
|
+
if (!text) return -1;
|
|
1365
|
+
var candidates = [text];
|
|
1366
|
+
/* 有些宿主把标题和值渲染在同一个文本节点里:`推理等级 Default`
|
|
1367
|
+
或 `Effort: Default`。去掉标题前缀后再做一次精确匹配。 */
|
|
1368
|
+
for (var li = 0; li < EFFORT_ROW_LABELS.length; li += 1) {
|
|
1369
|
+
var label = normalize(EFFORT_ROW_LABELS[li]);
|
|
1370
|
+
if (text.indexOf(label) === 0) {
|
|
1371
|
+
candidates.push(normalize(text.slice(label.length).replace(/^[::·\-—\s]+/, "")));
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
/* 值后面常跟展开箭头 / 分隔符;把整段拆成独立 token 再匹配,
|
|
1375
|
+
避免 `Max` 被 `Maximum` 这类更长文案误命中。 */
|
|
1376
|
+
var pieces = text.split(/[^a-z0-9\u4e00-\u9fff]+/i);
|
|
1377
|
+
for (var pi = 0; pi < pieces.length; pi += 1) {
|
|
1378
|
+
if (pieces[pi]) candidates.push(pieces[pi]);
|
|
1379
|
+
}
|
|
1380
|
+
for (var ci = 0; ci < candidates.length; ci += 1) {
|
|
1381
|
+
if (!candidates[ci]) continue;
|
|
1382
|
+
for (var i = 0; i < levels.length; i += 1) {
|
|
1383
|
+
var level = levels[i];
|
|
1384
|
+
if (!level) continue;
|
|
1385
|
+
var id = normalize(level.id);
|
|
1386
|
+
var name = normalize(level.name);
|
|
1387
|
+
if ((id && id === candidates[ci]) || (name && name === candidates[ci])) return i;
|
|
1388
|
+
}
|
|
1304
1389
|
}
|
|
1390
|
+
return -1;
|
|
1391
|
+
}
|
|
1392
|
+
while ((node = walker.nextNode())) {
|
|
1393
|
+
var found = matches(node.nodeValue);
|
|
1394
|
+
if (found >= 0) return found;
|
|
1305
1395
|
}
|
|
1306
1396
|
return -1;
|
|
1307
1397
|
}
|
|
@@ -2992,10 +3082,12 @@ window.__ModuleLoader__.load({
|
|
|
2992
3082
|
function createAccess(ctx, sessionId) {
|
|
2993
3083
|
var listeners = new Set();
|
|
2994
3084
|
var directory = null;
|
|
3085
|
+
var activeStore = null;
|
|
2995
3086
|
var unsubscribe = null;
|
|
2996
3087
|
var last = EMPTY_SNAPSHOT;
|
|
2997
3088
|
var retryIndex = 0;
|
|
2998
3089
|
var retryTimer = null;
|
|
3090
|
+
var notifyTimer = null;
|
|
2999
3091
|
var closed = false;
|
|
3000
3092
|
var lastLoadAt = 0;
|
|
3001
3093
|
|
|
@@ -3007,6 +3099,16 @@ window.__ModuleLoader__.load({
|
|
|
3007
3099
|
}
|
|
3008
3100
|
}
|
|
3009
3101
|
|
|
3102
|
+
/* 目录换代本身也要通知 React:新 store 可能已经带着完整快照,
|
|
3103
|
+
如果只依赖它后续的 subscribe 回调,轨道会一直停在旧档位 / 空白占位上。 */
|
|
3104
|
+
function scheduleNotify() {
|
|
3105
|
+
if (closed || notifyTimer !== null) return;
|
|
3106
|
+
notifyTimer = window.setTimeout(function () {
|
|
3107
|
+
notifyTimer = null;
|
|
3108
|
+
notify();
|
|
3109
|
+
}, 0);
|
|
3110
|
+
}
|
|
3111
|
+
|
|
3010
3112
|
function scheduleRetry() {
|
|
3011
3113
|
if (closed || retryTimer !== null || retryIndex >= RETRY_DELAYS.length) return;
|
|
3012
3114
|
var delay = RETRY_DELAYS[retryIndex];
|
|
@@ -3027,23 +3129,38 @@ window.__ModuleLoader__.load({
|
|
|
3027
3129
|
fresh = null;
|
|
3028
3130
|
}
|
|
3029
3131
|
if (!fresh || !fresh.store || typeof fresh.store.getSnapshot !== "function") fresh = null;
|
|
3030
|
-
|
|
3132
|
+
/* 解析失败时保留旧目录,别把已经挂上的桥拆掉;下次读写会再试。 */
|
|
3133
|
+
if (fresh === null) return directory;
|
|
3134
|
+
if (fresh === directory && activeStore === fresh.store) return directory;
|
|
3135
|
+
/* 有些宿主在换模型代时只换 directory 包装对象、store 还是同一个;
|
|
3136
|
+
这种情况不要重新订阅、也不要清空快照,否则会白闪一下空白。 */
|
|
3137
|
+
if (directory !== null && fresh.store === activeStore) {
|
|
3138
|
+
directory = fresh;
|
|
3139
|
+
return directory;
|
|
3140
|
+
}
|
|
3031
3141
|
if (unsubscribe !== null) {
|
|
3032
3142
|
try { unsubscribe(); } catch (err) { /* 退订失败不影响新订阅 */ }
|
|
3033
3143
|
unsubscribe = null;
|
|
3034
3144
|
}
|
|
3035
3145
|
directory = fresh;
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3146
|
+
activeStore = fresh.store;
|
|
3147
|
+
/* 换代后旧快照里的 current / groups 不再可信;先清空,
|
|
3148
|
+
等新 store 的 load 回调回来再重新判定档位和轨道。 */
|
|
3149
|
+
last = EMPTY_SNAPSHOT;
|
|
3150
|
+
retryIndex = 0;
|
|
3151
|
+
/* 不要沿用旧目录的加载节流时间:刚打开菜单就切模型时,
|
|
3152
|
+
旧目录的 load 可能还在 400ms 窗口内,新目录会被误跳过,
|
|
3153
|
+
一直停在空快照上。 */
|
|
3154
|
+
lastLoadAt = 0;
|
|
3155
|
+
try {
|
|
3156
|
+
unsubscribe = typeof directory.store.subscribe === "function"
|
|
3157
|
+
? directory.store.subscribe(notify)
|
|
3158
|
+
: null;
|
|
3159
|
+
} catch (err) {
|
|
3160
|
+
unsubscribe = null;
|
|
3046
3161
|
}
|
|
3162
|
+
kickLoad();
|
|
3163
|
+
scheduleNotify();
|
|
3047
3164
|
return directory;
|
|
3048
3165
|
}
|
|
3049
3166
|
|
|
@@ -3062,16 +3179,18 @@ window.__ModuleLoader__.load({
|
|
|
3062
3179
|
/** 同一份快照对象身份必须稳定,否则 useSyncExternalStore 会判定"每帧都变"。 */
|
|
3063
3180
|
function readStable() {
|
|
3064
3181
|
if (closed) return EMPTY_SNAPSHOT;
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3182
|
+
/* 每次读都重新解析:换模型代 / 连接重置后目录实例会换,
|
|
3183
|
+
只认第一次拿到的旧目录会把整条轨道留在旧模型上或直接空掉。 */
|
|
3184
|
+
resolve();
|
|
3185
|
+
if (directory === null) scheduleRetry();
|
|
3069
3186
|
if (directory !== null) {
|
|
3070
3187
|
try {
|
|
3071
3188
|
var value = directory.store.getSnapshot();
|
|
3072
3189
|
if (value && typeof value === "object") {
|
|
3073
3190
|
if (last === EMPTY_SNAPSHOT
|
|
3074
|
-
|| value.current !== last.current
|
|
3191
|
+
|| (value.current && value.current.provider) !== (last.current && last.current.provider)
|
|
3192
|
+
|| modelIdOf(value.current && value.current.model) !== modelIdOf(last.current && last.current.model)
|
|
3193
|
+
|| effortValueOf(value.current && value.current.reasoningEffort) !== effortValueOf(last.current && last.current.reasoningEffort)
|
|
3075
3194
|
|| value.groups !== last.groups
|
|
3076
3195
|
|| value.status !== last.status
|
|
3077
3196
|
|| value.error !== last.error) {
|
|
@@ -3089,25 +3208,25 @@ window.__ModuleLoader__.load({
|
|
|
3089
3208
|
getSnapshot: readStable,
|
|
3090
3209
|
subscribe: function (listener) {
|
|
3091
3210
|
if (closed) return function () {};
|
|
3211
|
+
resolve();
|
|
3212
|
+
if (directory === null) scheduleRetry();
|
|
3092
3213
|
listeners.add(listener);
|
|
3093
|
-
if (directory === null) {
|
|
3094
|
-
resolve();
|
|
3095
|
-
if (directory === null) scheduleRetry();
|
|
3096
|
-
}
|
|
3097
3214
|
return function () { listeners.delete(listener); };
|
|
3098
3215
|
},
|
|
3099
|
-
directory: function () { return
|
|
3216
|
+
directory: function () { return resolve(); },
|
|
3100
3217
|
select: function (payload) {
|
|
3101
|
-
|
|
3218
|
+
resolve();
|
|
3102
3219
|
if (directory === null || typeof directory.select !== "function") return null;
|
|
3103
3220
|
return directory.select(payload);
|
|
3104
3221
|
},
|
|
3105
3222
|
destroy: function () {
|
|
3106
3223
|
closed = true;
|
|
3107
3224
|
if (retryTimer !== null) { window.clearTimeout(retryTimer); retryTimer = null; }
|
|
3225
|
+
if (notifyTimer !== null) { window.clearTimeout(notifyTimer); notifyTimer = null; }
|
|
3108
3226
|
if (unsubscribe !== null) { try { unsubscribe(); } catch (err) { /* 忽略 */ } unsubscribe = null; }
|
|
3109
3227
|
listeners.clear();
|
|
3110
3228
|
directory = null;
|
|
3229
|
+
activeStore = null;
|
|
3111
3230
|
},
|
|
3112
3231
|
};
|
|
3113
3232
|
}
|
|
@@ -3137,12 +3256,22 @@ window.__ModuleLoader__.load({
|
|
|
3137
3256
|
}
|
|
3138
3257
|
|
|
3139
3258
|
function teardownEntry(entry) {
|
|
3140
|
-
if (entry
|
|
3259
|
+
if (!entry) return;
|
|
3260
|
+
var removed = false;
|
|
3261
|
+
/* 即使 row 已经在宿主重建时被换掉,也要把旧容器从它原来的父节点摘掉;
|
|
3262
|
+
否则会留下一个空 .dem-inline,行高仍是被 mountEntry 加高过的 8px 内边距。 */
|
|
3141
3263
|
try {
|
|
3142
3264
|
if (entry.container !== null && entry.container.parentNode) {
|
|
3143
3265
|
entry.container.parentNode.removeChild(entry.container);
|
|
3266
|
+
removed = true;
|
|
3144
3267
|
}
|
|
3145
3268
|
} catch (err) { /* 容器可能已被官方一起销毁 */ }
|
|
3269
|
+
if (entry.row === null) {
|
|
3270
|
+
entry.container = null;
|
|
3271
|
+
entry.setContainer(null);
|
|
3272
|
+
if (removed) bumpResize();
|
|
3273
|
+
return;
|
|
3274
|
+
}
|
|
3146
3275
|
try {
|
|
3147
3276
|
entry.row.style.height = entry.prevStyle.height;
|
|
3148
3277
|
entry.row.style.flexWrap = entry.prevStyle.flexWrap;
|
|
@@ -3170,6 +3299,7 @@ window.__ModuleLoader__.load({
|
|
|
3170
3299
|
? indexOverride
|
|
3171
3300
|
: indexOfLevel(levels, effectiveEffortId(snapshot));
|
|
3172
3301
|
var hot = liveIndex === levels.length - 1;
|
|
3302
|
+
var hotName = hot && levels[levels.length - 1] ? levels[levels.length - 1].name : "";
|
|
3173
3303
|
/* 档位名来自模型目录,内容不可控;用无原型表,避免名字恰好是
|
|
3174
3304
|
"__proto__" / "constructor" 时污染原型、把无关文字也染色。 */
|
|
3175
3305
|
var byName = Object.create(null);
|
|
@@ -3184,7 +3314,9 @@ window.__ModuleLoader__.load({
|
|
|
3184
3314
|
if (textInsideEditor(node, root)) continue;
|
|
3185
3315
|
var host = node.parentElement;
|
|
3186
3316
|
if (!host) continue;
|
|
3187
|
-
|
|
3317
|
+
/* 只给**当前最高档**那一段文字上蓝;不能把卡片里其它档位名
|
|
3318
|
+
(例如刚切到新模型后行里显示的 Medium)也一起染蓝。 */
|
|
3319
|
+
if (hot && hotName && text === hotName) host.style.setProperty("color", tintColorOf(), "important");
|
|
3188
3320
|
else if (host.style.getPropertyValue("color")) host.style.removeProperty("color");
|
|
3189
3321
|
}
|
|
3190
3322
|
}
|
|
@@ -3456,6 +3588,7 @@ window.__ModuleLoader__.load({
|
|
|
3456
3588
|
|
|
3457
3589
|
var levels = levelsOf(state);
|
|
3458
3590
|
var liveIndex = indexOfLevel(levels, effectiveEffortId(state));
|
|
3591
|
+
var currentModelId = modelIdOf(state && state.current && state.current.model);
|
|
3459
3592
|
|
|
3460
3593
|
/* 容器裁到宿主浮层:形变/粒子只能在菜单面板里出现,不能顶到面板外。 */
|
|
3461
3594
|
React.useEffect(function () {
|
|
@@ -3477,9 +3610,16 @@ window.__ModuleLoader__.load({
|
|
|
3477
3610
|
var _draft = React.useState(null);
|
|
3478
3611
|
var draft = _draft[0];
|
|
3479
3612
|
var setDraft = _draft[1];
|
|
3613
|
+
/* 模型切换的当帧不能继续使用上一代 draft:否则新模型的首帧会先
|
|
3614
|
+
按旧模型的 Max 画一遍,等 effect 清掉 draft 才回退,看起来就是
|
|
3615
|
+
非最高档字符先蓝一下。等 modelIdRef 跟上后再恢复 draft。 */
|
|
3616
|
+
var sameModelAsPrevious = entry.modelIdRef.current === null
|
|
3617
|
+
|| entry.modelIdRef.current === currentModelId;
|
|
3618
|
+
var draftForView = sameModelAsPrevious ? draft : null;
|
|
3480
3619
|
/* 给 SlotComponent 的胶囊观察器读:等待宿主回写的窗口里,
|
|
3481
3620
|
颜色必须跟 draft 目标走,不能读尚未更新的 snapshot。 */
|
|
3482
|
-
entry.displayIndexRef.current =
|
|
3621
|
+
entry.displayIndexRef.current = draftForView !== null ? draftForView : (liveIndex >= 0 ? liveIndex : null);
|
|
3622
|
+
entry.displayModelIdRef.current = currentModelId;
|
|
3483
3623
|
|
|
3484
3624
|
var _hint = React.useState(null);
|
|
3485
3625
|
var hint = _hint[0];
|
|
@@ -3491,6 +3631,41 @@ window.__ModuleLoader__.load({
|
|
|
3491
3631
|
var flushIdleRef = React.useRef(null);
|
|
3492
3632
|
var labelGuardRef = React.useRef(null);
|
|
3493
3633
|
|
|
3634
|
+
/* 模型换代时清掉上一代留下的乐观 draft / 待写档位:
|
|
3635
|
+
否则旧模型的索引会短暂盖在新模型的轨道上,甚至把旧档位写进新模型。 */
|
|
3636
|
+
React.useEffect(function () {
|
|
3637
|
+
var previous = entry.modelIdRef.current;
|
|
3638
|
+
if (previous === null) {
|
|
3639
|
+
entry.modelIdRef.current = currentModelId;
|
|
3640
|
+
return;
|
|
3641
|
+
}
|
|
3642
|
+
if (previous === currentModelId) return;
|
|
3643
|
+
entry.modelIdRef.current = currentModelId;
|
|
3644
|
+
/* 旧模型的最高档索引立即作废;下一次绘制由快照的 liveIndex 决定。 */
|
|
3645
|
+
entry.displayIndexRef.current = null;
|
|
3646
|
+
entry.displayModelIdRef.current = currentModelId;
|
|
3647
|
+
var pending = pendingRef.current;
|
|
3648
|
+
pending.levelId = null;
|
|
3649
|
+
pending.inFlight = false;
|
|
3650
|
+
pending.seq += 1;
|
|
3651
|
+
pending.landed = false;
|
|
3652
|
+
pending.effortless = false;
|
|
3653
|
+
if (deadlineRef.current !== null) {
|
|
3654
|
+
window.clearTimeout(deadlineRef.current);
|
|
3655
|
+
deadlineRef.current = null;
|
|
3656
|
+
}
|
|
3657
|
+
if (flushTimerRef.current !== null) {
|
|
3658
|
+
window.clearTimeout(flushTimerRef.current);
|
|
3659
|
+
flushTimerRef.current = null;
|
|
3660
|
+
}
|
|
3661
|
+
if (flushIdleRef.current !== null && typeof window.cancelIdleCallback === "function") {
|
|
3662
|
+
window.cancelIdleCallback(flushIdleRef.current);
|
|
3663
|
+
flushIdleRef.current = null;
|
|
3664
|
+
}
|
|
3665
|
+
setDraft(null);
|
|
3666
|
+
setHint(null);
|
|
3667
|
+
}, [currentModelId, entry]);
|
|
3668
|
+
|
|
3494
3669
|
function cancelPendingPick() {
|
|
3495
3670
|
if (flushTimerRef.current !== null) {
|
|
3496
3671
|
window.clearTimeout(flushTimerRef.current);
|
|
@@ -3512,17 +3687,17 @@ window.__ModuleLoader__.load({
|
|
|
3512
3687
|
这里负责在组件提交后 / 回滚时再校准)。draft 清空 = 宿主已经接上
|
|
3513
3688
|
真实档位,或写入失败要回滚,都用 liveIndex 重画。 */
|
|
3514
3689
|
React.useEffect(function () {
|
|
3515
|
-
var shown =
|
|
3690
|
+
var shown = draftForView !== null ? draftForView : liveIndex;
|
|
3516
3691
|
paintEffortEverywhere(entry, levels, shown);
|
|
3517
|
-
}, [
|
|
3692
|
+
}, [draftForView, liveIndex, levels, entry]);
|
|
3518
3693
|
|
|
3519
3694
|
/* 官方行 / 输入胶囊可能在等待宿主回写的窗口里被 React 重渲染回旧字符;
|
|
3520
3695
|
在 draft 未落库前守住目标文字,MutationObserver 的回调在 paint 前跑,
|
|
3521
3696
|
所以画面不会闪回旧档位。paint 是幂等的,不会自激。 */
|
|
3522
3697
|
React.useEffect(function () {
|
|
3523
|
-
if (
|
|
3698
|
+
if (draftForView === null) return undefined;
|
|
3524
3699
|
if (typeof MutationObserver !== "function") return undefined;
|
|
3525
|
-
var target =
|
|
3700
|
+
var target = draftForView;
|
|
3526
3701
|
var roots = [];
|
|
3527
3702
|
if (entry.row) roots.push(entry.row);
|
|
3528
3703
|
if (entry.card && entry.card !== entry.row) {
|
|
@@ -3564,7 +3739,7 @@ window.__ModuleLoader__.load({
|
|
|
3564
3739
|
}
|
|
3565
3740
|
if (labelGuardRef.current === guards) labelGuardRef.current = null;
|
|
3566
3741
|
};
|
|
3567
|
-
}, [
|
|
3742
|
+
}, [draftForView, levels, entry]);
|
|
3568
3743
|
|
|
3569
3744
|
React.useEffect(function () {
|
|
3570
3745
|
return function () {
|
|
@@ -3611,7 +3786,8 @@ window.__ModuleLoader__.load({
|
|
|
3611
3786
|
|
|
3612
3787
|
var snapshot = access.getSnapshot();
|
|
3613
3788
|
var current = snapshot && snapshot.current;
|
|
3614
|
-
|
|
3789
|
+
var currentModel = modelIdOf(current && current.model);
|
|
3790
|
+
if (!current || typeof current.provider !== "string" || currentModel.length === 0) {
|
|
3615
3791
|
setDraft(null);
|
|
3616
3792
|
setHint("模型目录尚未就绪");
|
|
3617
3793
|
return;
|
|
@@ -3620,7 +3796,7 @@ window.__ModuleLoader__.load({
|
|
|
3620
3796
|
|
|
3621
3797
|
var result;
|
|
3622
3798
|
try {
|
|
3623
|
-
result = access.select({ provider: current.provider, model:
|
|
3799
|
+
result = access.select({ provider: current.provider, model: currentModel, reasoningEffort: levelId });
|
|
3624
3800
|
} catch (err) {
|
|
3625
3801
|
result = Promise.reject(err);
|
|
3626
3802
|
}
|
|
@@ -3672,7 +3848,7 @@ window.__ModuleLoader__.load({
|
|
|
3672
3848
|
pending.inFlight = true; /* 兜底写也是一笔宿主写,别让新档位插进来抢 */
|
|
3673
3849
|
var plain = null;
|
|
3674
3850
|
try {
|
|
3675
|
-
plain = access.select({ provider: current.provider, model:
|
|
3851
|
+
plain = access.select({ provider: current.provider, model: currentModel });
|
|
3676
3852
|
} catch (err2) {
|
|
3677
3853
|
plain = Promise.reject(err2);
|
|
3678
3854
|
}
|
|
@@ -3791,11 +3967,18 @@ window.__ModuleLoader__.load({
|
|
|
3791
3967
|
if (levels.length === 0) return null;
|
|
3792
3968
|
|
|
3793
3969
|
/* 目录快照未就绪时,先读官方行里的当前档位名;它通常比快照更早可用。
|
|
3794
|
-
|
|
3970
|
+
两者都没有时先落在第 1 档,等快照回来再纠正;绝不先画在 0 档后消失。 */
|
|
3795
3971
|
var rowIndex = rowEffortIndex(entry.row, levels);
|
|
3796
3972
|
var seedIndex = liveIndex >= 0 ? liveIndex : rowIndex;
|
|
3797
|
-
|
|
3798
|
-
|
|
3973
|
+
/* 最后一道兜底:只要这个模型确实声明了档位,就不能让轨道因为
|
|
3974
|
+
`current.reasoningEffort` / 行文案暂时解析不出来而完全消失。
|
|
3975
|
+
正常路径仍优先用 liveIndex 或官方行里的真实档位名;两者都没有时
|
|
3976
|
+
才先落在第 1 档,等宿主快照回来再由上面的优先级纠正。 */
|
|
3977
|
+
if (seedIndex < 0 && levels.length > 0) seedIndex = 0;
|
|
3978
|
+
var indexReady = levels.length > 0;
|
|
3979
|
+
var displayIndex = draftForView !== null ? draftForView : seedIndex;
|
|
3980
|
+
entry.displayIndexRef.current = draftForView !== null ? draftForView : seedIndex;
|
|
3981
|
+
entry.displayModelIdRef.current = currentModelId;
|
|
3799
3982
|
|
|
3800
3983
|
return React.createElement(EffortTrack, {
|
|
3801
3984
|
levels: levels,
|
|
@@ -3845,6 +4028,11 @@ window.__ModuleLoader__.load({
|
|
|
3845
4028
|
setContainer: setContainer,
|
|
3846
4029
|
/* 当前应染蓝的档位索引;由 ConnectedTrack 在每次渲染 / 落位时更新。 */
|
|
3847
4030
|
displayIndexRef: { current: null },
|
|
4031
|
+
/* 这个索引属于哪个模型;模型切换后必须作废旧索引,否则会把
|
|
4032
|
+
新模型的非最高档字符继续按旧模型的最高档染蓝。 */
|
|
4033
|
+
displayModelIdRef: { current: null },
|
|
4034
|
+
/* 上一次渲染时的模型 id,用于换代时清掉旧 draft / 待写档位。 */
|
|
4035
|
+
modelIdRef: { current: null },
|
|
3848
4036
|
};
|
|
3849
4037
|
entryRef.current = entry;
|
|
3850
4038
|
composers.set(card, entry);
|
|
@@ -3865,7 +4053,13 @@ window.__ModuleLoader__.load({
|
|
|
3865
4053
|
等待宿主回写的窗口里读 displayIndexRef,不能读尚未更新的 snapshot,
|
|
3866
4054
|
否则会把刚落位的蓝先擦回灰。 */
|
|
3867
4055
|
var snap = entry.access.getSnapshot();
|
|
3868
|
-
var
|
|
4056
|
+
var snapModelId = modelIdOf(snap && snap.current && snap.current.model);
|
|
4057
|
+
/* 乐观索引必须和当前快照属于同一个模型;否则用户刚把模型 A 拉到
|
|
4058
|
+
最高档就切换模型 B,这里还会拿 A 的最高档索引去染 B 的档位字符,
|
|
4059
|
+
B 的非最高档就会被误染成蓝色。模型不一致时强制回到快照真实档位。 */
|
|
4060
|
+
var idx = entry.displayModelIdRef.current === snapModelId
|
|
4061
|
+
? entry.displayIndexRef.current
|
|
4062
|
+
: null;
|
|
3869
4063
|
tintEffortText(card, snap, typeof idx === "number" ? idx : undefined);
|
|
3870
4064
|
}
|
|
3871
4065
|
function queueTint(records) {
|
|
@@ -4426,6 +4620,10 @@ window.__ModuleLoader__.load({
|
|
|
4426
4620
|
exports.__internals = {
|
|
4427
4621
|
levelsOf: levelsOf,
|
|
4428
4622
|
effectiveEffortId: effectiveEffortId,
|
|
4623
|
+
indexOfLevel: indexOfLevel,
|
|
4624
|
+
rowEffortIndex: rowEffortIndex,
|
|
4625
|
+
tintEffortText: tintEffortText,
|
|
4626
|
+
createAccess: createAccess,
|
|
4429
4627
|
pctOfIndex: pctOfIndex,
|
|
4430
4628
|
indexOfPct: indexOfPct,
|
|
4431
4629
|
ampOf: ampOf,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-effort-mosaic",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "把 DSH 模型菜单里的推理等级档位换成一条滑轨:马赛克粒子墙(右侧静止、越往左越散)或 霓虹(蓝轨道 + 最高档蓝紫擦除渐变)。两套风格可切换 / A reasoning-effort track for DeepSeek Harness, with a pixel-mosaic style and a 霓虹变体",
|
|
5
5
|
"icon": "./icon.svg",
|
|
6
6
|
"license": "MIT",
|