@michengai/dsh-automation 0.1.32 → 0.1.35
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 +15 -0
- package/CHANGELOG.zh-CN.md +15 -0
- package/README.md +50 -34
- package/README.zh-CN.md +50 -34
- package/lib/client.js +333 -11
- package/lib/client.js.map +4 -4
- package/lib/index.js +412 -154
- package/lib/types/client/plugin-update-ui.d.ts +20 -0
- package/lib/types/plugin-updater.d.ts +21 -0
- package/package.json +6 -2
package/lib/client.js
CHANGED
|
@@ -927,7 +927,7 @@ function MenuRow({
|
|
|
927
927
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: label })
|
|
928
928
|
] }),
|
|
929
929
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-st-menu-row-side", children: [
|
|
930
|
-
hint,
|
|
930
|
+
hint !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: hint }),
|
|
931
931
|
active === true && chevron !== true && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("i", { className: "dsh-st-tick" }),
|
|
932
932
|
chevron === true && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("i", { className: "dsh-st-next" })
|
|
933
933
|
] })
|
|
@@ -1400,10 +1400,7 @@ function ModelPicker({
|
|
|
1400
1400
|
title: item.label,
|
|
1401
1401
|
onClick: () => selectModel(item),
|
|
1402
1402
|
children: [
|
|
1403
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.
|
|
1404
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-st-model-name", children: item.label }),
|
|
1405
|
-
item.description !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-st-model-description", children: item.description })
|
|
1406
|
-
] }),
|
|
1403
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-st-model-option-copy", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-st-model-name", children: item.label }) }),
|
|
1407
1404
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-st-model-check", children: value === modelKey && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives.IconCheckOutline16, {}) })
|
|
1408
1405
|
]
|
|
1409
1406
|
},
|
|
@@ -3918,12 +3915,12 @@ function NativeTaskRail({
|
|
|
3918
3915
|
// src/client/styles.ts
|
|
3919
3916
|
var STYLE_ID = "dsh-automation-styles";
|
|
3920
3917
|
var CSS_TEXT = `
|
|
3921
|
-
.dsh-st-shell{box-sizing:border-box;max-width:1080px;width:100%;margin:0 auto;padding:0 0 32px;color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family,system-ui)}
|
|
3918
|
+
.dsh-st-shell{container-type:inline-size;min-width:0;box-sizing:border-box;max-width:1080px;width:100%;margin:0 auto;padding:0 0 32px;color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family,system-ui)}
|
|
3922
3919
|
.dsh-st-top{display:flex;flex-direction:column;align-items:stretch;gap:12px;margin-bottom:12px}
|
|
3923
|
-
.dsh-st-heading h1,.dsh-st-top h1{margin:0;font-size:
|
|
3924
|
-
.dsh-st-heading-row{display:flex;align-items:center;gap:8px;min-width:0;flex-wrap:wrap}.dsh-st-heading-links{display:inline-flex;align-items:center;gap:4px;min-width:0}.dsh-st-heading-link{display:inline-flex;align-items:center;gap:5px;min-height:28px;padding:0 8px;color:var(--dsw-alias-label-secondary);background:transparent;border:1px solid var(--dsw-alias-border-l2);border-radius:7px;font-size:12px;font-weight:500;line-height:18px;text-decoration:none;white-space:nowrap}.dsh-st-heading-link:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}.dsh-st-heading-link:focus-visible{outline:2px solid var(--dsw-alias-state-success-primary);outline-offset:2px}.dsh-st-heading-link svg{flex:none}
|
|
3925
|
-
.dsh-st-heading p,.dsh-st-top p{margin:
|
|
3926
|
-
.dsh-st-toolbar{display:flex;flex-wrap:
|
|
3920
|
+
.dsh-st-heading h1,.dsh-st-top h1{margin:0;font-size:24px;line-height:32px;font-weight:600;letter-spacing:-.4px;white-space:nowrap}
|
|
3921
|
+
.dsh-st-heading-row{display:flex;align-items:center;gap:8px;min-width:0;flex-wrap:wrap}.dsh-st-heading-links{display:inline-flex;align-items:center;gap:4px;min-width:0;flex-wrap:wrap}.dsh-st-heading-link{display:inline-flex;align-items:center;gap:5px;min-height:28px;padding:0 8px;color:var(--dsw-alias-label-secondary);background:transparent;border:1px solid var(--dsw-alias-border-l2);border-radius:7px;font-size:12px;font-weight:500;line-height:18px;text-decoration:none;white-space:nowrap}.dsh-st-heading-link:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}.dsh-st-heading-link:focus-visible{outline:2px solid var(--dsw-alias-state-success-primary);outline-offset:2px}.dsh-st-heading-link svg{flex:none}
|
|
3922
|
+
.dsh-st-heading p,.dsh-st-top p{margin:12px 0 0;max-width:none;color:var(--dsw-alias-label-tertiary);font-size:14px;line-height:22px}
|
|
3923
|
+
.dsh-st-toolbar{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-start;gap:8px}
|
|
3927
3924
|
.dsh-st-search{flex:1;min-width:0;max-width:280px;height:32px;padding:0 12px;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;background:var(--dsw-alias-bg-layer-3,var(--dsw-alias-bg-layer-1));color:inherit;font:inherit;font-size:13px}
|
|
3928
3925
|
.dsh-st-btn,.dsh-st-icon{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:32px;padding:0 12px;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;background:transparent;color:inherit;font:inherit;font-size:13px;cursor:pointer;white-space:nowrap}
|
|
3929
3926
|
.dsh-st-icon{width:32px;padding:0;flex:none}
|
|
@@ -4052,7 +4049,7 @@ var CSS_TEXT = `
|
|
|
4052
4049
|
.dsh-st-chip-btn:hover{background:rgba(255,255,255,.06);color:var(--dsw-alias-label-primary)}
|
|
4053
4050
|
.dsh-st-chip-btn.is-static{cursor:default;opacity:.78}
|
|
4054
4051
|
.dsh-st-chip-btn em,.dsh-st-select.is-pill .dsh-st-select-btn em{width:6px;height:6px;margin-left:2px;opacity:.55}
|
|
4055
|
-
.dsh-st-model-select{position:relative;z-index:1;min-width:0;flex:none}.dsh-st-model-select.is-open{z-index:30}.dsh-st-model-select-trigger{display:flex;align-items:center;gap:4px;min-width:0;max-width:260px;height:28px;padding:0 4px 0 8px;border:0;border-radius:24px;background:transparent;color:var(--dsw-alias-label-secondary);font-size:13px;font-weight:500;line-height:20px;cursor:pointer}.dsh-st-model-select-trigger:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.dsh-st-model-select-trigger>span:first-child{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dsh-st-model-trigger-effort{flex:none;color:var(--dsw-alias-label-tertiary);white-space:nowrap}.dsh-st-model-trigger-chevron{flex:none;transition:transform .16s ease}.dsh-st-model-trigger-chevron.is-open{transform:rotate(180deg)}.dsh-st-model-select-menu{z-index:30;width:min(240px,calc(100vw - 32px));max-height:min(360px,calc(100vh - 96px));overflow-y:auto;padding:4px;border:1px solid var(--dsw-alias-border-inverted,var(--dsw-alias-border-l2));border-radius:12px;background:var(--dsw-specific-menu,var(--dsw-alias-bg-base));box-shadow:var(--dsw-shadow-lv3)}.dsh-st-model-select-menu.is-float{position:absolute;z-index:1200;box-sizing:border-box}.dsh-st-model-select-menu .dsh-st-menu-row{min-height:40px;padding:0 10px;border-radius:10px;font-size:14px}.dsh-st-model-select-menu .dsh-st-menu-row.is-kv .dsh-st-menu-row-side{font-size:13px;color:var(--dsw-alias-label-tertiary)}.dsh-st-model-group+.dsh-st-model-group{margin-top:4px}.dsh-st-model-group-title{position:sticky;top:0;z-index:1;padding:5px 8px 3px;background:var(--dsw-specific-menu,var(--dsw-alias-bg-base));color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:500;line-height:18px}.dsh-st-model-option{display:flex;width:100%;min-height:38px;align-items:center;gap:8px;padding:6px 8px;border:0;border-radius:10px;background:transparent;color:var(--dsw-alias-label-primary);text-align:left;cursor:pointer}.dsh-st-model-option:hover,.dsh-st-model-option:focus-visible{background:var(--dsw-alias-interactive-bg-hover);outline:none}.dsh-st-model-option-copy{display:flex;min-width:0;flex:1;flex-direction:column}.dsh-st-model-name{overflow:hidden;font-size:14px;font-weight:500;line-height:20px;text-overflow:ellipsis;white-space:nowrap}.dsh-st-model-description{overflow:hidden;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px;text-overflow:ellipsis;white-space:nowrap}.dsh-st-model-check{display:grid;flex:0 0 18px;place-items:center;color:var(--dsw-alias-label-primary)}.dsh-st-model-warning{margin:4px;padding:8px;border-radius:8px;background:var(--dsw-alias-interactive-bg-hover-danger,rgba(248,81,73,.1));color:var(--dsw-alias-state-error-primary,#f85149);font-size:12px;line-height:18px}.dsh-st-model-empty{padding:14px 12px;color:var(--dsw-alias-label-tertiary);font-size:12px;text-align:center}
|
|
4052
|
+
.dsh-st-model-select{position:relative;z-index:1;min-width:0;flex:none}.dsh-st-model-select.is-open{z-index:30}.dsh-st-model-select-trigger{display:flex;align-items:center;gap:4px;min-width:0;max-width:260px;height:28px;padding:0 4px 0 8px;border:0;border-radius:24px;background:transparent;color:var(--dsw-alias-label-secondary);font-size:13px;font-weight:500;line-height:20px;cursor:pointer}.dsh-st-model-select-trigger:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.dsh-st-model-select-trigger>span:first-child{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dsh-st-model-trigger-effort{flex:none;color:var(--dsw-alias-label-tertiary);white-space:nowrap}.dsh-st-model-trigger-chevron{flex:none;transition:transform .16s ease}.dsh-st-model-trigger-chevron.is-open{transform:rotate(180deg)}.dsh-st-model-select-menu{z-index:30;width:max-content;min-width:min(240px,calc(100vw - 32px));max-width:calc(100vw - 32px);max-height:min(360px,calc(100vh - 96px));overflow-y:auto;padding:4px;border:1px solid var(--dsw-alias-border-inverted,var(--dsw-alias-border-l2));border-radius:12px;background:var(--dsw-specific-menu,var(--dsw-alias-bg-base));box-shadow:var(--dsw-shadow-lv3)}.dsh-st-model-select-menu.is-float{position:absolute;z-index:1200;box-sizing:border-box}.dsh-st-model-select-menu .dsh-st-menu-row{min-height:40px;padding:0 10px;border-radius:10px;font-size:14px}.dsh-st-model-select-menu .dsh-st-menu-row-side>span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dsh-st-model-select-menu .dsh-st-menu-row.is-kv .dsh-st-menu-row-side{font-size:13px;color:var(--dsw-alias-label-tertiary)}.dsh-st-model-group+.dsh-st-model-group{margin-top:4px}.dsh-st-model-group-title{position:sticky;top:0;z-index:1;padding:5px 8px 3px;background:var(--dsw-specific-menu,var(--dsw-alias-bg-base));color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:500;line-height:18px}.dsh-st-model-option{display:flex;width:100%;min-height:38px;align-items:center;gap:8px;padding:6px 8px;border:0;border-radius:10px;background:transparent;color:var(--dsw-alias-label-primary);text-align:left;cursor:pointer}.dsh-st-model-option:hover,.dsh-st-model-option:focus-visible{background:var(--dsw-alias-interactive-bg-hover);outline:none}.dsh-st-model-option-copy{display:flex;min-width:0;flex:1;flex-direction:column}.dsh-st-model-name{overflow:hidden;font-size:14px;font-weight:500;line-height:20px;text-overflow:ellipsis;white-space:nowrap}.dsh-st-model-description{overflow:hidden;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px;text-overflow:ellipsis;white-space:nowrap}.dsh-st-model-check{display:grid;flex:0 0 18px;place-items:center;color:var(--dsw-alias-label-primary)}.dsh-st-model-warning{margin:4px;padding:8px;border-radius:8px;background:var(--dsw-alias-interactive-bg-hover-danger,rgba(248,81,73,.1));color:var(--dsw-alias-state-error-primary,#f85149);font-size:12px;line-height:18px}.dsh-st-model-empty{padding:14px 12px;color:var(--dsw-alias-label-tertiary);font-size:12px;text-align:center}
|
|
4056
4053
|
.dsh-st-suffix{color:var(--dsw-alias-label-secondary);font-size:13px}
|
|
4057
4054
|
.dsh-st-inline input.is-narrow{width:72px;flex:none}
|
|
4058
4055
|
.dsh-st-time{display:inline-flex;align-items:center;gap:2px;min-height:36px;padding:0 8px;border:1px solid var(--dsw-alias-border-l2);border-radius:12px;background:rgba(255,255,255,.04)}
|
|
@@ -4223,9 +4220,325 @@ function openSettingsSection(labels, onSelected, onMissing) {
|
|
|
4223
4220
|
schedule();
|
|
4224
4221
|
}
|
|
4225
4222
|
|
|
4223
|
+
// src/client/plugin-update-ui.ts
|
|
4224
|
+
var UPDATE_HEADER = "x-michengai-plugin-update";
|
|
4225
|
+
var STYLE_ID2 = "michengai-plugin-update-ui";
|
|
4226
|
+
var CSS = `
|
|
4227
|
+
.mpi-version{margin-left:8px;color:var(--dsw-alias-label-tertiary,#9da1aa);font-family:inherit;font-size:12px;font-weight:500;line-height:18px;letter-spacing:0;white-space:nowrap;vertical-align:baseline}.mpi-check{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:28px;padding:0 8px;border:1px solid var(--dsw-alias-border-l2,#4b4d52);border-radius:7px;background:transparent;color:var(--dsw-alias-label-secondary,#b8bbc2);font:inherit;font-size:12px;font-weight:500;line-height:18px;white-space:nowrap;cursor:pointer}.mpi-check:hover{background:var(--dsw-alias-interactive-bg-hover,#3a3b3f);color:var(--dsw-alias-label-primary,#fff)}.mpi-check:focus-visible,.mpi-action:focus-visible,.mpi-dialog-close:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary,#4f8cff);outline-offset:2px}.mpi-icon{display:inline-flex;flex:0 0 auto;width:16px;height:16px;align-items:center;justify-content:center;pointer-events:none}.mpi-icon svg{display:block;width:16px;height:16px}
|
|
4228
|
+
.mpi-overlay{position:fixed;inset:0;z-index:2147483647;display:flex;align-items:center;justify-content:center;padding:24px;background:rgba(0,0,0,.62)}.mpi-dialog{position:relative;box-sizing:border-box;width:min(680px,100%);max-height:calc(100vh - 48px);overflow:auto;border:1px solid var(--dsw-alias-border-l2,#4b4d52);border-radius:14px;padding:22px;background:var(--dsw-alias-bg-layer-2,var(--dsw-specific-menu,#202124));color:var(--dsw-alias-label-primary,#fff);box-shadow:var(--dsw-shadow-lv3,0 16px 48px rgba(0,0,0,.24));font-family:inherit}.mpi-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.mpi-dialog h2{margin:0;font-size:18px;line-height:26px}.mpi-dialog-close{display:inline-flex;flex:0 0 28px;width:28px;height:28px;align-items:center;justify-content:center;padding:0;border:0;border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary,#b8bbc2);cursor:pointer}.mpi-dialog-close:hover{background:var(--dsw-alias-interactive-bg-hover,#3a3b3f);color:var(--dsw-alias-label-primary,#fff)}.mpi-intro{margin:8px 0 18px;color:var(--dsw-alias-label-secondary,#c2c4ca);font-size:13px;line-height:20px}.mpi-meta{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:8px 18px;margin:0 0 16px;font-size:12px;line-height:18px}.mpi-meta dt{color:var(--dsw-alias-label-secondary,#c2c4ca)}.mpi-meta dd{margin:0;font-family:ui-monospace,SFMono-Regular,Consolas,monospace}.mpi-status{margin:0 0 18px;border-radius:7px;padding:12px 14px;background:var(--dsw-alias-bg-layer-3,var(--dsw-specific-menu-item-hover,#252527));font-size:13px;font-weight:600;line-height:20px}.mpi-status[data-kind=error]{color:var(--dsw-alias-state-error-primary,#ff6464)}.mpi-status[data-kind=success]{color:var(--dsw-alias-state-success-primary,#36d67a)}.mpi-manual{border-top:1px solid var(--dsw-alias-border-l2,#4b4d52);padding-top:16px}.mpi-manual h3{margin:0 0 6px;font-size:14px;line-height:20px}.mpi-manual p{margin:0 0 10px;color:var(--dsw-alias-label-secondary,#c2c4ca);font-size:12px;line-height:18px}.mpi-command{display:flex;align-items:center;gap:8px;border:1px solid var(--dsw-alias-border-l2,#4b4d52);border-radius:7px;padding:10px;background:var(--dsw-alias-bg-layer-3,var(--dsw-specific-menu-item-hover,#252527))}.mpi-command code{min-width:0;flex:1;overflow:auto;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12px;line-height:18px;white-space:nowrap}.mpi-actions{display:flex;align-items:center;justify-content:flex-end;gap:12px;margin-top:18px}.mpi-actions-group{display:flex;gap:8px}.mpi-action{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:32px;border:1px solid var(--dsw-alias-border-l2,#4b4d52);border-radius:7px;padding:6px 10px;background:transparent;color:inherit;font:inherit;font-size:12px;cursor:pointer}.mpi-action:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,#414247)}.mpi-action:disabled{cursor:not-allowed;opacity:.55}.mpi-primary{border-color:var(--dsw-alias-state-business-primary,#4f8cff);background:var(--dsw-alias-state-business-primary,#4f8cff);color:#fff}.mpi-progress{height:4px;margin-top:10px;overflow:hidden;border-radius:99px;background:var(--dsw-alias-border-l2,#4b4d52)}.mpi-progress::after{display:block;width:32%;height:100%;background:var(--dsw-alias-state-business-primary,#4f8cff);content:'';animation:mpi-wave 1.15s ease-in-out infinite}@keyframes mpi-wave{from{transform:translateX(-110%)}to{transform:translateX(330%)}}@media(max-width:560px){.mpi-overlay{padding:10px}.mpi-dialog{max-height:calc(100vh - 20px);padding:16px}.mpi-actions{align-items:stretch}.mpi-actions-group{justify-content:flex-end;flex-wrap:wrap}.mpi-meta{grid-template-columns:1fr;gap:2px}.mpi-meta dd{margin-bottom:6px}}
|
|
4229
|
+
`;
|
|
4230
|
+
var ZH = {
|
|
4231
|
+
check: "\u68C0\u67E5\u66F4\u65B0",
|
|
4232
|
+
update: "\u66F4\u65B0",
|
|
4233
|
+
close: "\u5173\u95ED",
|
|
4234
|
+
recheck: "\u91CD\u65B0\u68C0\u67E5",
|
|
4235
|
+
auto: "\u81EA\u52A8\u66F4\u65B0",
|
|
4236
|
+
updating: "\u6B63\u5728\u66F4\u65B0\u2026",
|
|
4237
|
+
copy: "\u590D\u5236\u547D\u4EE4",
|
|
4238
|
+
copied: "\u5DF2\u590D\u5236",
|
|
4239
|
+
copyFailed: "\u590D\u5236\u5931\u8D25",
|
|
4240
|
+
checking: "\u6B63\u5728\u68C0\u67E5\u66F4\u65B0\u2026",
|
|
4241
|
+
latest: "\u5DF2\u662F\u6700\u65B0\u7248\u672C",
|
|
4242
|
+
found: "\u53D1\u73B0\u65B0\u7248\u672C",
|
|
4243
|
+
failed: "\u68C0\u67E5\u66F4\u65B0\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",
|
|
4244
|
+
current: "\u8FD0\u884C\u7248\u672C",
|
|
4245
|
+
latestLabel: "\u6700\u65B0\u7248\u672C",
|
|
4246
|
+
profile: "\u76EE\u6807 profile",
|
|
4247
|
+
unknown: "\u672A\u77E5",
|
|
4248
|
+
manual: "\u624B\u5DE5\u66F4\u65B0",
|
|
4249
|
+
manualHint: "\u81EA\u52A8\u66F4\u65B0\u5931\u8D25\u65F6\uFF0C\u53EF\u5728\u5F53\u524D DSH \u7EC8\u7AEF\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\uFF0C\u5B8C\u6210\u540E\u91CD\u542F DSH Web\u3002",
|
|
4250
|
+
intro: "\u4EC5\u68C0\u67E5\u5E76\u66F4\u65B0\u5F53\u524D\u63D2\u4EF6\uFF0C\u4E0D\u4F1A\u8054\u52A8\u5B89\u88C5\u5176\u4ED6\u63D2\u4EF6\u3002",
|
|
4251
|
+
restart: "\u66F4\u65B0\u5B8C\u6210\uFF0C\u8BF7\u91CD\u542F DSH Web\u3002",
|
|
4252
|
+
restarting: "\u66F4\u65B0\u5B8C\u6210\uFF0C\u6B63\u5728\u91CD\u542F DSH Desktop\u2026",
|
|
4253
|
+
unavailable: "\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u81EA\u52A8\u66F4\u65B0\uFF0C\u8BF7\u4F7F\u7528\u624B\u5DE5\u66F4\u65B0\u547D\u4EE4\u3002"
|
|
4254
|
+
};
|
|
4255
|
+
var EN = {
|
|
4256
|
+
check: "Check for updates",
|
|
4257
|
+
update: "Update",
|
|
4258
|
+
close: "Close",
|
|
4259
|
+
recheck: "Check again",
|
|
4260
|
+
auto: "Update automatically",
|
|
4261
|
+
updating: "Updating\u2026",
|
|
4262
|
+
copy: "Copy command",
|
|
4263
|
+
copied: "Copied",
|
|
4264
|
+
copyFailed: "Copy failed",
|
|
4265
|
+
checking: "Checking for updates\u2026",
|
|
4266
|
+
latest: "You are up to date",
|
|
4267
|
+
found: "New version available",
|
|
4268
|
+
failed: "Could not check for updates. Try again later.",
|
|
4269
|
+
current: "Running version",
|
|
4270
|
+
latestLabel: "Latest version",
|
|
4271
|
+
profile: "Target profile",
|
|
4272
|
+
unknown: "Unknown",
|
|
4273
|
+
manual: "Manual update",
|
|
4274
|
+
manualHint: "If automatic update fails, run this command in the current DSH terminal, then restart DSH Web.",
|
|
4275
|
+
intro: "Only this plugin is checked and updated. Other plugins are not changed.",
|
|
4276
|
+
restart: "Update complete. Restart DSH Web.",
|
|
4277
|
+
restarting: "Update complete. Restarting DSH Desktop\u2026",
|
|
4278
|
+
unavailable: "Automatic update is unavailable. Use the manual command."
|
|
4279
|
+
};
|
|
4280
|
+
function strings() {
|
|
4281
|
+
const lang = document.documentElement.lang.toLowerCase();
|
|
4282
|
+
const settings = document.querySelector('[role="dialog"]')?.textContent ?? "";
|
|
4283
|
+
return lang.startsWith("en") || settings.includes("Settings") && !settings.includes("\u8BBE\u7F6E") ? EN : ZH;
|
|
4284
|
+
}
|
|
4285
|
+
function ensureStyle() {
|
|
4286
|
+
if (document.getElementById(STYLE_ID2) !== null) return;
|
|
4287
|
+
const style = document.createElement("style");
|
|
4288
|
+
style.id = STYLE_ID2;
|
|
4289
|
+
style.textContent = CSS;
|
|
4290
|
+
(document.head ?? document.documentElement).append(style);
|
|
4291
|
+
}
|
|
4292
|
+
function validPayload(value) {
|
|
4293
|
+
if (value === null || typeof value !== "object") return false;
|
|
4294
|
+
const item = value;
|
|
4295
|
+
return typeof item.packageName === "string" && typeof item.currentVersion === "string" && typeof item.updateAvailable === "boolean" && typeof item.profileName === "string" && typeof item.canAutoUpdate === "boolean" && typeof item.latestCheckFailed === "boolean" && (item.latestVersion === void 0 || typeof item.latestVersion === "string");
|
|
4296
|
+
}
|
|
4297
|
+
async function requestStatus(endpoint, method, signal) {
|
|
4298
|
+
const signalOption = signal === void 0 ? {} : { signal };
|
|
4299
|
+
const response = await fetch(endpoint, method === "GET" ? { cache: "no-store", ...signalOption } : {
|
|
4300
|
+
method: "POST",
|
|
4301
|
+
headers: { "content-type": "application/json", [UPDATE_HEADER]: "1" },
|
|
4302
|
+
body: "{}",
|
|
4303
|
+
...signalOption
|
|
4304
|
+
});
|
|
4305
|
+
const value = await response.json();
|
|
4306
|
+
if (!response.ok || !validPayload(value)) throw new Error(typeof value.error === "string" ? value.error : strings().failed);
|
|
4307
|
+
return value;
|
|
4308
|
+
}
|
|
4309
|
+
function manualPluginUpdateCommand(profileName, packageName, version) {
|
|
4310
|
+
const profile = profileName.trim() === "" ? "" : ` --profile ${profileName.trim()}`;
|
|
4311
|
+
return `dsh plugin${profile} add ${packageName}@${version} --registry=https://registry.npmjs.org/`;
|
|
4312
|
+
}
|
|
4313
|
+
function handlePluginUpdateEscape(event, close) {
|
|
4314
|
+
if (event.key !== "Escape") return false;
|
|
4315
|
+
event.preventDefault();
|
|
4316
|
+
event.stopPropagation();
|
|
4317
|
+
event.stopImmediatePropagation();
|
|
4318
|
+
close();
|
|
4319
|
+
return true;
|
|
4320
|
+
}
|
|
4321
|
+
function observePluginUpdate(options) {
|
|
4322
|
+
if (typeof document === "undefined" || document.body === null) return () => {
|
|
4323
|
+
};
|
|
4324
|
+
ensureStyle();
|
|
4325
|
+
const controller = new AbortController();
|
|
4326
|
+
let payload;
|
|
4327
|
+
let overlay;
|
|
4328
|
+
let frame;
|
|
4329
|
+
const setButtonContent = (button, label, iconName) => {
|
|
4330
|
+
const icon = options.createIcon(iconName);
|
|
4331
|
+
icon.classList.add("mpi-icon");
|
|
4332
|
+
icon.setAttribute("aria-hidden", "true");
|
|
4333
|
+
const text = document.createElement("span");
|
|
4334
|
+
text.dataset.mpiLabel = "";
|
|
4335
|
+
text.textContent = label;
|
|
4336
|
+
button.replaceChildren(icon, text);
|
|
4337
|
+
};
|
|
4338
|
+
const setButtonLabel = (button, label) => {
|
|
4339
|
+
const text = button.querySelector("[data-mpi-label]");
|
|
4340
|
+
if (text === null) button.textContent = label;
|
|
4341
|
+
else text.textContent = label;
|
|
4342
|
+
};
|
|
4343
|
+
const applyControls = () => {
|
|
4344
|
+
const row = document.querySelector(options.titleRowSelector);
|
|
4345
|
+
if (row === null) return;
|
|
4346
|
+
const heading = row.querySelector("h1,h2");
|
|
4347
|
+
if (heading !== null && payload !== void 0) {
|
|
4348
|
+
let version = heading.querySelector(`.mpi-version[data-package="${options.packageName}"]`);
|
|
4349
|
+
if (version === null) {
|
|
4350
|
+
version = document.createElement("span");
|
|
4351
|
+
version.className = "mpi-version";
|
|
4352
|
+
version.dataset.package = options.packageName;
|
|
4353
|
+
heading.append(version);
|
|
4354
|
+
}
|
|
4355
|
+
const versionLabel = `v${payload.currentVersion}`;
|
|
4356
|
+
if (version.textContent !== versionLabel) version.textContent = versionLabel;
|
|
4357
|
+
}
|
|
4358
|
+
const links = row.querySelector(options.linksSelector);
|
|
4359
|
+
if (links === null || links.querySelector(`[data-mpi-check="${options.packageName}"]`) !== null) return;
|
|
4360
|
+
const button = document.createElement("button");
|
|
4361
|
+
button.type = "button";
|
|
4362
|
+
button.className = "mpi-check";
|
|
4363
|
+
button.dataset.mpiCheck = options.packageName;
|
|
4364
|
+
setButtonContent(button, strings().check, "refresh");
|
|
4365
|
+
button.addEventListener("click", openDialog);
|
|
4366
|
+
links.append(button);
|
|
4367
|
+
};
|
|
4368
|
+
const load = async () => {
|
|
4369
|
+
payload = await requestStatus(options.endpoint, "GET", controller.signal);
|
|
4370
|
+
applyControls();
|
|
4371
|
+
return payload;
|
|
4372
|
+
};
|
|
4373
|
+
const closeDialog = () => {
|
|
4374
|
+
overlay?.remove();
|
|
4375
|
+
overlay = void 0;
|
|
4376
|
+
};
|
|
4377
|
+
function openDialog() {
|
|
4378
|
+
closeDialog();
|
|
4379
|
+
const text = strings();
|
|
4380
|
+
overlay = document.createElement("div");
|
|
4381
|
+
overlay.className = "mpi-overlay";
|
|
4382
|
+
const dialog = document.createElement("section");
|
|
4383
|
+
dialog.className = "mpi-dialog";
|
|
4384
|
+
dialog.setAttribute("role", "dialog");
|
|
4385
|
+
dialog.setAttribute("aria-modal", "true");
|
|
4386
|
+
dialog.innerHTML = `<header class="mpi-head"><h2></h2><button type="button" class="mpi-dialog-close" data-action="close"></button></header><p class="mpi-intro"></p><dl class="mpi-meta"><dt></dt><dd data-role="current"></dd><dt></dt><dd data-role="latest"></dd><dt></dt><dd data-role="profile"></dd></dl><div class="mpi-status" role="status"></div><div class="mpi-progress" hidden></div><section class="mpi-manual"><h3></h3><p></p><div class="mpi-command"><code></code><button type="button" class="mpi-action" data-action="copy"></button></div></section><footer class="mpi-actions"><div class="mpi-actions-group"><button type="button" class="mpi-action" data-action="check"></button><button type="button" class="mpi-action mpi-primary" data-action="update"></button></div></footer>`;
|
|
4387
|
+
const name2 = document.documentElement.lang.toLowerCase().startsWith("en") ? options.enName : options.zhName;
|
|
4388
|
+
dialog.querySelector("h2").textContent = `${name2} ${text.update}`;
|
|
4389
|
+
dialog.querySelector(".mpi-intro").textContent = text.intro;
|
|
4390
|
+
const terms = dialog.querySelectorAll("dt");
|
|
4391
|
+
terms[0].textContent = text.current;
|
|
4392
|
+
terms[1].textContent = text.latestLabel;
|
|
4393
|
+
terms[2].textContent = text.profile;
|
|
4394
|
+
dialog.querySelector(".mpi-manual h3").textContent = text.manual;
|
|
4395
|
+
dialog.querySelector(".mpi-manual p").textContent = text.manualHint;
|
|
4396
|
+
const status = dialog.querySelector(".mpi-status");
|
|
4397
|
+
const progress = dialog.querySelector(".mpi-progress");
|
|
4398
|
+
const command = dialog.querySelector(".mpi-command code");
|
|
4399
|
+
const close = dialog.querySelector("[data-action=close]");
|
|
4400
|
+
const check = dialog.querySelector("[data-action=check]");
|
|
4401
|
+
const update = dialog.querySelector("[data-action=update]");
|
|
4402
|
+
const copy = dialog.querySelector("[data-action=copy]");
|
|
4403
|
+
setButtonContent(close, text.close, "close");
|
|
4404
|
+
close.querySelector("[data-mpi-label]")?.remove();
|
|
4405
|
+
close.setAttribute("aria-label", text.close);
|
|
4406
|
+
close.title = text.close;
|
|
4407
|
+
setButtonContent(check, text.recheck, "refresh");
|
|
4408
|
+
setButtonContent(update, text.auto, "download");
|
|
4409
|
+
setButtonContent(copy, text.copy, "copy");
|
|
4410
|
+
let busy = false;
|
|
4411
|
+
const setMessage = (message, kind = "") => {
|
|
4412
|
+
status.textContent = message;
|
|
4413
|
+
status.dataset.kind = kind;
|
|
4414
|
+
};
|
|
4415
|
+
const setBusy = (value) => {
|
|
4416
|
+
busy = value;
|
|
4417
|
+
check.disabled = value;
|
|
4418
|
+
copy.disabled = value;
|
|
4419
|
+
update.disabled = value || payload?.canAutoUpdate !== true || payload.updateAvailable !== true;
|
|
4420
|
+
progress.hidden = !value;
|
|
4421
|
+
};
|
|
4422
|
+
const render = () => {
|
|
4423
|
+
dialog.querySelector("[data-role=current]").textContent = payload === void 0 ? text.unknown : `v${payload.currentVersion}`;
|
|
4424
|
+
dialog.querySelector("[data-role=latest]").textContent = payload?.latestVersion === void 0 ? text.unknown : `v${payload.latestVersion}`;
|
|
4425
|
+
dialog.querySelector("[data-role=profile]").textContent = payload?.profileName ?? text.unknown;
|
|
4426
|
+
command.textContent = manualPluginUpdateCommand(payload?.profileName ?? "", options.packageName, payload?.latestVersion ?? "latest");
|
|
4427
|
+
update.disabled = busy || payload?.canAutoUpdate !== true || payload.updateAvailable !== true;
|
|
4428
|
+
if (payload === void 0) setMessage(text.checking);
|
|
4429
|
+
else if (payload.latestCheckFailed) setMessage(text.failed, "error");
|
|
4430
|
+
else if (payload.updateAvailable) setMessage(`${text.found}: v${payload.latestVersion ?? text.unknown}`);
|
|
4431
|
+
else setMessage(text.latest, "success");
|
|
4432
|
+
if (payload !== void 0 && !payload.canAutoUpdate && payload.updateAvailable) setMessage(text.unavailable);
|
|
4433
|
+
};
|
|
4434
|
+
const checkNow = async () => {
|
|
4435
|
+
if (busy) return;
|
|
4436
|
+
setBusy(true);
|
|
4437
|
+
setMessage(text.checking);
|
|
4438
|
+
try {
|
|
4439
|
+
await load();
|
|
4440
|
+
setBusy(false);
|
|
4441
|
+
render();
|
|
4442
|
+
} catch (error) {
|
|
4443
|
+
setBusy(false);
|
|
4444
|
+
setMessage(error instanceof Error ? error.message : text.failed, "error");
|
|
4445
|
+
}
|
|
4446
|
+
};
|
|
4447
|
+
const updateNow = async () => {
|
|
4448
|
+
if (busy) return;
|
|
4449
|
+
setBusy(true);
|
|
4450
|
+
setButtonLabel(update, text.updating);
|
|
4451
|
+
setMessage(text.updating);
|
|
4452
|
+
try {
|
|
4453
|
+
payload = await requestStatus(options.endpoint, "POST", controller.signal);
|
|
4454
|
+
applyControls();
|
|
4455
|
+
render();
|
|
4456
|
+
setMessage(payload.autoReload === true ? text.restarting : text.restart, "success");
|
|
4457
|
+
} catch (error) {
|
|
4458
|
+
setMessage(error instanceof Error ? error.message : text.failed, "error");
|
|
4459
|
+
} finally {
|
|
4460
|
+
setButtonLabel(update, text.auto);
|
|
4461
|
+
setBusy(false);
|
|
4462
|
+
}
|
|
4463
|
+
};
|
|
4464
|
+
close.addEventListener("click", closeDialog);
|
|
4465
|
+
check.addEventListener("click", () => {
|
|
4466
|
+
void checkNow();
|
|
4467
|
+
});
|
|
4468
|
+
update.addEventListener("click", () => {
|
|
4469
|
+
void updateNow();
|
|
4470
|
+
});
|
|
4471
|
+
copy.addEventListener("click", () => {
|
|
4472
|
+
void navigator.clipboard?.writeText(command.textContent ?? "").then(() => {
|
|
4473
|
+
setButtonLabel(copy, text.copied);
|
|
4474
|
+
setTimeout(() => {
|
|
4475
|
+
setButtonLabel(copy, text.copy);
|
|
4476
|
+
}, 1400);
|
|
4477
|
+
}).catch(() => {
|
|
4478
|
+
setButtonLabel(copy, text.copyFailed);
|
|
4479
|
+
});
|
|
4480
|
+
});
|
|
4481
|
+
overlay.addEventListener("click", (event) => {
|
|
4482
|
+
if (event.target === overlay) closeDialog();
|
|
4483
|
+
});
|
|
4484
|
+
overlay.addEventListener("keydown", (event) => {
|
|
4485
|
+
handlePluginUpdateEscape(event, closeDialog);
|
|
4486
|
+
}, true);
|
|
4487
|
+
overlay.append(dialog);
|
|
4488
|
+
document.body.append(overlay);
|
|
4489
|
+
render();
|
|
4490
|
+
close.focus();
|
|
4491
|
+
void checkNow();
|
|
4492
|
+
}
|
|
4493
|
+
const observer = new MutationObserver(() => {
|
|
4494
|
+
if (frame !== void 0) return;
|
|
4495
|
+
frame = window.requestAnimationFrame(() => {
|
|
4496
|
+
frame = void 0;
|
|
4497
|
+
applyControls();
|
|
4498
|
+
});
|
|
4499
|
+
});
|
|
4500
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
4501
|
+
applyControls();
|
|
4502
|
+
void load().catch(() => {
|
|
4503
|
+
});
|
|
4504
|
+
return () => {
|
|
4505
|
+
controller.abort();
|
|
4506
|
+
observer.disconnect();
|
|
4507
|
+
closeDialog();
|
|
4508
|
+
if (frame !== void 0) window.cancelAnimationFrame(frame);
|
|
4509
|
+
document.querySelectorAll(`[data-mpi-check="${options.packageName}"],.mpi-version[data-package="${options.packageName}"]`).forEach((node) => node.remove());
|
|
4510
|
+
};
|
|
4511
|
+
}
|
|
4512
|
+
|
|
4226
4513
|
// src/client/index.ts
|
|
4227
4514
|
var name = "dsh-automation-client";
|
|
4228
4515
|
var inject = ["slots", "locale", "connection", "sessions"];
|
|
4516
|
+
var UPDATE_ICON_PATHS = {
|
|
4517
|
+
refresh: ["M13.5 5.5V2.5m0 0h-3m3 0-2.1 2.1A5.5 5.5 0 1 0 13.2 12"],
|
|
4518
|
+
download: ["M8 2v8m0 0 3-3m-3 3-3-3M3 13v2h10v-2"],
|
|
4519
|
+
copy: ["M5 5h8v8H5z", "M3 3h8"],
|
|
4520
|
+
close: ["m4 4 8 8M12 4 4 12"]
|
|
4521
|
+
};
|
|
4522
|
+
function createPluginUpdateIcon(name2) {
|
|
4523
|
+
const element = document.createElement("span");
|
|
4524
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
4525
|
+
svg.setAttribute("viewBox", "0 0 16 16");
|
|
4526
|
+
svg.setAttribute("width", "16");
|
|
4527
|
+
svg.setAttribute("height", "16");
|
|
4528
|
+
svg.setAttribute("fill", "none");
|
|
4529
|
+
svg.setAttribute("stroke", "currentColor");
|
|
4530
|
+
svg.setAttribute("stroke-width", "1.5");
|
|
4531
|
+
svg.setAttribute("stroke-linecap", "round");
|
|
4532
|
+
svg.setAttribute("stroke-linejoin", "round");
|
|
4533
|
+
svg.setAttribute("aria-hidden", "true");
|
|
4534
|
+
for (const d of UPDATE_ICON_PATHS[name2]) {
|
|
4535
|
+
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
4536
|
+
path.setAttribute("d", d);
|
|
4537
|
+
svg.append(path);
|
|
4538
|
+
}
|
|
4539
|
+
element.append(svg);
|
|
4540
|
+
return element;
|
|
4541
|
+
}
|
|
4229
4542
|
var SETTINGS_CLOCK_SVG = '<svg viewBox="0 0 16 16" width="16" height="16" fill="none" aria-hidden="true" data-dsh-schedule-icon="1"><path fill="currentColor" d="M8 1.15A6.85 6.85 0 1 0 8 14.85 6.85 6.85 0 0 0 8 1.15Zm0 1.4a5.45 5.45 0 1 1 0 10.9 5.45 5.45 0 0 1 0-10.9Z"/><path fill="currentColor" d="M8.62 4.35H7.28v4.2l3.02 1.78.67-1.13-2.35-1.39V4.35Z"/></svg>';
|
|
4230
4543
|
function isSessionSelector(value) {
|
|
4231
4544
|
return typeof value === "function";
|
|
@@ -4265,6 +4578,15 @@ function installSettingsNavIcon(labels) {
|
|
|
4265
4578
|
function apply(ctx) {
|
|
4266
4579
|
ctx.effect(() => installStyles(), "dsh-automation: styles");
|
|
4267
4580
|
ctx.effect(() => ctx.locale.register(NS, { zh, en }), "dsh-automation: locale");
|
|
4581
|
+
ctx.effect(() => observePluginUpdate({
|
|
4582
|
+
endpoint: "/api/michengai/dsh-automation/update",
|
|
4583
|
+
packageName: "@michengai/dsh-automation",
|
|
4584
|
+
titleRowSelector: ".dsh-st-heading-row",
|
|
4585
|
+
linksSelector: ".dsh-st-heading-links",
|
|
4586
|
+
zhName: "\u5B9A\u65F6\u4EFB\u52A1",
|
|
4587
|
+
enName: "Scheduled tasks",
|
|
4588
|
+
createIcon: createPluginUpdateIcon
|
|
4589
|
+
}), "dsh-automation: plugin update ui");
|
|
4268
4590
|
const t = ctx.locale.bind(NS);
|
|
4269
4591
|
const permissionT = ctx.locale.bind("permission.access");
|
|
4270
4592
|
const modelT = ctx.locale.bind("model");
|