dsh-plugin-trim 0.3.8 → 0.3.10
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 +2 -1
- package/client.js +251 -57
- package/dist/index.js +6 -1
- package/package.json +42 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npm i dsh-plugin-trim
|
|
|
13
13
|
从 GitHub Release 安装(备用):
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
npm i "https://github.com/Starlit-Sky-code/dsh-experience-optimizer/releases/download/v0.3.
|
|
16
|
+
npm i "https://github.com/Starlit-Sky-code/dsh-experience-optimizer/releases/download/v0.3.10/dsh-plugin-trim-0.3.10.tgz"
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
本地包:
|
|
@@ -50,6 +50,7 @@ npm i /absolute/path/to/packages/plugin-trim
|
|
|
50
50
|
## 安全边界
|
|
51
51
|
|
|
52
52
|
- 默认只建议,不自动禁用。
|
|
53
|
+
- Web API 需要 DSH 连接认证、同源请求和 `x-dsh-trim-client: 1` 请求头;未通过时不返回数据。
|
|
53
54
|
- `trim_apply_profile` 必须 `confirm: true`,但默认还要宿主审批返回 `allowed-once` 才真正写入;`confirm` 只是提案标记。
|
|
54
55
|
- `trim_rollback_profile` 始终需要宿主审批。
|
|
55
56
|
- 只应用 `risk: low`、非受保护的 disable/enable 项。
|
package/client.js
CHANGED
|
@@ -214,17 +214,17 @@ window.__ModuleLoader__.load({
|
|
|
214
214
|
.eo-tabs::-webkit-scrollbar{display:none}
|
|
215
215
|
.eo-tab{appearance:none;border:0;background:transparent;color:var(--eo-tertiary);font:inherit;font-size:13px;line-height:20px;padding:7px 1px 9px;cursor:pointer;position:relative;border-radius:0;display:inline-flex;align-items:center;gap:6px;white-space:nowrap}
|
|
216
216
|
.eo-icon{flex:0 0 auto}
|
|
217
|
-
.eo-progress-track{display:block;width:100%;min-width:40px;height:
|
|
218
|
-
.eo-progress-track i{display:block;height:100%;border-radius:
|
|
219
|
-
.eo-severity-bar{display:flex;gap:3px;height:
|
|
220
|
-
.eo-severity-bar span{display:block;height:100%;border-radius:
|
|
217
|
+
.eo-progress-track{display:block;width:100%;min-width:40px;height:6px;border-radius:6px;background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.1));overflow:hidden;margin-top:7px;box-shadow:inset 0 0 0 .5px var(--eo-border)}
|
|
218
|
+
.eo-progress-track i{display:block;height:100%;border-radius:6px;background:linear-gradient(90deg,var(--eo-primary),color-mix(in srgb,var(--eo-primary) 55%,var(--dsw-alias-state-business-primary,#4a7fd6)));transition:width .45s var(--eo-ease,cubic-bezier(.16,1,.3,1));min-width:2px}
|
|
219
|
+
.eo-severity-bar{display:flex;gap:3px;height:8px;margin:0 0 8px;border-radius:5px;overflow:hidden;background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.1))}
|
|
220
|
+
.eo-severity-bar span{display:block;height:100%;border-radius:4px}
|
|
221
221
|
.eo-severity-error{background:var(--eo-error)}
|
|
222
222
|
.eo-severity-warn{background:var(--dsw-alias-state-warning-primary,#9a6700)}
|
|
223
223
|
.eo-severity-info{background:var(--dsw-alias-state-business-primary,#4a7fd6)}
|
|
224
224
|
.eo-severity-empty{background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.12));flex:1}
|
|
225
|
-
.eo-progress-ok i{background:var(--eo-success)}
|
|
226
|
-
.eo-progress-warn i{background:var(--dsw-alias-state-warning-primary,#9a6700)}
|
|
227
|
-
.eo-progress-danger i{background:var(--eo-error)}
|
|
225
|
+
.eo-progress-ok i{background:linear-gradient(90deg,var(--eo-success),color-mix(in srgb,var(--eo-success) 65%,var(--dsw-alias-state-business-primary,#4a7fd6)))}
|
|
226
|
+
.eo-progress-warn i{background:linear-gradient(90deg,var(--dsw-alias-state-warning-primary,#9a6700),var(--amber,#fbbf24))}
|
|
227
|
+
.eo-progress-danger i{background:linear-gradient(90deg,var(--eo-error),color-mix(in srgb,var(--eo-error) 70%,var(--dsw-alias-state-warning-primary,#9a6700)))}
|
|
228
228
|
.eo-progress-dots{display:flex;gap:6px;align-items:center;margin:12px 0 2px}
|
|
229
229
|
.eo-progress-dot{width:6px;height:6px;border-radius:50%;background:var(--eo-border-strong)}
|
|
230
230
|
.eo-progress-dot-active{width:18px;border-radius:4px;background:var(--eo-primary)}
|
|
@@ -294,27 +294,27 @@ window.__ModuleLoader__.load({
|
|
|
294
294
|
.eo-inventory-card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px}
|
|
295
295
|
.eo-inventory-card code{font:400 11px/16px var(--eo-code);word-break:break-all;color:var(--eo-secondary)}
|
|
296
296
|
.eo-inventory-card-meta{display:flex;gap:10px;flex-wrap:wrap;margin-top:6px;color:var(--eo-tertiary);font-size:11px}
|
|
297
|
-
.eo-main-guide{position:fixed;
|
|
298
|
-
.eo-guide-beacon{position:fixed;left:18px;bottom:
|
|
299
|
-
.eo-guide-beacon span{padding:
|
|
297
|
+
.eo-main-guide{position:fixed;left:18px;right:auto;bottom:150px;z-index:30;box-sizing:border-box;width:min(380px,calc(100vw - 32px));padding:16px 18px;border:.5px solid var(--dsw-alias-border-l4,rgba(127,127,127,.25));border-radius:14px;background:var(--dsw-alias-bg-layer-1,#fff);box-shadow:0 14px 44px rgba(0,0,0,.2);color:var(--eo-primary);font-size:14px;line-height:22px}
|
|
298
|
+
.eo-guide-beacon{position:fixed;left:18px;bottom:84px;z-index:31;display:flex;flex-direction:column;align-items:center;gap:2px;color:var(--eo-primary);pointer-events:none;font-size:12px;line-height:17px}
|
|
299
|
+
.eo-guide-beacon span{padding:2px 8px;border-radius:5px;background:var(--dsw-alias-bg-layer-1,#fff);border:.5px solid var(--eo-border-strong);box-shadow:0 4px 14px rgba(0,0,0,.12)}
|
|
300
300
|
.eo-guide-beacon .eo-icon{color:var(--eo-primary);animation:eo-guide-bob 1.6s ease-in-out infinite}
|
|
301
301
|
@keyframes eo-guide-bob{0%,100%{transform:translateY(0)}50%{transform:translateY(5px)}}
|
|
302
|
-
.eo-guide-arrow{position:absolute;left
|
|
303
|
-
.eo-guide-kicker{margin:0 0
|
|
304
|
-
.eo-main-guide h3{margin:0 0
|
|
305
|
-
.eo-guide-path{display:flex;align-items:center;gap:
|
|
306
|
-
.eo-guide-path span{padding:2px
|
|
302
|
+
.eo-guide-arrow{position:absolute;left:6px;top:auto;bottom:-27px;width:54px;height:54px;border-radius:50%;display:grid;place-items:center;background:var(--dsw-alias-button-primary-fill,var(--eo-primary));color:var(--dsw-alias-label-primary-inverted,#fff);box-shadow:0 8px 20px rgba(0,0,0,.18)}
|
|
303
|
+
.eo-guide-kicker{margin:0 0 4px;color:var(--eo-tertiary);font:500 11px/17px var(--eo-code);letter-spacing:.12em}
|
|
304
|
+
.eo-main-guide h3{margin:0 0 9px;font-size:18px;line-height:26px}
|
|
305
|
+
.eo-guide-path{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:0 0 9px;font-size:13px;line-height:20px;font-weight:500}
|
|
306
|
+
.eo-guide-path span{padding:2px 8px;border-radius:5px;background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.08))}
|
|
307
307
|
.eo-guide-path i{font-style:normal;color:var(--eo-tertiary)}
|
|
308
|
-
.eo-guide-note{margin:0;color:var(--eo-tertiary);font-size:
|
|
309
|
-
.eo-guide-steps{max-height:
|
|
310
|
-
.eo-guide-steps li{display:flex;gap:
|
|
311
|
-
.eo-guide-steps b{font:500
|
|
312
|
-
.eo-guide-steps span{flex:0 0 auto;font-weight:500;font-size:
|
|
313
|
-
.eo-guide-steps small{color:var(--eo-tertiary);font-size:
|
|
308
|
+
.eo-guide-note{margin:0;color:var(--eo-tertiary);font-size:12.5px;line-height:19px}
|
|
309
|
+
.eo-guide-steps{max-height:180px;overflow:auto;margin:11px 0 0;padding:0;list-style:none;border-top:.5px solid var(--eo-border)}
|
|
310
|
+
.eo-guide-steps li{display:flex;gap:8px;align-items:flex-start;padding:8px 0;border-bottom:.5px solid var(--eo-border)}
|
|
311
|
+
.eo-guide-steps b{font:500 11px/19px var(--eo-code);color:var(--eo-tertiary);flex:0 0 auto}
|
|
312
|
+
.eo-guide-steps span{flex:0 0 auto;font-weight:500;font-size:13px;line-height:19px}
|
|
313
|
+
.eo-guide-steps small{color:var(--eo-tertiary);font-size:12px;line-height:18px}
|
|
314
314
|
.eo-guide-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:12px}
|
|
315
|
-
.eo-main-guide .eo-btn{height:
|
|
316
|
-
@media(max-width:600px){.eo-main-guide{left:12px;right:12px;bottom:12px;width:auto}.eo-guide-beacon{position:fixed;left:18px;bottom:
|
|
317
|
-
.eo-guide-beacon span{padding:
|
|
315
|
+
.eo-main-guide .eo-btn{height:30px;font-size:12px;padding:0 10px}
|
|
316
|
+
@media(max-width:600px){.eo-main-guide{left:12px;right:12px;bottom:12px;width:auto;max-height:calc(100vh - 24px);overflow:auto;font-size:13px;line-height:20px}.eo-guide-beacon{position:fixed;left:18px;bottom:84px;z-index:31;display:flex;flex-direction:column;align-items:center;gap:2px;color:var(--eo-primary);pointer-events:none;font-size:12px;line-height:17px}
|
|
317
|
+
.eo-guide-beacon span{padding:2px 8px;border-radius:5px;background:var(--dsw-alias-bg-layer-1,#fff);border:.5px solid var(--eo-border-strong);box-shadow:0 4px 14px rgba(0,0,0,.12)}
|
|
318
318
|
.eo-guide-beacon .eo-icon{color:var(--eo-primary);animation:eo-guide-bob 1.6s ease-in-out infinite}
|
|
319
319
|
@keyframes eo-guide-bob{0%,100%{transform:translateY(0)}50%{transform:translateY(5px)}}
|
|
320
320
|
.eo-guide-arrow{display:none}}
|
|
@@ -386,8 +386,31 @@ window.__ModuleLoader__.load({
|
|
|
386
386
|
.eo-owner-list{display:flex;flex-direction:column;gap:7px}
|
|
387
387
|
.eo-owner-head{display:flex;justify-content:space-between;gap:10px;font-size:12px;line-height:18px;color:var(--eo-tertiary)}
|
|
388
388
|
.eo-owner-head span:first-child{font-family:var(--eo-code);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
389
|
-
.eo-
|
|
390
|
-
.eo-
|
|
389
|
+
.eo-context-mix{display:flex;align-items:center;gap:18px;padding:2px 0 12px;margin-bottom:10px;border-bottom:.5px solid var(--eo-border)}
|
|
390
|
+
.eo-context-donut{position:relative;width:82px;height:82px;border-radius:50%;flex:0 0 auto;background:conic-gradient(var(--eo-success) 0 var(--eo-ok,0%),var(--dsw-alias-state-warning-primary,#9a6700) var(--eo-ok,0%) 100%)}
|
|
391
|
+
.eo-context-donut:after{content:"";position:absolute;inset:10px;border-radius:50%;background:var(--eo-card-bg,#fff)}
|
|
392
|
+
.eo-context-donut-label{position:absolute;inset:10px;z-index:1;display:flex;flex-direction:column;align-items:center;justify-content:center;line-height:1}
|
|
393
|
+
.eo-context-donut-label b{font-size:17px;line-height:22px;font-weight:600;color:var(--eo-primary)}
|
|
394
|
+
.eo-context-donut-label small{font-size:9px;line-height:13px;color:var(--eo-tertiary);margin-top:2px}
|
|
395
|
+
.eo-context-legend{display:flex;flex-direction:column;gap:6px;min-width:0;flex:1}
|
|
396
|
+
.eo-context-legend-row{display:grid;grid-template-columns:8px minmax(0,1fr) auto auto;gap:7px;align-items:center;font-size:11px;line-height:17px;color:var(--eo-tertiary)}
|
|
397
|
+
.eo-context-legend-row strong{color:var(--eo-primary);font-weight:500;font-family:var(--eo-code);font-size:11px}
|
|
398
|
+
.eo-context-legend-row em{font-style:normal;color:var(--eo-tertiary);font-family:var(--eo-code);font-size:10px;min-width:34px;text-align:right}
|
|
399
|
+
.eo-dot-ok,.eo-dot-warn,.eo-dot-error,.eo-dot-info{display:inline-block;width:7px;height:7px;border-radius:50%;flex:0 0 auto}
|
|
400
|
+
.eo-dot-ok{background:var(--eo-success)}
|
|
401
|
+
.eo-dot-warn{background:var(--dsw-alias-state-warning-primary,#9a6700)}
|
|
402
|
+
.eo-dot-error{background:var(--eo-error)}
|
|
403
|
+
.eo-dot-info{background:var(--dsw-alias-state-business-primary,#4a7fd6)}
|
|
404
|
+
.eo-severity-legend{display:flex;flex-wrap:wrap;gap:12px;margin:0 0 10px;color:var(--eo-tertiary);font-size:11px;line-height:17px}
|
|
405
|
+
.eo-severity-legend span{display:inline-flex;align-items:center;gap:5px}
|
|
406
|
+
.eo-compat-footer{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-top:12px;padding-top:12px;border-top:.5px solid var(--eo-border)}
|
|
407
|
+
.eo-share-cell{display:flex;flex-direction:column;gap:3px;min-width:64px}
|
|
408
|
+
.eo-share-bar{width:52px;height:4px;border-radius:4px;background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.1));overflow:hidden}
|
|
409
|
+
.eo-share-bar i{display:block;height:100%;min-width:2px;border-radius:4px;background:linear-gradient(90deg,var(--eo-primary),var(--dsw-alias-state-business-primary,#4a7fd6))}
|
|
410
|
+
.eo-inventory-share{height:4px;border-radius:4px;background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.1));overflow:hidden;margin-top:9px}
|
|
411
|
+
.eo-inventory-share i{display:block;height:100%;min-width:2px;border-radius:4px;background:linear-gradient(90deg,var(--eo-primary),var(--dsw-alias-state-business-primary,#4a7fd6));opacity:.85}
|
|
412
|
+
.eo-bar{height:6px;border-radius:6px;background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.1));margin-top:5px;overflow:hidden;box-shadow:inset 0 0 0 .5px var(--eo-border)}
|
|
413
|
+
.eo-bar i{display:block;height:100%;border-radius:6px;background:linear-gradient(90deg,var(--eo-primary),var(--dsw-alias-state-business-primary,#4a7fd6));opacity:.85;transition:width .45s var(--eo-ease,cubic-bezier(.16,1,.3,1))}
|
|
391
414
|
.eo-issue{display:flex;gap:8px;align-items:flex-start;padding:8px 10px;border-radius:var(--dsw-radius-md,8px);font-size:12px;line-height:18px;background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.06));border:.5px solid var(--eo-border)}
|
|
392
415
|
.eo-issue-error{border-color:color-mix(in srgb,var(--eo-error) 35%,transparent);color:var(--eo-error)}
|
|
393
416
|
.eo-issue-warn{border-color:color-mix(in srgb,var(--dsw-alias-state-warning-primary,#9a6700) 35%,transparent)}
|
|
@@ -404,7 +427,8 @@ window.__ModuleLoader__.load({
|
|
|
404
427
|
.eo-toast-error{border-color:color-mix(in srgb,var(--eo-error) 45%,transparent)}
|
|
405
428
|
.eo-loading{display:flex;align-items:center;justify-content:center;gap:8px;padding:24px;color:var(--eo-tertiary);font-size:12px}
|
|
406
429
|
.eo-spinner{width:13px;height:13px;border-radius:50%;border:2px solid var(--eo-border-strong);border-top-color:var(--eo-primary);animation:eo-spin .8s linear infinite}
|
|
407
|
-
.eo-
|
|
430
|
+
.eo-crash{padding:16px}
|
|
431
|
+
.eo-error{padding:10px 12px;border-radius:var(--dsw-radius-md,8px);background:color-mix(in srgb,var(--eo-error) 7%,transparent);border:.5px solid color-mix(in srgb,var(--eo-error) 35%,transparent);color:var(--eo-error);font-size:12px;line-height:18px;display:flex;gap:10px;align-items:center;justify-content:space-between}
|
|
408
432
|
.eo-muted{color:var(--eo-tertiary);font-size:12px;line-height:18px}
|
|
409
433
|
.eo-note{padding:9px 12px;border:1px solid var(--dsw-alias-border-l3);border-radius:8px;background:var(--dsw-alias-bg-layer-3);color:var(--eo-secondary);font-size:12px;line-height:19px}
|
|
410
434
|
.eo-code{font:400 11px/16px var(--eo-code);color:var(--eo-secondary);word-break:break-all}
|
|
@@ -430,7 +454,28 @@ window.__ModuleLoader__.load({
|
|
|
430
454
|
.eo-settings-row-wide .eo-settings-control{width:100%;flex:1 1 240px}
|
|
431
455
|
.eo-check{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--eo-primary);cursor:pointer;min-height:30px}
|
|
432
456
|
.eo-check input{width:14px;height:14px;accent-color:var(--eo-primary);cursor:pointer}
|
|
433
|
-
|
|
457
|
+
.eo-param{display:flex;flex-direction:column;gap:5px;flex:1 1 220px;min-width:220px}
|
|
458
|
+
.eo-param-section{display:flex;flex-direction:column;gap:0;margin-top:14px;padding-top:12px;border-top:.5px solid var(--eo-border)}
|
|
459
|
+
.eo-param-section-head{display:flex;align-items:baseline;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:4px}
|
|
460
|
+
.eo-param-section-head strong{font-size:13px;line-height:20px;color:var(--eo-primary)}
|
|
461
|
+
.eo-param-section-head span{font-size:11px;line-height:17px;color:var(--eo-tertiary)}
|
|
462
|
+
.eo-param-row{display:flex;align-items:center;gap:14px;padding:8px 0;border-bottom:.5px solid var(--eo-border)}
|
|
463
|
+
.eo-param-row:last-child{border-bottom:0;padding-bottom:0}
|
|
464
|
+
.eo-param-row>span{flex:0 0 120px;color:var(--eo-secondary);font-size:12px;line-height:18px}
|
|
465
|
+
.eo-param-head{display:flex;align-items:center;gap:5px}
|
|
466
|
+
.eo-param-input{width:70px;height:30px;padding:0 7px;text-align:center;font:500 12px/18px var(--eo-code);appearance:textfield}
|
|
467
|
+
.eo-param-input::-webkit-inner-spin-button,.eo-param-input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}
|
|
468
|
+
.eo-stepper{display:flex;flex-direction:column;gap:2px}
|
|
469
|
+
.eo-stepper-btn{width:22px;height:14px;display:grid;place-items:center;padding:0;border:.5px solid var(--eo-border-strong);border-radius:4px;background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.05));color:var(--eo-secondary);cursor:pointer;transition:background .16s ease,color .16s ease,border-color .16s ease}
|
|
470
|
+
.eo-stepper-btn:hover{border-color:var(--eo-primary);color:var(--eo-primary);background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.1))}
|
|
471
|
+
.eo-stepper-btn:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--eo-primary));outline-offset:1px}
|
|
472
|
+
.eo-stepper-btn .eo-icon{display:block}
|
|
473
|
+
.eo-stepper-up .eo-icon{transform:rotate(180deg)}
|
|
474
|
+
.eo-param-track{position:relative;height:6px;border-radius:6px;background:var(--eo-border)}
|
|
475
|
+
.eo-param-track i{display:block;height:100%;min-width:3px;border-radius:6px;background:linear-gradient(90deg,var(--eo-primary),var(--dsw-alias-state-success-primary,#1a7f37));transition:width .28s var(--eo-ease,cubic-bezier(.16,1,.3,1))}
|
|
476
|
+
.eo-param-track b{position:absolute;top:50%;width:9px;height:9px;border-radius:50%;background:var(--dsw-alias-bg-layer-1,#fff);border:1.5px solid var(--eo-primary);transform:translate(-50%,-50%);box-shadow:0 1px 4px rgba(0,0,0,.15)}
|
|
477
|
+
.eo-param-scale{display:flex;justify-content:space-between;color:var(--eo-tertiary);font:10px/14px var(--eo-code);letter-spacing:.02em}
|
|
478
|
+
@media(max-width:560px){.eo-settings-control{width:100%;flex:1 1 100%}.eo-param-row{align-items:flex-start;flex-direction:column;gap:5px}.eo-param-row>span{flex:0 0 auto}.eo-param{width:100%;min-width:0}}
|
|
434
479
|
.eo-codeblock{margin:0;padding:12px;border:.5px solid var(--eo-border-strong);border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.05));font:400 11px/18px var(--eo-code);color:var(--eo-secondary);white-space:pre-wrap;word-break:break-word}
|
|
435
480
|
.eo-faq{border-bottom:.5px solid var(--eo-border);padding:8px 0}
|
|
436
481
|
.eo-faq:last-child{border-bottom:0}
|
|
@@ -857,6 +902,7 @@ window.__ModuleLoader__.load({
|
|
|
857
902
|
...options,
|
|
858
903
|
headers: { ...(options && options.headers ? options.headers : {}) },
|
|
859
904
|
}
|
|
905
|
+
request.headers['x-dsh-trim-client'] = '1'
|
|
860
906
|
if (request.body !== undefined) request.headers['content-type'] = 'application/json'
|
|
861
907
|
const response = await fetch(path, request)
|
|
862
908
|
let body = null
|
|
@@ -958,6 +1004,31 @@ window.__ModuleLoader__.load({
|
|
|
958
1004
|
)
|
|
959
1005
|
}
|
|
960
1006
|
|
|
1007
|
+
class PluginErrorBoundary extends React.Component {
|
|
1008
|
+
constructor(props) {
|
|
1009
|
+
super(props)
|
|
1010
|
+
this.state = { error: null }
|
|
1011
|
+
}
|
|
1012
|
+
static getDerivedStateFromError(error) {
|
|
1013
|
+
return { error }
|
|
1014
|
+
}
|
|
1015
|
+
componentDidCatch(error) {
|
|
1016
|
+
try {
|
|
1017
|
+
console.error('[dsh-plugin-trim] UI render failed', error)
|
|
1018
|
+
} catch {
|
|
1019
|
+
// Logging must never mask the fallback.
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
render() {
|
|
1023
|
+
if (this.state.error) {
|
|
1024
|
+
return h('div', { className: 'eo-root eo-crash' },
|
|
1025
|
+
h('div', { className: 'eo-error' }, tr('界面渲染失败;插件本身仍在运行。', 'The UI failed to render; the plugin is still running.')),
|
|
1026
|
+
)
|
|
1027
|
+
}
|
|
1028
|
+
return this.props.children
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
|
|
961
1032
|
function OnboardingModal({ step, setStep, onFinish, onTutorial, onClose }) {
|
|
962
1033
|
const steps = [
|
|
963
1034
|
{
|
|
@@ -1115,7 +1186,7 @@ window.__ModuleLoader__.load({
|
|
|
1115
1186
|
h(
|
|
1116
1187
|
'div',
|
|
1117
1188
|
{ className: 'eo-main-guide', role: 'dialog', 'aria-label': tr('初次使用路径', 'First-run path') },
|
|
1118
|
-
h('div', { className: 'eo-guide-arrow' }, h(Icon, { name: '
|
|
1189
|
+
h('div', { className: 'eo-guide-arrow' }, h(Icon, { name: 'arrowDown', size: 28 })),
|
|
1119
1190
|
h('p', { className: 'eo-guide-kicker' }, tr('初次使用', 'FIRST RUN')),
|
|
1120
1191
|
h('h3', null, tr('从这里打开插件体检', 'Open Plugin checkup here')),
|
|
1121
1192
|
h(
|
|
@@ -1188,7 +1259,7 @@ window.__ModuleLoader__.load({
|
|
|
1188
1259
|
const [locale, setLocale] = useState(detectLocale)
|
|
1189
1260
|
const [showOnboarding, setShowOnboarding] = useState(false)
|
|
1190
1261
|
const [onboardingStep, setOnboardingStep] = useState(0)
|
|
1191
|
-
const [collapsedCards, setCollapsedCards] = useState({
|
|
1262
|
+
const [collapsedCards, setCollapsedCards] = useState({})
|
|
1192
1263
|
const [layout, setLayout] = useState(() => readPref('layout', 'standard'))
|
|
1193
1264
|
const [density, setDensity] = useState(() => readPref('density', 'comfortable'))
|
|
1194
1265
|
const [overview, setOverview] = useState(null)
|
|
@@ -1328,6 +1399,21 @@ window.__ModuleLoader__.load({
|
|
|
1328
1399
|
setSettingsDraft((current) => current ? { ...current, [field]: value } : current)
|
|
1329
1400
|
}, [])
|
|
1330
1401
|
|
|
1402
|
+
const loadRecommendedSettings = useCallback(() => {
|
|
1403
|
+
setSettingsDraft((current) => current ? {
|
|
1404
|
+
...current,
|
|
1405
|
+
mode: 'advise',
|
|
1406
|
+
approvalMode: 'always',
|
|
1407
|
+
suggestionPolicy: 'conservative',
|
|
1408
|
+
approvalThreshold: 5,
|
|
1409
|
+
trackUsage: true,
|
|
1410
|
+
usageRetentionDays: 30,
|
|
1411
|
+
maxDrafts: 20,
|
|
1412
|
+
protect: [],
|
|
1413
|
+
pinned: [],
|
|
1414
|
+
} : current)
|
|
1415
|
+
}, [])
|
|
1416
|
+
|
|
1331
1417
|
const discardSettings = useCallback(() => {
|
|
1332
1418
|
setSettingsDraft(settings ? { ...settings } : null)
|
|
1333
1419
|
setSettingsError('')
|
|
@@ -1370,7 +1456,7 @@ window.__ModuleLoader__.load({
|
|
|
1370
1456
|
} catch (err) {
|
|
1371
1457
|
const message = err instanceof Error ? err.message : String(err)
|
|
1372
1458
|
setUpdateInfo({
|
|
1373
|
-
current: '0.3.
|
|
1459
|
+
current: '0.3.10',
|
|
1374
1460
|
latest: null,
|
|
1375
1461
|
updateAvailable: false,
|
|
1376
1462
|
error: /unknown endpoint/i.test(message)
|
|
@@ -1848,6 +1934,32 @@ window.__ModuleLoader__.load({
|
|
|
1848
1934
|
}
|
|
1849
1935
|
}
|
|
1850
1936
|
|
|
1937
|
+
async function copyCompatibilityPlan() {
|
|
1938
|
+
const all = overview ? overview.findings.filter((finding) => finding.severity !== 'info') : []
|
|
1939
|
+
if (all.length === 0) {
|
|
1940
|
+
notify(tr('没有需要处理的兼容性问题。', 'No compatibility findings to handle.'), 'warn')
|
|
1941
|
+
return
|
|
1942
|
+
}
|
|
1943
|
+
const lines = [
|
|
1944
|
+
tr('# 兼容性处理清单', '# Compatibility checklist'),
|
|
1945
|
+
'',
|
|
1946
|
+
tr('只读生成;不会自动修改任何插件。', 'Generated read-only; no plugin is changed automatically.'),
|
|
1947
|
+
'',
|
|
1948
|
+
]
|
|
1949
|
+
for (const finding of all) {
|
|
1950
|
+
lines.push('- [ ] [' + finding.severity + '] ' + finding.code + ' — ' + finding.title)
|
|
1951
|
+
if (finding.subjects?.length) lines.push(' ' + tr('对象:', 'Subjects: ') + finding.subjects.join(', '))
|
|
1952
|
+
if (finding.fix?.summary) lines.push(' ' + tr('建议:', 'Fix: ') + finding.fix.summary)
|
|
1953
|
+
if (finding.evidence) lines.push(' ' + tr('证据:', 'Evidence: ') + (Array.isArray(finding.evidence) ? finding.evidence.join('; ') : String(finding.evidence)))
|
|
1954
|
+
}
|
|
1955
|
+
try {
|
|
1956
|
+
await navigator.clipboard.writeText(lines.join('\n'))
|
|
1957
|
+
notify(tr('已复制 ' + all.length + ' 项兼容性处理清单', 'Copied ' + all.length + ' compatibility items'))
|
|
1958
|
+
} catch {
|
|
1959
|
+
notify(tr('无法访问剪贴板,请手动复制问题详情', 'Clipboard unavailable; copy the findings manually'), 'warn')
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1851
1963
|
function renderSettings() {
|
|
1852
1964
|
if (settingsBusy && settings === null) {
|
|
1853
1965
|
return h('div', { className: 'eo-loading' }, h('span', { className: 'eo-spinner' }), tr('正在读取当前生效设置…', 'Loading effective settings…'))
|
|
@@ -1859,14 +1971,37 @@ window.__ModuleLoader__.load({
|
|
|
1859
1971
|
const form = settingsDraft || settings
|
|
1860
1972
|
const dirty = settingsChanged
|
|
1861
1973
|
const option = (labelZh, labelEn, value) => h('option', { key: value, value }, tr(labelZh, labelEn))
|
|
1862
|
-
const inputNumber = (field, min, max) =>
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
min,
|
|
1866
|
-
max,
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1974
|
+
const inputNumber = (field, min, max, displayMax = max, step = 1) => {
|
|
1975
|
+
const current = Math.min(max, Math.max(min, Number(form[field]) || min))
|
|
1976
|
+
const visualMax = Math.min(max, Math.max(min + 1, displayMax))
|
|
1977
|
+
const percent = Math.min(100, Math.max(0, ((current - min) / (visualMax - min)) * 100))
|
|
1978
|
+
const setValue = (value) => updateSettingsField(field, Math.min(max, Math.max(min, Number(value) || min)))
|
|
1979
|
+
return h(
|
|
1980
|
+
'div',
|
|
1981
|
+
{ className: 'eo-param' },
|
|
1982
|
+
h(
|
|
1983
|
+
'div',
|
|
1984
|
+
{ className: 'eo-param-head' },
|
|
1985
|
+
h('input', {
|
|
1986
|
+
className: 'eo-input eo-param-input',
|
|
1987
|
+
type: 'number',
|
|
1988
|
+
min,
|
|
1989
|
+
max,
|
|
1990
|
+
step,
|
|
1991
|
+
value: form[field],
|
|
1992
|
+
onChange: (event) => setValue(event.target.value),
|
|
1993
|
+
}),
|
|
1994
|
+
h(
|
|
1995
|
+
'div',
|
|
1996
|
+
{ className: 'eo-stepper' },
|
|
1997
|
+
h('button', { type: 'button', className: 'eo-stepper-btn eo-stepper-up', onClick: () => setValue(current + step), 'aria-label': tr('增加', 'Increase') }, h(Icon, { name: 'chevron', size: 11 })),
|
|
1998
|
+
h('button', { type: 'button', className: 'eo-stepper-btn', onClick: () => setValue(current - step), 'aria-label': tr('减少', 'Decrease') }, h(Icon, { name: 'chevron', size: 11 })),
|
|
1999
|
+
),
|
|
2000
|
+
),
|
|
2001
|
+
h('div', { className: 'eo-param-track', 'aria-hidden': 'true' }, h('i', { style: { width: percent + '%' } }), h('b', { style: { left: percent + '%' } })),
|
|
2002
|
+
h('div', { className: 'eo-param-scale' }, h('span', null, String(min)), h('span', null, String(visualMax) + (max > visualMax ? ' · ' + tr('上限 ', 'max ') + max : ''))),
|
|
2003
|
+
)
|
|
2004
|
+
}
|
|
1870
2005
|
return h(
|
|
1871
2006
|
'div',
|
|
1872
2007
|
{ className: 'eo-stack' },
|
|
@@ -1909,6 +2044,7 @@ window.__ModuleLoader__.load({
|
|
|
1909
2044
|
{
|
|
1910
2045
|
title: tr('插件设置', 'Plugin settings'),
|
|
1911
2046
|
subtitle: tr('改动后才会出现应用按钮;应用会重载插件', 'The apply button appears after changes; applying reloads the plugin'),
|
|
2047
|
+
extra: h(Button, { variant: 'ghost', onClick: loadRecommendedSettings }, tr('推荐默认值', 'Recommended')),
|
|
1912
2048
|
},
|
|
1913
2049
|
h(
|
|
1914
2050
|
'div',
|
|
@@ -1926,7 +2062,6 @@ window.__ModuleLoader__.load({
|
|
|
1926
2062
|
option('仅超过阈值时审批', 'Approve only above threshold', 'risk-based'),
|
|
1927
2063
|
),
|
|
1928
2064
|
),
|
|
1929
|
-
h('div', { className: 'eo-settings-row' }, h('span', null, tr('审批阈值', 'Approval threshold')), inputNumber('approvalThreshold', 1, 100)),
|
|
1930
2065
|
h('div', { className: 'eo-settings-row' }, h('span', null, tr('建议策略', 'Suggestion policy')),
|
|
1931
2066
|
h('select', { className: 'eo-select eo-settings-control', value: form.suggestionPolicy, onChange: (event) => updateSettingsField('suggestionPolicy', event.target.value) },
|
|
1932
2067
|
option('证据优先(推荐)', 'Evidence-first (recommended)', 'conservative'),
|
|
@@ -1939,8 +2074,6 @@ window.__ModuleLoader__.load({
|
|
|
1939
2074
|
h('span', null, form.trackUsage ? tr('开启', 'On') : tr('关闭', 'Off')),
|
|
1940
2075
|
),
|
|
1941
2076
|
),
|
|
1942
|
-
h('div', { className: 'eo-settings-row' }, h('span', null, tr('账本保留', 'Ledger retention')), inputNumber('usageRetentionDays', 1, 365)),
|
|
1943
|
-
h('div', { className: 'eo-settings-row' }, h('span', null, tr('草稿/还原点上限', 'Draft/snapshot limit')), inputNumber('maxDrafts', 1, 200)),
|
|
1944
2077
|
h('div', { className: 'eo-settings-row eo-settings-row-wide' }, h('span', null, tr('保护名单', 'Protect list')),
|
|
1945
2078
|
h('input', { className: 'eo-input eo-settings-control', value: form.protect.join(', '), placeholder: tr('包名,用逗号分隔', 'Package names, comma separated'), onChange: (event) => updateSettingsField('protect', splitList(event.target.value)) }),
|
|
1946
2079
|
),
|
|
@@ -1948,6 +2081,19 @@ window.__ModuleLoader__.load({
|
|
|
1948
2081
|
h('input', { className: 'eo-input eo-settings-control', value: form.pinned.join(', '), placeholder: tr('包名,用逗号分隔', 'Package names, comma separated'), onChange: (event) => updateSettingsField('pinned', splitList(event.target.value)) }),
|
|
1949
2082
|
),
|
|
1950
2083
|
),
|
|
2084
|
+
h(
|
|
2085
|
+
'div',
|
|
2086
|
+
{ className: 'eo-param-section' },
|
|
2087
|
+
h(
|
|
2088
|
+
'div',
|
|
2089
|
+
{ className: 'eo-param-section-head' },
|
|
2090
|
+
h('strong', null, tr('参数范围', 'Parameter ranges')),
|
|
2091
|
+
h('span', null, tr('上下箭头微调;进度条按推荐范围显示,右侧标注配置上限', 'Use the arrows to tune; the bar shows the recommended range, with the config cap on the right')),
|
|
2092
|
+
),
|
|
2093
|
+
h('div', { className: 'eo-param-row' }, h('span', null, tr('审批阈值', 'Approval threshold')), inputNumber('approvalThreshold', 1, 100, 20)),
|
|
2094
|
+
h('div', { className: 'eo-param-row' }, h('span', null, tr('账本保留', 'Ledger retention')), inputNumber('usageRetentionDays', 1, 365, 90)),
|
|
2095
|
+
h('div', { className: 'eo-param-row' }, h('span', null, tr('草稿/还原点上限', 'Draft/snapshot limit')), inputNumber('maxDrafts', 1, 200, 50)),
|
|
2096
|
+
),
|
|
1951
2097
|
h('div', { className: 'eo-muted', style: { marginTop: '10px' } }, tr('配置目录:', 'Config directory: ') + form.profileDir),
|
|
1952
2098
|
settingsError ? h('div', { className: 'eo-error', style: { marginTop: '10px' } }, h('span', null, settingsError)) : null,
|
|
1953
2099
|
dirty
|
|
@@ -1963,7 +2109,7 @@ window.__ModuleLoader__.load({
|
|
|
1963
2109
|
h(
|
|
1964
2110
|
Card,
|
|
1965
2111
|
{ title: tr('更新与反馈', 'Updates & feedback'), subtitle: tr('检查 npm 最新版本;反馈请走 GitHub Issues', 'Check the latest npm version; feedback via GitHub Issues') },
|
|
1966
|
-
h('div', { className: 'eo-settings-row' }, h('span', null, tr('当前版本', 'Current version')), h('code', null, updateInfo?.current || '0.3.
|
|
2112
|
+
h('div', { className: 'eo-settings-row' }, h('span', null, tr('当前版本', 'Current version')), h('code', null, updateInfo?.current || '0.3.10')),
|
|
1967
2113
|
h('div', { className: 'eo-settings-row' }, h('span', null, tr('最新版本', 'Latest version')), h('code', null, updateInfo ? (updateInfo.latest || tr('检查失败', 'Check failed')) : tr('未检查', 'Not checked'))),
|
|
1968
2114
|
updateInfo && updateInfo.updateAvailable
|
|
1969
2115
|
? h('div', { className: 'eo-issue' }, h('span', null, tr('发现新版本:', 'New version available: ') + updateInfo.latest + ' · '), h('a', { href: updateInfo.url, target: '_blank', rel: 'noreferrer' }, tr('查看 npm', 'View npm')))
|
|
@@ -2022,7 +2168,7 @@ window.__ModuleLoader__.load({
|
|
|
2022
2168
|
{ className: 'eo-about-card' },
|
|
2023
2169
|
h('div', { className: 'eo-inline', style: { marginBottom: '8px' } }, h(Icon, { name: 'shield', size: 24 }), h('strong', null, 'DSH Plugin Checkup')),
|
|
2024
2170
|
h('p', null, tr('少一点插件负担,多一点兼容确定性。', 'Less plugin overhead, more compatibility certainty.')),
|
|
2025
|
-
h('p', null, tr('版本:', 'Version: ') + '0.3.
|
|
2171
|
+
h('p', null, tr('版本:', 'Version: ') + '0.3.10 · AGPL-3.0-only'),
|
|
2026
2172
|
h('p', null, tr('作者:Starlit Sky', 'Author: Starlit Sky')),
|
|
2027
2173
|
),
|
|
2028
2174
|
h(
|
|
@@ -2098,6 +2244,9 @@ window.__ModuleLoader__.load({
|
|
|
2098
2244
|
}
|
|
2099
2245
|
|
|
2100
2246
|
function renderTrim() {
|
|
2247
|
+
const shareOf = (bundle) => totalContextTokens > 0
|
|
2248
|
+
? Math.min(100, Math.max(0, (bundle.contextTokens / totalContextTokens) * 100))
|
|
2249
|
+
: 0
|
|
2101
2250
|
const renderInventoryCards = () =>
|
|
2102
2251
|
h(
|
|
2103
2252
|
'div',
|
|
@@ -2140,6 +2289,9 @@ window.__ModuleLoader__.load({
|
|
|
2140
2289
|
bundle.protected ? h('span', null, tr('受保护', 'Protected')) : null,
|
|
2141
2290
|
h('span', null, bundle.guardStatus ? guardLabel(bundle.guardStatus) : '—'),
|
|
2142
2291
|
),
|
|
2292
|
+
h('div', { className: 'eo-inventory-share', title: tr('占可归属上下文的比例', 'Share of attributable context') },
|
|
2293
|
+
h('i', { style: { width: shareOf(bundle) + '%' } }),
|
|
2294
|
+
),
|
|
2143
2295
|
),
|
|
2144
2296
|
),
|
|
2145
2297
|
)
|
|
@@ -2155,8 +2307,8 @@ window.__ModuleLoader__.load({
|
|
|
2155
2307
|
h(Metric, {
|
|
2156
2308
|
key: 'tokens',
|
|
2157
2309
|
label: tr('可归属上下文', 'Attributable context'),
|
|
2158
|
-
value: formatTokens(
|
|
2159
|
-
hint: tr('
|
|
2310
|
+
value: formatTokens(attributedContext),
|
|
2311
|
+
hint: Math.round(contextPct) + tr('% 占比 · 未归属 ', '% share · unattributed ') + formatTokens(overview.context.unattributedTokens),
|
|
2160
2312
|
progress: contextPct,
|
|
2161
2313
|
progressTone: 'ok',
|
|
2162
2314
|
}),
|
|
@@ -2255,6 +2407,13 @@ window.__ModuleLoader__.load({
|
|
|
2255
2407
|
compat.info > 0 ? h('span', { key: 'i', className: 'eo-severity-info', style: { flex: compat.info } }) : null,
|
|
2256
2408
|
],
|
|
2257
2409
|
),
|
|
2410
|
+
compat.error + compat.warn + compat.info > 0
|
|
2411
|
+
? h('div', { className: 'eo-severity-legend' },
|
|
2412
|
+
h('span', null, h('i', { className: 'eo-dot-error' }), compat.error + tr(' 错误', ' errors')),
|
|
2413
|
+
h('span', null, h('i', { className: 'eo-dot-warn' }), compat.warn + tr(' 警告', ' warnings')),
|
|
2414
|
+
h('span', null, h('i', { className: 'eo-dot-info' }), compat.info + tr(' 信息', ' info')),
|
|
2415
|
+
)
|
|
2416
|
+
: null,
|
|
2258
2417
|
findings.length === 0
|
|
2259
2418
|
? h('div', { className: 'eo-empty' }, tr('没有匹配的兼容性问题。', 'No matching compatibility findings.'))
|
|
2260
2419
|
: h(
|
|
@@ -2294,6 +2453,22 @@ window.__ModuleLoader__.load({
|
|
|
2294
2453
|
),
|
|
2295
2454
|
),
|
|
2296
2455
|
),
|
|
2456
|
+
h(
|
|
2457
|
+
'div',
|
|
2458
|
+
{ className: 'eo-compat-footer' },
|
|
2459
|
+
h('span', { className: 'eo-muted' }, tr('生成只读修复清单;不会自动修改插件。', 'Creates a read-only fix checklist; no plugin is changed.')),
|
|
2460
|
+
h(
|
|
2461
|
+
Button,
|
|
2462
|
+
{
|
|
2463
|
+
variant: 'accent',
|
|
2464
|
+
onClick: () => void copyCompatibilityPlan(),
|
|
2465
|
+
disabled: compat.error + compat.warn === 0,
|
|
2466
|
+
},
|
|
2467
|
+
compat.error + compat.warn > 0
|
|
2468
|
+
? tr('处理兼容性 · ' + (compat.error + compat.warn) + ' 项', 'Handle compatibility · ' + (compat.error + compat.warn))
|
|
2469
|
+
: tr('没有待处理项', 'Nothing to handle'),
|
|
2470
|
+
),
|
|
2471
|
+
),
|
|
2297
2472
|
),
|
|
2298
2473
|
h(
|
|
2299
2474
|
Card,
|
|
@@ -2311,6 +2486,23 @@ window.__ModuleLoader__.load({
|
|
|
2311
2486
|
showContext ? tr('收起明细', 'Collapse details') : tr('查看明细', 'View details'),
|
|
2312
2487
|
),
|
|
2313
2488
|
},
|
|
2489
|
+
h(
|
|
2490
|
+
'div',
|
|
2491
|
+
{ className: 'eo-context-mix' },
|
|
2492
|
+
h('div', {
|
|
2493
|
+
className: 'eo-context-donut',
|
|
2494
|
+
style: { '--eo-ok': contextPct + '%' },
|
|
2495
|
+
role: 'img',
|
|
2496
|
+
'aria-label': tr('可归属与未归属上下文的构成', 'Attributable vs unattributed context'),
|
|
2497
|
+
title: tr('可归属与未归属上下文的构成', 'Attributable vs unattributed context'),
|
|
2498
|
+
}, h('div', { className: 'eo-context-donut-label' }, h('b', null, Math.round(contextPct) + '%'), h('small', null, tr('可归属', 'attributed')))),
|
|
2499
|
+
h(
|
|
2500
|
+
'div',
|
|
2501
|
+
{ className: 'eo-context-legend' },
|
|
2502
|
+
h('div', { className: 'eo-context-legend-row' }, h('i', { className: 'eo-dot-ok' }), h('span', null, tr('可归属', 'Attributable')), h('strong', null, formatNumber(attributedContext)), h('em', null, Math.round(contextPct) + '%')),
|
|
2503
|
+
h('div', { className: 'eo-context-legend-row' }, h('i', { className: 'eo-dot-warn' }), h('span', null, tr('未归属', 'Unattributed')), h('strong', null, formatNumber(overview.context.unattributedTokens)), h('em', null, Math.round(100 - contextPct) + '%')),
|
|
2504
|
+
),
|
|
2505
|
+
),
|
|
2314
2506
|
h(
|
|
2315
2507
|
'div',
|
|
2316
2508
|
{ className: 'eo-owner-list' },
|
|
@@ -2322,11 +2514,11 @@ window.__ModuleLoader__.load({
|
|
|
2322
2514
|
'div',
|
|
2323
2515
|
{ className: 'eo-owner-head' },
|
|
2324
2516
|
h('span', null, owner.owner),
|
|
2325
|
-
h('span', null, formatNumber(owner.tokens)),
|
|
2517
|
+
h('span', null, formatNumber(owner.tokens) + ' · ' + Math.round((owner.tokens / Math.max(1, totalContextTokens)) * 100) + '%'),
|
|
2326
2518
|
),
|
|
2327
2519
|
h(
|
|
2328
2520
|
'div',
|
|
2329
|
-
{ className: 'eo-bar' },
|
|
2521
|
+
{ className: 'eo-bar', title: owner.owner + ' · ' + formatNumber(owner.tokens) + ' tokens' },
|
|
2330
2522
|
h('i', {
|
|
2331
2523
|
style: { width: Math.max(3, (owner.tokens / maxOwner) * 100) + '%' },
|
|
2332
2524
|
}),
|
|
@@ -2501,9 +2693,8 @@ window.__ModuleLoader__.load({
|
|
|
2501
2693
|
h(
|
|
2502
2694
|
'td',
|
|
2503
2695
|
{ className: 'eo-muted eo-share-cell', title: tr('占可归属上下文的比例', 'Share of attributable context') },
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
: '—',
|
|
2696
|
+
h('span', null, Math.round(shareOf(bundle)) + '%'),
|
|
2697
|
+
h('div', { className: 'eo-share-bar' }, h('i', { style: { width: shareOf(bundle) + '%' } })),
|
|
2507
2698
|
),
|
|
2508
2699
|
h(
|
|
2509
2700
|
'td',
|
|
@@ -3221,6 +3412,9 @@ window.__ModuleLoader__.load({
|
|
|
3221
3412
|
function apply(ctx) {
|
|
3222
3413
|
CURRENT_LOCALE = detectLocale()
|
|
3223
3414
|
injectCss()
|
|
3415
|
+
const guard = (Component) => function Guarded(props) {
|
|
3416
|
+
return h(PluginErrorBoundary, null, h(Component, props))
|
|
3417
|
+
}
|
|
3224
3418
|
ctx.slots.inject('conversation.composer.dock', () =>
|
|
3225
3419
|
ctx.slots.register(
|
|
3226
3420
|
{
|
|
@@ -3228,7 +3422,7 @@ window.__ModuleLoader__.load({
|
|
|
3228
3422
|
id: 'experience-optimizer-checkup',
|
|
3229
3423
|
order: 20,
|
|
3230
3424
|
},
|
|
3231
|
-
CheckupBubble,
|
|
3425
|
+
guard(CheckupBubble),
|
|
3232
3426
|
),
|
|
3233
3427
|
)
|
|
3234
3428
|
ctx.slots.inject('conversation.chat.reasoning.body', () =>
|
|
@@ -3237,7 +3431,7 @@ window.__ModuleLoader__.load({
|
|
|
3237
3431
|
name: 'conversation.chat.reasoning.body',
|
|
3238
3432
|
priority: 90,
|
|
3239
3433
|
},
|
|
3240
|
-
ReasoningCheckup,
|
|
3434
|
+
guard(ReasoningCheckup),
|
|
3241
3435
|
),
|
|
3242
3436
|
)
|
|
3243
3437
|
ctx.slots.inject('plugins.bundle.activation', () =>
|
|
@@ -3246,7 +3440,7 @@ window.__ModuleLoader__.load({
|
|
|
3246
3440
|
name: 'plugins.bundle.activation',
|
|
3247
3441
|
key: 'dsh-plugin-trim',
|
|
3248
3442
|
},
|
|
3249
|
-
ActivationGuide,
|
|
3443
|
+
guard(ActivationGuide),
|
|
3250
3444
|
),
|
|
3251
3445
|
)
|
|
3252
3446
|
ctx.slots.inject('shell.overlay', () =>
|
|
@@ -3256,7 +3450,7 @@ window.__ModuleLoader__.load({
|
|
|
3256
3450
|
id: 'experience-optimizer-guide',
|
|
3257
3451
|
order: 10,
|
|
3258
3452
|
},
|
|
3259
|
-
MainGuide,
|
|
3453
|
+
guard(MainGuide),
|
|
3260
3454
|
),
|
|
3261
3455
|
)
|
|
3262
3456
|
ctx.slots.inject('settings.plugins.tab', () =>
|
|
@@ -3267,7 +3461,7 @@ window.__ModuleLoader__.load({
|
|
|
3267
3461
|
order: 40,
|
|
3268
3462
|
label: () => '插件体检',
|
|
3269
3463
|
},
|
|
3270
|
-
ExperiencePanel,
|
|
3464
|
+
guard(ExperiencePanel),
|
|
3271
3465
|
),
|
|
3272
3466
|
)
|
|
3273
3467
|
ctx.slots.inject('settings.section', () =>
|
|
@@ -3278,7 +3472,7 @@ window.__ModuleLoader__.load({
|
|
|
3278
3472
|
order: 25,
|
|
3279
3473
|
label: () => '插件体检',
|
|
3280
3474
|
},
|
|
3281
|
-
ExperiencePanel,
|
|
3475
|
+
guard(ExperiencePanel),
|
|
3282
3476
|
),
|
|
3283
3477
|
)
|
|
3284
3478
|
ctx.slots.inject('settings.section.icon', () =>
|
package/dist/index.js
CHANGED
|
@@ -4588,7 +4588,8 @@ function registerCompatTool(ctx, config) {
|
|
|
4588
4588
|
}
|
|
4589
4589
|
// src/api.ts
|
|
4590
4590
|
const API_PREFIX = "/api/dsh-experience-optimizer";
|
|
4591
|
-
const
|
|
4591
|
+
const CLIENT_HEADER = "x-dsh-trim-client";
|
|
4592
|
+
const CURRENT_VERSION = "0.3.10";
|
|
4592
4593
|
let updateCache;
|
|
4593
4594
|
const TASK_TAGS = [
|
|
4594
4595
|
"bugfix",
|
|
@@ -4634,6 +4635,10 @@ async function handleTrimRequest(req, res, ctx, config, ledger) {
|
|
|
4634
4635
|
sendError(res, 403, "cross-site request rejected");
|
|
4635
4636
|
return;
|
|
4636
4637
|
}
|
|
4638
|
+
if (req.headers[CLIENT_HEADER] !== "1") {
|
|
4639
|
+
sendError(res, 403, "client header required");
|
|
4640
|
+
return;
|
|
4641
|
+
}
|
|
4637
4642
|
const path = new URL(req.url ?? "/", "http://localhost").pathname.slice(29) || "/";
|
|
4638
4643
|
try {
|
|
4639
4644
|
if (req.method === "GET" && path === "/overview") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-trim",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.10",
|
|
4
4
|
"description": "DSH plugin checkup and compatibility analyzer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -69,6 +69,47 @@
|
|
|
69
69
|
"@deepseek-ai/dsh-tools": "^0.2.2-rc.1",
|
|
70
70
|
"@deepseek-ai/schemastery": "~3.19.0"
|
|
71
71
|
},
|
|
72
|
+
"peerDependenciesMeta": {
|
|
73
|
+
"@deepseek-ai/cordis": {
|
|
74
|
+
"optional": true
|
|
75
|
+
},
|
|
76
|
+
"@deepseek-ai/cordis-plugin-loader": {
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
79
|
+
"@deepseek-ai/dsh": {
|
|
80
|
+
"optional": true
|
|
81
|
+
},
|
|
82
|
+
"@deepseek-ai/dsh-agent": {
|
|
83
|
+
"optional": true
|
|
84
|
+
},
|
|
85
|
+
"@deepseek-ai/dsh-app-boot": {
|
|
86
|
+
"optional": true
|
|
87
|
+
},
|
|
88
|
+
"@deepseek-ai/dsh-host-plugin-inventory": {
|
|
89
|
+
"optional": true
|
|
90
|
+
},
|
|
91
|
+
"@deepseek-ai/dsh-llm": {
|
|
92
|
+
"optional": true
|
|
93
|
+
},
|
|
94
|
+
"@deepseek-ai/dsh-plugin-manager": {
|
|
95
|
+
"optional": true
|
|
96
|
+
},
|
|
97
|
+
"@deepseek-ai/dsh-scope": {
|
|
98
|
+
"optional": true
|
|
99
|
+
},
|
|
100
|
+
"@deepseek-ai/dsh-session": {
|
|
101
|
+
"optional": true
|
|
102
|
+
},
|
|
103
|
+
"@deepseek-ai/dsh-system-prompt": {
|
|
104
|
+
"optional": true
|
|
105
|
+
},
|
|
106
|
+
"@deepseek-ai/dsh-tools": {
|
|
107
|
+
"optional": true
|
|
108
|
+
},
|
|
109
|
+
"@deepseek-ai/schemastery": {
|
|
110
|
+
"optional": true
|
|
111
|
+
}
|
|
112
|
+
},
|
|
72
113
|
"devDependencies": {
|
|
73
114
|
"@deepseek-ai/cordis": "~4.1.0",
|
|
74
115
|
"@deepseek-ai/cordis-plugin-loader": "~1.1.0",
|