@dsh-plugin/dsh-pack-plugin 0.0.0-stage → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +178 -3
  3. package/cordis.patch.yml +9 -0
  4. package/icons/folder-zip-line.svg +1 -0
  5. package/lib/ball.js +597 -0
  6. package/lib/client.js +2934 -0
  7. package/lib/host.js +51745 -0
  8. package/lib/migrate-helper.js +35346 -0
  9. package/lib/progress-main.cjs +79 -0
  10. package/lib/progress-window.ps1 +114 -0
  11. package/lib/progress.html +126 -0
  12. package/lib/publish-to-github/SKILL.md +132 -0
  13. package/package.json +77 -4
  14. package/src/ball-entry.js +5 -0
  15. package/src/ball-host.js +99 -0
  16. package/src/ball-settings.js +352 -0
  17. package/src/ball.js +418 -0
  18. package/src/channel.js +12 -0
  19. package/src/client-plugin.js +58 -0
  20. package/src/client-rpc.js +14 -0
  21. package/src/client.js +5 -0
  22. package/src/core/discovery.js +192 -0
  23. package/src/core/dspack.js +93 -0
  24. package/src/core/extension-files.js +102 -0
  25. package/src/core/extension-install.js +295 -0
  26. package/src/core/extension-patch.js +369 -0
  27. package/src/core/extension-skills.js +164 -0
  28. package/src/core/extension-validate.js +127 -0
  29. package/src/core/extensions.js +207 -0
  30. package/src/core/home-store.js +32 -0
  31. package/src/core/host.js +149 -0
  32. package/src/core/index.js +59 -0
  33. package/src/core/inspect.js +162 -0
  34. package/src/core/install.js +775 -0
  35. package/src/core/managed-install.js +84 -0
  36. package/src/core/manifest.js +717 -0
  37. package/src/core/market.js +268 -0
  38. package/src/core/mcp-composition.js +189 -0
  39. package/src/core/mcp-install.js +112 -0
  40. package/src/core/mcp-transport.js +116 -0
  41. package/src/core/pack.js +371 -0
  42. package/src/core/plugin-metadata.js +355 -0
  43. package/src/core/registry.js +316 -0
  44. package/src/core/repo.js +339 -0
  45. package/src/core/scan.js +78 -0
  46. package/src/core/security.js +101 -0
  47. package/src/core/special.js +50 -0
  48. package/src/core/tar.js +103 -0
  49. package/src/core/update-config.js +234 -0
  50. package/src/core/update.js +792 -0
  51. package/src/core/vendored.js +715 -0
  52. package/src/core/workspace.js +95 -0
  53. package/src/endpoints.js +455 -0
  54. package/src/ensure-manager.js +186 -0
  55. package/src/host-node.js +625 -0
  56. package/src/host.js +17 -0
  57. package/src/index.d.ts +7 -0
  58. package/src/index.js +39 -0
  59. package/src/junction.js +142 -0
  60. package/src/migrate-helper.js +225 -0
  61. package/src/migrate.js +56 -0
  62. package/src/packaged.js +9 -0
  63. package/src/profiles.js +106 -0
  64. package/src/progress-main.cjs +79 -0
  65. package/src/progress-window.ps1 +114 -0
  66. package/src/progress.html +126 -0
  67. package/src/progress.js +132 -0
  68. package/src/rpc.js +157 -0
  69. package/src/runtime.js +43 -0
  70. package/src/section-gate.js +50 -0
  71. package/src/settings-nav-icon.js +188 -0
  72. package/src/settings.js +1611 -0
  73. package/src/skills/index.js +90 -0
  74. package/src/skills/publish-to-github/SKILL.md +132 -0
  75. package/src/tasks.js +145 -0
  76. package/src/v6-dialogs.js +312 -0
package/lib/client.js ADDED
@@ -0,0 +1,2934 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "@dsh-plugin/dsh-pack-plugin",
3
+ factory: (require) => {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
6
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __export = (target, all) => {
12
+ for (var name2 in all)
13
+ __defProp(target, name2, { get: all[name2], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+
25
+ // src/client.js
26
+ var client_exports = {};
27
+ __export(client_exports, {
28
+ apply: () => apply,
29
+ inject: () => inject,
30
+ name: () => name
31
+ });
32
+ module.exports = __toCommonJS(client_exports);
33
+
34
+ // src/v6-dialogs.js
35
+ function node(tag, text) {
36
+ const element = document.createElement(tag);
37
+ if (text !== void 0) element.textContent = text;
38
+ return element;
39
+ }
40
+ function labelOf(value) {
41
+ if (typeof value === "string") return value;
42
+ return value?.[navigator.language] || value?.[navigator.language.split("-")[0]] || Object.values(value || {})[0] || "";
43
+ }
44
+ function field(parent, caption, value = "", type = "text") {
45
+ const label = node("label", caption + " ");
46
+ label.style.display = "block";
47
+ const input = node("input");
48
+ input.type = type;
49
+ input.value = value;
50
+ if (type === "password") input.autocomplete = "new-password";
51
+ label.append(input);
52
+ parent.append(label);
53
+ return input;
54
+ }
55
+ function openForm(title, build) {
56
+ return new Promise((resolve) => {
57
+ const dialog = node("dialog");
58
+ dialog.className = "pack-resource-dialog";
59
+ const style = node("style");
60
+ style.textContent = `
61
+ .pack-resource-dialog {box-sizing:border-box;width:min(46rem,90vw);max-height:80vh;overflow:auto;padding:1.4rem 1.6rem;border:1px solid var(--dsw-border-l1,GrayText);border-radius:14px;color:var(--dsw-label-primary,CanvasText);background:var(--dsw-bg-layer-1,Canvas);box-shadow:0 18px 64px #0003}
62
+ .pack-resource-dialog::backdrop {background:#151b2b60}
63
+ .pack-resource-dialog h2 {margin:0 0 1rem;font-size:1.25rem}
64
+ .pack-resource-dialog h3 {font-size:1rem;margin:.9rem 0 .4rem}
65
+ .pack-resource-dialog details,.pack-resource-dialog .pack-resource-row {border:1px solid var(--dsw-border-l1,GrayText);border-radius:8px;padding:.65rem .85rem;margin:.5rem 0}
66
+ .pack-resource-dialog summary {cursor:pointer;font-weight:600}
67
+ .pack-resource-dialog label {margin:.35rem 0}
68
+ .pack-resource-dialog input:not([type=checkbox]) {display:block;max-width:100%;width:100%;box-sizing:border-box}
69
+ .pack-resource-dialog small {overflow-wrap:anywhere;color:var(--dsw-label-tertiary,GrayText)}
70
+ .pack-resource-row>label {display:flex;align-items:center;justify-content:space-between;gap:1rem;font-weight:600}
71
+ .pack-resource-row>label>select {width:auto}
72
+ .pack-resource-row p {margin:.35rem 0;font-size:.9em}
73
+ .pack-resource-actions {display:flex;justify-content:flex-end;gap:.5rem;margin-top:1rem}
74
+ `;
75
+ dialog.append(style);
76
+ const form = node("form");
77
+ form.append(node("h2", title));
78
+ const read = build(form);
79
+ const error = node("p");
80
+ error.role = "alert";
81
+ const ok = node("button", "\u786E\u8BA4");
82
+ const cancel = node("button", "\u53D6\u6D88");
83
+ cancel.type = "button";
84
+ cancel.onclick = () => dialog.close();
85
+ let result = null;
86
+ const buttons = node("div");
87
+ buttons.className = "pack-resource-actions";
88
+ cancel.className = "ghost";
89
+ ok.className = "primary";
90
+ buttons.append(cancel, ok);
91
+ form.append(error, buttons);
92
+ form.onsubmit = (event) => {
93
+ event.preventDefault();
94
+ try {
95
+ result = read();
96
+ dialog.close();
97
+ } catch (cause) {
98
+ error.textContent = cause.message;
99
+ }
100
+ };
101
+ dialog.onclose = () => {
102
+ dialog.remove();
103
+ resolve(result);
104
+ };
105
+ dialog.append(form);
106
+ document.body.append(dialog);
107
+ dialog.showModal();
108
+ });
109
+ }
110
+ function textValue(input) {
111
+ const value = input.value.trim();
112
+ return value.startsWith("{") ? JSON.parse(value) : value;
113
+ }
114
+ function asInput(value) {
115
+ return typeof value === "object" && value ? JSON.stringify(value) : value || "";
116
+ }
117
+ function chooseExportResources(candidates, units, current = {}, whole = false) {
118
+ return openForm("\u6574\u5408\u5305\u8D44\u6E90\u4E0E\u63D2\u4EF6", (form) => {
119
+ const fields = [];
120
+ const groups = { paths: "\u63D2\u4EF6\u989D\u5916\u8DEF\u5F84", providers: "\u6A21\u578B\u63D0\u4F9B\u5546", mcp: "MCP \u670D\u52A1\u5668", skills: "\u6280\u80FD" };
121
+ for (const [group, title] of Object.entries(groups)) {
122
+ const list = candidates[group] || [];
123
+ if (!list.length) continue;
124
+ form.append(node("h3", title));
125
+ for (const item of list) {
126
+ const saved = current.selection?.[group]?.find((entry) => (entry.key || entry) === item.key);
127
+ const box = field(form, [labelOf(item.name) || item.id, item.scope].filter(Boolean).join(" \xB7 "), "", "checkbox");
128
+ box.checked = Boolean(saved);
129
+ if (item.desc) form.append(node("small", labelOf(item.desc)));
130
+ let skill;
131
+ if (group === "skills") skill = skillFields(form, { ...item.source, ...item, ...typeof saved === "object" ? saved : {} });
132
+ let metadata;
133
+ if (!skill) {
134
+ const details = node("details");
135
+ details.append(node("summary", "\u8D44\u6E90\u663E\u793A\u4FE1\u606F"));
136
+ const name2 = field(details, "\u540D\u79F0\uFF08\u6587\u672C\u6216\u8BED\u8A00\u5BF9\u8C61\uFF09", asInput(saved?.name ?? item.name));
137
+ const desc = field(details, "\u7B80\u4ECB\uFF08\u6587\u672C\u6216\u8BED\u8A00\u5BF9\u8C61\uFF09", asInput(saved?.desc ?? item.desc));
138
+ form.append(details);
139
+ metadata = () => {
140
+ const values = { key: item.key };
141
+ const nextName = textValue(name2), nextDesc = textValue(desc);
142
+ if (nextName && JSON.stringify(nextName) !== JSON.stringify(item.name)) values.name = nextName;
143
+ if (JSON.stringify(nextDesc) !== JSON.stringify(item.desc || "")) values.desc = nextDesc;
144
+ return Object.keys(values).length > 1 ? values : item.key;
145
+ };
146
+ }
147
+ fields.push({ group, item, box, skill, metadata });
148
+ }
149
+ }
150
+ form.append(node("h3", "\u8FDC\u7A0B\u6280\u80FD"));
151
+ const remote = [];
152
+ const add = node("button", "\u6DFB\u52A0 Git \u4ED3\u5E93\u6280\u80FD");
153
+ add.type = "button";
154
+ const remoteList = node("div");
155
+ form.append(remoteList, add);
156
+ function appendRemote(item) {
157
+ const row = node("fieldset");
158
+ const id = field(row, "\u6280\u80FD\u76EE\u5F55\u540D", item.id);
159
+ const scope = node("select");
160
+ if (whole) {
161
+ scope.setAttribute("aria-label", "\u6280\u80FD\u5B89\u88C5\u8303\u56F4");
162
+ for (const value of ["home", ...Object.keys(units).map((name2) => "profile:" + name2)]) {
163
+ const option = node("option", value);
164
+ option.value = value;
165
+ scope.append(option);
166
+ }
167
+ scope.value = item.scope || (item.key?.startsWith("skill:profile:") ? item.key.slice(6, item.key.lastIndexOf(":")) : "home");
168
+ row.append(scope);
169
+ }
170
+ const readSkill = skillFields(row, { mode: "fixed", ...item }, false);
171
+ const remove = node("button", "\u79FB\u9664");
172
+ remove.type = "button";
173
+ remove.onclick = () => row.remove();
174
+ row.append(remove);
175
+ remoteList.append(row);
176
+ remote.push(() => row.isConnected ? {
177
+ ...readSkill(),
178
+ id: id.value.trim(),
179
+ scope: whole ? scope.value : "home",
180
+ key: "skill:" + (whole ? scope.value : "home") + ":" + id.value.trim()
181
+ } : null);
182
+ }
183
+ for (const item of current.selection?.skills || []) {
184
+ if (typeof item === "object" && !fields.some((f) => f.item.key === item.key)) appendRemote(item);
185
+ }
186
+ add.onclick = () => appendRemote({});
187
+ const pluginRows = [];
188
+ for (const [profile, unit] of Object.entries(units)) {
189
+ const plugins = unit.plugins || {};
190
+ const ids = /* @__PURE__ */ new Set([...Object.keys(plugins), ...unit.bundles || [], ...Object.keys(unit.dependencies || {})]);
191
+ for (const id of ids) {
192
+ const details = node("details");
193
+ const version = unit.dependencies?.[id];
194
+ details.append(node("summary", profile + " \xB7 " + id + (version ? "@" + version : "")));
195
+ const before = (whole ? current.profilePlugins?.[profile] : current.plugins)?.[id] || {};
196
+ const auto = plugins[id] || {};
197
+ const name2 = field(details, "\u540D\u79F0\uFF08\u6587\u672C\u6216\u8BED\u8A00\u5BF9\u8C61\uFF09", asInput(before.name ?? auto.name));
198
+ const desc = field(details, "\u7B80\u4ECB\uFF08\u6587\u672C\u6216\u8BED\u8A00\u5BF9\u8C61\uFF09", asInput(before.desc ?? auto.desc));
199
+ const icon = field(details, "\u56FE\u6807\u5730\u5740", before.icon ?? auto.icon);
200
+ const savedSource = version && before.version === version ? before.source : void 0;
201
+ const registry = field(details, "\u6B64\u7248\u672C\u4E13\u7528 npm registry", savedSource?.registry ?? auto.source?.registry);
202
+ registry.placeholder = "\u4F7F\u7528\u9ED8\u8BA4 registry";
203
+ form.append(details);
204
+ pluginRows.push(() => {
205
+ const entry = {};
206
+ const update = (key, value) => {
207
+ if (value && (Object.hasOwn(before, key) || JSON.stringify(value) !== JSON.stringify(auto[key]))) entry[key] = value;
208
+ };
209
+ update("name", textValue(name2));
210
+ update("desc", textValue(desc));
211
+ update("icon", icon.value.trim());
212
+ if (registry.value.trim()) {
213
+ entry.source = { type: "npm", registry: registry.value.trim() };
214
+ entry.version = unit.dependencies?.[id];
215
+ } else if (auto.source?.registry || savedSource) {
216
+ entry.source = { type: "npm" };
217
+ entry.version = unit.dependencies?.[id];
218
+ }
219
+ return { profile, id, entry };
220
+ });
221
+ }
222
+ }
223
+ return () => {
224
+ const selection = { paths: [], providers: [], mcp: [], skills: [] };
225
+ for (const { group, box, item, skill, metadata } of fields) {
226
+ if (box.checked) selection[group].push(skill ? { key: item.key, id: item.id, ...skill() } : metadata());
227
+ }
228
+ selection.skills.push(...remote.map((row) => row()).filter(Boolean));
229
+ const profilePlugins = /* @__PURE__ */ Object.create(null);
230
+ for (const read of pluginRows) {
231
+ const { profile, id, entry } = read();
232
+ if (!Object.keys(entry).length) continue;
233
+ (profilePlugins[profile] ?? (profilePlugins[profile] = /* @__PURE__ */ Object.create(null)))[id] = entry;
234
+ }
235
+ return whole ? { selection, profilePlugins } : { selection, plugins: Object.values(profilePlugins)[0] || {} };
236
+ };
237
+ });
238
+ }
239
+ function skillFields(parent, skill, embedded = true) {
240
+ const details = node("details");
241
+ details.append(node("summary", "\u6280\u80FD\u6765\u6E90\u4E0E\u663E\u793A\u4FE1\u606F"));
242
+ const mode = node("select");
243
+ for (const [id, title] of [["embedded", "\u968F\u5305\u643A\u5E26"], ["fixed", "\u56FA\u5B9A\u63D0\u4EA4"], ["track", "\u8DDF\u8E2A\u5206\u652F\u6216\u6807\u7B7E"]]) {
244
+ if (!embedded && id === "embedded") continue;
245
+ const option = node("option", title);
246
+ option.value = id;
247
+ mode.append(option);
248
+ }
249
+ mode.value = skill.mode || (embedded ? "embedded" : "fixed");
250
+ details.append(mode);
251
+ const repo = field(details, "Git \u4ED3\u5E93", skill.repository || skill.repo);
252
+ const subdir = field(details, "\u4ED3\u5185\u76EE\u5F55", skill.subdir);
253
+ const ref = field(details, "\u63D0\u4EA4\u3001\u5206\u652F\u6216\u6807\u7B7E", mode.value === "fixed" ? skill.commit || skill.ref : skill.ref || skill.commit);
254
+ mode.onchange = () => {
255
+ ref.value = mode.value === "fixed" ? skill.commit || "" : skill.ref || "";
256
+ };
257
+ const name2 = field(details, "\u540D\u79F0\uFF08\u6587\u672C\u6216\u8BED\u8A00\u5BF9\u8C61\uFF09", asInput(skill.name));
258
+ const desc = field(details, "\u7B80\u4ECB\uFF08\u6587\u672C\u6216\u8BED\u8A00\u5BF9\u8C61\uFF09", asInput(skill.desc));
259
+ parent.append(details);
260
+ return () => ({ mode: mode.value, repository: repo.value.trim(), subdir: subdir.value.trim(), ref: ref.value.trim(), name: textValue(name2), desc: textValue(desc) });
261
+ }
262
+ function selectResources(form, items) {
263
+ const kinds = { path: "\u63D2\u4EF6\u6570\u636E", provider: "\u6A21\u578B\u670D\u52A1\u5546", mcp: "MCP \u670D\u52A1", skill: "\u6280\u80FD" };
264
+ const rows = items.map((item) => {
265
+ const row = node("section");
266
+ row.className = "pack-resource-row";
267
+ const title = labelOf(item.name) || item.id;
268
+ const heading = node("label", title);
269
+ const action = node("select");
270
+ action.setAttribute("aria-label", title + "\u7684\u5BFC\u5165\u65B9\u5F0F");
271
+ for (const [value, label] of [
272
+ ["auto", item.canReplace === false ? "\u4FDD\u7559\u73B0\u72B6" : item.conflict ? "\u6309\u66F4\u65B0\u89C4\u5219\u5408\u5E76" : "\u5BFC\u5165"],
273
+ ...item.conflict && item.canReplace !== false ? [["keep", "\u4FDD\u7559\u672C\u5730"], ["replace", "\u9009\u7528\u5305\u5185\u6761\u76EE"]] : [],
274
+ ["skip", "\u8DF3\u8FC7"]
275
+ ]) {
276
+ const option = node("option", label);
277
+ option.value = value;
278
+ action.append(option);
279
+ }
280
+ heading.append(action);
281
+ row.append(heading, node("small", [kinds[item.kind], item.scope, item.destination].filter(Boolean).join(" \xB7 ")));
282
+ if (item.desc) row.append(node("p", labelOf(item.desc)));
283
+ if (item.notice) row.append(node("p", item.notice));
284
+ const inputs = node("div");
285
+ const reuse = item.availableCredentials?.length ? field(inputs, "\u5141\u8BB8\u6B64\u76EE\u6807\u4F7F\u7528\u672C\u673A\u5DF2\u6709\u51ED\u636E", "", "checkbox") : null;
286
+ const secrets = (item.credentialRefs || []).map((key) => [key, field(inputs, key, "", "password")]);
287
+ if (secrets.length && item.canReplace !== false) row.append(inputs);
288
+ action.onchange = () => {
289
+ inputs.hidden = action.value === "skip" || action.value === "keep";
290
+ };
291
+ form.append(row);
292
+ return { item, action, reuse, secrets };
293
+ });
294
+ return () => {
295
+ var _a;
296
+ const decisions = /* @__PURE__ */ Object.create(null), credentials = /* @__PURE__ */ Object.create(null), confirmedCredentials = /* @__PURE__ */ Object.create(null);
297
+ for (const { item, action, reuse, secrets } of rows) {
298
+ if (action.value !== "auto") decisions[item.key] = action.value;
299
+ if (item.canReplace === false || action.value === "skip" || action.value === "keep") continue;
300
+ if (reuse?.checked) confirmedCredentials[item.key] = true;
301
+ for (const [key, input] of secrets) if (input.value) (credentials[_a = item.key] ?? (credentials[_a] = /* @__PURE__ */ Object.create(null)))[key] = input.value;
302
+ }
303
+ return { decisions, credentials, confirmedCredentials };
304
+ };
305
+ }
306
+ async function reviewInstall(preview, options) {
307
+ if (options.dryRun) return preview({ ...options, dryRun: true });
308
+ const listing = await preview({ ...options, dryRun: true, listResourcesOnly: true, recoverInterrupted: true });
309
+ if (listing.exists && !options.update && !options.force && listing.manifest?.manifestVersion === 6) {
310
+ const confirmed = await openForm("\u66F4\u65B0\u5DF2\u6709\u6574\u5408\u5305", (form) => {
311
+ form.append(node("p", "\u4FDD\u7559\u672C\u5730\u6570\u636E\u5E76\u66F4\u65B0 " + listing.dir));
312
+ return () => true;
313
+ });
314
+ if (!confirmed) return null;
315
+ options = { ...options, update: true };
316
+ }
317
+ if (listing.items?.length) {
318
+ const choices = await openForm("\u9009\u62E9\u8981\u5BFC\u5165\u7684\u8D44\u6E90", (form) => selectResources(form, listing.items));
319
+ if (!choices) return null;
320
+ options = { ...options, ...choices };
321
+ }
322
+ const prepare = () => preview({ ...options, dryRun: true, recoverInterrupted: true });
323
+ let plan = listing.resourcesOnly || options.update ? await prepare() : listing;
324
+ if (plan.unknownBase) {
325
+ const old = await openForm("\u9996\u6B21\u66F4\u65B0\uFF1A\u6838\u5BF9\u65E7\u5305", (form) => {
326
+ const source = field(form, "\u53EF\u9009\u7684\u65E7\u6574\u5408\u5305\u8DEF\u5F84\u6216 URL");
327
+ const sha = field(form, "\u539F\u7248\u672C SHA-256");
328
+ return () => ({ previousSource: source.value.trim(), previousSha256: sha.value.trim() });
329
+ });
330
+ if (!old) return null;
331
+ if (old.previousSource) {
332
+ options = { ...options, ...old };
333
+ plan = await prepare();
334
+ }
335
+ }
336
+ const conflicts = plan.conflicts || [];
337
+ let resolutions = {};
338
+ if (conflicts.length) {
339
+ resolutions = await openForm("\u66F4\u65B0\u51B2\u7A81\uFF08\u9ED8\u8BA4\u4FDD\u7559\u672C\u5730\uFF09", (form) => {
340
+ const rows = conflicts.flatMap((item) => (item.fields?.length ? item.fields : [{ key: item.path }]).map((member) => [
341
+ member.key,
342
+ field(form, "\u91C7\u7528\u65B0\u7248 \xB7 " + [item.path, member.label].filter(Boolean).join(" / "), "", "checkbox")
343
+ ]));
344
+ return () => Object.fromEntries(rows.filter(([, input]) => input.checked).map(([path]) => [path, "upstream"]));
345
+ });
346
+ if (!resolutions) return null;
347
+ }
348
+ return { ...options, previewToken: plan.previewToken, resolutions };
349
+ }
350
+
351
+ // src/settings.js
352
+ var import_react = require("react");
353
+
354
+ // src/channel.js
355
+ var CHANNEL = "/dsh-pack";
356
+ var PROFILE_NAME_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
357
+ var RESERVED_PROFILE_NAMES = ["desktop", "default"];
358
+
359
+ // src/ball-settings.js
360
+ var SECTION_FOCUS_HOOK = "__dspackFocusSection";
361
+ var SETTINGS_DIALOG_SELECTOR = '[role="dialog"][aria-modal="true"]';
362
+ var OWN_SECTION_SELECTOR = "[data-dspack-nav-icon]";
363
+ var OWN_SECTION_ATTR = "data-dspack-nav-icon";
364
+ var SECTION_LABEL_HOOK = "__dspackSectionLabel";
365
+ var SECTION_WANT_FLAG = "__dspackWantSection";
366
+ var NAV_ROW_SELECTOR = '[role="dialog"] nav button';
367
+ var ACTIVE_ROW_SELECTOR = '[role="dialog"] nav button[aria-current="true"]';
368
+ var SETTINGS_AREA_HINT = "_settingsArea";
369
+ var SETTINGS_TRIGGER_CLASS_HINT = "_trigger";
370
+ var SETTINGS_TRIGGER_MIN_SCORE = 4;
371
+ var TRIGGER_LABEL_RE = /settings?|preferences|设置|偏好/i;
372
+ var FOREIGN_WIDGET_RE = /(^|[-_\s])(cost|usage|billing|pet|whale|meter|stats?)([-_\s]|$)/i;
373
+ function isSettingsDialogOpen(doc) {
374
+ return Boolean(doc?.querySelector?.(SETTINGS_DIALOG_SELECTOR));
375
+ }
376
+ function scoreSettingsTrigger(signals = {}) {
377
+ const own = String(signals.className ?? "");
378
+ const ancestors = Array.isArray(signals.ancestorClasses) ? signals.ancestorClasses.join(" ") : "";
379
+ if (FOREIGN_WIDGET_RE.test(own) || FOREIGN_WIDGET_RE.test(ancestors)) return -100;
380
+ if (signals.inDialog) return -100;
381
+ let score = 0;
382
+ if (ancestors.includes(SETTINGS_AREA_HINT)) score += 5;
383
+ if (TRIGGER_LABEL_RE.test(String(signals.ariaLabel ?? ""))) score += 4;
384
+ if (own.includes(SETTINGS_TRIGGER_CLASS_HINT)) score += 2;
385
+ if (signals.hasPopup) score += 1;
386
+ return score;
387
+ }
388
+ function signalsOf(el) {
389
+ const chain = [];
390
+ let node2 = el?.parentElement ?? null;
391
+ for (let i = 0; node2 && i < 8; i += 1) {
392
+ chain.push(String(node2.className ?? ""));
393
+ node2 = node2.parentElement ?? null;
394
+ }
395
+ return {
396
+ ariaLabel: el?.getAttribute?.("aria-label") ?? "",
397
+ className: String(el?.className ?? el?.getAttribute?.("class") ?? ""),
398
+ ancestorClasses: chain,
399
+ inDialog: typeof el?.closest === "function" ? Boolean(el.closest('[role="dialog"]')) : false,
400
+ hasPopup: el?.getAttribute?.("aria-haspopup") === "dialog"
401
+ };
402
+ }
403
+ function candidatesOf(doc) {
404
+ const out = [];
405
+ const seen = /* @__PURE__ */ new Set();
406
+ for (const selector of ['button[aria-haspopup="dialog"]', "button[aria-expanded]"]) {
407
+ let list = [];
408
+ try {
409
+ list = Array.from(doc.querySelectorAll(selector) ?? []);
410
+ } catch {
411
+ list = [];
412
+ }
413
+ for (const el of list) {
414
+ if (seen.has(el)) continue;
415
+ seen.add(el);
416
+ out.push({ el, score: scoreSettingsTrigger(signalsOf(el)) });
417
+ }
418
+ }
419
+ return out;
420
+ }
421
+ function findSettingsTrigger(doc) {
422
+ if (!doc?.querySelector) return null;
423
+ let best = null;
424
+ for (const candidate of candidatesOf(doc)) {
425
+ if (candidate.score < SETTINGS_TRIGGER_MIN_SCORE) continue;
426
+ if (!best || candidate.score > best.score) best = candidate;
427
+ }
428
+ return best?.el ?? null;
429
+ }
430
+ function focusOwnSection(doc, win) {
431
+ const view = win || doc?.defaultView || (typeof window === "undefined" ? null : window);
432
+ const hook = view?.[SECTION_FOCUS_HOOK];
433
+ if (typeof hook === "function") {
434
+ try {
435
+ if (hook()) return isOwnRowActive(doc, view) ? "active" : "clicked";
436
+ } catch {
437
+ }
438
+ }
439
+ const row = ownRowOf(doc, view);
440
+ if (!row) return "none";
441
+ if (String(row.getAttribute?.("aria-current")) === "true") return "active";
442
+ try {
443
+ row.click();
444
+ } catch {
445
+ return "none";
446
+ }
447
+ return isOwnRowActive(doc, view) ? "active" : "clicked";
448
+ }
449
+ function isOwnRowActive(doc, win) {
450
+ const active = doc?.querySelector?.(ACTIVE_ROW_SELECTOR);
451
+ if (!active) return false;
452
+ if (active.hasAttribute?.(OWN_SECTION_ATTR)) return true;
453
+ const label = normalizeLabel(readOwnLabel(win));
454
+ return label.length > 0 && normalizeLabel(active.textContent) === label;
455
+ }
456
+ function normalizeLabel(value) {
457
+ return String(value ?? "").replace(/\s+/g, " ").trim();
458
+ }
459
+ function readOwnLabel(win) {
460
+ const view = win || (typeof window === "undefined" ? null : window);
461
+ const source = view?.[SECTION_LABEL_HOOK];
462
+ if (typeof source === "function") {
463
+ try {
464
+ return source();
465
+ } catch {
466
+ return "";
467
+ }
468
+ }
469
+ return source ?? "";
470
+ }
471
+ function ownRowOf(doc, win) {
472
+ const marked = doc?.querySelector?.(OWN_SECTION_SELECTOR);
473
+ if (marked) return marked;
474
+ if (typeof doc?.querySelectorAll !== "function") return null;
475
+ const label = normalizeLabel(readOwnLabel(win));
476
+ if (label.length === 0) return null;
477
+ for (const row of doc.querySelectorAll(NAV_ROW_SELECTOR)) {
478
+ const text = normalizeLabel(row?.textContent);
479
+ if (text === label || text.length > 0 && (text.includes(label) || label.includes(text))) return row;
480
+ }
481
+ return null;
482
+ }
483
+ function describeSettingsNav(doc, win) {
484
+ const view = win || (typeof window === "undefined" ? null : window);
485
+ const rows = [];
486
+ try {
487
+ for (const row of doc?.querySelectorAll?.(NAV_ROW_SELECTOR) ?? []) {
488
+ const text = normalizeLabel(row?.textContent);
489
+ if (text.length > 0) rows.push(text);
490
+ }
491
+ } catch {
492
+ }
493
+ return {
494
+ dialogOpen: isSettingsDialogOpen(doc),
495
+ ownLabel: normalizeLabel(readOwnLabel(view)),
496
+ hasFocusHook: typeof view?.[SECTION_FOCUS_HOOK] === "function",
497
+ hasLabelHook: view?.[SECTION_LABEL_HOOK] != null,
498
+ marked: Boolean(doc?.querySelector?.(OWN_SECTION_SELECTOR)),
499
+ activeLabel: normalizeLabel(doc?.querySelector?.(ACTIVE_ROW_SELECTOR)?.textContent),
500
+ rows
501
+ };
502
+ }
503
+ function undoMisclick(trigger) {
504
+ try {
505
+ if (String(trigger?.getAttribute?.("aria-expanded")) !== "true") return;
506
+ let node2 = trigger;
507
+ for (let i = 0; node2 && i < 8; i += 1) {
508
+ if (String(node2.className ?? "").includes(SETTINGS_AREA_HINT)) return;
509
+ node2 = node2.parentElement ?? null;
510
+ }
511
+ trigger.click();
512
+ } catch {
513
+ }
514
+ }
515
+ function openSettingsPage(doc, opts = {}) {
516
+ if (!doc?.querySelector) return "no-trigger";
517
+ const win = opts.win || doc.defaultView || null;
518
+ const focusOwn = opts.focusOwnSection !== false;
519
+ const onFail = typeof opts.onFail === "function" ? opts.onFail : null;
520
+ const alreadyOpen = isSettingsDialogOpen(doc);
521
+ let trigger = null;
522
+ if (!alreadyOpen) {
523
+ trigger = findSettingsTrigger(doc);
524
+ if (!trigger) return "no-trigger";
525
+ try {
526
+ if (focusOwn && win) win[SECTION_WANT_FLAG] = true;
527
+ } catch {
528
+ }
529
+ try {
530
+ trigger.click();
531
+ } catch {
532
+ return "no-trigger";
533
+ }
534
+ }
535
+ const result = alreadyOpen ? "already-open" : "clicked";
536
+ if (!win || typeof win.setTimeout !== "function") {
537
+ if (focusOwn) focusOwnSection(doc, win);
538
+ return result;
539
+ }
540
+ const attempts = Number(opts.attempts) > 0 ? Number(opts.attempts) : 40;
541
+ const interval = Number(opts.intervalMs) > 0 ? Number(opts.intervalMs) : 50;
542
+ const maxClicks = Number(opts.maxClicks) > 0 ? Number(opts.maxClicks) : 3;
543
+ let left = attempts;
544
+ let clicks = 0;
545
+ let focused = false;
546
+ const tick = () => {
547
+ const open = isSettingsDialogOpen(doc);
548
+ if (open && focusOwn && !focused) {
549
+ const info = describeSettingsNav(doc, win);
550
+ const verdict = info.activeLabel.length > 0;
551
+ if (verdict && info.ownLabel.length > 0 && info.activeLabel === info.ownLabel) {
552
+ focused = true;
553
+ } else {
554
+ if (clicks < maxClicks) {
555
+ const state = focusOwnSection(doc, win);
556
+ if (state !== "none") clicks += 1;
557
+ if (state === "active") focused = true;
558
+ }
559
+ if (!verdict && clicks > 0) focused = true;
560
+ }
561
+ }
562
+ if (open && (!focusOwn || focused)) return;
563
+ if (--left > 0) {
564
+ win.setTimeout(tick, interval);
565
+ return;
566
+ }
567
+ if (open) {
568
+ try {
569
+ win[SECTION_WANT_FLAG] = false;
570
+ } catch {
571
+ }
572
+ opts.onFocusFail?.();
573
+ return;
574
+ }
575
+ if (trigger) undoMisclick(trigger);
576
+ onFail?.();
577
+ };
578
+ try {
579
+ win.setTimeout(tick, 0);
580
+ } catch {
581
+ }
582
+ return result;
583
+ }
584
+
585
+ // src/settings-nav-icon.js
586
+ var NAV_ICON_MARKER = "data-dspack-nav-icon";
587
+ var NAV_ROW_SELECTOR2 = '[role="dialog"] nav button';
588
+ var NAV_ICON_SIZE = 16;
589
+ function navIconMaskSvg(path, viewBox = "0 0 1024 1024") {
590
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${viewBox}" fill="#000"><path d="${path}"/></svg>`;
591
+ }
592
+ function navIconMaskUrl(svg) {
593
+ return `data:image/svg+xml,${encodeURIComponent(svg)}`;
594
+ }
595
+ function isOwnNavRow(rowText, wantedLabel) {
596
+ const wanted = String(wantedLabel ?? "").trim();
597
+ if (wanted.length === 0) return false;
598
+ return String(rowText ?? "").trim() === wanted;
599
+ }
600
+ function navIconCss(maskUrl) {
601
+ return [
602
+ `[${NAV_ICON_MARKER}] > svg { display: none; }`,
603
+ `[${NAV_ICON_MARKER}]::before {`,
604
+ ` content: '';`,
605
+ ` flex: none;`,
606
+ ` width: ${NAV_ICON_SIZE}px;`,
607
+ ` height: ${NAV_ICON_SIZE}px;`,
608
+ ` background-color: currentColor;`,
609
+ ` -webkit-mask-image: url("${maskUrl}");`,
610
+ ` mask-image: url("${maskUrl}");`,
611
+ ` -webkit-mask-repeat: no-repeat;`,
612
+ ` mask-repeat: no-repeat;`,
613
+ ` -webkit-mask-position: center;`,
614
+ ` mask-position: center;`,
615
+ ` -webkit-mask-size: ${NAV_ICON_SIZE}px ${NAV_ICON_SIZE}px;`,
616
+ ` mask-size: ${NAV_ICON_SIZE}px ${NAV_ICON_SIZE}px;`,
617
+ `}`
618
+ ].join("\n");
619
+ }
620
+ function installSettingsNavIcon(ctx, resolveLabel, maskUrl) {
621
+ if (typeof document === "undefined") return;
622
+ if (!ctx || typeof ctx.effect !== "function") return;
623
+ ctx.effect(() => {
624
+ const tag = document.createElement("style");
625
+ tag.dataset.plugin = "dsh-packforge";
626
+ tag.dataset.pluginCss = "dsh-packforge/settings-nav-icon";
627
+ tag.textContent = navIconCss(maskUrl);
628
+ document.head.appendChild(tag);
629
+ let disposed = false;
630
+ let scheduled = false;
631
+ const sync = () => {
632
+ scheduled = false;
633
+ if (disposed) return;
634
+ const wanted = resolveLabel();
635
+ for (const row of document.querySelectorAll(NAV_ROW_SELECTOR2)) {
636
+ if (isOwnNavRow(row.textContent, wanted)) row.setAttribute(NAV_ICON_MARKER, "");
637
+ else row.removeAttribute(NAV_ICON_MARKER);
638
+ }
639
+ if (window[SECTION_WANT_FLAG] === true) {
640
+ const wantedText = String(wanted ?? "").trim();
641
+ if (wantedText.length > 0) {
642
+ for (const row of document.querySelectorAll(NAV_ROW_SELECTOR2)) {
643
+ if (!isOwnNavRow(row.textContent, wantedText)) continue;
644
+ window[SECTION_WANT_FLAG] = false;
645
+ row.click();
646
+ break;
647
+ }
648
+ }
649
+ }
650
+ };
651
+ const schedule = () => {
652
+ if (scheduled || disposed) return;
653
+ scheduled = true;
654
+ queueMicrotask(sync);
655
+ };
656
+ sync();
657
+ const observer = new MutationObserver(schedule);
658
+ observer.observe(document.body, { childList: true, subtree: true, characterData: true });
659
+ return () => {
660
+ disposed = true;
661
+ observer.disconnect();
662
+ for (const row of document.querySelectorAll(`[${NAV_ICON_MARKER}]`)) row.removeAttribute(NAV_ICON_MARKER);
663
+ tag.remove();
664
+ };
665
+ }, "dsh-packforge: settings nav icon");
666
+ }
667
+ function installSectionFocusHook(ctx, resolveLabel) {
668
+ if (typeof document === "undefined" || typeof window === "undefined") return false;
669
+ const focus = () => {
670
+ const wanted = String(resolveLabel?.() ?? "").trim();
671
+ if (wanted.length === 0) return false;
672
+ for (const row of document.querySelectorAll(NAV_ROW_SELECTOR2)) {
673
+ if (!isOwnNavRow(row.textContent, wanted)) continue;
674
+ row.click();
675
+ return true;
676
+ }
677
+ return false;
678
+ };
679
+ const previous = window[SECTION_FOCUS_HOOK] ?? null;
680
+ window[SECTION_FOCUS_HOOK] = focus;
681
+ const previousLabel = window[SECTION_LABEL_HOOK] ?? null;
682
+ window[SECTION_LABEL_HOOK] = () => String(resolveLabel?.() ?? "");
683
+ if (ctx && typeof ctx.effect === "function") {
684
+ ctx.effect(() => () => {
685
+ if (window[SECTION_FOCUS_HOOK] === focus) window[SECTION_FOCUS_HOOK] = previous;
686
+ if (window[SECTION_LABEL_HOOK] !== null && typeof window[SECTION_LABEL_HOOK] === "function") {
687
+ window[SECTION_LABEL_HOOK] = previousLabel;
688
+ }
689
+ }, "dsh-packforge: section focus hook");
690
+ }
691
+ return true;
692
+ }
693
+
694
+ // src/section-gate.js
695
+ function createSectionGate(register) {
696
+ let ready = false;
697
+ let removed = false;
698
+ let dispose = null;
699
+ const apply2 = () => {
700
+ if (!ready) return;
701
+ const shouldShow = !removed;
702
+ if (shouldShow && dispose === null) {
703
+ dispose = register();
704
+ return;
705
+ }
706
+ if (!shouldShow && dispose !== null) {
707
+ const stop = dispose;
708
+ dispose = null;
709
+ stop();
710
+ }
711
+ };
712
+ return {
713
+ /** slots 服务已就位(inject 回调触发)。幂等:重复调用不会二次 register。 */
714
+ available: () => {
715
+ ready = true;
716
+ apply2();
717
+ },
718
+ /** 当前入口是否已注册。 */
719
+ visible: () => dispose !== null,
720
+ /** 本包被移除:永久注销,后续任何 available 都不再复活。 */
721
+ retire: () => {
722
+ removed = true;
723
+ apply2();
724
+ }
725
+ };
726
+ }
727
+
728
+ // src/settings.js
729
+ var NS = "dspack";
730
+ var MANAGER_PKG = "@dsh-plugin/dsh-pack-plugin";
731
+ var VERSION = false ? "0.0.1" : "0.0.1";
732
+ var LOGO_PATH = "M444.330667 128l85.333333 85.333333H896a42.666667 42.666667 0 0 1 42.666667 42.666667v597.333333a42.666667 42.666667 0 0 1-42.666667 42.666667H128a42.666667 42.666667 0 0 1-42.666667-42.666667V170.666667a42.666667 42.666667 0 0 1 42.666667-42.666667h316.330667zM768 768h-170.666667v-128h85.333334v-85.333333h-85.333334v-85.333334h85.333334V384h-85.333334V298.666667h-102.997333l-85.333333-85.333334H170.666667v597.333334h682.666666V298.666667h-170.666666v85.333333h85.333333v85.333333h-85.333333v85.333334h85.333333v213.333333z";
733
+ var AUTHOR = "hxh230802";
734
+ var AUTHOR_URL = "https://github.com/hxh230802";
735
+ var REPO_URL = "https://github.com/dsh-plugins/dsh-pack-plugin";
736
+ var NPM_URL = "https://www.npmjs.com/package/" + MANAGER_PKG;
737
+ var SPEC_URL = "https://github.com/DSH-PackForge/DSH-PackForge";
738
+ var APP_URL = "https://github.com/DSH-PackForge/dsh-packforge-app";
739
+ var MARKET_URL = "https://github.com/DSH-PackForge/dsh-pack-market";
740
+ function localizedLabel(value) {
741
+ if (typeof value === "string") return value;
742
+ if (!value || typeof value !== "object") return "";
743
+ const language = globalThis.navigator?.language || "zh";
744
+ return [value[language], value[language.split("-")[0]], ...Object.values(value)].find((v) => typeof v === "string" && v) || "";
745
+ }
746
+ function displayIcon(icon, cache) {
747
+ if (typeof icon !== "string") return void 0;
748
+ if (icon.startsWith("assets/plugins/")) {
749
+ const value = cache?.[icon];
750
+ return typeof value === "string" && /^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[a-z0-9+/]+=*$/i.test(value) ? value : void 0;
751
+ }
752
+ try {
753
+ const url = new URL(icon);
754
+ return url.protocol === "https:" && !url.username && !url.password ? url.href : void 0;
755
+ } catch {
756
+ return void 0;
757
+ }
758
+ }
759
+ function marketResources(manifest, icons, t) {
760
+ if (manifest?.manifestVersion !== 6) return null;
761
+ const units = manifest.type === "dshhome" ? Object.entries(manifest.profiles || {}) : [["", manifest]];
762
+ const groups = [];
763
+ function group(id, title, items) {
764
+ if (!items.length) return;
765
+ groups.push((0, import_react.createElement)("section", { key: id }, (0, import_react.createElement)("h4", null, title), (0, import_react.createElement)("ul", null, ...items)));
766
+ }
767
+ function display(id, name2, desc, meta, icon) {
768
+ const title = localizedLabel(name2) || id;
769
+ return (0, import_react.createElement)(
770
+ "li",
771
+ { key: id },
772
+ icon ? (0, import_react.createElement)("img", {
773
+ src: icon,
774
+ width: 24,
775
+ height: 24,
776
+ alt: "",
777
+ loading: "lazy",
778
+ referrerPolicy: "no-referrer",
779
+ onError: (e) => {
780
+ const image = e.currentTarget;
781
+ if (image.src.startsWith("https://cdn.jsdelivr.com/npm/")) image.src = image.src.replace("https://cdn.jsdelivr.com/npm/", "https://cdn.jsdelivr.net/npm/");
782
+ }
783
+ }) : null,
784
+ (0, import_react.createElement)("strong", null, title),
785
+ " ",
786
+ (0, import_react.createElement)("code", null, [title === id ? "" : id, ...meta].filter(Boolean).join(" \xB7 ")),
787
+ desc ? (0, import_react.createElement)("p", null, localizedLabel(desc)) : null
788
+ );
789
+ }
790
+ for (const [scope, unit] of units) {
791
+ const items = Object.entries(unit.plugins || {}).map(([id, p]) => display(id, p.name, p.desc, [unit.dependencies?.[id]], displayIcon(p.icon, icons)));
792
+ group("plugins:" + scope, [t("market.plugins"), scope].filter(Boolean).join(" \xB7 "), items);
793
+ }
794
+ const labels = { "path.json": "market.paths", "provider.json": "market.providers", "mcp.json": "market.mcp", "skill.json": "market.skills" };
795
+ for (const [file, label] of Object.entries(labels)) {
796
+ const list = manifest.resources?.[file];
797
+ if (Array.isArray(list)) group(file, t(label), list.map((item) => (0, import_react.createElement)(
798
+ "li",
799
+ { key: [item.scope, item.plugin, item.id].join(":") },
800
+ (0, import_react.createElement)("strong", null, localizedLabel(item.name) || item.id),
801
+ " ",
802
+ (0, import_react.createElement)("code", null, [item.plugin, item.scope, item.ref, item.commit].filter(Boolean).join(" \xB7 ")),
803
+ item.desc ? (0, import_react.createElement)("p", null, localizedLabel(item.desc)) : null
804
+ )));
805
+ }
806
+ return groups;
807
+ }
808
+ var dict = {
809
+ zh: {
810
+ nav: "\u6574\u5408\u5305",
811
+ "tab.manage": "\u7BA1\u7406",
812
+ "tab.export": "\u5BFC\u51FA",
813
+ "tab.market": "\u5E02\u573A",
814
+ "running.title": "\u6B63\u5728\u8FD0\u884C\u7684\u6574\u5408\u5305",
815
+ "running.profile": "profile\u540D\uFF1A",
816
+ "action.openDir": "\u6253\u5F00\u76EE\u5F55",
817
+ "create.title": "\u521B\u5EFA\u6574\u5408\u5305",
818
+ "action.newEmpty": "\u7A7A\u6574\u5408\u5305",
819
+ "action.import": "\u5BFC\u5165\u65B0\u5305",
820
+ "action.market": "\u6D4F\u89C8\u5E02\u573A",
821
+ "action.refresh": "\u5237\u65B0",
822
+ "action.tasks": "\u4EFB\u52A1\u4E2D\u5FC3",
823
+ "tasks.empty": "\u6682\u65E0\u4EFB\u52A1",
824
+ "tasks.close": "\u5173\u95ED",
825
+ "installed.title": "\u5DF2\u5B89\u88C5\u7684\u6574\u5408\u5305",
826
+ "action.delete": "\u5220\u9664",
827
+ "hint.restart": "\u70B9\u5207\u6362\u540E\u91CD\u542F\u751F\u6548",
828
+ "group.meta": "\u5143\u6570\u636E\uFF08\u7559\u7A7A\u7528 profile \u9ED8\u8BA4\uFF09",
829
+ "group.output": "\u8F93\u51FA",
830
+ "field.name": "\u6574\u5408\u5305\u540D",
831
+ "field.version": "\u7248\u672C",
832
+ "field.displayName": "\u5C55\u793A\u540D",
833
+ "field.description": "\u63CF\u8FF0",
834
+ "field.author": "\u4F5C\u8005",
835
+ "field.icon": "\u56FE\u6807 URL",
836
+ "field.dshVersion": "DSH \u7248\u672C\uFF08\u7559\u7A7A\u53D6\u6700\u65B0\u5DF2\u88C5\uFF09",
837
+ "field.out": "\u8F93\u51FA\u76EE\u5F55\uFF08\u7559\u7A7A\u7528\u5F53\u524D\u76EE\u5F55\uFF09",
838
+ "field.profile": "\u5BFC\u51FA\u8303\u56F4",
839
+ "scope.home": "\u6574\u4E2A DSH_HOME\uFF08\u5168\u90E8\u914D\u7F6E\u6863\uFF09",
840
+ "field.defaultProfile": "\u5B89\u88C5\u540E\u7684\u9ED8\u8BA4\u914D\u7F6E\u6863",
841
+ "content.data": "\u5BFC\u51FA data/",
842
+ "action.editResources": "\u63D2\u4EF6\u4E0E\u8D44\u6E90",
843
+ "market.plugins": "\u63D2\u4EF6",
844
+ "market.paths": "\u63D2\u4EF6\u6570\u636E",
845
+ "market.providers": "\u6A21\u578B\u670D\u52A1\u5546",
846
+ "market.mcp": "MCP \u670D\u52A1",
847
+ "market.skills": "\u6280\u80FD",
848
+ "field.source": ".dspack \u8DEF\u5F84\u6216 URL",
849
+ "field.newName": "\u65B0 profile \u540D",
850
+ "action.export": "\u5BFC\u51FA",
851
+ "action.quickExport": "\u5FEB\u6377\u5BFC\u51FA",
852
+ "action.upload": "\u4E0A\u4F20\u5230 GitHub",
853
+ "upload.hint": "\u5148\u5BFC\u51FA\uFF0C\u518D\u70B9\u6B64\u5207\u56DE\u804A\u5929\u6846\u8BA9 AI \u5E2E\u4F60\u53D1 Release",
854
+ "upload.sent": "\u5DF2\u5207\u56DE\u804A\u5929\u6846\uFF0CAI \u63A5\u624B\u4E0A\u4F20",
855
+ "upload.failed": "\u53D1\u9001\u5931\u8D25",
856
+ "upload.noService": "\u804A\u5929\u670D\u52A1\u4E0D\u53EF\u7528\uFF08DSH \u7248\u672C\u8FC7\u4F4E\uFF09",
857
+ "action.install": "\u5B89\u88C5",
858
+ "action.switch": "\u5207\u6362",
859
+ "action.create": "\u65B0\u5EFA",
860
+ "action.save": "\u4FDD\u5B58",
861
+ "action.load": "\u8BFB\u53D6",
862
+ "field.profileName": "\u5B89\u88C5\u540D\uFF08\u8986\u76D6 manifest profileName\uFF09",
863
+ "field.mode": "\u5BFC\u51FA\u5F62\u6001",
864
+ "mode.dspack": "\u5355\u6587\u4EF6\uFF08.dspack\uFF09",
865
+ "mode.repo": "\u6E90\u4ED3\u5E93",
866
+ "field.content": "\u4ED3\u5E93\u5185\u5BB9\u6863",
867
+ "content.manifest": "\u4EC5\u6E05\u5355\uFF08manifest.json\uFF09",
868
+ "content.readme": "\u6E05\u5355 + README",
869
+ "content.full": "\u5168\u5957\u6587\u4EF6\uFF08overrides/ + release/\uFF09",
870
+ "vendor.title": "\u5185\u5D4C\u4F9D\u8D56\uFF08vendored \xB7 \u79BB\u7EBF\u5206\u53D1\uFF09",
871
+ "vendor.hint": "\u52FE\u9009\u8981\u5185\u5D4C\u8FDB .dspack \u7684\u63D2\u4EF6\uFF1A\u4E0A\u6E38\u5DF2\u6D88\u5931 / \u9B54\u6539 / \u9700\u79BB\u7EBF\u5206\u53D1\u7684\u4F9D\u8D56\u5EFA\u8BAE\u5185\u5D4C\uFF1B\u4F53\u79EF\u5927\u65F6\u4F18\u5148 files[] \u6307\u9488\u5236",
872
+ "vendor.reload": "\u5237\u65B0\u4F9D\u8D56",
873
+ "vendor.none": "\u8BE5 profile \u6CA1\u6709\u4F9D\u8D56",
874
+ "vendor.already": "\u5DF2\u5185\u5D4C\uFF08\u590D\u7528\u539F tarball\uFF09",
875
+ "vendor.notInstalled": "\u672A\u5B89\u88C5\uFF08\u65E0\u6CD5\u5185\u5D4C\uFF09",
876
+ "vendor.selected": "\u5DF2\u9009",
877
+ "vendor.kind.npm": "npm",
878
+ "vendor.kind.git": "git",
879
+ "vendor.kind.vendored": "\u5185\u5D4C",
880
+ "vendor.mode": "\u5185\u5D4C\u6863\u4F4D",
881
+ "vendor.mode.auto": "\u81EA\u52A8\uFF08\u624B\u52A8\u52FE\u9009 + \u5DF2\u5185\u5D4C\u590D\u7528\uFF09",
882
+ "vendor.mode.off": "\u5173\u95ED\uFF08\u4E0D\u5185\u5D4C\uFF09",
883
+ "vendor.mode.full": "\u5168\u91CF\uFF08\u5168\u90E8\u76F4\u63A5\u4F9D\u8D56 \xB7 \u79BB\u7EBF\u5305\uFF09",
884
+ "compat.title": "\u517C\u5BB9\u6027\uFF08v5 r2\uFF09",
885
+ "compat.dshVersions": "\u517C\u5BB9 DSH \u7248\u672C\u96C6\uFF08dshVersions\uFF09",
886
+ "compat.dshVersionsHint": "\u9017\u53F7\u5206\u9694\u7684\u5B9E\u6D4B\u517C\u5BB9\u7248\u672C\u679A\u4E3E\uFF08\u5982 0.1.1-rc.2, 0.1.0\uFF09\uFF1B\u300CDSH \u7248\u672C\u300D\u5FC5\u987B\u5305\u542B\u5728\u5185\uFF1B\u7559\u7A7A = \u4EC5\u6309 dshVersion",
887
+ "compat.launchers": "\u542F\u52A8\u5668\u517C\u5BB9\u58F0\u660E\uFF08launchers\uFF09",
888
+ "launcher.none": "\u672A\u58F0\u660E",
889
+ "launcher.support": "\u652F\u6301",
890
+ "launcher.conflict": "\u51B2\u7A81",
891
+ "launcher.minVersion": "\u6700\u4F4E\u7248\u672C\uFF08\u53EF\u9009\uFF09",
892
+ "launcher.reason": "\u51B2\u7A81\u539F\u56E0\uFF08\u5EFA\u8BAE\u586B\u5199\uFF09",
893
+ "group.content": "\u5BFC\u51FA\u5185\u5BB9\uFF08\u4E0A\u4E00\u7EA7\u76EE\u5F55\u5F00\u5173\uFF09",
894
+ "content.preset": "\u5BFC\u51FA .agent-presets/",
895
+ "content.instruction": "\u5BFC\u51FA AGENTS.md",
896
+ "result.saved": "\u5DF2\u4FDD\u5B58\u5DE5\u4F5C\u533A\u914D\u7F6E",
897
+ "result.loaded": "\u5DF2\u8BFB\u53D6\u5DE5\u4F5C\u533A\u914D\u7F6E",
898
+ "result.noCfg": "\u8BE5\u5BFC\u51FA\u8303\u56F4\u8FD8\u6CA1\u6709\u4FDD\u5B58\u7684\u5DE5\u4F5C\u533A\u914D\u7F6E",
899
+ "result.pending": "\u5904\u7406\u4E2D\u2026",
900
+ "result.taskStarted": "\u5DF2\u52A0\u5165\u4EFB\u52A1\u4E2D\u5FC3\uFF0C\u8FDB\u5EA6\u89C1\u9762\u677F",
901
+ "result.noRpc": "\u540E\u7AEF RPC \u4E0D\u53EF\u7528\uFF08connection \u670D\u52A1\u7F3A\u5931\uFF09",
902
+ "err.name": "\u8BF7\u586B\u5199 profile \u540D",
903
+ "err.source": "\u8BF7\u586B\u5199 .dspack \u8DEF\u5F84\u6216 URL",
904
+ "err.nameInvalid": "\u540D\u5B57\u683C\u5F0F\u4E0D\u5BF9\uFF1A\u53EA\u80FD\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26\uFF08\u5982 aaa-bb-c\uFF09",
905
+ "err.nameReserved": "\u300C{name}\u300D\u662F\u4FDD\u7559\u540D\uFF0C\u4E0D\u80FD\u4F5C\u4E3A profile \u540D",
906
+ "hint.nameFormat": "\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\uFF0C\u7528\u8FDE\u5B57\u7B26\u5206\u9694\uFF0C\u5982 aaa-bb-c",
907
+ "hint.import": ".dspack \u6587\u4EF6\u8DEF\u5F84\u6216 URL",
908
+ "dialog.createTitle": "\u521B\u5EFA\u7A7A\u7684\u6574\u5408\u5305",
909
+ "dialog.importTitle": "\u5BFC\u5165\u65B0\u5305",
910
+ "profile.active": "\u5F53\u524D",
911
+ "market.loading": "\u52A0\u8F7D\u5E02\u573A\u4E2D\u2026",
912
+ "market.empty": "\u5E02\u573A\u6682\u65E0\u5185\u5BB9",
913
+ "market.error": "\u5E02\u573A\u52A0\u8F7D\u5931\u8D25",
914
+ "market.none": "\uFF08\u65E0\uFF09",
915
+ "market.detail": "\u8BE6\u60C5",
916
+ "market.detailTitle": "\u6574\u5408\u5305\u8BE6\u60C5",
917
+ "market.launcherRestricted": "\u542F\u52A8\u5668\u9650\u5236",
918
+ "market.r2.launcherRequire": "\u9700\u542F\u52A8\u5668 {id} \u2265 {ver}",
919
+ "market.r2.launcherConflict": "\u4E0D\u652F\u6301\u5728 {id} \u4E0A\u8FD0\u884C\uFF1A{reason}",
920
+ "market.r2.noReason": "\u672A\u63D0\u4F9B\u539F\u56E0",
921
+ "market.r2.vendored": "\u5185\u5D4C {count} \u4E2A\u4F9D\u8D56\uFF08\u79BB\u7EBF\u5206\u53D1\uFF09",
922
+ "market.r2.dshVersions": "\u517C\u5BB9 DSH \u7248\u672C\uFF1A{versions}",
923
+ "market.r2.none": "\u65E0\u542F\u52A8\u5668\u517C\u5BB9\u9650\u5236\uFF0C\u672A\u5185\u5D4C\u4F9D\u8D56",
924
+ "installConfirm.title": "\u5B89\u88C5\u786E\u8BA4",
925
+ "installConfirm.hint": "\u8BE5\u6574\u5408\u5305\u7684\u542F\u52A8\u5668\u517C\u5BB9\u58F0\u660E\u5B58\u5728\u8B66\u544A\uFF0C\u786E\u8BA4\u540E\u5C06\u7167\u5E38\u5B89\u88C5\uFF1A",
926
+ "installConfirm.ok": "\u4ECD\u8981\u5B89\u88C5",
927
+ "confirm.title": "\u5207\u6362 profile",
928
+ "confirm.from": "\u5F53\u524D",
929
+ "confirm.to": "\u76EE\u6807",
930
+ "confirm.firstTime": "\u9996\u6B21\u5207\u6362\uFF1A\u4F1A\u628A\u5F53\u524D\u76EE\u5F55\u5B58\u6863\u4E3A default",
931
+ "confirm.warning": "\u68C0\u6D4B\u5230\u76EE\u6807 profile \u6CA1\u6709 {pkg}\uFF0C\u9700\u8981\u5B89\u88C5\u3002\u82E5\u6CA1\u6709\u6B64\u63D2\u4EF6\uFF0C\u5C06\u65E0\u6CD5\u4ECE\u5E94\u7528\u5185\u518D\u6B21\u5207\u6362 profile\u3002",
932
+ "confirm.cancel": "\u53D6\u6D88",
933
+ "confirm.ok": "\u786E\u8BA4\u5207\u6362",
934
+ "confirm.hintRestart": "\u5207\u6362\u540E\u4F1A\u81EA\u52A8\u91CD\u542F\u5BA2\u6237\u7AEF\uFF1B\u82E5\u957F\u65F6\u95F4\u672A\u81EA\u52A8\u91CD\u542F\uFF0C\u8BF7\u624B\u52A8\u62C9\u8D77\u5BA2\u6237\u7AEF\u3002",
935
+ "confirm.managerSource": "\u76EE\u6807\u7F3A\u5C11\u63D2\u4EF6\uFF0C\u5B89\u88C5\u65B9\u5F0F\uFF1A",
936
+ "confirm.source.copy": "\u4ECE\u5F53\u524D profile \u590D\u5236",
937
+ "confirm.source.npm": "\u4ECE NPM \u62C9\u53D6\u6700\u65B0",
938
+ "tab.about": "\u5173\u4E8E",
939
+ "about.version": "\u7248\u672C",
940
+ "about.desc": "DSH \u6574\u5408\u5305\u7BA1\u7406\u63D2\u4EF6\uFF1A.dspack \u5BFC\u51FA/\u5BFC\u5165\u3001\u591A profile \u5207\u6362\uFF0C\u96F6\u5B98\u65B9\u6E90\u7801\u6539\u52A8\u3002",
941
+ "about.philosophy": "\u6574\u5408\u2014\u2014\u5305\u7F57\u4E07\u8C61",
942
+ "about.author": "\u4F5C\u8005",
943
+ "about.repo": "\u4ED3\u5E93",
944
+ "about.star": "\u6C42 Star",
945
+ "about.checkUpdate": "\u68C0\u67E5\u66F4\u65B0",
946
+ "about.checking": "\u68C0\u67E5\u4E2D\u2026",
947
+ "about.upToDate": "\u5DF2\u662F\u6700\u65B0\u7248\u672C",
948
+ "about.newVersion": "\u6709\u65B0\u7248\u672C {latest}\uFF08\u5F53\u524D {current}\uFF09",
949
+ "about.checkFailed": "\u68C0\u67E5\u66F4\u65B0\u5931\u8D25",
950
+ "about.viewNpm": "\u5728 npm \u67E5\u770B",
951
+ "about.ecosystem": "\u751F\u6001",
952
+ "about.ecosystem.spec": "\u7406\u5FF5\u53CA\u89C4\u8303",
953
+ "about.ecosystem.app": "\u5305\u7BA1\u7406\u5668",
954
+ "about.ecosystem.market": "\u5E02\u573A",
955
+ "group.network": "\u7F51\u7EDC",
956
+ "field.proxyMode": "\u4EE3\u7406\u6A21\u5F0F",
957
+ "proxyMode.auto": "\u81EA\u52A8\uFF08\u8DDF\u968F\u7CFB\u7EDF\u4EE3\u7406\uFF09",
958
+ "proxyMode.direct": "\u76F4\u8FDE\uFF08\u4E0D\u4F7F\u7528\u4EE3\u7406\uFF09",
959
+ "proxyMode.manual": "\u624B\u52A8\u6307\u5B9A\u4EE3\u7406",
960
+ "field.proxy": "\u4EE3\u7406\u5730\u5740",
961
+ "hint.proxy": "\u81EA\u52A8\u6A21\u5F0F\u56DE\u843D\u73AF\u5883\u53D8\u91CF\uFF08HTTP_PROXY / HTTPS_PROXY / ALL_PROXY / NO_PROXY\uFF09\u4E0E Windows \u7CFB\u7EDF\u4EE3\u7406\uFF1B\u624B\u52A8\u652F\u6301 http / https / socks / socks5\uFF0C\u5982 http://127.0.0.1:7890",
962
+ "result.proxySaved": "\u5DF2\u4FDD\u5B58\u4EE3\u7406\u8BBE\u7F6E\uFF08\u7ACB\u5373\u751F\u6548\uFF09",
963
+ "about.copyright": "\xA9 2026 DSH-PackForge contributors \xB7 MIT License"
964
+ },
965
+ en: {
966
+ nav: "Modpacks",
967
+ "tab.manage": "Manage",
968
+ "tab.export": "Export",
969
+ "tab.market": "Market",
970
+ "running.title": "Running modpack",
971
+ "running.profile": "profile: ",
972
+ "action.openDir": "Open folder",
973
+ "create.title": "Create modpack",
974
+ "action.newEmpty": "Empty pack",
975
+ "action.import": "Import pack",
976
+ "action.market": "Browse market",
977
+ "action.refresh": "Refresh",
978
+ "action.tasks": "Task Center",
979
+ "tasks.empty": "No tasks",
980
+ "tasks.close": "Close",
981
+ "installed.title": "Installed modpacks",
982
+ "action.delete": "Delete",
983
+ "hint.restart": "Takes effect after restart",
984
+ "group.meta": "Metadata (blank = profile default)",
985
+ "group.output": "Output",
986
+ "field.name": "Pack name",
987
+ "field.version": "Version",
988
+ "field.displayName": "Display name",
989
+ "field.description": "Description",
990
+ "field.author": "Author",
991
+ "field.icon": "Icon URL",
992
+ "field.dshVersion": "DSH version (blank = latest)",
993
+ "field.out": "Output dir (blank = current)",
994
+ "field.profile": "Export scope",
995
+ "scope.home": "Entire DSH_HOME (all profiles)",
996
+ "field.defaultProfile": "Default profile after installation",
997
+ "content.data": "Include data/",
998
+ "action.editResources": "Plugins and resources",
999
+ "market.plugins": "Plugins",
1000
+ "market.paths": "Plugin data",
1001
+ "market.providers": "Model providers",
1002
+ "market.mcp": "MCP servers",
1003
+ "market.skills": "Skills",
1004
+ "field.source": ".dspack path or URL",
1005
+ "field.newName": "New profile name",
1006
+ "vendor.title": "Vendored deps (offline distribution)",
1007
+ "vendor.hint": "Pick plugins to embed into the .dspack: dead-upstream / modified / offline deps are good candidates; prefer files[] pointers for large content",
1008
+ "vendor.reload": "Reload deps",
1009
+ "vendor.none": "No dependencies in this profile",
1010
+ "vendor.already": "Vendored (reuses original tarball)",
1011
+ "vendor.notInstalled": "Not installed (cannot embed)",
1012
+ "vendor.selected": "selected",
1013
+ "vendor.kind.npm": "npm",
1014
+ "vendor.kind.git": "git",
1015
+ "vendor.kind.vendored": "vendored",
1016
+ "vendor.mode": "Vendor mode",
1017
+ "vendor.mode.auto": "Auto (manual picks + re-use embedded)",
1018
+ "vendor.mode.off": "Off (no embedding)",
1019
+ "vendor.mode.full": "Full (all direct deps \xB7 offline pack)",
1020
+ "compat.title": "Compatibility (v5 r2)",
1021
+ "compat.dshVersions": "Compatible DSH versions (dshVersions)",
1022
+ "compat.dshVersionsHint": 'Comma-separated tested versions (e.g. 0.1.1-rc.2, 0.1.0); must include the "DSH version" field; blank = dshVersion only',
1023
+ "compat.launchers": "Launcher compatibility (launchers)",
1024
+ "launcher.none": "Unspecified",
1025
+ "launcher.support": "Supported",
1026
+ "launcher.conflict": "Conflict",
1027
+ "launcher.minVersion": "Min version (optional)",
1028
+ "launcher.reason": "Conflict reason (recommended)",
1029
+ "action.export": "Export",
1030
+ "action.quickExport": "Quick export",
1031
+ "action.upload": "Upload to GitHub",
1032
+ "upload.hint": "Export first, then switch to chat and let the AI publish the release",
1033
+ "upload.sent": "Switched to chat \u2014 the AI is on it",
1034
+ "upload.failed": "Send failed",
1035
+ "upload.noService": "Chat service unavailable (DSH too old)",
1036
+ "action.install": "Install",
1037
+ "action.switch": "Switch",
1038
+ "action.create": "Create",
1039
+ "result.pending": "Working\u2026",
1040
+ "result.taskStarted": "Added to task center \u2014 see the panel",
1041
+ "result.noRpc": "Backend RPC unavailable (no connection service)",
1042
+ "err.name": "Please fill a profile name",
1043
+ "err.source": "Please fill a .dspack path or URL",
1044
+ "err.nameInvalid": "Invalid name: lowercase letters, digits and hyphens only (e.g. aaa-bb-c)",
1045
+ "err.nameReserved": '"{name}" is a reserved name and cannot be used as a profile name',
1046
+ "hint.nameFormat": "Lowercase letters and digits separated by hyphens, e.g. aaa-bb-c",
1047
+ "hint.import": ".dspack file path or URL",
1048
+ "dialog.createTitle": "Create empty modpack",
1049
+ "dialog.importTitle": "Import modpack",
1050
+ "profile.active": "current",
1051
+ "market.loading": "Loading market\u2026",
1052
+ "market.empty": "Market is empty",
1053
+ "market.error": "Market load failed",
1054
+ "market.none": "(none)",
1055
+ "market.detail": "Details",
1056
+ "market.detailTitle": "Modpack details",
1057
+ "market.launcherRestricted": "launcher-restricted",
1058
+ "market.r2.launcherRequire": "Requires launcher {id} \u2265 {ver}",
1059
+ "market.r2.launcherConflict": "Not supported on {id}: {reason}",
1060
+ "market.r2.noReason": "no reason given",
1061
+ "market.r2.vendored": "{count} vendored deps (offline distribution)",
1062
+ "market.r2.dshVersions": "Compatible DSH versions: {versions}",
1063
+ "market.r2.none": "No launcher restrictions, no vendored deps",
1064
+ "installConfirm.title": "Install confirmation",
1065
+ "installConfirm.hint": "This pack has launcher-compatibility warnings. It will still be installed after you confirm:",
1066
+ "installConfirm.ok": "Install anyway",
1067
+ "confirm.title": "Switch profile",
1068
+ "confirm.from": "current",
1069
+ "confirm.to": "target",
1070
+ "confirm.firstTime": "First switch: current folder will be archived as default",
1071
+ "confirm.warning": "Target profile has no {pkg}; it must be installed. Without it you cannot switch again from inside the app.",
1072
+ "confirm.cancel": "Cancel",
1073
+ "confirm.ok": "Confirm switch",
1074
+ "confirm.hintRestart": "The client restarts automatically after switching; if it does not restart for a while, please launch it manually.",
1075
+ "confirm.managerSource": "Target profile is missing the plugin. Install via:",
1076
+ "confirm.source.copy": "Copy from current profile",
1077
+ "confirm.source.npm": "Pull latest from NPM",
1078
+ "tab.about": "About",
1079
+ "about.version": "Version",
1080
+ "about.desc": "DSH modpack plugin: .dspack export/import, multi-profile switching, zero official source changes.",
1081
+ "about.philosophy": "Integrate \u2014 embrace everything",
1082
+ "about.author": "Author",
1083
+ "about.repo": "Repository",
1084
+ "about.star": "Star on GitHub",
1085
+ "about.checkUpdate": "Check for updates",
1086
+ "about.checking": "Checking\u2026",
1087
+ "about.upToDate": "You are up to date",
1088
+ "about.newVersion": "New version {latest} (current {current})",
1089
+ "about.checkFailed": "Update check failed",
1090
+ "about.viewNpm": "View on npm",
1091
+ "about.ecosystem": "Ecosystem",
1092
+ "about.ecosystem.spec": "Philosophy & Spec",
1093
+ "about.ecosystem.app": "Package Manager",
1094
+ "about.ecosystem.market": "Market",
1095
+ "group.network": "Network",
1096
+ "field.proxyMode": "Proxy mode",
1097
+ "proxyMode.auto": "Auto (follow system proxy)",
1098
+ "proxyMode.direct": "Direct (no proxy)",
1099
+ "proxyMode.manual": "Manual proxy",
1100
+ "field.proxy": "Proxy",
1101
+ "hint.proxy": "Auto mode falls back to env vars (HTTP_PROXY / HTTPS_PROXY / ALL_PROXY / NO_PROXY) and the Windows system proxy; manual supports http / https / socks / socks5, e.g. http://127.0.0.1:7890",
1102
+ "result.proxySaved": "Proxy saved (takes effect immediately)",
1103
+ "about.copyright": "\xA9 2026 DSH-PackForge contributors \xB7 MIT License"
1104
+ }
1105
+ };
1106
+ function registerSettingsSection(ctx, packforge = {}) {
1107
+ const slots = ctx?.slots;
1108
+ const locale = ctx?.locale;
1109
+ if (!slots || typeof slots.inject !== "function") return false;
1110
+ if (!locale || typeof locale.register !== "function" || typeof locale.bind !== "function") return false;
1111
+ const registerLocale = () => {
1112
+ try {
1113
+ locale.register(NS, dict);
1114
+ } catch (e) {
1115
+ if (/already has locale/.test(String(e?.message ?? e))) return;
1116
+ throw e;
1117
+ }
1118
+ };
1119
+ if (typeof ctx.effect === "function") ctx.effect(registerLocale, "dspack: settings dict");
1120
+ else registerLocale();
1121
+ const t = locale.bind(NS);
1122
+ installSettingsNavIcon(ctx, () => t("nav"), navIconMaskUrl(navIconMaskSvg(LOGO_PATH)));
1123
+ installSectionFocusHook(ctx, () => t("nav"));
1124
+ const sectionGate = createSectionGate(() => {
1125
+ const off = slots.register(
1126
+ {
1127
+ name: "settings.section",
1128
+ id: "dspack",
1129
+ order: 20,
1130
+ label: () => t("nav"),
1131
+ locale: NS,
1132
+ inject: () => ({ t, packforge })
1133
+ },
1134
+ DspackSection
1135
+ );
1136
+ return typeof off === "function" ? off : () => {
1137
+ };
1138
+ });
1139
+ slots.inject("settings.section", () => {
1140
+ sectionGate.available();
1141
+ });
1142
+ return true;
1143
+ }
1144
+ var META_FIELDS = ["name", "version", "displayName", "description", "author", "icon", "profileName"];
1145
+ var OUTPUT_FIELDS = ["dshVersion", "out"];
1146
+ var MODES = ["dspack", "repo"];
1147
+ var CONTENT_LEVELS = ["manifest", "readme", "full"];
1148
+ var HOME_EXPORT = "@dshhome";
1149
+ var exportLocation = (name2) => name2 === HOME_EXPORT ? { type: "dshhome" } : { type: "profile", profile: name2 };
1150
+ var LAUNCHER_IDS = ["dshl", "hdsl", "dsh-packforge-app", "official-desktop", "dsh-cli"];
1151
+ function DspackSection({ t, packforge }) {
1152
+ const rpc = packforge?.rpc;
1153
+ const sendToChat = packforge?.sendToChat;
1154
+ const [tab, setTab] = (0, import_react.useState)("manage");
1155
+ const [profiles, setProfiles] = (0, import_react.useState)([]);
1156
+ const [result, setResult] = (0, import_react.useState)(null);
1157
+ const [dialog, setDialog] = (0, import_react.useState)(null);
1158
+ const [newName, setNewName] = (0, import_react.useState)("");
1159
+ const [source, setSource] = (0, import_react.useState)("");
1160
+ const [fieldError, setFieldError] = (0, import_react.useState)("");
1161
+ const [submitting, setSubmitting] = (0, import_react.useState)(false);
1162
+ const [market, setMarket] = (0, import_react.useState)(null);
1163
+ const [meta, setMeta] = (0, import_react.useState)({});
1164
+ const [resources, setResources] = (0, import_react.useState)({});
1165
+ const [exportProfile, setExportProfile] = (0, import_react.useState)("");
1166
+ const wholeHome = exportProfile === HOME_EXPORT;
1167
+ const selectedExport = (0, import_react.useRef)(exportProfile);
1168
+ selectedExport.current = exportProfile;
1169
+ const metadataFields = wholeHome ? META_FIELDS.filter((k) => k !== "profileName").concat("defaultProfile") : META_FIELDS;
1170
+ const [mode, setMode] = (0, import_react.useState)("dspack");
1171
+ const [contentLevel, setContentLevel] = (0, import_react.useState)("readme");
1172
+ const [exportContent, setExportContent] = (0, import_react.useState)({ preset: false, instruction: false, data: false });
1173
+ const [loadedFor, setLoadedFor] = (0, import_react.useState)(null);
1174
+ const [deps, setDeps] = (0, import_react.useState)(null);
1175
+ const [depsFor, setDepsFor] = (0, import_react.useState)(null);
1176
+ const [vendorSel, setVendorSel] = (0, import_react.useState)({});
1177
+ const [dshVersionsText, setDshVersionsText] = (0, import_react.useState)("");
1178
+ const [launchersState, setLaunchersState] = (0, import_react.useState)({});
1179
+ const [vendorMode, setVendorMode] = (0, import_react.useState)("auto");
1180
+ const [installedDsh, setInstalledDsh] = (0, import_react.useState)([]);
1181
+ const [launchersReg, setLaunchersReg] = (0, import_react.useState)(null);
1182
+ const [confirm, setConfirm] = (0, import_react.useState)(null);
1183
+ const [managerSource, setManagerSource] = (0, import_react.useState)("npm");
1184
+ const [tasksOpen, setTasksOpen] = (0, import_react.useState)(false);
1185
+ const [taskList, setTaskList] = (0, import_react.useState)([]);
1186
+ const [update, setUpdate] = (0, import_react.useState)(null);
1187
+ const [proxy, setProxy] = (0, import_react.useState)("");
1188
+ const [proxyMode, setProxyMode] = (0, import_react.useState)("auto");
1189
+ const [upload, setUpload] = (0, import_react.useState)(null);
1190
+ const [installConfirm, setInstallConfirm] = (0, import_react.useState)(null);
1191
+ const [detail, setDetail] = (0, import_react.useState)(null);
1192
+ const call = async (endpoint, payload) => {
1193
+ if (!rpc) return { ok: false, error: t("result.noRpc") };
1194
+ try {
1195
+ const res = await rpc.call(endpoint, payload ?? {});
1196
+ return res?.ok ? { ok: true, value: res.value } : { ok: false, error: res?.error?.message ?? String(res?.error ?? "\u5931\u8D25") };
1197
+ } catch (e) {
1198
+ return { ok: false, error: String(e?.message ?? e) };
1199
+ }
1200
+ };
1201
+ const refresh = async () => {
1202
+ const r = await call("profile/list", {});
1203
+ if (r.ok) {
1204
+ const list = r.value.profiles ?? [];
1205
+ setProfiles(list);
1206
+ setExportProfile((prev) => prev || list.find((p) => p.active)?.name || list[0]?.name || HOME_EXPORT);
1207
+ } else setResult(r);
1208
+ };
1209
+ const watch = (id) => {
1210
+ setTasksOpen(true);
1211
+ const timer = setInterval(async () => {
1212
+ const r = await call("task/get", { id });
1213
+ if (!r.ok) {
1214
+ clearInterval(timer);
1215
+ return;
1216
+ }
1217
+ const t2 = r.value;
1218
+ if (!t2 || t2.status !== "done" && t2.status !== "failed") return;
1219
+ clearInterval(timer);
1220
+ if (t2.status === "failed") showErr(t2.error || "\u4EFB\u52A1\u5931\u8D25");
1221
+ void refresh();
1222
+ }, 600);
1223
+ };
1224
+ (0, import_react.useEffect)(() => {
1225
+ void refresh();
1226
+ }, []);
1227
+ (0, import_react.useEffect)(() => {
1228
+ void (async () => {
1229
+ const r = await call("config/get", {});
1230
+ if (!r.ok) return;
1231
+ const v = r.value?.proxy ?? "";
1232
+ if (v === "direct") {
1233
+ setProxyMode("direct");
1234
+ setProxy("");
1235
+ } else if (v) {
1236
+ setProxyMode("manual");
1237
+ setProxy(v);
1238
+ } else {
1239
+ setProxyMode("auto");
1240
+ setProxy("");
1241
+ }
1242
+ })();
1243
+ void (async () => {
1244
+ const r = await call("runtime/get", {});
1245
+ if (r.ok && Array.isArray(r.value?.installedDshVersions)) setInstalledDsh(r.value.installedDshVersions);
1246
+ })();
1247
+ void (async () => {
1248
+ const r = await call("launchers/registry", {});
1249
+ if (r.ok && Array.isArray(r.value?.launchers) && r.value.launchers.length) {
1250
+ setLaunchersReg(r.value.launchers);
1251
+ }
1252
+ })();
1253
+ }, []);
1254
+ const active = profiles.find((p) => p.active) ?? null;
1255
+ const showOk = (text) => setResult({ ok: true, text });
1256
+ const showErr = (error) => setResult({ ok: false, error });
1257
+ const openUrl = (url) => {
1258
+ void call("plugin/open-url", { url });
1259
+ };
1260
+ const doCheckUpdate = async () => {
1261
+ setUpdate({ checking: true });
1262
+ const r = await call("plugin/check-update", {});
1263
+ if (!r.ok) setUpdate({ error: r.error });
1264
+ else setUpdate(r.value);
1265
+ };
1266
+ const doSaveProxy = async () => {
1267
+ const value = proxyMode === "direct" ? "direct" : proxyMode === "manual" ? proxy.trim() : "";
1268
+ const r = await call("config/set", { proxy: value });
1269
+ if (!r.ok) return showErr(r.error);
1270
+ showOk(t("result.proxySaved"));
1271
+ };
1272
+ const askSwitch = async (name2) => {
1273
+ const r = await call("profile/switch-check", { name: name2 });
1274
+ if (!r.ok) return showErr(r.error);
1275
+ setManagerSource("npm");
1276
+ setConfirm({
1277
+ from: r.value.from,
1278
+ to: r.value.to,
1279
+ hasManager: r.value.hasManager,
1280
+ firstTime: r.value.firstTime
1281
+ });
1282
+ };
1283
+ const confirmSwitch = async () => {
1284
+ if (!confirm) return;
1285
+ const name2 = confirm.to;
1286
+ setConfirm(null);
1287
+ setResult({ pending: true });
1288
+ const r = await call("profile/switch", { name: name2, managerSource });
1289
+ if (!r.ok) return showErr(r.error);
1290
+ showOk(r.value?.restarting ? `\u5207\u6362\u4E2D\uFF1A\u684C\u9762\u5C06\u81EA\u52A8\u91CD\u542F\u5230\u300C${name2}\u300D` : `\u5DF2\u5207\u6362\u5230\u300C${name2}\u300D\uFF0C\u91CD\u542F DSH \u540E\u751F\u6548`);
1291
+ void refresh();
1292
+ };
1293
+ const doDelete = async (name2) => {
1294
+ setResult({ pending: true });
1295
+ const r = await call("profile/delete", { name: name2 });
1296
+ if (!r.ok) return showErr(r.error);
1297
+ showOk(`\u5DF2\u5220\u9664\u300C${name2}\u300D`);
1298
+ void refresh();
1299
+ };
1300
+ const doExportProfile = async (name2) => {
1301
+ setResult({ pending: true });
1302
+ const r = await call("pack/export", name2 ? { profile: name2 } : {});
1303
+ if (!r.ok) return showErr(r.error);
1304
+ showOk(t("result.taskStarted"));
1305
+ watch(r.value.taskId);
1306
+ };
1307
+ const doOpenTasks = () => {
1308
+ setTasksOpen((v) => !v);
1309
+ };
1310
+ const doOpenDir = async (name2) => {
1311
+ const r = await call("profile/open-dir", { name: name2 });
1312
+ if (r.ok) showOk(`\u5DF2\u6253\u5F00 ${r.value.dir}`);
1313
+ else showErr(r.error);
1314
+ };
1315
+ const openDialog = (type) => {
1316
+ setFieldError("");
1317
+ setSubmitting(false);
1318
+ setDialog(type);
1319
+ };
1320
+ const closeDialog = () => {
1321
+ setDialog(null);
1322
+ setFieldError("");
1323
+ setSubmitting(false);
1324
+ };
1325
+ const doCreate = async () => {
1326
+ const name2 = newName.trim();
1327
+ if (!name2) return setFieldError(t("err.name"));
1328
+ if (!PROFILE_NAME_RE.test(name2)) return setFieldError(t("err.nameInvalid"));
1329
+ if (RESERVED_PROFILE_NAMES.includes(name2)) return setFieldError(t("err.nameReserved").replace("{name}", name2));
1330
+ setSubmitting(true);
1331
+ const r = await call("profile/create", { name: name2 });
1332
+ setSubmitting(false);
1333
+ if (!r.ok) return setFieldError(r.error);
1334
+ setNewName("");
1335
+ closeDialog();
1336
+ showOk(t("result.taskStarted"));
1337
+ watch(r.value.taskId);
1338
+ };
1339
+ const doImport = async () => {
1340
+ const src = source.trim();
1341
+ if (!src) return setFieldError(t("err.source"));
1342
+ setSubmitting(true);
1343
+ const v = await call("pack/view", { source: src });
1344
+ setSubmitting(false);
1345
+ if (!v.ok) return setFieldError(v.error);
1346
+ const warnings = v.value?.launchersWarnings ?? [];
1347
+ if (warnings.some((w) => w.level === "warn")) {
1348
+ setInstallConfirm({ source: src, extra: {}, warnings, fromDialog: true });
1349
+ return;
1350
+ }
1351
+ const infos = warnings.filter((w) => w.level === "info");
1352
+ if (infos.length) showOk(infos.map((w) => w.message).join("\n"));
1353
+ setSource("");
1354
+ closeDialog();
1355
+ await doInstallTask(src, {});
1356
+ };
1357
+ const loadMarket = async () => {
1358
+ setMarket(void 0);
1359
+ const r = await call("pack/market", {});
1360
+ if (r.ok) setMarket({ packs: r.value.packs ?? [], error: r.value.error ?? null });
1361
+ else setMarket({ packs: [], error: r.error });
1362
+ };
1363
+ const doInstallTask = async (src, extra) => {
1364
+ setResult({ pending: true });
1365
+ let reviewed;
1366
+ try {
1367
+ const preview = async (options) => {
1368
+ const result2 = await call("pack/preview-install", options);
1369
+ if (!result2.ok) throw new Error(result2.error);
1370
+ return result2.value;
1371
+ };
1372
+ reviewed = await reviewInstall(preview, { source: src, ...extra });
1373
+ if (!reviewed) {
1374
+ setResult(null);
1375
+ return;
1376
+ }
1377
+ } catch (error) {
1378
+ return showErr(error.message);
1379
+ }
1380
+ const r = await call("pack/install", reviewed);
1381
+ if (!r.ok) return showErr(r.error);
1382
+ showOk(t("result.taskStarted"));
1383
+ watch(r.value.taskId);
1384
+ };
1385
+ const doInstallFromMarket = async (pack) => {
1386
+ const src = pack?.downloadUrl || pack?.urls?.[0];
1387
+ if (!src) return showErr("\u8BE5\u5305\u6CA1\u6709\u53EF\u4E0B\u8F7D\u5730\u5740");
1388
+ setResult({ pending: true });
1389
+ const v = await call("pack/view", { source: src });
1390
+ if (!v.ok) return showErr(v.error);
1391
+ const warnings = v.value?.launchersWarnings ?? [];
1392
+ const extra = {
1393
+ expectedSha256: pack?.sha256 || void 0,
1394
+ expectedSize: pack?.size || void 0
1395
+ };
1396
+ if (warnings.some((w) => w.level === "warn")) {
1397
+ setInstallConfirm({ source: src, extra, warnings, fromDialog: false });
1398
+ return;
1399
+ }
1400
+ const infos = warnings.filter((w) => w.level === "info");
1401
+ if (infos.length) showOk(infos.map((w) => w.message).join("\n"));
1402
+ await doInstallTask(src, extra);
1403
+ };
1404
+ const confirmInstall = async () => {
1405
+ const c = installConfirm;
1406
+ if (!c) return;
1407
+ setInstallConfirm(null);
1408
+ if (c.fromDialog) {
1409
+ setSource("");
1410
+ closeDialog();
1411
+ }
1412
+ await doInstallTask(c.source, c.extra ?? {});
1413
+ };
1414
+ const doMarketDetail = async (pack) => {
1415
+ setDetail({ pending: true, pack });
1416
+ const r = await call("pack/market-detail", { pack });
1417
+ if (!r.ok) {
1418
+ setDetail({ error: r.error, pack });
1419
+ return;
1420
+ }
1421
+ setDetail({
1422
+ pack,
1423
+ manifest: r.value.manifest,
1424
+ icons: r.value.icons,
1425
+ readme: r.value.readme ?? "",
1426
+ r2: r.value.r2 ?? {},
1427
+ badges: r.value.badges ?? []
1428
+ });
1429
+ };
1430
+ const badgeText = (b) => {
1431
+ if (b.kind === "launcher-require") return t("market.r2.launcherRequire").replace("{id}", b.id).replace("{ver}", b.minVersion);
1432
+ if (b.kind === "launcher-conflict") return t("market.r2.launcherConflict").replace("{id}", b.id).replace("{reason}", b.reason || t("market.r2.noReason"));
1433
+ if (b.kind === "vendored") return t("market.r2.vendored").replace("{count}", String(b.count));
1434
+ if (b.kind === "dsh-versions") return t("market.r2.dshVersions").replace("{versions}", b.versions.join(", "));
1435
+ return "";
1436
+ };
1437
+ const editResources = async () => {
1438
+ const options = await call("pack/export-choices", { ...exportLocation(exportProfile), plugins: resources.plugins, profilePlugins: resources.profilePlugins });
1439
+ if (!options.ok) return showErr(options.error);
1440
+ const result2 = await chooseExportResources(options.value.candidates, options.value.units, resources, wholeHome);
1441
+ if (result2 && selectedExport.current === exportProfile) setResources(result2);
1442
+ };
1443
+ const doExportFromForm = async () => {
1444
+ setResult({ pending: true });
1445
+ const overrides = exportLocation(exportProfile);
1446
+ for (const k of [...metadataFields, ...OUTPUT_FIELDS]) {
1447
+ const v = (meta[k] ?? "").trim();
1448
+ if (v) overrides[k] = v;
1449
+ }
1450
+ overrides.mode = mode;
1451
+ overrides.content = contentLevel;
1452
+ overrides.exportContent = {
1453
+ ...wholeHome ? { data: !!exportContent.data } : {},
1454
+ preset: !!exportContent.preset,
1455
+ instruction: !!exportContent.instruction
1456
+ };
1457
+ const versions = parseDshVersionsInput(dshVersionsText);
1458
+ if (versions.length) {
1459
+ overrides.dshVersions = versions;
1460
+ if (!overrides.dshVersion) overrides.dshVersion = versions[0];
1461
+ }
1462
+ const launchers = buildLaunchersField();
1463
+ if (Object.keys(launchers).length) overrides.launchers = launchers;
1464
+ if (mode === "dspack") overrides.vendor = vendorMode;
1465
+ if (mode === "dspack" && Object.keys(vendorSel).length) {
1466
+ overrides.vendorCoords = { ...vendorSel };
1467
+ }
1468
+ const r = await call("pack/export", { ...overrides, ...resources });
1469
+ if (!r.ok) return showErr(r.error);
1470
+ showOk(t("result.taskStarted"));
1471
+ watch(r.value.taskId);
1472
+ };
1473
+ const doAiUpload = async () => {
1474
+ if (!sendToChat) {
1475
+ setUpload({ ok: false, error: t("upload.noService") });
1476
+ return;
1477
+ }
1478
+ setUpload({ pending: true });
1479
+ const parts = ["\u8BF7\u5E2E\u6211\u628A\u6574\u5408\u5305\u53D1\u5E03\u5230 GitHub"];
1480
+ if (wholeHome) parts.push("\u5F62\u6001\u4E3A\u5168\u5C40\u76EE\u5F55\uFF08dshhome\uFF09");
1481
+ else if (exportProfile) parts.push(`profile=${exportProfile}`);
1482
+ if ((meta.name ?? "").trim()) parts.push(`name=${String(meta.name).trim()}`);
1483
+ if ((meta.version ?? "").trim()) parts.push(`version=${String(meta.version).trim()}`);
1484
+ const prompt = parts.join("\uFF0C") + "\u3002";
1485
+ try {
1486
+ await sendToChat(prompt);
1487
+ setUpload({ ok: true, text: t("upload.sent") });
1488
+ } catch (e) {
1489
+ setUpload({ ok: false, error: `${t("upload.failed")}\uFF1A${String(e?.message ?? e)}` });
1490
+ }
1491
+ };
1492
+ const parseDshVersionsInput = (text) => [...new Set(String(text ?? "").split(/[,,;;\s]+/).map((s) => s.trim()).filter(Boolean))];
1493
+ const buildLaunchersField = () => {
1494
+ const out = {};
1495
+ for (const [id, s] of Object.entries(launchersState)) {
1496
+ if (!s || s.mode !== "support" && s.mode !== "conflict") continue;
1497
+ if (s.mode === "support") out[id] = (s.minVersion ?? "").trim() || true;
1498
+ else out[id] = (s.reason ?? "").trim() ? { supported: false, reason: (s.reason ?? "").trim() } : false;
1499
+ }
1500
+ return out;
1501
+ };
1502
+ const launchersValueToState = (value) => {
1503
+ const out = {};
1504
+ for (const [id, v] of Object.entries(value ?? {})) {
1505
+ if (v === true) out[id] = { mode: "support", minVersion: "", reason: "" };
1506
+ else if (typeof v === "string") out[id] = { mode: "support", minVersion: v, reason: "" };
1507
+ else if (v === false) out[id] = { mode: "conflict", minVersion: "", reason: "" };
1508
+ else if (v && typeof v === "object") out[id] = { mode: v.supported === false ? "conflict" : "support", minVersion: typeof v.minVersion === "string" ? v.minVersion : "", reason: typeof v.reason === "string" ? v.reason : "" };
1509
+ }
1510
+ return out;
1511
+ };
1512
+ const applyConfig = (cfg) => {
1513
+ const next = {};
1514
+ for (const k of [...metadataFields, ...OUTPUT_FIELDS]) {
1515
+ const v = cfg?.[k];
1516
+ if (typeof v === "string" && v.trim()) next[k] = v;
1517
+ }
1518
+ setMeta(next);
1519
+ setResources(wholeHome ? { selection: cfg?.selection, profilePlugins: cfg?.profilePlugins } : { selection: cfg?.selection, plugins: cfg?.plugins });
1520
+ setMode(!wholeHome && MODES.includes(cfg?.mode) ? cfg.mode : "dspack");
1521
+ setContentLevel(CONTENT_LEVELS.includes(cfg?.content) ? cfg.content : "readme");
1522
+ const ec = cfg?.exportContent;
1523
+ setExportContent({
1524
+ data: ec?.data === true,
1525
+ preset: ec?.preset === true,
1526
+ instruction: ec?.instruction === true
1527
+ });
1528
+ setDshVersionsText(Array.isArray(cfg?.dshVersions) ? cfg.dshVersions.join(", ") : "");
1529
+ setLaunchersState(launchersValueToState(cfg?.launchers));
1530
+ setVendorMode(["auto", "off", "full"].includes(cfg?.vendor) ? cfg.vendor : "auto");
1531
+ };
1532
+ const loadConfig = async (name2, silent = false) => {
1533
+ const r = await call("pack/config-load", exportLocation(name2));
1534
+ if (selectedExport.current !== name2) return;
1535
+ if (!r.ok) return showErr(r.error);
1536
+ setLoadedFor(name2);
1537
+ if (!r.value.config) {
1538
+ applyConfig(null);
1539
+ if (!silent) showOk(t("result.noCfg"));
1540
+ return;
1541
+ }
1542
+ applyConfig(r.value.config);
1543
+ if (!silent) showOk(t("result.loaded"));
1544
+ };
1545
+ const doLoadConfig = () => {
1546
+ if (exportProfile) void loadConfig(exportProfile, false);
1547
+ };
1548
+ const doSaveConfig = async () => {
1549
+ if (!exportProfile) return;
1550
+ setResult({ pending: true });
1551
+ const cfg = {};
1552
+ for (const k of [...metadataFields, ...OUTPUT_FIELDS]) cfg[k] = (meta[k] ?? "").trim();
1553
+ Object.assign(cfg, resources);
1554
+ cfg.mode = mode;
1555
+ cfg.content = contentLevel;
1556
+ cfg.exportContent = {
1557
+ ...wholeHome ? { data: !!exportContent.data } : {},
1558
+ preset: !!exportContent.preset,
1559
+ instruction: !!exportContent.instruction
1560
+ };
1561
+ const versions = parseDshVersionsInput(dshVersionsText);
1562
+ if (versions.length) cfg.dshVersions = versions;
1563
+ const launchers = buildLaunchersField();
1564
+ if (Object.keys(launchers).length) cfg.launchers = launchers;
1565
+ if (vendorMode !== "auto") cfg.vendor = vendorMode;
1566
+ const r = await call("pack/config-save", { ...exportLocation(exportProfile), ...cfg });
1567
+ if (!r.ok) return showErr(r.error);
1568
+ showOk(t("result.saved") + " \u2192 " + r.value.path);
1569
+ };
1570
+ (0, import_react.useEffect)(() => {
1571
+ if (tab !== "export" || !exportProfile || loadedFor === exportProfile) return;
1572
+ void loadConfig(exportProfile, true);
1573
+ }, [tab, exportProfile, loadedFor]);
1574
+ const loadDeps = async (name2, silent = false) => {
1575
+ if (!name2) return;
1576
+ const r = await call("pack/dependencies", exportLocation(name2));
1577
+ if (selectedExport.current !== name2) return;
1578
+ if (!r.ok) {
1579
+ if (!silent) showErr(r.error);
1580
+ return;
1581
+ }
1582
+ const list = r.value.deps ?? [];
1583
+ setDeps(list);
1584
+ setDepsFor(name2);
1585
+ const sel = {};
1586
+ for (const d of list) if (d.vendored) sel[d.coord] = "explicit";
1587
+ setVendorSel(sel);
1588
+ };
1589
+ (0, import_react.useEffect)(() => {
1590
+ if (tab !== "export" || mode !== "dspack" || !exportProfile || depsFor === exportProfile) return;
1591
+ void loadDeps(exportProfile, true);
1592
+ }, [tab, mode, exportProfile, depsFor]);
1593
+ (0, import_react.useEffect)(() => {
1594
+ if (!tasksOpen) return;
1595
+ let stopped = false;
1596
+ const load = async () => {
1597
+ const r = await call("task/list", {});
1598
+ if (stopped || !r.ok) return;
1599
+ setTaskList(r.value.tasks ?? []);
1600
+ };
1601
+ void load();
1602
+ const timer = setInterval(load, 600);
1603
+ return () => {
1604
+ stopped = true;
1605
+ clearInterval(timer);
1606
+ };
1607
+ }, [tasksOpen]);
1608
+ const style = {
1609
+ section: { display: "flex", flexDirection: "column", gap: 12, maxWidth: 720, padding: "8px 0" },
1610
+ tabs: { display: "flex", gap: 4, borderBottom: "1px solid var(--dsw-alias-border-l2)", paddingBottom: 8 },
1611
+ tab: {
1612
+ height: 32,
1613
+ padding: "0 16px",
1614
+ borderRadius: 16,
1615
+ border: "none",
1616
+ cursor: "pointer",
1617
+ fontSize: 13,
1618
+ lineHeight: "20px",
1619
+ background: "transparent",
1620
+ color: "var(--dsw-alias-label-secondary)",
1621
+ font: "inherit"
1622
+ },
1623
+ tabActive: { background: "var(--dsw-alias-bg-layer-1)", color: "var(--dsw-alias-label-primary)", fontWeight: 600 },
1624
+ group: { display: "flex", flexDirection: "column", gap: 6 },
1625
+ groupTitle: { margin: "0", fontSize: 13, fontWeight: 600, lineHeight: "20px", color: "var(--dsw-alias-label-primary)" },
1626
+ field: { display: "flex", flexDirection: "column", gap: 4 },
1627
+ fieldLabel: { fontSize: 12, lineHeight: "18px", color: "var(--dsw-alias-label-secondary)" },
1628
+ input: {
1629
+ height: 32,
1630
+ padding: "4px 10px",
1631
+ borderRadius: 8,
1632
+ border: "1px solid var(--dsw-alias-border-l2)",
1633
+ fontSize: 13,
1634
+ lineHeight: "20px",
1635
+ background: "var(--dsw-alias-bg-layer-1)",
1636
+ color: "var(--dsw-alias-label-primary)",
1637
+ font: "inherit",
1638
+ outline: "none",
1639
+ boxSizing: "border-box"
1640
+ },
1641
+ row: { display: "flex", gap: 8, alignItems: "center", flexWrap: "wrap" },
1642
+ btn: {
1643
+ height: 30,
1644
+ padding: "0 12px",
1645
+ borderRadius: 15,
1646
+ border: "1px solid var(--dsw-alias-border-l2)",
1647
+ cursor: "pointer",
1648
+ fontSize: 13,
1649
+ lineHeight: "18px",
1650
+ background: "var(--dsw-alias-bg-layer-1)",
1651
+ color: "var(--dsw-alias-label-primary)",
1652
+ font: "inherit",
1653
+ width: "fit-content",
1654
+ flex: "0 0 auto"
1655
+ },
1656
+ btnSmall: {
1657
+ height: 26,
1658
+ padding: "0 10px",
1659
+ borderRadius: 13,
1660
+ border: "1px solid var(--dsw-alias-border-l2)",
1661
+ cursor: "pointer",
1662
+ fontSize: 12,
1663
+ lineHeight: "18px",
1664
+ background: "var(--dsw-alias-bg-layer-1)",
1665
+ color: "var(--dsw-alias-label-primary)",
1666
+ font: "inherit",
1667
+ width: "fit-content",
1668
+ flex: "0 0 auto"
1669
+ },
1670
+ list: { margin: 0, padding: 0, listStyle: "none", display: "flex", flexDirection: "column", gap: 8 },
1671
+ listItem: {
1672
+ display: "flex",
1673
+ alignItems: "center",
1674
+ justifyContent: "space-between",
1675
+ gap: 8,
1676
+ padding: "10px 12px",
1677
+ borderRadius: 10,
1678
+ border: "1px solid var(--dsw-alias-border-l2)",
1679
+ background: "var(--dsw-alias-bg-layer-1)"
1680
+ },
1681
+ listName: { fontSize: 13, lineHeight: "20px", color: "var(--dsw-alias-label-primary)" },
1682
+ line: { margin: 0, fontSize: 12, lineHeight: "18px", color: "var(--dsw-alias-label-secondary)" },
1683
+ marketHead: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 },
1684
+ refreshBtn: {
1685
+ width: 26,
1686
+ height: 26,
1687
+ padding: 0,
1688
+ borderRadius: "50%",
1689
+ border: "1px solid var(--dsw-alias-border-l2)",
1690
+ cursor: "pointer",
1691
+ background: "var(--dsw-alias-bg-layer-1)",
1692
+ color: "var(--dsw-alias-label-secondary)",
1693
+ fontSize: 15,
1694
+ lineHeight: "18px",
1695
+ font: "inherit",
1696
+ display: "flex",
1697
+ alignItems: "center",
1698
+ justifyContent: "center",
1699
+ flex: "0 0 auto"
1700
+ },
1701
+ sectionBox: { display: "flex", flexDirection: "column", gap: 8, paddingBottom: 14, marginBottom: 14, borderBottom: "1px solid var(--dsw-alias-border-l2)" },
1702
+ sectionBoxLast: { display: "flex", flexDirection: "column", gap: 8 },
1703
+ hint: { margin: "4px 0 0", fontSize: 12, lineHeight: "18px", color: "var(--dsw-alias-label-tertiary)" },
1704
+ ok: { margin: 0, fontSize: 12, lineHeight: "18px", color: "var(--dsw-alias-success)", whiteSpace: "pre-wrap", wordBreak: "break-all" },
1705
+ err: { margin: 0, fontSize: 12, lineHeight: "18px", color: "var(--dsw-alias-danger)", whiteSpace: "pre-wrap", wordBreak: "break-all" },
1706
+ // —— 切换确认弹窗 ——
1707
+ overlay: { position: "fixed", inset: 0, background: "rgba(0,0,0,0.45)", display: "flex", alignItems: "center", justifyContent: "center", zIndex: 1e3 },
1708
+ modal: {
1709
+ background: "var(--dsw-alias-bg-layer-1)",
1710
+ borderRadius: 12,
1711
+ padding: "20px 22px",
1712
+ minWidth: 360,
1713
+ maxWidth: 440,
1714
+ boxShadow: "0 12px 40px rgba(0,0,0,0.45)",
1715
+ display: "flex",
1716
+ flexDirection: "column",
1717
+ gap: 14
1718
+ },
1719
+ modalTitle: { margin: 0, fontSize: 15, fontWeight: 600, color: "var(--dsw-alias-label-primary)", textAlign: "center" },
1720
+ ticket: {
1721
+ position: "relative",
1722
+ display: "flex",
1723
+ alignItems: "stretch",
1724
+ border: "1px solid var(--dsw-alias-border-l2)",
1725
+ borderRadius: 10,
1726
+ background: "var(--dsw-alias-bg-layer-1)"
1727
+ },
1728
+ ticketSide: { flex: 1, display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", gap: 4, padding: "16px 10px", minWidth: 0 },
1729
+ ticketName: { fontSize: 18, fontWeight: 700, color: "var(--dsw-alias-label-primary)", wordBreak: "break-all", textAlign: "center" },
1730
+ ticketRole: { fontSize: 12, color: "var(--dsw-alias-label-tertiary)" },
1731
+ ticketLine: { width: 0, borderLeft: "2px dashed var(--dsw-alias-border-l2)", alignSelf: "stretch" },
1732
+ ticketBadge: {
1733
+ position: "absolute",
1734
+ top: "50%",
1735
+ left: "50%",
1736
+ transform: "translate(-50%,-50%)",
1737
+ width: 28,
1738
+ height: 28,
1739
+ borderRadius: "50%",
1740
+ background: "var(--dsw-alias-bg-layer-1)",
1741
+ border: "2px dashed var(--dsw-alias-border-l2)",
1742
+ color: "var(--dsw-alias-label-secondary)",
1743
+ fontSize: 15,
1744
+ fontWeight: 700,
1745
+ display: "flex",
1746
+ alignItems: "center",
1747
+ justifyContent: "center"
1748
+ },
1749
+ warn: {
1750
+ display: "flex",
1751
+ gap: 8,
1752
+ alignItems: "flex-start",
1753
+ padding: "8px 10px",
1754
+ borderRadius: 8,
1755
+ border: "1px solid rgba(232,162,58,0.45)",
1756
+ background: "rgba(232,162,58,0.10)",
1757
+ fontSize: 12,
1758
+ lineHeight: "18px",
1759
+ color: "var(--dsw-alias-label-primary)",
1760
+ wordBreak: "break-word"
1761
+ },
1762
+ warnIcon: { flex: "0 0 auto", lineHeight: "18px", color: "#e8a23a", fontWeight: 700 },
1763
+ confirmBtns: { display: "flex", justifyContent: "flex-end", gap: 8 },
1764
+ logoTile: {
1765
+ width: 88,
1766
+ height: 88,
1767
+ borderRadius: 20,
1768
+ background: "#fff",
1769
+ color: "#4b7bec",
1770
+ display: "flex",
1771
+ alignItems: "center",
1772
+ justifyContent: "center",
1773
+ boxShadow: "0 4px 16px rgba(0,0,0,0.28)",
1774
+ flex: "0 0 auto"
1775
+ },
1776
+ btnPrimary: {
1777
+ height: 30,
1778
+ padding: "0 14px",
1779
+ borderRadius: 15,
1780
+ border: "1px solid #4b7bec",
1781
+ cursor: "pointer",
1782
+ fontSize: 13,
1783
+ lineHeight: "18px",
1784
+ background: "#4b7bec",
1785
+ color: "#fff",
1786
+ fontWeight: 600,
1787
+ font: "inherit",
1788
+ width: "fit-content",
1789
+ flex: "0 0 auto"
1790
+ },
1791
+ // —— 任务中心内嵌面板 ——
1792
+ taskPanel: { display: "flex", flexDirection: "column", gap: 8, padding: "10px 12px", marginBottom: 12, borderRadius: 10, border: "1px solid var(--dsw-alias-border-l2)", background: "var(--dsw-alias-bg-layer-1)" },
1793
+ taskCard: { display: "flex", flexDirection: "column", gap: 8, padding: "10px 12px", borderRadius: 10, border: "1px solid var(--dsw-alias-border-l2)", background: "var(--dsw-alias-bg-layer-1)" },
1794
+ taskTitle: { fontSize: 13, fontWeight: 600, lineHeight: "20px", color: "var(--dsw-alias-label-primary)", wordBreak: "break-all" },
1795
+ taskTimeline: { display: "flex", flexWrap: "wrap", gap: "6px 16px" },
1796
+ taskStep: { display: "flex", alignItems: "center", gap: 5, fontSize: 12, lineHeight: "18px", color: "var(--dsw-alias-label-secondary)" },
1797
+ taskDot: { width: 14, height: 14, borderRadius: "50%", flex: "0 0 auto", display: "flex", alignItems: "center", justifyContent: "center", fontSize: 10, lineHeight: 1, border: "1.5px solid var(--dsw-alias-border-l2)", color: "transparent", background: "transparent" },
1798
+ taskLog: { margin: 0, padding: "8px 10px", borderRadius: 8, border: "1px solid var(--dsw-alias-border-l2)", background: "var(--dsw-alias-bg-layer-1)", color: "var(--dsw-alias-label-secondary)", font: '12px/1.5 ui-monospace, Consolas, "Courier New", monospace', maxHeight: 160, overflow: "auto", whiteSpace: "pre-wrap", wordBreak: "break-all" }
1799
+ };
1800
+ const fieldInput = (key) => (0, import_react.createElement)(
1801
+ "label",
1802
+ { key, style: style.field },
1803
+ (0, import_react.createElement)("span", { style: style.fieldLabel }, t("field." + key)),
1804
+ (0, import_react.createElement)("input", {
1805
+ style: style.input,
1806
+ value: meta[key] ?? "",
1807
+ onInput: (e) => setMeta((m) => ({ ...m, [key]: e.target.value }))
1808
+ })
1809
+ );
1810
+ const renderManage = () => {
1811
+ const rows = profiles.map(
1812
+ (p) => (0, import_react.createElement)(
1813
+ "li",
1814
+ { key: p.name, style: style.listItem },
1815
+ (0, import_react.createElement)("span", { style: style.listName }, p.name + (p.active ? `\uFF08${t("profile.active")}\uFF09` : "")),
1816
+ (0, import_react.createElement)(
1817
+ "div",
1818
+ { style: style.row },
1819
+ p.active ? null : (0, import_react.createElement)("button", { type: "button", style: style.btnSmall, onClick: () => askSwitch(p.name) }, t("action.switch")),
1820
+ (0, import_react.createElement)("button", { type: "button", style: style.btnSmall, onClick: () => doExportProfile(p.name) }, t("action.export")),
1821
+ (0, import_react.createElement)("button", { type: "button", style: style.btnSmall, onClick: () => doDelete(p.name) }, t("action.delete"))
1822
+ )
1823
+ )
1824
+ );
1825
+ return (0, import_react.createElement)(
1826
+ "div",
1827
+ { style: { display: "flex", flexDirection: "column" } },
1828
+ // 区域 1:正在运行的整合包
1829
+ (0, import_react.createElement)(
1830
+ "section",
1831
+ { key: "running", style: style.sectionBox },
1832
+ (0, import_react.createElement)("h3", { style: style.groupTitle }, t("running.title")),
1833
+ (0, import_react.createElement)("p", { style: style.line }, t("running.profile") + (active ? active.name : t("market.none"))),
1834
+ (0, import_react.createElement)(
1835
+ "div",
1836
+ { style: style.row },
1837
+ (0, import_react.createElement)("button", { type: "button", style: style.btn, disabled: !rpc || !active, onClick: () => doExportProfile(active?.name) }, t("action.quickExport")),
1838
+ (0, import_react.createElement)("button", { type: "button", style: style.btn, disabled: !rpc || !active, onClick: () => doOpenDir(active?.name) }, t("action.openDir")),
1839
+ (0, import_react.createElement)("button", { type: "button", style: style.btn, disabled: !rpc, onClick: doOpenTasks }, t("action.tasks"))
1840
+ )
1841
+ ),
1842
+ // 区域 2:创建整合包
1843
+ (0, import_react.createElement)(
1844
+ "section",
1845
+ { key: "create", style: style.sectionBox },
1846
+ (0, import_react.createElement)("h3", { style: style.groupTitle }, t("create.title")),
1847
+ (0, import_react.createElement)(
1848
+ "div",
1849
+ { style: style.row },
1850
+ (0, import_react.createElement)("button", { type: "button", style: style.btn, disabled: !rpc, onClick: () => openDialog("create") }, t("action.newEmpty")),
1851
+ (0, import_react.createElement)("button", { type: "button", style: style.btn, disabled: !rpc, onClick: () => openDialog("import") }, t("action.import")),
1852
+ (0, import_react.createElement)("button", { type: "button", style: style.btn, disabled: !rpc, onClick: () => {
1853
+ setTab("market");
1854
+ void loadMarket();
1855
+ } }, t("action.market"))
1856
+ )
1857
+ ),
1858
+ // 区域 3:已安装的整合包
1859
+ (0, import_react.createElement)(
1860
+ "section",
1861
+ { key: "installed", style: style.sectionBoxLast },
1862
+ (0, import_react.createElement)("h3", { style: style.groupTitle }, t("installed.title")),
1863
+ profiles.length === 0 ? (0, import_react.createElement)("p", { style: style.line }, t("market.none")) : (0, import_react.createElement)("ul", { style: style.list }, rows)
1864
+ )
1865
+ );
1866
+ };
1867
+ const renderExport = () => (0, import_react.createElement)(
1868
+ "div",
1869
+ { style: { display: "flex", flexDirection: "column", gap: 12 } },
1870
+ (0, import_react.createElement)(
1871
+ "div",
1872
+ { style: style.group },
1873
+ (0, import_react.createElement)("div", { style: style.groupTitle }, t("group.meta")),
1874
+ ...metadataFields.map(fieldInput)
1875
+ ),
1876
+ (0, import_react.createElement)(
1877
+ "div",
1878
+ { style: style.group },
1879
+ (0, import_react.createElement)("div", { style: style.groupTitle }, t("group.output")),
1880
+ ...OUTPUT_FIELDS.map(fieldInput),
1881
+ (0, import_react.createElement)(
1882
+ "label",
1883
+ { style: style.field },
1884
+ (0, import_react.createElement)("span", { style: style.fieldLabel }, t("field.profile")),
1885
+ (0, import_react.createElement)(
1886
+ "select",
1887
+ { style: style.input, value: exportProfile, onChange: (e) => setExportProfile(e.target.value) },
1888
+ (0, import_react.createElement)("option", { value: HOME_EXPORT }, t("scope.home")),
1889
+ profiles.map((p) => (0, import_react.createElement)("option", { key: p.name, value: p.name }, p.name + (p.active ? `\uFF08${t("profile.active")}\uFF09` : "")))
1890
+ )
1891
+ ),
1892
+ (0, import_react.createElement)(
1893
+ "label",
1894
+ { style: style.field },
1895
+ (0, import_react.createElement)("span", { style: style.fieldLabel }, t("field.mode")),
1896
+ (0, import_react.createElement)(
1897
+ "select",
1898
+ { style: style.input, value: mode, onChange: (e) => setMode(e.target.value) },
1899
+ (wholeHome ? ["dspack"] : MODES).map((m) => (0, import_react.createElement)("option", { key: m, value: m }, t("mode." + m)))
1900
+ )
1901
+ ),
1902
+ mode === "repo" ? (0, import_react.createElement)(
1903
+ "label",
1904
+ { style: style.field },
1905
+ (0, import_react.createElement)("span", { style: style.fieldLabel }, t("field.content")),
1906
+ (0, import_react.createElement)(
1907
+ "select",
1908
+ { style: style.input, value: contentLevel, onChange: (e) => setContentLevel(e.target.value) },
1909
+ CONTENT_LEVELS.map((c) => (0, import_react.createElement)("option", { key: c, value: c }, t("content." + c)))
1910
+ )
1911
+ ) : null
1912
+ ),
1913
+ (0, import_react.createElement)(
1914
+ "div",
1915
+ { style: style.group },
1916
+ (0, import_react.createElement)("div", { style: style.groupTitle }, t("compat.title")),
1917
+ (0, import_react.createElement)(
1918
+ "label",
1919
+ { style: style.field },
1920
+ (0, import_react.createElement)("span", { style: style.fieldLabel }, t("compat.dshVersions")),
1921
+ (0, import_react.createElement)("input", {
1922
+ style: style.input,
1923
+ value: dshVersionsText,
1924
+ placeholder: "0.1.1-rc.2, 0.1.0",
1925
+ list: "dspack-dshversions",
1926
+ onChange: (e) => setDshVersionsText(e.target.value)
1927
+ }),
1928
+ installedDsh.length ? (0, import_react.createElement)(
1929
+ "datalist",
1930
+ { id: "dspack-dshversions" },
1931
+ installedDsh.map((v) => (0, import_react.createElement)("option", { key: v, value: v }))
1932
+ ) : null
1933
+ ),
1934
+ (0, import_react.createElement)("p", { style: style.hint }, t("compat.dshVersionsHint")),
1935
+ (0, import_react.createElement)(
1936
+ "div",
1937
+ { style: style.field },
1938
+ (0, import_react.createElement)("span", { style: style.fieldLabel }, t("compat.launchers")),
1939
+ ...(launchersReg ?? LAUNCHER_IDS.map((id) => ({ id, name: id }))).map(({ id, name: name2 }) => {
1940
+ const st = launchersState[id] ?? { mode: "none", minVersion: "", reason: "" };
1941
+ const setEntry = (patch) => setLaunchersState((s) => ({ ...s, [id]: { ...s[id] ?? { minVersion: "", reason: "" }, ...patch } }));
1942
+ return (0, import_react.createElement)(
1943
+ "div",
1944
+ { key: id, style: { ...style.row, flexWrap: "nowrap" } },
1945
+ (0, import_react.createElement)("span", { style: { ...style.line, flex: "0 0 190px", wordBreak: "break-all" } }, name2 && name2 !== id ? `${name2}\uFF08${id}\uFF09` : id),
1946
+ (0, import_react.createElement)(
1947
+ "select",
1948
+ {
1949
+ style: { ...style.input, flex: "0 0 auto", width: 110 },
1950
+ value: st.mode,
1951
+ onChange: (e) => {
1952
+ const mode2 = e.target.value;
1953
+ if (mode2 === "none") setLaunchersState((s) => {
1954
+ const n = { ...s };
1955
+ delete n[id];
1956
+ return n;
1957
+ });
1958
+ else setEntry({ mode: mode2 });
1959
+ }
1960
+ },
1961
+ (0, import_react.createElement)("option", { value: "none" }, t("launcher.none")),
1962
+ (0, import_react.createElement)("option", { value: "support" }, t("launcher.support")),
1963
+ (0, import_react.createElement)("option", { value: "conflict" }, t("launcher.conflict"))
1964
+ ),
1965
+ st.mode === "support" ? (0, import_react.createElement)("input", {
1966
+ style: { ...style.input, flex: "0 1 170px" },
1967
+ placeholder: t("launcher.minVersion"),
1968
+ value: st.minVersion ?? "",
1969
+ onChange: (e) => setEntry({ minVersion: e.target.value })
1970
+ }) : null,
1971
+ st.mode === "conflict" ? (0, import_react.createElement)("input", {
1972
+ style: { ...style.input, flex: "1 1 auto", minWidth: 120 },
1973
+ placeholder: t("launcher.reason"),
1974
+ value: st.reason ?? "",
1975
+ onChange: (e) => setEntry({ reason: e.target.value })
1976
+ }) : null
1977
+ );
1978
+ })
1979
+ )
1980
+ ),
1981
+ (0, import_react.createElement)(
1982
+ "div",
1983
+ { style: style.group },
1984
+ (0, import_react.createElement)("div", { style: style.groupTitle }, t("group.content")),
1985
+ ...(wholeHome ? ["preset", "instruction", "data"] : ["preset", "instruction"]).map(
1986
+ (k) => (0, import_react.createElement)(
1987
+ "label",
1988
+ { key: k, style: style.row },
1989
+ (0, import_react.createElement)("input", {
1990
+ type: "checkbox",
1991
+ checked: !!exportContent[k],
1992
+ style: { width: 16, height: 16, cursor: "pointer", accentColor: "#4b7bec" },
1993
+ onChange: (e) => setExportContent((ec) => ({ ...ec, [k]: e.target.checked }))
1994
+ }),
1995
+ (0, import_react.createElement)("span", { style: style.line }, t("content." + k))
1996
+ )
1997
+ )
1998
+ ),
1999
+ mode === "dspack" ? (0, import_react.createElement)(
2000
+ "div",
2001
+ { style: style.group },
2002
+ (0, import_react.createElement)(
2003
+ "div",
2004
+ { style: style.marketHead },
2005
+ (0, import_react.createElement)(
2006
+ "div",
2007
+ { style: style.groupTitle },
2008
+ t("vendor.title"),
2009
+ Object.keys(vendorSel).length ? (0, import_react.createElement)("span", { style: { ...style.line, marginLeft: 8 } }, `\uFF08${Object.keys(vendorSel).length} ${t("vendor.selected")}\uFF09`) : null
2010
+ ),
2011
+ (0, import_react.createElement)(
2012
+ "div",
2013
+ { style: style.row },
2014
+ (0, import_react.createElement)(
2015
+ "select",
2016
+ {
2017
+ style: { ...style.input, width: 220 },
2018
+ value: vendorMode,
2019
+ title: t("vendor.mode"),
2020
+ onChange: (e) => setVendorMode(e.target.value)
2021
+ },
2022
+ (0, import_react.createElement)("option", { value: "auto" }, t("vendor.mode.auto")),
2023
+ (0, import_react.createElement)("option", { value: "off" }, t("vendor.mode.off")),
2024
+ (0, import_react.createElement)("option", { value: "full" }, t("vendor.mode.full"))
2025
+ ),
2026
+ (0, import_react.createElement)("button", {
2027
+ type: "button",
2028
+ style: style.btnSmall,
2029
+ disabled: !rpc || !exportProfile,
2030
+ onClick: () => void loadDeps(exportProfile, false)
2031
+ }, t("vendor.reload"))
2032
+ )
2033
+ ),
2034
+ (0, import_react.createElement)("p", { style: style.hint }, t("vendor.hint")),
2035
+ deps == null ? (0, import_react.createElement)("p", { style: style.line }, "\u2026") : deps.length === 0 ? (0, import_react.createElement)("p", { style: style.line }, t("vendor.none")) : (0, import_react.createElement)(
2036
+ "ul",
2037
+ { style: style.list },
2038
+ deps.map((d) => (0, import_react.createElement)(
2039
+ "li",
2040
+ { key: d.coord, style: style.listItem },
2041
+ (0, import_react.createElement)(
2042
+ "label",
2043
+ { style: { display: "flex", alignItems: "center", gap: 10, cursor: "pointer", minWidth: 0 } },
2044
+ (0, import_react.createElement)("input", {
2045
+ type: "checkbox",
2046
+ checked: !!vendorSel[d.coord],
2047
+ disabled: !d.installed && !d.vendored,
2048
+ style: { width: 16, height: 16, cursor: d.installed || d.vendored ? "pointer" : "not-allowed", accentColor: "#4b7bec", flex: "0 0 auto" },
2049
+ onChange: (e) => setVendorSel((s) => {
2050
+ const next = { ...s };
2051
+ if (e.target.checked) next[d.coord] = "explicit";
2052
+ else delete next[d.coord];
2053
+ return next;
2054
+ })
2055
+ }),
2056
+ (0, import_react.createElement)(
2057
+ "div",
2058
+ { style: { display: "flex", flexDirection: "column", gap: 2, minWidth: 0 } },
2059
+ (0, import_react.createElement)("span", { style: style.listName }, `${d.pkgName}${d.version ? ` \xB7 ${d.version}` : ""}`),
2060
+ (0, import_react.createElement)(
2061
+ "span",
2062
+ { style: style.line },
2063
+ t("vendor.kind." + d.kind) + (d.vendored ? ` \xB7 ${t("vendor.already")}` : "") + (!d.installed && !d.vendored ? ` \xB7 ${t("vendor.notInstalled")}` : "")
2064
+ )
2065
+ )
2066
+ )
2067
+ ))
2068
+ )
2069
+ ) : null,
2070
+ (0, import_react.createElement)(
2071
+ "div",
2072
+ { style: style.row },
2073
+ (0, import_react.createElement)("button", { type: "button", style: style.btn, disabled: !rpc || loadedFor !== exportProfile, onClick: doSaveConfig }, t("action.save")),
2074
+ (0, import_react.createElement)("button", { type: "button", style: style.btn, disabled: !rpc, onClick: doLoadConfig }, t("action.load")),
2075
+ (0, import_react.createElement)("button", { type: "button", style: style.btn, disabled: !rpc || loadedFor !== exportProfile, onClick: editResources }, t("action.editResources")),
2076
+ (0, import_react.createElement)("button", { type: "button", style: style.btn, disabled: !rpc || loadedFor !== exportProfile, onClick: doExportFromForm }, t("action.export"))
2077
+ ),
2078
+ (0, import_react.createElement)(
2079
+ "div",
2080
+ { style: style.row },
2081
+ (0, import_react.createElement)("button", { type: "button", style: style.btn, disabled: !sendToChat || upload?.pending, onClick: doAiUpload }, t("action.upload")),
2082
+ upload?.pending ? (0, import_react.createElement)("span", { style: style.line }, t("result.pending")) : upload?.ok ? (0, import_react.createElement)("span", { style: style.ok }, upload.text) : upload?.ok === false ? (0, import_react.createElement)("span", { style: style.err }, upload.error) : (0, import_react.createElement)("span", { style: style.hint }, t("upload.hint"))
2083
+ )
2084
+ );
2085
+ const renderMarket = () => {
2086
+ const packs = market?.packs ?? [];
2087
+ let body;
2088
+ if (market === void 0) body = (0, import_react.createElement)("p", { style: style.line }, t("market.loading"));
2089
+ else if (market.error) body = (0, import_react.createElement)("p", { style: style.err }, `${t("market.error")}\uFF1A${market.error}`);
2090
+ else if (packs.length === 0) body = (0, import_react.createElement)("p", { style: style.line }, t("market.empty"));
2091
+ else body = (0, import_react.createElement)(
2092
+ "ul",
2093
+ { style: style.list },
2094
+ packs.map((p) => (0, import_react.createElement)(
2095
+ "li",
2096
+ { key: (p.id || p.name) + "@" + (p.version ?? ""), style: style.listItem },
2097
+ (0, import_react.createElement)(
2098
+ "div",
2099
+ { style: { display: "flex", flexDirection: "column", gap: 2 } },
2100
+ (0, import_react.createElement)("span", { style: style.listName }, p.displayName || p.name),
2101
+ p.description ? (0, import_react.createElement)("span", { style: style.line }, p.description) : null,
2102
+ (0, import_react.createElement)(
2103
+ "span",
2104
+ { style: style.line },
2105
+ `${p.author ? p.author + " \xB7 " : ""}${p.version || "?"}${p.dshVersion ? " \xB7 DSH " + p.dshVersion : ""}` + (p.launcherRestricted ? " \xB7 \u26A0 " + t("market.launcherRestricted") : "")
2106
+ )
2107
+ ),
2108
+ (0, import_react.createElement)(
2109
+ "div",
2110
+ { style: style.row },
2111
+ (0, import_react.createElement)("button", { type: "button", style: style.btnSmall, disabled: !rpc || detail?.pending, onClick: () => void doMarketDetail(p) }, t("market.detail")),
2112
+ (0, import_react.createElement)("button", { type: "button", style: style.btnSmall, disabled: !rpc, onClick: () => doInstallFromMarket(p) }, t("action.install"))
2113
+ )
2114
+ ))
2115
+ );
2116
+ return (0, import_react.createElement)(
2117
+ "div",
2118
+ { style: { display: "flex", flexDirection: "column", gap: 8 } },
2119
+ (0, import_react.createElement)(
2120
+ "div",
2121
+ { style: style.marketHead },
2122
+ packs.length > 0 ? (0, import_react.createElement)("p", { style: style.line }, `\u5E02\u573A\u5171 ${packs.length} \u4E2A\u6574\u5408\u5305`) : null,
2123
+ (0, import_react.createElement)("button", {
2124
+ type: "button",
2125
+ style: style.refreshBtn,
2126
+ disabled: !rpc || market === void 0,
2127
+ title: t("action.refresh"),
2128
+ onClick: () => void loadMarket()
2129
+ }, "\u21BB")
2130
+ ),
2131
+ body
2132
+ );
2133
+ };
2134
+ const renderLogo = () => (0, import_react.createElement)(
2135
+ "div",
2136
+ { style: style.logoTile },
2137
+ (0, import_react.createElement)(
2138
+ "svg",
2139
+ { viewBox: "0 0 1024 1024", width: 52, height: 52, style: { display: "block" } },
2140
+ (0, import_react.createElement)("path", { d: LOGO_PATH, fill: "currentColor" })
2141
+ )
2142
+ );
2143
+ const renderAbout = () => {
2144
+ const updateLine = !update ? null : update.checking ? (0, import_react.createElement)("p", { style: { ...style.line, margin: 0 } }, t("about.checking")) : update.error ? (0, import_react.createElement)("p", { style: { ...style.err, margin: 0 } }, `${t("about.checkFailed")}\uFF1A${update.error}`) : update.outdated ? (0, import_react.createElement)(
2145
+ "div",
2146
+ { style: { ...style.row, justifyContent: "center" } },
2147
+ (0, import_react.createElement)(
2148
+ "p",
2149
+ { style: { margin: 0, fontSize: 12, lineHeight: "18px", color: "#e8a23a", fontWeight: 600 } },
2150
+ t("about.newVersion").replace("{latest}", update.latest).replace("{current}", update.current)
2151
+ ),
2152
+ (0, import_react.createElement)("button", { type: "button", style: style.btnSmall, onClick: () => openUrl(update.npmUrl || NPM_URL) }, t("about.viewNpm"))
2153
+ ) : (0, import_react.createElement)("p", { style: { ...style.line, margin: 0 } }, `${t("about.upToDate")}\uFF08${update.latest}\uFF09`);
2154
+ return (0, import_react.createElement)(
2155
+ "div",
2156
+ { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: 12, padding: "24px 0" } },
2157
+ renderLogo(),
2158
+ (0, import_react.createElement)("div", { style: { fontSize: 16, fontWeight: 700, lineHeight: "24px", color: "var(--dsw-alias-label-primary)" } }, MANAGER_PKG),
2159
+ (0, import_react.createElement)("p", { style: { ...style.line, margin: 0 } }, `${t("about.version")} ${VERSION}`),
2160
+ (0, import_react.createElement)("p", { style: { ...style.line, margin: 0, maxWidth: 440, textAlign: "center" } }, t("about.desc")),
2161
+ (0, import_react.createElement)("p", { style: { ...style.line, margin: 0, maxWidth: 440, textAlign: "center", fontStyle: "italic", color: "var(--dsw-alias-label-primary)" } }, t("about.philosophy")),
2162
+ (0, import_react.createElement)(
2163
+ "div",
2164
+ { style: { ...style.row, justifyContent: "center" } },
2165
+ (0, import_react.createElement)("button", { type: "button", style: style.btn, onClick: () => doCheckUpdate() }, t("about.checkUpdate"))
2166
+ ),
2167
+ updateLine,
2168
+ // —— 网络(代理设置:覆盖环境变量,保存即生效)——
2169
+ (0, import_react.createElement)(
2170
+ "div",
2171
+ { style: { ...style.group, width: "100%", maxWidth: 440, paddingTop: 14, borderTop: "1px solid var(--dsw-alias-border-l2)" } },
2172
+ (0, import_react.createElement)("p", { style: style.groupTitle }, t("group.network")),
2173
+ (0, import_react.createElement)(
2174
+ "div",
2175
+ { style: style.field },
2176
+ (0, import_react.createElement)("span", { style: style.fieldLabel }, t("field.proxyMode")),
2177
+ (0, import_react.createElement)(
2178
+ "div",
2179
+ { style: style.row },
2180
+ ["auto", "direct", "manual"].map(
2181
+ (m) => (0, import_react.createElement)("button", {
2182
+ key: m,
2183
+ type: "button",
2184
+ style: proxyMode === m ? { ...style.tab, ...style.tabActive } : style.tab,
2185
+ onClick: () => setProxyMode(m)
2186
+ }, t("proxyMode." + m))
2187
+ )
2188
+ )
2189
+ ),
2190
+ proxyMode === "manual" ? (0, import_react.createElement)(
2191
+ "label",
2192
+ { style: style.field },
2193
+ (0, import_react.createElement)("span", { style: style.fieldLabel }, t("field.proxy")),
2194
+ (0, import_react.createElement)("input", {
2195
+ style: style.input,
2196
+ value: proxy,
2197
+ placeholder: "http://127.0.0.1:7890",
2198
+ onInput: (e) => setProxy(e.target.value)
2199
+ })
2200
+ ) : null,
2201
+ (0, import_react.createElement)("p", { style: style.hint }, t("hint.proxy")),
2202
+ (0, import_react.createElement)(
2203
+ "div",
2204
+ { style: style.row },
2205
+ (0, import_react.createElement)("button", { type: "button", style: style.btn, disabled: !rpc, onClick: doSaveProxy }, t("action.save"))
2206
+ )
2207
+ ),
2208
+ (0, import_react.createElement)(
2209
+ "div",
2210
+ { style: { ...style.row, justifyContent: "center" } },
2211
+ (0, import_react.createElement)("button", { type: "button", style: style.btnSmall, onClick: () => openUrl(AUTHOR_URL) }, `${t("about.author")} ${AUTHOR}`),
2212
+ (0, import_react.createElement)("button", { type: "button", style: style.btnSmall, onClick: () => openUrl(REPO_URL) }, t("about.repo")),
2213
+ (0, import_react.createElement)("button", { type: "button", style: style.btnSmall, onClick: () => openUrl(REPO_URL) }, `\u2B50 ${t("about.star")}`)
2214
+ ),
2215
+ // —— 生态(DSH-PackForge 名下其它项目)——
2216
+ (0, import_react.createElement)(
2217
+ "div",
2218
+ { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: 8, width: "100%", maxWidth: 440, paddingTop: 14, borderTop: "1px solid var(--dsw-alias-border-l2)" } },
2219
+ (0, import_react.createElement)("p", { style: style.groupTitle }, t("about.ecosystem")),
2220
+ (0, import_react.createElement)(
2221
+ "div",
2222
+ { style: { ...style.row, justifyContent: "center" } },
2223
+ (0, import_react.createElement)("button", { type: "button", style: style.btnSmall, onClick: () => openUrl(SPEC_URL) }, t("about.ecosystem.spec")),
2224
+ (0, import_react.createElement)("button", { type: "button", style: style.btnSmall, onClick: () => openUrl(APP_URL) }, t("about.ecosystem.app")),
2225
+ (0, import_react.createElement)("button", { type: "button", style: style.btnSmall, onClick: () => openUrl(MARKET_URL) }, t("about.ecosystem.market"))
2226
+ )
2227
+ ),
2228
+ // —— 版权说明 ——
2229
+ (0, import_react.createElement)("p", { style: { ...style.hint, margin: "4px 0 0", textAlign: "center", maxWidth: 440 } }, t("about.copyright"))
2230
+ );
2231
+ };
2232
+ const content = tab === "manage" ? renderManage() : tab === "export" ? renderExport() : tab === "market" ? renderMarket() : renderAbout();
2233
+ const renderConfirm = () => {
2234
+ if (!confirm) return null;
2235
+ const warning = t("confirm.warning").replace("{pkg}", MANAGER_PKG);
2236
+ return (0, import_react.createElement)(
2237
+ "div",
2238
+ { style: style.overlay, onClick: () => setConfirm(null) },
2239
+ (0, import_react.createElement)(
2240
+ "div",
2241
+ { style: style.modal, onClick: (e) => e.stopPropagation() },
2242
+ (0, import_react.createElement)("h3", { style: style.modalTitle }, t("confirm.title")),
2243
+ (0, import_react.createElement)(
2244
+ "div",
2245
+ { style: style.ticket },
2246
+ (0, import_react.createElement)(
2247
+ "div",
2248
+ { style: style.ticketSide },
2249
+ (0, import_react.createElement)("span", { style: style.ticketName }, confirm.from),
2250
+ (0, import_react.createElement)("span", { style: style.ticketRole }, t("confirm.from"))
2251
+ ),
2252
+ (0, import_react.createElement)("div", { style: style.ticketLine }),
2253
+ (0, import_react.createElement)("div", { style: style.ticketBadge }, "\u2192"),
2254
+ (0, import_react.createElement)(
2255
+ "div",
2256
+ { style: style.ticketSide },
2257
+ (0, import_react.createElement)("span", { style: style.ticketName }, confirm.to),
2258
+ (0, import_react.createElement)("span", { style: style.ticketRole }, t("confirm.to"))
2259
+ )
2260
+ ),
2261
+ confirm.firstTime ? (0, import_react.createElement)("p", { style: style.hint }, t("confirm.firstTime")) : null,
2262
+ confirm.hasManager ? null : (0, import_react.createElement)(
2263
+ "div",
2264
+ { style: style.warn },
2265
+ (0, import_react.createElement)("span", { style: style.warnIcon }, "!"),
2266
+ (0, import_react.createElement)("span", null, warning)
2267
+ ),
2268
+ confirm.hasManager ? null : (0, import_react.createElement)(
2269
+ "div",
2270
+ { style: style.group },
2271
+ (0, import_react.createElement)("span", { style: style.fieldLabel }, t("confirm.managerSource")),
2272
+ (0, import_react.createElement)(
2273
+ "label",
2274
+ { key: "npm", style: style.row },
2275
+ (0, import_react.createElement)("input", {
2276
+ type: "radio",
2277
+ name: "managerSource",
2278
+ checked: managerSource === "npm",
2279
+ style: { width: 14, height: 14, cursor: "pointer", accentColor: "#4b7bec" },
2280
+ onChange: () => setManagerSource("npm")
2281
+ }),
2282
+ (0, import_react.createElement)("span", { style: style.line }, t("confirm.source.npm"))
2283
+ ),
2284
+ (0, import_react.createElement)(
2285
+ "label",
2286
+ { key: "copy", style: style.row },
2287
+ (0, import_react.createElement)("input", {
2288
+ type: "radio",
2289
+ name: "managerSource",
2290
+ checked: managerSource === "copy",
2291
+ style: { width: 14, height: 14, cursor: "pointer", accentColor: "#4b7bec" },
2292
+ onChange: () => setManagerSource("copy")
2293
+ }),
2294
+ (0, import_react.createElement)("span", { style: style.line }, t("confirm.source.copy"))
2295
+ )
2296
+ ),
2297
+ (0, import_react.createElement)("p", { style: style.hint }, t("confirm.hintRestart")),
2298
+ (0, import_react.createElement)(
2299
+ "div",
2300
+ { style: style.confirmBtns },
2301
+ (0, import_react.createElement)("button", { type: "button", style: style.btn, onClick: () => setConfirm(null) }, t("confirm.cancel")),
2302
+ (0, import_react.createElement)("button", { type: "button", style: style.btnPrimary, onClick: confirmSwitch }, t("confirm.ok"))
2303
+ )
2304
+ )
2305
+ );
2306
+ };
2307
+ const renderDialog = () => {
2308
+ if (!dialog) return null;
2309
+ const isCreate = dialog === "create";
2310
+ const value = isCreate ? newName : source;
2311
+ const submit = () => {
2312
+ if (!submitting) void (isCreate ? doCreate() : doImport());
2313
+ };
2314
+ return (0, import_react.createElement)(
2315
+ "div",
2316
+ { style: style.overlay, onClick: closeDialog },
2317
+ (0, import_react.createElement)(
2318
+ "div",
2319
+ { style: style.modal, onClick: (e) => e.stopPropagation() },
2320
+ (0, import_react.createElement)("h3", { style: style.modalTitle }, isCreate ? t("dialog.createTitle") : t("dialog.importTitle")),
2321
+ (0, import_react.createElement)(
2322
+ "label",
2323
+ { style: style.field },
2324
+ (0, import_react.createElement)("span", { style: style.fieldLabel }, isCreate ? t("field.newName") : t("field.source")),
2325
+ (0, import_react.createElement)("input", {
2326
+ style: style.input,
2327
+ value,
2328
+ autoFocus: true,
2329
+ placeholder: isCreate ? t("field.newName") : t("field.source"),
2330
+ onInput: (e) => {
2331
+ if (isCreate) setNewName(e.target.value);
2332
+ else setSource(e.target.value);
2333
+ if (fieldError) setFieldError("");
2334
+ },
2335
+ onKeyDown: (e) => {
2336
+ if (e.key === "Enter") submit();
2337
+ }
2338
+ })
2339
+ ),
2340
+ (0, import_react.createElement)("p", { style: style.hint }, isCreate ? t("hint.nameFormat") : t("hint.import")),
2341
+ fieldError ? (0, import_react.createElement)("p", { style: style.err }, fieldError) : null,
2342
+ (0, import_react.createElement)(
2343
+ "div",
2344
+ { style: style.confirmBtns },
2345
+ (0, import_react.createElement)("button", { type: "button", style: style.btn, disabled: submitting, onClick: closeDialog }, t("confirm.cancel")),
2346
+ (0, import_react.createElement)(
2347
+ "button",
2348
+ { type: "button", style: style.btnPrimary, disabled: !rpc || submitting, onClick: submit },
2349
+ submitting ? t("result.pending") : isCreate ? t("action.create") : t("action.install")
2350
+ )
2351
+ )
2352
+ )
2353
+ );
2354
+ };
2355
+ const renderInstallConfirm = () => {
2356
+ if (!installConfirm) return null;
2357
+ const warnings = installConfirm.warnings ?? [];
2358
+ return (0, import_react.createElement)(
2359
+ "div",
2360
+ { style: style.overlay, onClick: () => setInstallConfirm(null) },
2361
+ (0, import_react.createElement)(
2362
+ "div",
2363
+ { style: style.modal, onClick: (e) => e.stopPropagation() },
2364
+ (0, import_react.createElement)("h3", { style: style.modalTitle }, t("installConfirm.title")),
2365
+ (0, import_react.createElement)("p", { style: style.hint }, t("installConfirm.hint")),
2366
+ ...warnings.map((w, i) => (0, import_react.createElement)(
2367
+ "div",
2368
+ { key: i, style: style.warn },
2369
+ (0, import_react.createElement)("span", { style: style.warnIcon }, "!"),
2370
+ (0, import_react.createElement)("span", null, w.message)
2371
+ )),
2372
+ (0, import_react.createElement)(
2373
+ "div",
2374
+ { style: style.confirmBtns },
2375
+ (0, import_react.createElement)("button", { type: "button", style: style.btn, onClick: () => setInstallConfirm(null) }, t("confirm.cancel")),
2376
+ (0, import_react.createElement)("button", { type: "button", style: style.btnPrimary, onClick: confirmInstall }, t("installConfirm.ok"))
2377
+ )
2378
+ )
2379
+ );
2380
+ };
2381
+ const renderDetail = () => {
2382
+ if (!detail) return null;
2383
+ const close = () => setDetail(null);
2384
+ const pack = detail.pack ?? {};
2385
+ return (0, import_react.createElement)(
2386
+ "div",
2387
+ { style: style.overlay, onClick: close },
2388
+ (0, import_react.createElement)(
2389
+ "div",
2390
+ { style: { ...style.modal, maxWidth: 560, maxHeight: "calc(100dvh - 240px)" }, onClick: (e) => e.stopPropagation() },
2391
+ (0, import_react.createElement)("h3", { style: style.modalTitle }, t("market.detailTitle")),
2392
+ detail.pending ? (0, import_react.createElement)("p", { style: style.line }, t("market.loading")) : detail.error ? (0, import_react.createElement)("p", { style: style.err }, `${t("market.error")}\uFF1A${detail.error}`) : (0, import_react.createElement)(
2393
+ "div",
2394
+ { style: { display: "flex", flexDirection: "column", gap: 8, minWidth: 0, minHeight: 0, overflowY: "auto" } },
2395
+ (0, import_react.createElement)(
2396
+ "div",
2397
+ { style: { display: "flex", flexDirection: "column", gap: 2 } },
2398
+ (0, import_react.createElement)("span", { style: style.listName }, pack.displayName || pack.name || detail.manifest?.name || ""),
2399
+ pack.description ? (0, import_react.createElement)("span", { style: style.line }, pack.description) : null,
2400
+ (0, import_react.createElement)(
2401
+ "span",
2402
+ { style: style.line },
2403
+ `${pack.author ? pack.author + " \xB7 " : ""}${pack.version || "?"}${pack.dshVersion ? " \xB7 DSH " + pack.dshVersion : ""}`
2404
+ )
2405
+ ),
2406
+ // v5 r2 兼容性徽标:需启动器 ≥ x / 声明冲突 / 内嵌 N 个依赖 / 兼容 DSH 版本集
2407
+ (detail.badges ?? []).length ? (0, import_react.createElement)(
2408
+ "div",
2409
+ { style: { display: "flex", flexDirection: "column", gap: 4 } },
2410
+ detail.badges.map((b, i) => b.kind === "launcher-conflict" ? (0, import_react.createElement)(
2411
+ "div",
2412
+ { key: i, style: style.warn },
2413
+ (0, import_react.createElement)("span", { style: style.warnIcon }, "!"),
2414
+ (0, import_react.createElement)("span", null, badgeText(b))
2415
+ ) : (0, import_react.createElement)("p", { key: i, style: style.line }, "\xB7 " + badgeText(b)))
2416
+ ) : (0, import_react.createElement)("p", { style: style.line }, t("market.r2.none")),
2417
+ marketResources(detail.manifest, detail.icons, t),
2418
+ detail.readme ? (0, import_react.createElement)("pre", { style: { ...style.taskLog, maxHeight: 260 } }, detail.readme) : null
2419
+ ),
2420
+ (0, import_react.createElement)(
2421
+ "div",
2422
+ { style: style.confirmBtns },
2423
+ (0, import_react.createElement)("button", { type: "button", style: style.btn, onClick: close }, t("tasks.close")),
2424
+ detail.pending || detail.error ? null : (0, import_react.createElement)("button", {
2425
+ type: "button",
2426
+ style: style.btnPrimary,
2427
+ disabled: !rpc,
2428
+ onClick: () => {
2429
+ const p = detail.pack;
2430
+ setDetail(null);
2431
+ void doInstallFromMarket(p);
2432
+ }
2433
+ }, t("action.install"))
2434
+ )
2435
+ )
2436
+ );
2437
+ };
2438
+ const TASK_STATUS = {
2439
+ queued: ["\u6392\u961F\u4E2D", "#e8a23a"],
2440
+ running: ["\u8FDB\u884C\u4E2D", "#6ab7ff"],
2441
+ done: ["\u5B8C\u6210", "#2ea44f"],
2442
+ failed: ["\u5931\u8D25", "#d3383a"]
2443
+ };
2444
+ const taskDotStyle = (status) => status === "done" ? { borderColor: "#2ea44f", background: "#2ea44f", color: "#fff" } : status === "failed" ? { borderColor: "#d3383a", background: "#d3383a", color: "#fff" } : status === "running" ? { borderColor: "#6ab7ff", color: "#6ab7ff" } : {};
2445
+ const renderTasks = () => {
2446
+ const cards = taskList.map((t2) => {
2447
+ const [stLabel, stColor] = TASK_STATUS[t2.status] || ["?", "#9a9ba3"];
2448
+ const log = t2.log || [];
2449
+ const stages = t2.stages || [];
2450
+ return (0, import_react.createElement)(
2451
+ "li",
2452
+ { key: t2.id, style: style.taskCard },
2453
+ (0, import_react.createElement)(
2454
+ "div",
2455
+ { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } },
2456
+ (0, import_react.createElement)("span", { style: style.taskTitle }, t2.title || "\u4EFB\u52A1"),
2457
+ (0, import_react.createElement)("span", { style: { flex: "0 0 auto", fontSize: 12, fontWeight: 600, color: stColor } }, stLabel)
2458
+ ),
2459
+ stages.length ? (0, import_react.createElement)(
2460
+ "div",
2461
+ { style: style.taskTimeline },
2462
+ stages.map(
2463
+ (s) => (0, import_react.createElement)(
2464
+ "span",
2465
+ { key: s.id, style: style.taskStep },
2466
+ (0, import_react.createElement)("span", { style: { ...style.taskDot, ...taskDotStyle(s.status) } }, s.status === "done" ? "\u2713" : s.status === "failed" ? "\u2717" : ""),
2467
+ (0, import_react.createElement)("span", null, s.label)
2468
+ )
2469
+ )
2470
+ ) : null,
2471
+ t2.error ? (0, import_react.createElement)("p", { style: style.err }, "\u9519\u8BEF\uFF1A" + t2.error) : null,
2472
+ log.length ? (0, import_react.createElement)("pre", { style: style.taskLog }, (t2.logTruncated ? "\u2026\uFF08\u5DF2\u622A\u65AD\uFF0C\u4EC5\u4FDD\u7559\u6700\u540E " + log.length + " \u884C\uFF09\n" : "") + log.join("\n")) : null
2473
+ );
2474
+ });
2475
+ return (0, import_react.createElement)(
2476
+ "div",
2477
+ { style: style.taskPanel },
2478
+ (0, import_react.createElement)(
2479
+ "div",
2480
+ { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } },
2481
+ (0, import_react.createElement)("h3", { style: style.groupTitle }, t("action.tasks")),
2482
+ (0, import_react.createElement)("button", { type: "button", style: style.btnSmall, onClick: doOpenTasks, title: t("tasks.close") }, "\u2715")
2483
+ ),
2484
+ taskList.length === 0 ? (0, import_react.createElement)("p", { style: style.line }, t("tasks.empty")) : (0, import_react.createElement)("ul", { style: style.list }, cards)
2485
+ );
2486
+ };
2487
+ return (0, import_react.createElement)(
2488
+ import_react.Fragment,
2489
+ null,
2490
+ (0, import_react.createElement)(
2491
+ "div",
2492
+ { style: style.section },
2493
+ (0, import_react.createElement)(
2494
+ "div",
2495
+ { style: style.tabs },
2496
+ ["manage", "export", "market", "about"].map((id) => (0, import_react.createElement)("button", {
2497
+ key: id,
2498
+ type: "button",
2499
+ style: tab === id ? { ...style.tab, ...style.tabActive } : style.tab,
2500
+ onClick: () => {
2501
+ setTab(id);
2502
+ if (id === "market" && market === null) void loadMarket();
2503
+ }
2504
+ }, t("tab." + id)))
2505
+ ),
2506
+ tasksOpen ? renderTasks() : null,
2507
+ content,
2508
+ tab === "manage" ? (0, import_react.createElement)("p", { style: style.hint }, t("hint.restart")) : null,
2509
+ result ? (0, import_react.createElement)(
2510
+ "p",
2511
+ { style: result.ok === false ? style.err : style.ok },
2512
+ result.pending ? t("result.pending") : result.text ?? result.error
2513
+ ) : null
2514
+ ),
2515
+ renderConfirm(),
2516
+ renderDialog(),
2517
+ renderInstallConfirm(),
2518
+ renderDetail()
2519
+ );
2520
+ }
2521
+
2522
+ // src/client-rpc.js
2523
+ function createRpc(ctx) {
2524
+ const rpc = ctx?.connection?.rpc;
2525
+ if (!rpc || typeof rpc.call !== "function") return null;
2526
+ return {
2527
+ call: (endpoint, payload, signal) => rpc.call(CHANNEL, endpoint, payload ?? {}, signal)
2528
+ };
2529
+ }
2530
+
2531
+ // src/ball.js
2532
+ var BALL_SIZE = 48;
2533
+ var SNAP_RATIO = 0.25;
2534
+ var CLICK_SQ = 9;
2535
+ var STORE_KEY = "dspack-ball-pos";
2536
+ var DEFAULT_OFFSET = 24;
2537
+ function clamp(v, min, max) {
2538
+ const n = Number(v);
2539
+ if (!Number.isFinite(n)) return min;
2540
+ return n < min ? min : n > max ? max : n;
2541
+ }
2542
+ function viewportOf(w, h2) {
2543
+ return { w: Math.max(0, Number(w) || 0), h: Math.max(0, Number(h2) || 0) };
2544
+ }
2545
+ function decideSnap(rect, vp) {
2546
+ const cx = (Number(rect?.left) || 0) + (Number(rect?.w) || 0) / 2;
2547
+ const cy = (Number(rect?.top) || 0) + (Number(rect?.h) || 0) / 2;
2548
+ let h2 = null;
2549
+ let v = null;
2550
+ if (cx < vp.w * SNAP_RATIO) h2 = "left";
2551
+ else if (cx > vp.w * (1 - SNAP_RATIO)) h2 = "right";
2552
+ if (cy < vp.h * SNAP_RATIO) v = "top";
2553
+ else if (cy > vp.h * (1 - SNAP_RATIO)) v = "bottom";
2554
+ return { h: h2, v };
2555
+ }
2556
+ function anchorFrom(rect, vp, snap) {
2557
+ const left = Number(rect?.left) || 0;
2558
+ const top = Number(rect?.top) || 0;
2559
+ const w = Number(rect?.w) || 0;
2560
+ const h2 = Number(rect?.h) || 0;
2561
+ return {
2562
+ h: snap?.h ?? null,
2563
+ v: snap?.v ?? null,
2564
+ hOff: Math.max(0, snap?.h === "right" ? vp.w - (left + w) : left),
2565
+ vOff: Math.max(0, snap?.v === "bottom" ? vp.h - (top + h2) : top)
2566
+ };
2567
+ }
2568
+ function positionFrom(anchor, size, vp) {
2569
+ const sw = Number(size?.w) || 0;
2570
+ const sh = Number(size?.h) || 0;
2571
+ const maxL = Math.max(0, vp.w - sw);
2572
+ const maxT = Math.max(0, vp.h - sh);
2573
+ const hOff = Math.max(0, Number(anchor?.hOff) || 0);
2574
+ const vOff = Math.max(0, Number(anchor?.vOff) || 0);
2575
+ const rawLeft = anchor?.h === "right" ? vp.w - sw - hOff : hOff;
2576
+ const rawTop = anchor?.v === "bottom" ? vp.h - sh - vOff : vOff;
2577
+ return {
2578
+ left: clamp(rawLeft, 0, maxL),
2579
+ top: clamp(rawTop, 0, maxT),
2580
+ hOff,
2581
+ vOff
2582
+ };
2583
+ }
2584
+ function defaultAnchor() {
2585
+ return { h: "right", v: "bottom", hOff: DEFAULT_OFFSET, vOff: DEFAULT_OFFSET };
2586
+ }
2587
+ var H_VALUES = /* @__PURE__ */ new Set(["left", "right"]);
2588
+ var V_VALUES = /* @__PURE__ */ new Set(["top", "bottom"]);
2589
+ function normalizeStored(raw, vp = null) {
2590
+ let parsed = null;
2591
+ try {
2592
+ parsed = typeof raw === "string" ? JSON.parse(raw) : raw;
2593
+ } catch {
2594
+ return defaultAnchor();
2595
+ }
2596
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return defaultAnchor();
2597
+ if (!("h" in parsed) && !("v" in parsed) && !("hOff" in parsed) && !("vOff" in parsed)) return defaultAnchor();
2598
+ const h2 = H_VALUES.has(parsed.h) ? parsed.h : null;
2599
+ const v = V_VALUES.has(parsed.v) ? parsed.v : null;
2600
+ const hOff = Number.isFinite(Number(parsed.hOff)) ? Math.max(0, Number(parsed.hOff)) : DEFAULT_OFFSET;
2601
+ const vOff = Number.isFinite(Number(parsed.vOff)) ? Math.max(0, Number(parsed.vOff)) : DEFAULT_OFFSET;
2602
+ const anchor = { h: h2, v, hOff, vOff };
2603
+ if (vp && vp.w > 0 && vp.h > 0) {
2604
+ const pos = positionFrom(anchor, { w: BALL_SIZE, h: BALL_SIZE }, vp);
2605
+ return anchorFrom({ left: pos.left, top: pos.top, w: BALL_SIZE, h: BALL_SIZE }, vp, { h: h2, v });
2606
+ }
2607
+ return anchor;
2608
+ }
2609
+ function serializeAnchor(anchor) {
2610
+ return JSON.stringify({
2611
+ h: anchor?.h ?? null,
2612
+ v: anchor?.v ?? null,
2613
+ hOff: Math.max(0, Number(anchor?.hOff) || 0),
2614
+ vOff: Math.max(0, Number(anchor?.vOff) || 0)
2615
+ });
2616
+ }
2617
+ var BALL_SVG = [
2618
+ '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9"',
2619
+ ' stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">',
2620
+ '<path d="M3.5 6.5h17v11a2 2 0 0 1-2 2h-13a2 2 0 0 1-2-2z"/>',
2621
+ '<path d="M3.5 6.5V5.2a1.7 1.7 0 0 1 1.7-1.7h4.4l1.6 2.2"/>',
2622
+ '<path d="M12 9.5v7"/>',
2623
+ '<path d="M10.4 11.1h3.2M10.4 13h3.2M10.4 14.9h3.2"/>',
2624
+ "</svg>"
2625
+ ].join("");
2626
+ var BALL_CSS = [
2627
+ // 外层防御:宿主皮肤会按几何特征(position:fixed + 高 z-index)给元素套背景/边框/阴影/滤镜,
2628
+ // 关键属性全部 !important 顶回去(鲸鱼挂件 issue #133 的同类问题)。
2629
+ "#dspack-ball{position:fixed;box-sizing:border-box;width:48px;height:48px;border-radius:50%;",
2630
+ "display:flex;align-items:center;justify-content:center;cursor:grab;",
2631
+ "user-select:none;-webkit-user-select:none;touch-action:none;z-index:99999;color:#fff;",
2632
+ "background:linear-gradient(145deg,#4d6bfe,#203170) !important;",
2633
+ "border:2px solid rgba(255,255,255,.86) !important;",
2634
+ "box-shadow:0 6px 18px rgba(15,23,42,.34) !important;",
2635
+ "backdrop-filter:none !important;-webkit-backdrop-filter:none !important;",
2636
+ "transition:left .18s ease,top .18s ease,transform .18s ease}",
2637
+ "#dspack-ball::before,#dspack-ball::after{content:none !important}",
2638
+ "#dspack-ball.dspack-ball-dragging{cursor:grabbing;transition:none}",
2639
+ "#dspack-ball:active{transform:scale(.92)}",
2640
+ "#dspack-ball svg{width:26px;height:26px;display:block;pointer-events:none}",
2641
+ // 贴左时整体镜像(朝屏幕内),图标再反向镜像一次保持可读
2642
+ "#dspack-ball.dspack-ball-left{transform:scaleX(-1)}",
2643
+ "#dspack-ball.dspack-ball-left svg{transform:scaleX(-1)}",
2644
+ "#dspack-ball-tip{position:fixed;box-sizing:border-box;max-width:min(320px,calc(100vw - 24px));",
2645
+ "padding:8px 12px;border-radius:8px;background:rgba(15,23,42,.92);color:#fff;",
2646
+ 'font:12px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif;z-index:100000;pointer-events:none;',
2647
+ "box-shadow:0 6px 18px rgba(15,23,42,.3)}"
2648
+ ].join("");
2649
+ function safeStorage(win, key) {
2650
+ try {
2651
+ const ls = win?.localStorage;
2652
+ if (!ls) return null;
2653
+ return {
2654
+ get: () => {
2655
+ try {
2656
+ return ls.getItem(key);
2657
+ } catch {
2658
+ return null;
2659
+ }
2660
+ },
2661
+ set: (v) => {
2662
+ try {
2663
+ ls.setItem(key, v);
2664
+ } catch {
2665
+ }
2666
+ }
2667
+ };
2668
+ } catch {
2669
+ return null;
2670
+ }
2671
+ }
2672
+ function mountBall(opts = {}) {
2673
+ const win = opts.win || (typeof window === "undefined" ? null : window);
2674
+ const doc = opts.doc || win && win.document || null;
2675
+ if (!win || !doc) return null;
2676
+ if (win.__dspackBall) return win.__dspackBall;
2677
+ const size = Number(opts.size) || BALL_SIZE;
2678
+ const store = safeStorage(win, opts.storeKey || STORE_KEY);
2679
+ const mount = () => {
2680
+ if (win.__dspackBall) return win.__dspackBall;
2681
+ const style = doc.createElement("style");
2682
+ style.id = "dspack-ball-style";
2683
+ style.textContent = BALL_CSS;
2684
+ (doc.head || doc.documentElement).appendChild(style);
2685
+ const root = doc.createElement("div");
2686
+ root.id = "dspack-ball";
2687
+ root.setAttribute("role", "button");
2688
+ root.setAttribute("tabindex", "0");
2689
+ root.setAttribute("title", opts.title || "\u6253\u5F00\u8BBE\u7F6E \xB7 DSH PackForge");
2690
+ root.innerHTML = BALL_SVG;
2691
+ const state = normalizeStored(store ? store.get() : null);
2692
+ let drag = null;
2693
+ let tip = null;
2694
+ let tipTimer = 0;
2695
+ let action = null;
2696
+ const viewport = () => viewportOf(win.innerWidth || doc.documentElement.clientWidth, win.innerHeight || doc.documentElement.clientHeight);
2697
+ const initial = positionFrom(state, { w: size, h: size }, viewport());
2698
+ state.hOff = initial.hOff;
2699
+ state.vOff = initial.vOff;
2700
+ root.style.left = `${initial.left}px`;
2701
+ root.style.top = `${initial.top}px`;
2702
+ function express() {
2703
+ root.style.left = `${state.left}px`;
2704
+ root.style.top = `${state.top}px`;
2705
+ root.classList.toggle("dspack-ball-left", state.h === "left");
2706
+ }
2707
+ function settle() {
2708
+ const vp = viewport();
2709
+ const pos = positionFrom(state, { w: size, h: size }, vp);
2710
+ state.left = pos.left;
2711
+ state.top = pos.top;
2712
+ state.hOff = pos.hOff;
2713
+ state.vOff = pos.vOff;
2714
+ express();
2715
+ }
2716
+ function save() {
2717
+ if (store) store.set(serializeAnchor(state));
2718
+ }
2719
+ function showTip(text) {
2720
+ const vp = viewport();
2721
+ if (tip) {
2722
+ try {
2723
+ tip.remove();
2724
+ } catch {
2725
+ }
2726
+ }
2727
+ tip = doc.createElement("div");
2728
+ tip.id = "dspack-ball-tip";
2729
+ tip.textContent = text;
2730
+ doc.body.appendChild(tip);
2731
+ const below = state.top + size + 8 + 40 < vp.h;
2732
+ tip.style.left = `${clamp(state.left - 40, 8, Math.max(8, vp.w - 200))}px`;
2733
+ tip.style.top = `${below ? state.top + size + 8 : Math.max(8, state.top - 44)}px`;
2734
+ if (tipTimer) win.clearTimeout(tipTimer);
2735
+ tipTimer = win.setTimeout(() => {
2736
+ if (tip) {
2737
+ try {
2738
+ tip.remove();
2739
+ } catch {
2740
+ }
2741
+ }
2742
+ tip = null;
2743
+ }, 2600);
2744
+ }
2745
+ function focusFailTip() {
2746
+ const info = describeSettingsNav(doc, win);
2747
+ try {
2748
+ console.info("[dspack] \u60AC\u6D6E\u7403\u5207\u5206\u533A\u5931\u8D25\uFF0C\u8BCA\u65AD\uFF1A", info);
2749
+ } catch {
2750
+ }
2751
+ const label = info.ownLabel || "\u6574\u5408\u5305";
2752
+ const rows = info.rows.join(" / ") || "\uFF08\u6CA1\u8BFB\u5230\u5BFC\u822A\uFF09";
2753
+ return `\u8BBE\u7F6E\u5DF2\u6253\u5F00\uFF0C\u8BF7\u5728\u5DE6\u4FA7\u9009\u300C${label}\u300D\uFF1B\u6211\u770B\u5230\u7684\u5BFC\u822A\uFF1A${rows}`;
2754
+ }
2755
+ function openSettings() {
2756
+ const result = openSettingsPage(doc, {
2757
+ win,
2758
+ // 轮询校验没通过(没弹出设置弹窗)才提示:点错/被拦/真的没有入口,都算失败。
2759
+ onFail: () => showTip(opts.noTriggerTip || "\u6CA1\u627E\u5230\u5B98\u65B9\u8BBE\u7F6E\u5165\u53E3\uFF1A\u4FA7\u8FB9\u680F/\u8BBE\u7F6E\u90A3\u68F5\u53EF\u80FD\u5DF2\u4E0D\u53EF\u7528"),
2760
+ // 弹窗开了但没切过去:明确指路,别把人晾在别人的分区上。
2761
+ onFocusFail: () => showTip(opts.focusFailTip || focusFailTip())
2762
+ });
2763
+ if (result === "no-trigger") {
2764
+ showTip(opts.noTriggerTip || "\u6CA1\u627E\u5230\u5B98\u65B9\u8BBE\u7F6E\u5165\u53E3\uFF1A\u4FA7\u8FB9\u680F/\u8BBE\u7F6E\u90A3\u68F5\u53EF\u80FD\u5DF2\u4E0D\u53EF\u7528");
2765
+ }
2766
+ return result;
2767
+ }
2768
+ function fireClick() {
2769
+ try {
2770
+ win.dispatchEvent(new win.CustomEvent("dspack/ball-click", { detail: { api: api2 } }));
2771
+ } catch {
2772
+ }
2773
+ const run = typeof opts.onClick === "function" ? opts.onClick : action;
2774
+ if (typeof run === "function") {
2775
+ try {
2776
+ run(api2);
2777
+ } catch {
2778
+ }
2779
+ return;
2780
+ }
2781
+ openSettings();
2782
+ }
2783
+ function onMove(e) {
2784
+ if (!drag) return;
2785
+ const dx = (Number(e.clientX) || 0) - drag.startX;
2786
+ const dy = (Number(e.clientY) || 0) - drag.startY;
2787
+ if (dx * dx + dy * dy >= CLICK_SQ) drag.moved = true;
2788
+ const vp = viewport();
2789
+ state.left = clamp(drag.origLeft + dx, 0, Math.max(0, vp.w - size));
2790
+ state.top = clamp(drag.origTop + dy, 0, Math.max(0, vp.h - size));
2791
+ express();
2792
+ }
2793
+ function detach() {
2794
+ doc.removeEventListener("pointermove", onMove, true);
2795
+ doc.removeEventListener("pointerup", onUp, true);
2796
+ doc.removeEventListener("pointercancel", onCancel, true);
2797
+ }
2798
+ function end(clickable) {
2799
+ if (!drag) return;
2800
+ const moved = drag.moved;
2801
+ drag = null;
2802
+ root.classList.remove("dspack-ball-dragging");
2803
+ detach();
2804
+ const vp = viewport();
2805
+ const rect = { left: state.left, top: state.top, w: size, h: size };
2806
+ Object.assign(state, anchorFrom(rect, vp, decideSnap(rect, vp)));
2807
+ settle();
2808
+ save();
2809
+ if (clickable && !moved) fireClick();
2810
+ }
2811
+ function onUp() {
2812
+ end(true);
2813
+ }
2814
+ function onCancel() {
2815
+ end(false);
2816
+ }
2817
+ function onDown(e) {
2818
+ if (drag) return;
2819
+ if (e?.pointerType === "mouse" && e.button !== 0) return;
2820
+ drag = { startX: Number(e.clientX) || 0, startY: Number(e.clientY) || 0, origLeft: state.left, origTop: state.top, moved: false };
2821
+ root.classList.add("dspack-ball-dragging");
2822
+ try {
2823
+ e.preventDefault();
2824
+ e.stopPropagation();
2825
+ } catch {
2826
+ }
2827
+ doc.addEventListener("pointermove", onMove, true);
2828
+ doc.addEventListener("pointerup", onUp, true);
2829
+ doc.addEventListener("pointercancel", onCancel, true);
2830
+ }
2831
+ function onKeyDown(e) {
2832
+ if (e.key !== "Enter" && e.key !== " ") return;
2833
+ try {
2834
+ e.preventDefault();
2835
+ } catch {
2836
+ }
2837
+ fireClick();
2838
+ }
2839
+ const onResize = () => settle();
2840
+ root.addEventListener("pointerdown", onDown);
2841
+ root.addEventListener("keydown", onKeyDown);
2842
+ root.addEventListener("click", (e) => {
2843
+ try {
2844
+ e.stopPropagation();
2845
+ } catch {
2846
+ }
2847
+ });
2848
+ win.addEventListener("resize", onResize);
2849
+ doc.body.appendChild(root);
2850
+ settle();
2851
+ save();
2852
+ const api2 = {
2853
+ root,
2854
+ state,
2855
+ size,
2856
+ showTip,
2857
+ click: fireClick,
2858
+ openSettings,
2859
+ setAction(fn) {
2860
+ action = typeof fn === "function" ? fn : null;
2861
+ return api2;
2862
+ },
2863
+ settle,
2864
+ viewport,
2865
+ /** 诊断:设置导航长什么样、钩子/标记在不在(排查「点了没切过去」时用)。 */
2866
+ diag: () => describeSettingsNav(doc, win),
2867
+ destroy() {
2868
+ win.removeEventListener("resize", onResize);
2869
+ detach();
2870
+ if (tipTimer) win.clearTimeout(tipTimer);
2871
+ try {
2872
+ root.remove();
2873
+ } catch {
2874
+ }
2875
+ try {
2876
+ style.remove();
2877
+ } catch {
2878
+ }
2879
+ win.__dspackBall = null;
2880
+ }
2881
+ };
2882
+ return api2;
2883
+ };
2884
+ const body = doc.body;
2885
+ if (!body) {
2886
+ doc.addEventListener("DOMContentLoaded", () => {
2887
+ win.__dspackBall = null;
2888
+ win.__dspackBall = mount();
2889
+ }, { once: true });
2890
+ win.__dspackBall = { pending: true };
2891
+ return win.__dspackBall;
2892
+ }
2893
+ const api = mount();
2894
+ if (api) win.__dspackBall = api;
2895
+ return api;
2896
+ }
2897
+
2898
+ // src/client-plugin.js
2899
+ var name = "dsh-packforge";
2900
+ var inject = ["slots", "locale", "connection", "sessions", "uiWorkspace"];
2901
+ function apply(ctx) {
2902
+ console.error("[dsh-pack][client] apply slots=" + !!ctx?.slots + " locale=" + !!ctx?.locale + " connection=" + !!ctx?.connection + " rpc=" + !!ctx?.connection?.rpc + " sessions=" + !!ctx?.sessions + " uiWorkspace=" + !!ctx?.uiWorkspace);
2903
+ const rpc = createRpc(ctx);
2904
+ registerSettingsSection(ctx, { rpc, sendToChat: makeSendToChat(ctx) });
2905
+ mountBallFallback();
2906
+ }
2907
+ function mountBallFallback() {
2908
+ try {
2909
+ mountBall();
2910
+ } catch (error) {
2911
+ console.error("[dsh-pack][client] \u60AC\u6D6E\u7403\u6302\u8F7D\u5931\u8D25\uFF08\u4E0D\u5F71\u54CD\u8BBE\u7F6E\u9762\u677F\uFF09:", error);
2912
+ }
2913
+ }
2914
+ function makeSendToChat(ctx) {
2915
+ const sessions = ctx?.sessions;
2916
+ const uiWorkspace = ctx?.uiWorkspace;
2917
+ if (!sessions || typeof sessions.create !== "function" || typeof sessions.using !== "function" || typeof sessions.scope !== "function" || !uiWorkspace || typeof uiWorkspace.openSession !== "function") {
2918
+ return null;
2919
+ }
2920
+ return async (text) => {
2921
+ const id = await sessions.create({});
2922
+ if (!id) throw new Error("\u521B\u5EFA\u4F1A\u8BDD\u672A\u8FD4\u56DE sessionId");
2923
+ uiWorkspace.openSession(id);
2924
+ await sessions.using(id, { source: "dspack" }, async () => {
2925
+ const scoped = sessions.scope(id);
2926
+ const conversation = scoped?.conversation;
2927
+ if (!conversation || typeof conversation.send !== "function") throw new Error("conversation \u670D\u52A1\u4E0D\u53EF\u7528");
2928
+ await conversation.send(text);
2929
+ });
2930
+ };
2931
+ }
2932
+ return module.exports;
2933
+ },
2934
+ });