dsh-image-gen 0.5.0 → 0.5.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.
- package/lib/client.js +67 -19
- package/lib/client.js.map +1 -1
- package/lib/types/client/index.d.ts +4 -2
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -6560,6 +6560,8 @@ window.__ModuleLoader__.load({
|
|
|
6560
6560
|
apiKeyPlaceholder: "留空即可保留已配置的 Key",
|
|
6561
6561
|
apiKeyHint: "安全保存为 {key};页面不会读回明文。",
|
|
6562
6562
|
keyReadOnly: "Key 由 {source} 提供且只读;请在该来源中修改。",
|
|
6563
|
+
credentialsUnavailable: "凭据服务不可用,无法保存 API Key;建议升级 DSH 到稳定版本。",
|
|
6564
|
+
badgeUnavailable: "凭据服务不可用",
|
|
6563
6565
|
badgeChecking: "检查中…",
|
|
6564
6566
|
badgeConfigured: "Key 已配置",
|
|
6565
6567
|
badgeMissing: "Key 未配置",
|
|
@@ -6658,6 +6660,8 @@ window.__ModuleLoader__.load({
|
|
|
6658
6660
|
apiKeyPlaceholder: "Leave empty to keep configured key",
|
|
6659
6661
|
apiKeyHint: "Securely saved as {key}; never read back in plaintext.",
|
|
6660
6662
|
keyReadOnly: "Key is supplied read-only by {source}; update it there.",
|
|
6663
|
+
credentialsUnavailable: "Credentials service unavailable: API keys cannot be saved; please upgrade DSH to a stable release.",
|
|
6664
|
+
badgeUnavailable: "Credentials unavailable",
|
|
6661
6665
|
badgeChecking: "Checking…",
|
|
6662
6666
|
badgeConfigured: "Key set",
|
|
6663
6667
|
badgeMissing: "Key missing",
|
|
@@ -7074,20 +7078,21 @@ window.__ModuleLoader__.load({
|
|
|
7074
7078
|
credentialListeners.delete(callback);
|
|
7075
7079
|
};
|
|
7076
7080
|
} };
|
|
7077
|
-
const injectSettingsItem = (owner
|
|
7081
|
+
const injectSettingsItem = (owner) => {
|
|
7078
7082
|
const ownerRegister = owner.slots.register.bind(owner.slots);
|
|
7079
7083
|
owner.slots.inject("settings.plugin.item", () => ownerRegister({
|
|
7080
7084
|
name: "settings.plugin.item",
|
|
7081
7085
|
key: IMAGE_GENERATION_NAMESPACE,
|
|
7082
7086
|
inject: () => ({
|
|
7083
7087
|
scope,
|
|
7084
|
-
credentials,
|
|
7088
|
+
credentials: credentialsProxy,
|
|
7089
|
+
credentialsAvailable,
|
|
7085
7090
|
locale,
|
|
7086
7091
|
credentialEvents
|
|
7087
7092
|
})
|
|
7088
7093
|
}, ImageGenerationSettingsCard));
|
|
7089
7094
|
};
|
|
7090
|
-
const injectComposerPill = (owner
|
|
7095
|
+
const injectComposerPill = (owner) => {
|
|
7091
7096
|
const ownerRegister = owner.slots.register.bind(owner.slots);
|
|
7092
7097
|
owner.slots.inject("conversation.input.right", () => ownerRegister({
|
|
7093
7098
|
name: "conversation.input.right",
|
|
@@ -7095,25 +7100,43 @@ window.__ModuleLoader__.load({
|
|
|
7095
7100
|
order: 10,
|
|
7096
7101
|
inject: () => ({
|
|
7097
7102
|
scope,
|
|
7098
|
-
credentials,
|
|
7103
|
+
credentials: credentialsProxy,
|
|
7099
7104
|
locale,
|
|
7100
7105
|
credentialEvents
|
|
7101
7106
|
})
|
|
7102
7107
|
}, ImageProviderPill));
|
|
7103
7108
|
};
|
|
7104
|
-
const
|
|
7105
|
-
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
|
|
7109
|
+
const credentialsRef = { current: asCredentialsRemote(ctx.get("remote.credentials")) ?? credentialsFromLegacyConnection(ctx.get("connection")) };
|
|
7110
|
+
/** Stable delegating remote so the host-cached inject face never goes stale. */
|
|
7111
|
+
const credentialsProxy = {
|
|
7112
|
+
describe(refs) {
|
|
7113
|
+
const remote = credentialsRef.current;
|
|
7114
|
+
return remote === void 0 ? Promise.resolve({ ok: false }) : remote.describe(refs);
|
|
7115
|
+
},
|
|
7116
|
+
set(ref, value) {
|
|
7117
|
+
const remote = credentialsRef.current;
|
|
7118
|
+
return remote === void 0 ? Promise.resolve({
|
|
7119
|
+
ok: false,
|
|
7120
|
+
error: { message: "credentials service unavailable" }
|
|
7121
|
+
}) : remote.set(ref, value);
|
|
7122
|
+
},
|
|
7123
|
+
get unset() {
|
|
7124
|
+
const remote = credentialsRef.current;
|
|
7125
|
+
return remote?.unset?.bind(remote);
|
|
7126
|
+
}
|
|
7127
|
+
};
|
|
7128
|
+
/** False while the host core exposes no credentials service (preview cores). */
|
|
7129
|
+
const credentialsAvailable = () => credentialsRef.current !== void 0;
|
|
7130
|
+
injectSettingsItem(ctx);
|
|
7131
|
+
injectComposerPill(ctx);
|
|
7132
|
+
ctx.inject(["remote.credentials"], (remoteCtx) => {
|
|
7113
7133
|
const credentials = asCredentialsRemote(remoteCtx.get("remote.credentials"));
|
|
7114
|
-
if (credentials === void 0)
|
|
7115
|
-
|
|
7116
|
-
|
|
7134
|
+
if (credentials === void 0) {
|
|
7135
|
+
console.warn("dsh-image-gen: remote.credentials resolved with an incompatible interface; key settings stay degraded");
|
|
7136
|
+
return;
|
|
7137
|
+
}
|
|
7138
|
+
credentialsRef.current = credentials;
|
|
7139
|
+
notifyCredentialsUpdated();
|
|
7117
7140
|
});
|
|
7118
7141
|
ctx.slots.inject("tool.call.toolview", () => register({
|
|
7119
7142
|
name: "tool.call.toolview",
|
|
@@ -7322,8 +7345,23 @@ window.__ModuleLoader__.load({
|
|
|
7322
7345
|
});
|
|
7323
7346
|
}, [snapshot]);
|
|
7324
7347
|
const credentials = props.credentials;
|
|
7348
|
+
const credentialsAvailable = props.credentialsAvailable;
|
|
7325
7349
|
(0, react.useEffect)(() => {
|
|
7326
7350
|
let active = true;
|
|
7351
|
+
if (!credentialsAvailable()) {
|
|
7352
|
+
setRows((current) => {
|
|
7353
|
+
const next = { ...current };
|
|
7354
|
+
for (const provider of CLOUD_IMAGE_PROVIDERS) next[provider] = {
|
|
7355
|
+
...current[provider],
|
|
7356
|
+
keyStatus: "unavailable",
|
|
7357
|
+
keyInfo: void 0
|
|
7358
|
+
};
|
|
7359
|
+
return next;
|
|
7360
|
+
});
|
|
7361
|
+
return () => {
|
|
7362
|
+
active = false;
|
|
7363
|
+
};
|
|
7364
|
+
}
|
|
7327
7365
|
for (const provider of CLOUD_IMAGE_PROVIDERS) {
|
|
7328
7366
|
const keyRef = cloudCredentialRef(provider);
|
|
7329
7367
|
if (keyRef === void 0) continue;
|
|
@@ -7359,7 +7397,11 @@ window.__ModuleLoader__.load({
|
|
|
7359
7397
|
return () => {
|
|
7360
7398
|
active = false;
|
|
7361
7399
|
};
|
|
7362
|
-
}, [
|
|
7400
|
+
}, [
|
|
7401
|
+
credentials,
|
|
7402
|
+
credentialsAvailable,
|
|
7403
|
+
keyTick
|
|
7404
|
+
]);
|
|
7363
7405
|
const updateRow = (provider, patch) => {
|
|
7364
7406
|
setRows((current) => ({
|
|
7365
7407
|
...current,
|
|
@@ -7412,6 +7454,7 @@ window.__ModuleLoader__.load({
|
|
|
7412
7454
|
if (row.keyInput.trim().length > 0) {
|
|
7413
7455
|
const keyRef = cloudCredentialRef(provider);
|
|
7414
7456
|
if (keyRef === void 0) throw new Error(t("comfyuiNoKey"));
|
|
7457
|
+
if (!credentialsAvailable()) throw new Error(t("credentialsUnavailable"));
|
|
7415
7458
|
const response = await props.credentials.set(keyRef, row.keyInput.trim());
|
|
7416
7459
|
if (!response.ok) throw new Error(response.error?.message ?? t("saveKeyFailed"));
|
|
7417
7460
|
updateRow(provider, {
|
|
@@ -7564,6 +7607,10 @@ window.__ModuleLoader__.load({
|
|
|
7564
7607
|
text: t("badgeMissing"),
|
|
7565
7608
|
className: "dsh-ig-badge dsh-ig-badge-missing"
|
|
7566
7609
|
};
|
|
7610
|
+
if (status === "unavailable") return {
|
|
7611
|
+
text: t("badgeUnavailable"),
|
|
7612
|
+
className: "dsh-ig-badge dsh-ig-badge-neutral"
|
|
7613
|
+
};
|
|
7567
7614
|
return {
|
|
7568
7615
|
text: t("badgeUnknown"),
|
|
7569
7616
|
className: "dsh-ig-badge dsh-ig-badge-neutral"
|
|
@@ -7695,6 +7742,7 @@ window.__ModuleLoader__.load({
|
|
|
7695
7742
|
const row = rows[provider];
|
|
7696
7743
|
const keyRef = cloudCredentialRef(provider) ?? "";
|
|
7697
7744
|
const keyReadOnly = row.keyInfo?.writable === false;
|
|
7745
|
+
const keyUnavailable = !credentialsAvailable();
|
|
7698
7746
|
return (0, react_jsx_runtime.jsx)("div", {
|
|
7699
7747
|
className: "dsh-ig-provider-body",
|
|
7700
7748
|
children: (0, react_jsx_runtime.jsxs)("form", {
|
|
@@ -7719,11 +7767,11 @@ window.__ModuleLoader__.load({
|
|
|
7719
7767
|
updateRow(provider, { keyInput: event.target.value });
|
|
7720
7768
|
},
|
|
7721
7769
|
placeholder: row.keyStatus === "configured" ? t("apiKeyPlaceholder") : "",
|
|
7722
|
-
disabled: !snapshot.writable || keyReadOnly
|
|
7770
|
+
disabled: !snapshot.writable || keyReadOnly || keyUnavailable
|
|
7723
7771
|
}),
|
|
7724
7772
|
(0, react_jsx_runtime.jsx)("span", {
|
|
7725
7773
|
className: "dsh-ig-hint",
|
|
7726
|
-
children: keyReadOnly ? t("keyReadOnly", { source: row.keyInfo?.source ?? "" }) : t("apiKeyHint", { key: keyRef })
|
|
7774
|
+
children: keyUnavailable ? t("credentialsUnavailable") : keyReadOnly ? t("keyReadOnly", { source: row.keyInfo?.source ?? "" }) : t("apiKeyHint", { key: keyRef })
|
|
7727
7775
|
})
|
|
7728
7776
|
]
|
|
7729
7777
|
}),
|