@dan-ai-studio/dshopencodego 0.1.21 → 0.1.23
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.en.md +2 -1
- package/README.md +2 -1
- package/lib/client.js +299 -10
- package/lib/index.js +156 -10
- package/lib/types/catalog/constants.d.ts +3 -1
- package/lib/types/catalog/constants.js +3 -1
- package/lib/types/catalog/index.d.ts +1 -1
- package/lib/types/catalog/index.js +1 -1
- package/lib/types/conversion/stream.js +6 -0
- package/lib/types/go-limits.js +1 -1
- package/lib/types/index.d.ts +3 -3
- package/lib/types/index.js +7 -4
- package/lib/types/remotes.js +2 -1
- package/lib/types/session-header.d.ts +5 -3
- package/lib/types/session-header.js +8 -4
- package/lib/types/update/check.d.ts +74 -0
- package/lib/types/update/check.js +132 -0
- package/lib/types/update/contract.d.ts +23 -0
- package/lib/types/update/contract.js +52 -0
- package/lib/types/update/index.d.ts +12 -0
- package/lib/types/update/index.js +10 -0
- package/lib/types/update/service.d.ts +28 -0
- package/lib/types/update/service.js +28 -0
- package/lib/types/update/version.d.ts +14 -0
- package/lib/types/update/version.js +16 -0
- package/package.json +26 -26
package/README.en.md
CHANGED
|
@@ -83,7 +83,8 @@ Configuration lives in the profile's `cordis.patch.yml`:
|
|
|
83
83
|
config:
|
|
84
84
|
enabled: true # false withdraws the route only
|
|
85
85
|
apiKeyEnv: OPENCODE_GO_API_KEY # default
|
|
86
|
-
baseURL: https://opencode.ai/
|
|
86
|
+
baseURL: https://opencode.ai/inference/go/v1 # default (OpenCode Go endpoint, 37 subscription models)
|
|
87
|
+
# or https://opencode.ai/inference/v1 (Console main endpoint, 86 pay-as-you-go/free models)
|
|
87
88
|
refreshMinutes: 60 # live catalog TTL
|
|
88
89
|
modelVisibility: # per-model switches (deprecated default off)
|
|
89
90
|
glm-5: true
|
package/README.md
CHANGED
|
@@ -83,7 +83,8 @@ DSH 桌面端是 Electron 壳 + 完整的 dsh Web 应用,本插件对它同样
|
|
|
83
83
|
config:
|
|
84
84
|
enabled: true # false 仅撤下路由,插件保持挂载
|
|
85
85
|
apiKeyEnv: OPENCODE_GO_API_KEY # 默认值
|
|
86
|
-
baseURL: https://opencode.ai/
|
|
86
|
+
baseURL: https://opencode.ai/inference/go/v1 # 默认值(OpenCode Go 端点,37 个订阅模型)
|
|
87
|
+
# 也可指定为 https://opencode.ai/inference/v1(Console 主端点,包含 86 个按量/免费模型)
|
|
87
88
|
refreshMinutes: 60 # 目录缓存时长
|
|
88
89
|
modelVisibility: # 逐模型开关(弃用模型默认关闭)
|
|
89
90
|
glm-5: true
|
package/lib/client.js
CHANGED
|
@@ -152,6 +152,44 @@ var catalogRemote = {
|
|
|
152
152
|
]
|
|
153
153
|
};
|
|
154
154
|
|
|
155
|
+
// src/update/contract.ts
|
|
156
|
+
function parseUpdateStatus(value) {
|
|
157
|
+
if (value === null || typeof value !== "object") throw new Error("invalid update reading");
|
|
158
|
+
const row = value;
|
|
159
|
+
if (typeof row["current"] !== "string") throw new Error("invalid update reading");
|
|
160
|
+
if (row["latest"] !== void 0 && typeof row["latest"] !== "string") throw new Error("invalid update reading");
|
|
161
|
+
if (typeof row["available"] !== "boolean") throw new Error("invalid update reading");
|
|
162
|
+
if (typeof row["checkedAt"] !== "number" || !Number.isFinite(row["checkedAt"])) {
|
|
163
|
+
throw new Error("invalid update reading");
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
current: row["current"],
|
|
167
|
+
latest: typeof row["latest"] === "string" ? row["latest"] : void 0,
|
|
168
|
+
available: row["available"],
|
|
169
|
+
checkedAt: row["checkedAt"]
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
var codec2 = (typeSymbol, parse) => ({
|
|
173
|
+
mode: "strict",
|
|
174
|
+
typeSymbol,
|
|
175
|
+
schema: { parse },
|
|
176
|
+
create: () => ({ parse })
|
|
177
|
+
});
|
|
178
|
+
var updateRemote = {
|
|
179
|
+
package: "@dan-ai-studio/dshopencodego",
|
|
180
|
+
descriptors: [
|
|
181
|
+
{
|
|
182
|
+
id: "@dan-ai-studio/dshopencodego#opencodeGoUpdate/readUpdate",
|
|
183
|
+
service: "opencodeGoUpdate",
|
|
184
|
+
namespace: "opencodeGoUpdate",
|
|
185
|
+
method: "readUpdate",
|
|
186
|
+
invocation: { kind: "direct" },
|
|
187
|
+
parameters: [],
|
|
188
|
+
result: codec2("@dan-ai-studio/dshopencodego#UpdateStatus", parseUpdateStatus)
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
};
|
|
192
|
+
|
|
155
193
|
// src/usage/contract.ts
|
|
156
194
|
function parseWindow(value, key) {
|
|
157
195
|
if (value === null || typeof value !== "object") throw new Error(`invalid usage window "${key}"`);
|
|
@@ -206,7 +244,7 @@ function parseGoMeter(value) {
|
|
|
206
244
|
})
|
|
207
245
|
};
|
|
208
246
|
}
|
|
209
|
-
var
|
|
247
|
+
var codec3 = (typeSymbol, parse) => ({
|
|
210
248
|
mode: "strict",
|
|
211
249
|
typeSymbol,
|
|
212
250
|
schema: { parse },
|
|
@@ -222,7 +260,7 @@ var usageRemote = {
|
|
|
222
260
|
method: "readWindows",
|
|
223
261
|
invocation: { kind: "direct" },
|
|
224
262
|
parameters: [],
|
|
225
|
-
result:
|
|
263
|
+
result: codec3("@dan-ai-studio/dshopencodego#GoUsageWindows", parseUsageWindows)
|
|
226
264
|
},
|
|
227
265
|
{
|
|
228
266
|
id: "@dan-ai-studio/dshopencodego#opencodeGoUsage/readMeter",
|
|
@@ -231,7 +269,7 @@ var usageRemote = {
|
|
|
231
269
|
method: "readMeter",
|
|
232
270
|
invocation: { kind: "direct" },
|
|
233
271
|
parameters: [],
|
|
234
|
-
result:
|
|
272
|
+
result: codec3("@dan-ai-studio/dshopencodego#GoMeter", parseGoMeter)
|
|
235
273
|
}
|
|
236
274
|
]
|
|
237
275
|
};
|
|
@@ -302,7 +340,24 @@ var en = {
|
|
|
302
340
|
usageTokensUnit: "tokens",
|
|
303
341
|
usageCached: "cached read",
|
|
304
342
|
usageLocalHint: "The gateway publishes quota percentages only; token counts are what this process actually spent.",
|
|
305
|
-
usageLoading: "Loading\u2026"
|
|
343
|
+
usageLoading: "Loading\u2026",
|
|
344
|
+
updateTitle: "Plugin update",
|
|
345
|
+
updateChecking: "Checking for updates\u2026",
|
|
346
|
+
updateAvailable: "New version available:",
|
|
347
|
+
updateCurrent: "current",
|
|
348
|
+
updateNow: "Update now",
|
|
349
|
+
updateNotes: "Release notes",
|
|
350
|
+
updateRecheck: "Check again",
|
|
351
|
+
updateConfirmHint: "This removes the running version first, then installs",
|
|
352
|
+
updateConfirm: "Confirm update",
|
|
353
|
+
updateCancel: "Cancel",
|
|
354
|
+
updateApplying: "Updating\u2026 (removing the old version, then installing the new one)",
|
|
355
|
+
updateDone: "Updated to",
|
|
356
|
+
updateRestart: "Restart DSH to finish applying the update.",
|
|
357
|
+
updateFailed: "Update failed:",
|
|
358
|
+
updateStopProfile: "The running version cannot be removed without a restart; restart DSH first, then retry.",
|
|
359
|
+
updateIncompatible: "The new version is incompatible with this DSH build; finish the update from the plugin manager page (a version exemption needs your explicit approval).",
|
|
360
|
+
updatePendingBuilds: "Installation needs build-script approval; approve it on the plugin manager page, then retry."
|
|
306
361
|
};
|
|
307
362
|
var zh = {
|
|
308
363
|
nav: "OpenCode Go",
|
|
@@ -369,12 +424,34 @@ var zh = {
|
|
|
369
424
|
usageTokensUnit: "tokens",
|
|
370
425
|
usageCached: "\u7F13\u5B58\u8BFB\u53D6",
|
|
371
426
|
usageLocalHint: "\u7F51\u5173\u53EA\u516C\u5E03\u989D\u5EA6\u767E\u5206\u6BD4\uFF1Btoken \u6570\u4E3A\u672C\u8FDB\u7A0B\u5B9E\u9645\u6D88\u8017\u3002",
|
|
372
|
-
usageLoading: "\u52A0\u8F7D\u4E2D\u2026"
|
|
427
|
+
usageLoading: "\u52A0\u8F7D\u4E2D\u2026",
|
|
428
|
+
updateTitle: "\u63D2\u4EF6\u66F4\u65B0",
|
|
429
|
+
updateChecking: "\u6B63\u5728\u68C0\u67E5\u66F4\u65B0\u2026",
|
|
430
|
+
updateAvailable: "\u53D1\u73B0\u65B0\u7248\u672C\uFF1A",
|
|
431
|
+
updateCurrent: "\u5F53\u524D",
|
|
432
|
+
updateNow: "\u7ACB\u5373\u66F4\u65B0",
|
|
433
|
+
updateNotes: "\u66F4\u65B0\u8BF4\u660E",
|
|
434
|
+
updateRecheck: "\u91CD\u65B0\u68C0\u67E5",
|
|
435
|
+
updateConfirmHint: "\u5C06\u5148\u5378\u8F7D\u5F53\u524D\u8FD0\u884C\u7248\u672C\uFF0C\u518D\u5B89\u88C5",
|
|
436
|
+
updateConfirm: "\u786E\u8BA4\u66F4\u65B0",
|
|
437
|
+
updateCancel: "\u53D6\u6D88",
|
|
438
|
+
updateApplying: "\u66F4\u65B0\u4E2D\u2026\uFF08\u5148\u5378\u8F7D\u65E7\u7248\uFF0C\u518D\u5B89\u88C5\u65B0\u7248\uFF09",
|
|
439
|
+
updateDone: "\u5DF2\u66F4\u65B0\u5230",
|
|
440
|
+
updateRestart: "\u8BF7\u91CD\u542F DSH \u4EE5\u5B8C\u6210\u66F4\u65B0\u3002",
|
|
441
|
+
updateFailed: "\u66F4\u65B0\u5931\u8D25\uFF1A",
|
|
442
|
+
updateStopProfile: "\u8FD0\u884C\u4E2D\u7684\u7248\u672C\u9700\u91CD\u542F\u540E\u624D\u80FD\u79FB\u9664\uFF1B\u8BF7\u5148\u91CD\u542F DSH \u518D\u91CD\u8BD5\u3002",
|
|
443
|
+
updateIncompatible: "\u65B0\u7248\u672C\u4E0E\u5F53\u524D DSH \u4E0D\u517C\u5BB9\uFF0C\u8BF7\u524D\u5F80\u63D2\u4EF6\u7BA1\u7406\u9875\u5B8C\u6210\u66F4\u65B0\uFF08\u7248\u672C\u8C41\u514D\u9700\u660E\u786E\u6279\u51C6\uFF09\u3002",
|
|
444
|
+
updatePendingBuilds: "\u5B89\u88C5\u9700\u8981\u6279\u51C6\u6784\u5EFA\u811A\u672C\uFF1B\u8BF7\u524D\u5F80\u63D2\u4EF6\u7BA1\u7406\u9875\u6279\u51C6\u540E\u518D\u91CD\u8BD5\u3002"
|
|
373
445
|
};
|
|
374
446
|
|
|
375
447
|
// src/client/Section.tsx
|
|
376
448
|
var import_react = require("react");
|
|
377
449
|
|
|
450
|
+
// src/update/check.ts
|
|
451
|
+
var PACKAGE_NAME = "@dan-ai-studio/dshopencodego";
|
|
452
|
+
var REGISTRY_LATEST_URL = `https://registry.npmjs.org/${encodeURIComponent(PACKAGE_NAME)}/latest`;
|
|
453
|
+
var CHECK_CACHE_MS = 6 * 60 * 60 * 1e3;
|
|
454
|
+
|
|
378
455
|
// src/go-limits.ts
|
|
379
456
|
var SEED_TRANSCRIBED = "2026-09-25";
|
|
380
457
|
function monthlyRequestsRank(quota) {
|
|
@@ -462,7 +539,7 @@ if (!document.querySelector("style[data-plugin-css=" + JSON.stringify(id) + "]")
|
|
|
462
539
|
style.textContent = ".d7lz0W_root{color:var(--dsw-alias-label-primary);flex-direction:column;gap:1.25rem;display:flex}.d7lz0W_title{margin:0;font-size:1.05rem}.d7lz0W_hint{color:var(--dsw-alias-label-secondary);margin:0;font-size:.8rem}.d7lz0W_warn{color:var(--dsw-alias-state-warn-primary);margin:0;font-size:.8rem}.d7lz0W_ok{color:var(--dsw-alias-state-success-primary);font-size:.8rem}.d7lz0W_block{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:.6rem;flex-direction:column;gap:.5rem;padding:.85rem;display:flex}.d7lz0W_row{flex-wrap:wrap;align-items:center;gap:.5rem;display:flex}.d7lz0W_row>strong{margin-right:auto}.d7lz0W_input{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-base);min-width:10rem;color:var(--dsw-alias-label-primary);font:inherit;border-radius:.35rem;flex:14rem;padding:.35rem .5rem;font-size:.85rem}.d7lz0W_button{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;border-radius:.35rem;padding:.35rem .7rem;font-size:.8rem}.d7lz0W_button:disabled{color:var(--dsw-alias-state-idle-primary);cursor:default}.d7lz0W_number{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-base);width:5rem;color:var(--dsw-alias-label-primary);font:inherit;border-radius:.35rem;padding:.25rem .4rem;font-size:.8rem}.d7lz0W_select{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-base);width:auto;max-width:100%;color:var(--dsw-alias-label-primary);font:inherit;border-radius:.35rem;padding:.25rem .4rem;font-size:.8rem}.d7lz0W_list{flex-direction:column;display:flex}.d7lz0W_item{border-top:1px solid var(--dsw-alias-border-l1);align-items:flex-start;gap:.5rem;padding:.45rem .15rem;display:flex}.d7lz0W_item input[type=checkbox]{accent-color:var(--dsw-alias-brand-primary);margin-top:.15rem}.d7lz0W_itemBody{flex-direction:column;gap:.15rem;min-width:0;display:flex}.d7lz0W_itemMain{flex-wrap:wrap;align-items:baseline;gap:.6rem;display:flex}.d7lz0W_itemMeta{color:var(--dsw-alias-label-secondary);flex-wrap:wrap;gap:.75rem;font-size:.75rem;display:flex}.d7lz0W_itemModalities{color:var(--dsw-alias-label-secondary);font-size:.75rem}.d7lz0W_name{color:var(--dsw-alias-label-primary)}.d7lz0W_mono{color:var(--dsw-alias-label-secondary);font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.d7lz0W_badge{color:var(--dsw-alias-brand-primary)}";
|
|
463
540
|
document.head.appendChild(style);
|
|
464
541
|
}
|
|
465
|
-
var section_default = { "
|
|
542
|
+
var section_default = { "button": "d7lz0W_button", "ok": "d7lz0W_ok", "list": "d7lz0W_list", "title": "d7lz0W_title", "root": "d7lz0W_root", "itemMeta": "d7lz0W_itemMeta", "input": "d7lz0W_input", "badge": "d7lz0W_badge", "number": "d7lz0W_number", "hint": "d7lz0W_hint", "itemMain": "d7lz0W_itemMain", "name": "d7lz0W_name", "select": "d7lz0W_select", "itemModalities": "d7lz0W_itemModalities", "block": "d7lz0W_block", "mono": "d7lz0W_mono", "item": "d7lz0W_item", "row": "d7lz0W_row", "itemBody": "d7lz0W_itemBody", "warn": "d7lz0W_warn" };
|
|
466
543
|
|
|
467
544
|
// src/client/Section.tsx
|
|
468
545
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -478,7 +555,8 @@ var INITIAL = {
|
|
|
478
555
|
settings: void 0,
|
|
479
556
|
writable: false,
|
|
480
557
|
saving: false,
|
|
481
|
-
filter: INITIAL_FILTER
|
|
558
|
+
filter: INITIAL_FILTER,
|
|
559
|
+
update: { phase: "idle", status: void 0, message: void 0 }
|
|
482
560
|
};
|
|
483
561
|
function settingsOf(value) {
|
|
484
562
|
if (value === null || typeof value !== "object") return void 0;
|
|
@@ -492,7 +570,7 @@ function settingsOf(value) {
|
|
|
492
570
|
refreshMinutes: minutes
|
|
493
571
|
};
|
|
494
572
|
}
|
|
495
|
-
var SectionController = class {
|
|
573
|
+
var SectionController = class _SectionController {
|
|
496
574
|
state = INITIAL;
|
|
497
575
|
listeners = /* @__PURE__ */ new Set();
|
|
498
576
|
services;
|
|
@@ -514,6 +592,7 @@ var SectionController = class {
|
|
|
514
592
|
}
|
|
515
593
|
void this.load(false);
|
|
516
594
|
void this.loadKey();
|
|
595
|
+
void this.checkUpdate(false);
|
|
517
596
|
}
|
|
518
597
|
subscribe = (listener) => {
|
|
519
598
|
this.listeners.add(listener);
|
|
@@ -556,6 +635,117 @@ var SectionController = class {
|
|
|
556
635
|
this.set({ keyConfigured: void 0 });
|
|
557
636
|
}
|
|
558
637
|
}
|
|
638
|
+
/**
|
|
639
|
+
* Ask the Host whether a newer release is published.
|
|
640
|
+
*
|
|
641
|
+
* The Host answers from a cached registry reading and fails silent, so an
|
|
642
|
+
* unreachable registry hides the panel instead of erroring the page. Runs
|
|
643
|
+
* once with the page and again only on explicit refresh.
|
|
644
|
+
*/
|
|
645
|
+
async checkUpdate(force) {
|
|
646
|
+
const previous = this.state.update;
|
|
647
|
+
this.set({ update: { ...previous, phase: "checking", message: void 0 } });
|
|
648
|
+
try {
|
|
649
|
+
const result = await this.services.remote.opencodeGoUpdate.readUpdate(force);
|
|
650
|
+
if (!result.ok) throw result.error;
|
|
651
|
+
const status = result.value;
|
|
652
|
+
this.set({
|
|
653
|
+
update: {
|
|
654
|
+
phase: status.available && status.latest !== void 0 ? "ready" : "idle",
|
|
655
|
+
status,
|
|
656
|
+
message: void 0
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
} catch (error) {
|
|
660
|
+
this.set({
|
|
661
|
+
update: {
|
|
662
|
+
...previous,
|
|
663
|
+
phase: previous.phase === "checking" ? "idle" : previous.phase,
|
|
664
|
+
message: error instanceof Error ? error.message : void 0
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
/** Arm the confirm step; the destructive two-step runs only from `applyUpdate`. */
|
|
670
|
+
armUpdate() {
|
|
671
|
+
if (this.state.update.phase === "ready") {
|
|
672
|
+
this.set({ update: { ...this.state.update, phase: "confirming" } });
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
/** Stand down from the confirm step without doing anything. */
|
|
676
|
+
disarmUpdate() {
|
|
677
|
+
if (this.state.update.phase === "confirming") {
|
|
678
|
+
this.set({ update: { ...this.state.update, phase: "ready" } });
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
/** Read one field off an unknown host answer without guessing its shape. */
|
|
682
|
+
static field(value, key) {
|
|
683
|
+
return value !== null && typeof value === "object" ? value[key] : void 0;
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* One-click update: inspect, then the host's own remove + install.
|
|
687
|
+
*
|
|
688
|
+
* This mirrors the official plugin-update button exactly — the plugin never
|
|
689
|
+
* touches its own files. `removeBundle` stops the running build first, so
|
|
690
|
+
* the install call that follows is issued by this page (which survives),
|
|
691
|
+
* not by the Host code being removed. Outcomes that need a human —
|
|
692
|
+
* incompatibility (never auto-exempted), pending build approvals, a removal
|
|
693
|
+
* that needs a restart first — surface as guidance, never as silent retries.
|
|
694
|
+
*/
|
|
695
|
+
async applyUpdate() {
|
|
696
|
+
const status = this.state.update.status;
|
|
697
|
+
const latest = status?.latest;
|
|
698
|
+
if (this.state.update.phase !== "confirming" || latest === void 0) return;
|
|
699
|
+
const manager = this.services.remote.pluginManager;
|
|
700
|
+
const spec = `${PACKAGE_NAME}@${latest}`;
|
|
701
|
+
this.set({ update: { phase: "updating", status, message: void 0 } });
|
|
702
|
+
const fail = (message) => {
|
|
703
|
+
this.set({ update: { phase: "failed", status, message } });
|
|
704
|
+
};
|
|
705
|
+
try {
|
|
706
|
+
const inspected = await manager.inspect(spec);
|
|
707
|
+
if (_SectionController.field(inspected, "bundle") === false) {
|
|
708
|
+
fail(`the registry target is not a DSH bundle: ${spec}`);
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
} catch (error) {
|
|
712
|
+
fail(error instanceof Error ? error.message : `could not inspect ${spec}`);
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
try {
|
|
716
|
+
const removed = await manager.removeBundle(PACKAGE_NAME);
|
|
717
|
+
if (!removed.ok) throw removed.error;
|
|
718
|
+
const stopCode = _SectionController.field(removed.value, "error");
|
|
719
|
+
const code = typeof stopCode === "object" && stopCode !== null ? _SectionController.field(stopCode, "code") : void 0;
|
|
720
|
+
if (code === "stop-profile") {
|
|
721
|
+
fail("stop-profile");
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
} catch (error) {
|
|
725
|
+
fail(error instanceof Error ? error.message : `could not remove ${PACKAGE_NAME}`);
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
try {
|
|
729
|
+
const installed = await manager.installBundle(spec, { saveExact: true });
|
|
730
|
+
if (!installed.ok) throw installed.error;
|
|
731
|
+
const value = installed.value ?? {};
|
|
732
|
+
if (value.error?.code === "incompatible-version") {
|
|
733
|
+
fail("incompatible-version");
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
if (value.pendingBuilds !== void 0) {
|
|
737
|
+
fail("pending-builds");
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
if (value.application === "restart-required") {
|
|
741
|
+
this.set({ update: { phase: "done", status, message: "restart-required" } });
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
this.set({ update: { phase: "done", status, message: void 0 } });
|
|
745
|
+
} catch (error) {
|
|
746
|
+
fail(error instanceof Error ? error.message : `could not install ${spec}`);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
559
749
|
async saveKey(value) {
|
|
560
750
|
const trimmed = value.trim();
|
|
561
751
|
if (trimmed.length === 0) return;
|
|
@@ -697,6 +887,104 @@ function quotaLabel(model, t) {
|
|
|
697
887
|
const requests = quota.monthlyRequests === "unlimited" ? t("quotaUnlimited") : `${compactCount(quota.monthlyRequests)} ${t("quotaPerMonth")}`;
|
|
698
888
|
return `${usd} \xB7 ${requests}`;
|
|
699
889
|
}
|
|
890
|
+
function UpdateBanner({ controller, t, busy, act, update }) {
|
|
891
|
+
if (update.phase === "idle") return null;
|
|
892
|
+
const status = update.status;
|
|
893
|
+
const notes = `https://www.npmjs.com/package/${encodeURIComponent(PACKAGE_NAME)}`;
|
|
894
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: section_default.block, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: section_default.row, children: [
|
|
895
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: t("updateTitle") }),
|
|
896
|
+
update.phase === "checking" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: section_default.hint, children: t("updateChecking") }),
|
|
897
|
+
update.phase === "ready" && status?.latest !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
898
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: section_default.hint, children: `${t("updateAvailable")} ${status.latest} (${t("updateCurrent")} ${status.current})` }),
|
|
899
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
900
|
+
"button",
|
|
901
|
+
{
|
|
902
|
+
type: "button",
|
|
903
|
+
className: section_default.button,
|
|
904
|
+
disabled: busy,
|
|
905
|
+
onClick: () => {
|
|
906
|
+
controller.armUpdate();
|
|
907
|
+
},
|
|
908
|
+
children: t("updateNow")
|
|
909
|
+
}
|
|
910
|
+
),
|
|
911
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { className: section_default.hint, href: notes, target: "_blank", rel: "noreferrer", children: t("updateNotes") }),
|
|
912
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
913
|
+
"button",
|
|
914
|
+
{
|
|
915
|
+
type: "button",
|
|
916
|
+
className: section_default.button,
|
|
917
|
+
disabled: busy,
|
|
918
|
+
onClick: () => {
|
|
919
|
+
void act(async () => {
|
|
920
|
+
await controller.checkUpdate(true);
|
|
921
|
+
});
|
|
922
|
+
},
|
|
923
|
+
children: t("updateRecheck")
|
|
924
|
+
}
|
|
925
|
+
)
|
|
926
|
+
] }),
|
|
927
|
+
update.phase === "confirming" && status?.latest !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
928
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: section_default.hint, children: `${t("updateConfirmHint")} ${status.latest}` }),
|
|
929
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
930
|
+
"button",
|
|
931
|
+
{
|
|
932
|
+
type: "button",
|
|
933
|
+
className: section_default.button,
|
|
934
|
+
disabled: busy,
|
|
935
|
+
onClick: () => {
|
|
936
|
+
void act(async () => {
|
|
937
|
+
await controller.applyUpdate();
|
|
938
|
+
});
|
|
939
|
+
},
|
|
940
|
+
children: t("updateConfirm")
|
|
941
|
+
}
|
|
942
|
+
),
|
|
943
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
944
|
+
"button",
|
|
945
|
+
{
|
|
946
|
+
type: "button",
|
|
947
|
+
className: section_default.button,
|
|
948
|
+
disabled: busy,
|
|
949
|
+
onClick: () => {
|
|
950
|
+
controller.disarmUpdate();
|
|
951
|
+
},
|
|
952
|
+
children: t("updateCancel")
|
|
953
|
+
}
|
|
954
|
+
)
|
|
955
|
+
] }),
|
|
956
|
+
update.phase === "updating" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: section_default.hint, children: t("updateApplying") }),
|
|
957
|
+
update.phase === "done" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
958
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: section_default.ok, children: `${t("updateDone")} ${status?.latest ?? ""}`.trim() }),
|
|
959
|
+
update.message === "restart-required" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: section_default.warn, children: t("updateRestart") })
|
|
960
|
+
] }),
|
|
961
|
+
update.phase === "failed" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
962
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: section_default.warn, children: t("updateFailed") }),
|
|
963
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: section_default.hint, children: updateFailureText(update.message, t) }),
|
|
964
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
965
|
+
"button",
|
|
966
|
+
{
|
|
967
|
+
type: "button",
|
|
968
|
+
className: section_default.button,
|
|
969
|
+
disabled: busy,
|
|
970
|
+
onClick: () => {
|
|
971
|
+
void act(async () => {
|
|
972
|
+
await controller.checkUpdate(true);
|
|
973
|
+
});
|
|
974
|
+
},
|
|
975
|
+
children: t("updateRecheck")
|
|
976
|
+
}
|
|
977
|
+
)
|
|
978
|
+
] })
|
|
979
|
+
] }) });
|
|
980
|
+
}
|
|
981
|
+
function updateFailureText(message, t) {
|
|
982
|
+
if (message === void 0 || message.length === 0) return "";
|
|
983
|
+
if (message === "stop-profile") return t("updateStopProfile");
|
|
984
|
+
if (message === "incompatible-version") return t("updateIncompatible");
|
|
985
|
+
if (message === "pending-builds") return t("updatePendingBuilds");
|
|
986
|
+
return message;
|
|
987
|
+
}
|
|
700
988
|
function Section({ controller, t, getLocale }) {
|
|
701
989
|
const state = (0, import_react.useSyncExternalStore)(controller.subscribe, controller.snapshot, controller.snapshot);
|
|
702
990
|
const [keyDraft, setKeyDraft] = (0, import_react.useState)("");
|
|
@@ -720,6 +1008,7 @@ function Section({ controller, t, getLocale }) {
|
|
|
720
1008
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: section_default.root, children: [
|
|
721
1009
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: section_default.title, children: t("nav") }),
|
|
722
1010
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: section_default.hint, children: t("intro") }),
|
|
1011
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(UpdateBanner, { controller, t, busy, act, update: state.update }),
|
|
723
1012
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: section_default.block, children: [
|
|
724
1013
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: section_default.row, children: [
|
|
725
1014
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: t("keyTitle") }),
|
|
@@ -963,7 +1252,7 @@ if (!document.querySelector("style[data-plugin-css=" + JSON.stringify(id2) + "]"
|
|
|
963
1252
|
style.textContent = ".mMNkkW_root{align-items:center;display:inline-flex;position:relative}.mMNkkW_trigger{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-secondary);font:inherit;cursor:pointer;white-space:nowrap;border-radius:999px;padding:.35rem .6rem;font-size:.8rem;line-height:1}.mMNkkW_trigger:hover{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-border-l2)}.mMNkkW_panel{z-index:20;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-overlay);width:18rem;color:var(--dsw-alias-label-primary);border-radius:.6rem;flex-direction:column;gap:.6rem;padding:.75rem .85rem;display:flex;position:absolute;bottom:calc(100% + .5rem);right:0;box-shadow:0 8px 24px #0000002e}.mMNkkW_window{flex-direction:column;gap:.25rem;display:flex}.mMNkkW_row{justify-content:space-between;gap:.5rem;font-size:.85rem;display:flex}.mMNkkW_hint{color:var(--dsw-alias-label-secondary);margin:0;font-size:.75rem}.mMNkkW_progress{width:100%;height:.35rem;accent-color:var(--dsw-alias-brand-primary)}.mMNkkW_limited{color:var(--dsw-alias-state-warn-primary);font-size:.75rem}.mMNkkW_warning{border:1px solid var(--dsw-alias-state-warn-primary);color:var(--dsw-alias-label-primary);border-radius:.4rem;padding:.4rem .5rem;font-size:.75rem}.mMNkkW_retry{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;border-radius:.35rem;align-self:flex-start;padding:.25rem .5rem;font-size:.75rem}.mMNkkW_local{border-top:1px solid var(--dsw-alias-border-l1);flex-direction:column;gap:.2rem;padding-top:.5rem;display:flex}";
|
|
964
1253
|
document.head.appendChild(style);
|
|
965
1254
|
}
|
|
966
|
-
var pill_default = { "
|
|
1255
|
+
var pill_default = { "warning": "mMNkkW_warning", "row": "mMNkkW_row", "root": "mMNkkW_root", "retry": "mMNkkW_retry", "window": "mMNkkW_window", "trigger": "mMNkkW_trigger", "hint": "mMNkkW_hint", "limited": "mMNkkW_limited", "local": "mMNkkW_local", "progress": "mMNkkW_progress", "panel": "mMNkkW_panel" };
|
|
967
1256
|
|
|
968
1257
|
// src/client/UsagePill.tsx
|
|
969
1258
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
@@ -1121,7 +1410,7 @@ function apply(ctx) {
|
|
|
1121
1410
|
ctx.effect(() => ctx.locale.register(NS, { zh, en }), "dshopencodego: copy dictionaries");
|
|
1122
1411
|
const mounted = ctx.remote.$mount({
|
|
1123
1412
|
package: usageRemote.package,
|
|
1124
|
-
descriptors: [...usageRemote.descriptors, ...catalogRemote.descriptors]
|
|
1413
|
+
descriptors: [...usageRemote.descriptors, ...catalogRemote.descriptors, ...updateRemote.descriptors]
|
|
1125
1414
|
});
|
|
1126
1415
|
ctx.effect(() => {
|
|
1127
1416
|
let dispose;
|