dsh-workbench-vault 0.3.10 → 0.3.12
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 +514 -170
- package/lib/domain/actions.js +21 -21
- package/lib/index.js +1 -1
- package/package.json +3 -3
package/lib/client.js
CHANGED
|
@@ -844,6 +844,107 @@ var require_icons2 = __commonJS({
|
|
|
844
844
|
}
|
|
845
845
|
});
|
|
846
846
|
|
|
847
|
+
// packages/addons/lib/vault-lock.cjs
|
|
848
|
+
var require_vault_lock = __commonJS({
|
|
849
|
+
"packages/addons/lib/vault-lock.cjs"(exports2, module2) {
|
|
850
|
+
"use strict";
|
|
851
|
+
var POLL_MS = 4e3;
|
|
852
|
+
function create(options) {
|
|
853
|
+
var cfg = options || {};
|
|
854
|
+
var prefix = String(cfg.prefix || "wb");
|
|
855
|
+
var wrapClass = String(cfg.wrapClass || prefix);
|
|
856
|
+
var lock = {
|
|
857
|
+
POLL_MS: Number(cfg.pollMs) > 0 ? Number(cfg.pollMs) : POLL_MS,
|
|
858
|
+
prefix,
|
|
859
|
+
use,
|
|
860
|
+
Panel,
|
|
861
|
+
styles
|
|
862
|
+
};
|
|
863
|
+
function use(opts) {
|
|
864
|
+
var React = opts.React;
|
|
865
|
+
var api = opts.api;
|
|
866
|
+
var C = opts.C;
|
|
867
|
+
var every = Number(opts.pollMs) > 0 ? Number(opts.pollMs) : Number(lock.POLL_MS) || POLL_MS;
|
|
868
|
+
var action = opts.action || "vault.status";
|
|
869
|
+
var st = React.useState({ ready: false, locked: true, initialized: false, error: "" });
|
|
870
|
+
var tick = React.useState(0);
|
|
871
|
+
function read() {
|
|
872
|
+
return C.call(api, action).then(function(data) {
|
|
873
|
+
st[1](function(old) {
|
|
874
|
+
var next = {
|
|
875
|
+
ready: true,
|
|
876
|
+
locked: !(data && data.locked === false),
|
|
877
|
+
initialized: !!(data && data.initialized),
|
|
878
|
+
error: ""
|
|
879
|
+
};
|
|
880
|
+
if (old.ready === next.ready && old.locked === next.locked && old.initialized === next.initialized && !old.error) return old;
|
|
881
|
+
return next;
|
|
882
|
+
});
|
|
883
|
+
}).catch(function(e) {
|
|
884
|
+
st[1](function(old) {
|
|
885
|
+
return Object.assign({}, old, { ready: true, locked: true, error: C.errText(e) });
|
|
886
|
+
});
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
React.useEffect(function() {
|
|
890
|
+
var alive = true;
|
|
891
|
+
function poll() {
|
|
892
|
+
if (alive) read();
|
|
893
|
+
}
|
|
894
|
+
poll();
|
|
895
|
+
var timer = setInterval(poll, every);
|
|
896
|
+
if (timer && typeof timer.unref === "function") timer.unref();
|
|
897
|
+
return function() {
|
|
898
|
+
alive = false;
|
|
899
|
+
clearInterval(timer);
|
|
900
|
+
};
|
|
901
|
+
}, [tick[0]]);
|
|
902
|
+
return {
|
|
903
|
+
ready: st[0].ready,
|
|
904
|
+
locked: st[0].locked,
|
|
905
|
+
initialized: st[0].initialized,
|
|
906
|
+
error: st[0].error,
|
|
907
|
+
refresh: function() {
|
|
908
|
+
tick[1](tick[0] + 1);
|
|
909
|
+
}
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
function Panel(props) {
|
|
913
|
+
var h = props.h;
|
|
914
|
+
var C = props.C;
|
|
915
|
+
var lang = props.lang === "en" ? "en" : "zh";
|
|
916
|
+
var Icon2 = props.Icon || cfg.Icon || null;
|
|
917
|
+
function pick(custom, fallback) {
|
|
918
|
+
var v = custom !== void 0 ? custom : fallback;
|
|
919
|
+
if (v && typeof v === "object") return v[lang] || v.zh || v.en || "";
|
|
920
|
+
return v || "";
|
|
921
|
+
}
|
|
922
|
+
return h(
|
|
923
|
+
"div",
|
|
924
|
+
{ className: props.wrapClass || wrapClass },
|
|
925
|
+
h(
|
|
926
|
+
"div",
|
|
927
|
+
{ className: prefix + "-lock-card", role: "status", "aria-live": "polite" },
|
|
928
|
+
Icon2 ? h(Icon2, { size: 22, strokeWidth: 2, "aria-hidden": "true", className: prefix + "-lock-ico" }) : null,
|
|
929
|
+
h("div", { className: prefix + "-lock-title" }, pick(props.title, cfg.title)),
|
|
930
|
+
h("div", { className: prefix + "-muted" }, pick(props.hint, cfg.hint)),
|
|
931
|
+
props.error ? h(C.Notice, { h, kind: "error", text: props.error }) : null
|
|
932
|
+
)
|
|
933
|
+
);
|
|
934
|
+
}
|
|
935
|
+
function styles() {
|
|
936
|
+
return [
|
|
937
|
+
"." + prefix + "-lock-card{max-width:560px;margin:28px auto;padding:26px 24px;border:1px solid var(--wb-border);border-radius:12px;background:var(--wb-card);display:flex;flex-direction:column;gap:8px;align-items:flex-start}",
|
|
938
|
+
"." + prefix + "-lock-ico{color:var(--wb-muted)}",
|
|
939
|
+
"." + prefix + "-lock-title{font-size:15px;font-weight:600}"
|
|
940
|
+
];
|
|
941
|
+
}
|
|
942
|
+
return lock;
|
|
943
|
+
}
|
|
944
|
+
module2.exports = { create, POLL_MS };
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
|
|
847
948
|
// packages/addons/lib/filter-checklist-styles.cjs
|
|
848
949
|
var require_filter_checklist_styles = __commonJS({
|
|
849
950
|
"packages/addons/lib/filter-checklist-styles.cjs"(exports2, module2) {
|
|
@@ -1005,11 +1106,257 @@ var require_styles = __commonJS({
|
|
|
1005
1106
|
".wbv-empty-title{font-size:14px;font-weight:600}",
|
|
1006
1107
|
".wbv-check-list{display:flex;flex-wrap:wrap;gap:6px 14px;margin:4px 0}",
|
|
1007
1108
|
".wbv-check{display:inline-flex;align-items:center;gap:6px;font-size:12px;cursor:pointer}",
|
|
1008
|
-
".wbv-dot{width:8px;height:8px;border-radius:50%;display:inline-block;flex:none}"
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1109
|
+
".wbv-dot{width:8px;height:8px;border-radius:50%;display:inline-block;flex:none}"
|
|
1110
|
+
].concat(require_vault_lock().create({ prefix: "wbv" }).styles()).concat(require_filter_checklist_styles()).concat(require_client_base_styles().secretFieldStyles, require_icon_label().styles);
|
|
1111
|
+
}
|
|
1112
|
+
});
|
|
1113
|
+
|
|
1114
|
+
// packages/addons/lib/switch.cjs
|
|
1115
|
+
var require_switch = __commonJS({
|
|
1116
|
+
"packages/addons/lib/switch.cjs"(exports2, module2) {
|
|
1117
|
+
"use strict";
|
|
1118
|
+
var SWITCH_STYLES = [
|
|
1119
|
+
".wbctl-switch{display:inline-flex;align-items:center;gap:7px;min-height:24px;padding:2px;border:0;background:transparent;font:inherit;font-size:12px;color:var(--wb-muted,#6b7280);cursor:pointer;user-select:none;border-radius:999px}",
|
|
1120
|
+
".wbctl-switch-track{position:relative;display:inline-flex;align-items:center;box-sizing:border-box;width:34px;height:20px;padding:2px;border-radius:999px;background:color-mix(in oklab,currentColor 22%,transparent);transition:background .16s ease;flex:none}",
|
|
1121
|
+
".wbctl-switch-knob{display:block;width:16px;height:16px;border-radius:50%;background:var(--wb-card,#fff);box-shadow:0 1px 2px rgba(0,0,0,.25);transition:transform .16s ease}",
|
|
1122
|
+
".wbctl-switch[aria-checked=true]{color:var(--wb-accent,#2563eb)}",
|
|
1123
|
+
".wbctl-switch[aria-checked=true] .wbctl-switch-track{background:var(--wb-accent,#2563eb)}",
|
|
1124
|
+
".wbctl-switch[aria-checked=true] .wbctl-switch-knob{transform:translateX(14px)}",
|
|
1125
|
+
".wbctl-switch:hover:not(:disabled) .wbctl-switch-track{outline:1px solid var(--wb-accent,#2563eb)}",
|
|
1126
|
+
".wbctl-switch:focus-visible{outline:2px solid var(--wb-accent,#2563eb);outline-offset:2px}",
|
|
1127
|
+
".wbctl-switch:disabled{opacity:.45;cursor:not-allowed}",
|
|
1128
|
+
".wbctl-switch-text{white-space:nowrap}",
|
|
1129
|
+
"@media (prefers-reduced-motion:reduce){.wbctl-switch-track,.wbctl-switch-knob{transition:none}}"
|
|
1130
|
+
];
|
|
1131
|
+
function Switch(props) {
|
|
1132
|
+
var h = props.h;
|
|
1133
|
+
var on = props.checked === true || props.checked === "true";
|
|
1134
|
+
var disabled = !!props.disabled;
|
|
1135
|
+
var text = props.label;
|
|
1136
|
+
if (props.showState) text = on ? props.onText || "\u5F00" : props.offText || "\u5173";
|
|
1137
|
+
return h(
|
|
1138
|
+
"button",
|
|
1139
|
+
{
|
|
1140
|
+
type: "button",
|
|
1141
|
+
role: "switch",
|
|
1142
|
+
"aria-checked": on ? "true" : "false",
|
|
1143
|
+
className: "wbctl-switch" + (props.className ? " " + props.className : ""),
|
|
1144
|
+
disabled,
|
|
1145
|
+
title: props.title,
|
|
1146
|
+
"aria-label": text ? void 0 : props.ariaLabel,
|
|
1147
|
+
onClick: function(e) {
|
|
1148
|
+
e.preventDefault();
|
|
1149
|
+
if (disabled) return;
|
|
1150
|
+
if (typeof props.onChange === "function") props.onChange(!on);
|
|
1151
|
+
}
|
|
1152
|
+
},
|
|
1153
|
+
h(
|
|
1154
|
+
"span",
|
|
1155
|
+
{ className: "wbctl-switch-track", "aria-hidden": "true" },
|
|
1156
|
+
h("span", { className: "wbctl-switch-knob" })
|
|
1157
|
+
),
|
|
1158
|
+
text ? h("span", { className: "wbctl-switch-text" }, text) : null
|
|
1159
|
+
);
|
|
1160
|
+
}
|
|
1161
|
+
module2.exports = { Switch, styles: SWITCH_STYLES };
|
|
1162
|
+
}
|
|
1163
|
+
});
|
|
1164
|
+
|
|
1165
|
+
// packages/addons/lib/number-field.cjs
|
|
1166
|
+
var require_number_field = __commonJS({
|
|
1167
|
+
"packages/addons/lib/number-field.cjs"(exports2, module2) {
|
|
1168
|
+
"use strict";
|
|
1169
|
+
var React = require("react");
|
|
1170
|
+
var NUM = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/;
|
|
1171
|
+
var TEXT = {
|
|
1172
|
+
zh: {
|
|
1173
|
+
required: "\u8BF7\u586B\u5199\u6570\u5B57",
|
|
1174
|
+
invalid: "\u8BF7\u8F93\u5165\u6570\u5B57",
|
|
1175
|
+
integer: "\u9700\u8981\u662F\u6574\u6570",
|
|
1176
|
+
min: "\u4E0D\u80FD\u5C0F\u4E8E {min}",
|
|
1177
|
+
max: "\u4E0D\u80FD\u5927\u4E8E {max}",
|
|
1178
|
+
range: "\u9700\u8981\u5728 {min}\u2013{max} \u4E4B\u95F4",
|
|
1179
|
+
step: "\u9700\u8981\u662F {step} \u7684\u500D\u6570",
|
|
1180
|
+
unit: "\u5355\u4F4D"
|
|
1181
|
+
},
|
|
1182
|
+
en: {
|
|
1183
|
+
required: "Please enter a number",
|
|
1184
|
+
invalid: "Please enter a number",
|
|
1185
|
+
integer: "Must be a whole number",
|
|
1186
|
+
min: "Must be at least {min}",
|
|
1187
|
+
max: "Must be at most {max}",
|
|
1188
|
+
range: "Must be between {min} and {max}",
|
|
1189
|
+
step: "Must be a multiple of {step}",
|
|
1190
|
+
unit: "unit"
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
function messages(lang) {
|
|
1194
|
+
return lang === "en" ? TEXT.en : TEXT.zh;
|
|
1195
|
+
}
|
|
1196
|
+
function fill(text, vars) {
|
|
1197
|
+
return String(text).replace(/\{(\w+)\}/g, function(m, key) {
|
|
1198
|
+
return vars && vars[key] !== void 0 ? String(vars[key]) : m;
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
function validateNumber(raw, opts) {
|
|
1202
|
+
var o = opts || {};
|
|
1203
|
+
var M = messages(o.lang);
|
|
1204
|
+
var text = raw === null || raw === void 0 ? "" : String(raw).trim();
|
|
1205
|
+
if (text === "") {
|
|
1206
|
+
return o.allowEmpty ? { ok: true, value: null, error: "" } : { ok: false, value: null, error: M.required };
|
|
1207
|
+
}
|
|
1208
|
+
if (!NUM.test(text)) return { ok: false, value: null, error: M.invalid };
|
|
1209
|
+
var n = Number(text);
|
|
1210
|
+
if (!isFinite(n)) return { ok: false, value: null, error: M.invalid };
|
|
1211
|
+
if (o.integer && Math.round(n) !== n) return { ok: false, value: null, error: M.integer };
|
|
1212
|
+
var hasMin = o.min !== void 0 && o.min !== null && o.min !== "";
|
|
1213
|
+
var hasMax = o.max !== void 0 && o.max !== null && o.max !== "";
|
|
1214
|
+
if (hasMin && hasMax && n >= o.min && n <= o.max) {
|
|
1215
|
+
} else if (hasMin && hasMax) {
|
|
1216
|
+
return { ok: false, value: null, error: fill(M.range, { min: o.min, max: o.max }) };
|
|
1217
|
+
} else if (hasMin && n < o.min) {
|
|
1218
|
+
return { ok: false, value: null, error: fill(M.min, { min: o.min }) };
|
|
1219
|
+
} else if (hasMax && n > o.max) {
|
|
1220
|
+
return { ok: false, value: null, error: fill(M.max, { max: o.max }) };
|
|
1221
|
+
}
|
|
1222
|
+
if (o.step && Number(o.step) > 0) {
|
|
1223
|
+
var q = n / Number(o.step);
|
|
1224
|
+
if (Math.abs(q - Math.round(q)) > 1e-9) {
|
|
1225
|
+
return { ok: false, value: null, error: fill(M.step, { step: o.step }) };
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
return { ok: true, value: n, error: "" };
|
|
1229
|
+
}
|
|
1230
|
+
function rangeHint(opts, lang) {
|
|
1231
|
+
var o = opts || {};
|
|
1232
|
+
var M = messages(lang);
|
|
1233
|
+
var en = lang === "en";
|
|
1234
|
+
var hasMin = o.min !== void 0 && o.min !== null && o.min !== "";
|
|
1235
|
+
var hasMax = o.max !== void 0 && o.max !== null && o.max !== "";
|
|
1236
|
+
var parts = [];
|
|
1237
|
+
if (hasMin && hasMax) parts.push(String(o.min) + "\u2013" + String(o.max));
|
|
1238
|
+
else if (hasMin) parts.push((en ? "\u2265 " : "\u2265 ") + String(o.min));
|
|
1239
|
+
else if (hasMax) parts.push((en ? "\u2264 " : "\u2264 ") + String(o.max));
|
|
1240
|
+
if (o.integer) parts.push(en ? "whole numbers" : "\u6574\u6570");
|
|
1241
|
+
else if (o.step && Number(o.step) > 0) parts.push((en ? "step " : "\u6B65\u957F ") + String(o.step));
|
|
1242
|
+
return parts.join(en ? ", " : "\uFF0C");
|
|
1243
|
+
}
|
|
1244
|
+
function NumberField(props) {
|
|
1245
|
+
var h = props.h || React.createElement;
|
|
1246
|
+
var lang = props.lang;
|
|
1247
|
+
var M = messages(lang);
|
|
1248
|
+
var text = props.value === null || props.value === void 0 ? "" : String(props.value);
|
|
1249
|
+
var draftS = React.useState(text);
|
|
1250
|
+
var draft = draftS[0];
|
|
1251
|
+
var setDraft = draftS[1];
|
|
1252
|
+
var focusS = React.useState(false);
|
|
1253
|
+
var focused = focusS[0];
|
|
1254
|
+
var setFocused = focusS[1];
|
|
1255
|
+
var errS = React.useState("");
|
|
1256
|
+
var err = errS[0];
|
|
1257
|
+
var setErr = errS[1];
|
|
1258
|
+
var lastRef = React.useRef(text);
|
|
1259
|
+
var skipBlurRef = React.useRef(false);
|
|
1260
|
+
React.useEffect(
|
|
1261
|
+
function() {
|
|
1262
|
+
if (focused) return;
|
|
1263
|
+
if (lastRef.current === text) return;
|
|
1264
|
+
lastRef.current = text;
|
|
1265
|
+
setDraft(text);
|
|
1266
|
+
setErr("");
|
|
1267
|
+
},
|
|
1268
|
+
[text, focused]
|
|
1269
|
+
);
|
|
1270
|
+
function commit(raw) {
|
|
1271
|
+
var r = validateNumber(raw, props);
|
|
1272
|
+
if (!r.ok) {
|
|
1273
|
+
setErr(r.error);
|
|
1274
|
+
if (typeof props.onValidChange === "function") props.onValidChange(false, r.error);
|
|
1275
|
+
return false;
|
|
1276
|
+
}
|
|
1277
|
+
setErr("");
|
|
1278
|
+
if (typeof props.onValidChange === "function") props.onValidChange(true, "");
|
|
1279
|
+
var cur = props.value === null || props.value === void 0 ? null : Number(props.value);
|
|
1280
|
+
if (r.value !== cur) {
|
|
1281
|
+
lastRef.current = r.value === null ? "" : String(r.value);
|
|
1282
|
+
if (typeof props.onCommit === "function") props.onCommit(r.value);
|
|
1283
|
+
}
|
|
1284
|
+
return true;
|
|
1285
|
+
}
|
|
1286
|
+
var hint = props.hint !== void 0 ? props.hint : rangeHint(props, lang);
|
|
1287
|
+
var shown = props.hint === false ? "" : hint;
|
|
1288
|
+
return h(
|
|
1289
|
+
"span",
|
|
1290
|
+
{ className: "wbctl-num" + (props.wide ? " is-wide" : "") + (props.className ? " " + props.className : "") },
|
|
1291
|
+
h(
|
|
1292
|
+
"span",
|
|
1293
|
+
{ className: "wbctl-num-box" },
|
|
1294
|
+
h("input", {
|
|
1295
|
+
className: "wbctl-num-input" + (err ? " is-invalid" : ""),
|
|
1296
|
+
type: "text",
|
|
1297
|
+
inputMode: props.integer || Number(props.step) === 1 ? "numeric" : "decimal",
|
|
1298
|
+
value: draft,
|
|
1299
|
+
disabled: !!props.disabled,
|
|
1300
|
+
placeholder: props.placeholder,
|
|
1301
|
+
title: props.title,
|
|
1302
|
+
"aria-label": props.ariaLabel,
|
|
1303
|
+
"aria-invalid": err ? "true" : void 0,
|
|
1304
|
+
onFocus: function() {
|
|
1305
|
+
setFocused(true);
|
|
1306
|
+
},
|
|
1307
|
+
onChange: function(e) {
|
|
1308
|
+
setDraft(e.target.value);
|
|
1309
|
+
if (err) setErr("");
|
|
1310
|
+
if (typeof props.onDraft === "function") props.onDraft(e.target.value);
|
|
1311
|
+
},
|
|
1312
|
+
onBlur: function() {
|
|
1313
|
+
setFocused(false);
|
|
1314
|
+
if (skipBlurRef.current) {
|
|
1315
|
+
skipBlurRef.current = false;
|
|
1316
|
+
return;
|
|
1317
|
+
}
|
|
1318
|
+
commit(draft);
|
|
1319
|
+
},
|
|
1320
|
+
onKeyDown: function(e) {
|
|
1321
|
+
if (e.key === "Enter") {
|
|
1322
|
+
e.preventDefault();
|
|
1323
|
+
if (e.target && e.target.blur) e.target.blur();
|
|
1324
|
+
} else if (e.key === "Escape") {
|
|
1325
|
+
e.preventDefault();
|
|
1326
|
+
skipBlurRef.current = true;
|
|
1327
|
+
setDraft(text);
|
|
1328
|
+
setErr("");
|
|
1329
|
+
if (e.target && e.target.blur) e.target.blur();
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
}),
|
|
1333
|
+
props.unit ? h("span", { className: "wbctl-num-unit" }, props.unit) : null
|
|
1334
|
+
),
|
|
1335
|
+
err ? h("span", { className: "wbctl-num-err", role: "alert" }, err) : shown ? h("span", { className: "wbctl-num-hint" }, shown) : null
|
|
1336
|
+
);
|
|
1337
|
+
}
|
|
1338
|
+
var NUMBER_STYLES = [
|
|
1339
|
+
".wbctl-num{display:inline-flex;flex-direction:column;gap:3px;min-width:0;max-width:100%}",
|
|
1340
|
+
".wbctl-num.is-wide{display:flex;width:100%}",
|
|
1341
|
+
".wbctl-num-box{display:inline-flex;align-items:center;gap:6px;min-width:0}",
|
|
1342
|
+
".wbctl-num-input{box-sizing:border-box;width:96px;min-width:0;padding:6px 9px;border:1px solid var(--wb-line,rgba(127,127,127,.35));border-radius:6px;background:var(--wb-surface,var(--wb-card,transparent));color:inherit;font:inherit;font-size:13px;font-variant-numeric:tabular-nums;transition:border-color .14s ease,outline-color .14s ease}",
|
|
1343
|
+
".wbctl-num-input:hover:not(:disabled){border-color:var(--wb-border,var(--wb-line))}",
|
|
1344
|
+
".wbctl-num-input:focus{outline:2px solid color-mix(in oklab,var(--wb-accent,#2563eb) 55%,transparent);outline-offset:1px;border-color:var(--wb-accent,#2563eb)}",
|
|
1345
|
+
".wbctl-num-input.is-invalid{border-color:var(--wb-danger,#dc2626)}",
|
|
1346
|
+
".wbctl-num-input.is-invalid:focus{outline-color:color-mix(in oklab,var(--wb-danger,#dc2626) 55%,transparent)}",
|
|
1347
|
+
".wbctl-num-input:disabled{opacity:.5;cursor:not-allowed}",
|
|
1348
|
+
".wbctl-num-unit{color:var(--wb-muted,inherit);font-size:12px;white-space:nowrap}",
|
|
1349
|
+
".wbctl-num-hint{color:var(--wb-muted,inherit);font-size:11px;line-height:1.4}",
|
|
1350
|
+
".wbctl-num-err{color:var(--wb-danger,#dc2626);font-size:11px;line-height:1.4}",
|
|
1351
|
+
"@media (prefers-reduced-motion:reduce){.wbctl-num-input{transition:none}}"
|
|
1352
|
+
];
|
|
1353
|
+
module2.exports = {
|
|
1354
|
+
NumberField,
|
|
1355
|
+
validateNumber,
|
|
1356
|
+
rangeHint,
|
|
1357
|
+
messages,
|
|
1358
|
+
styles: NUMBER_STYLES
|
|
1359
|
+
};
|
|
1013
1360
|
}
|
|
1014
1361
|
});
|
|
1015
1362
|
|
|
@@ -1119,6 +1466,11 @@ var require_client_common = __commonJS({
|
|
|
1119
1466
|
call,
|
|
1120
1467
|
errText,
|
|
1121
1468
|
fmtTime,
|
|
1469
|
+
Switch: require_switch().Switch,
|
|
1470
|
+
switchStyles: require_switch().styles,
|
|
1471
|
+
NumberField: require_number_field().NumberField,
|
|
1472
|
+
numberFieldStyles: require_number_field().styles,
|
|
1473
|
+
validateNumber: require_number_field().validateNumber,
|
|
1122
1474
|
Btn,
|
|
1123
1475
|
Field,
|
|
1124
1476
|
Notice,
|
|
@@ -1644,75 +1996,15 @@ var require_status = __commonJS({
|
|
|
1644
1996
|
var require_lock = __commonJS({
|
|
1645
1997
|
"packages/addons/vault/client/ui/lock.cjs"(exports2, module2) {
|
|
1646
1998
|
"use strict";
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
var st = React.useState({ ready: false, locked: true, initialized: false, error: "" });
|
|
1655
|
-
var tick = React.useState(0);
|
|
1656
|
-
function read() {
|
|
1657
|
-
return C.call(api, "vault.status").then(function(data) {
|
|
1658
|
-
st[1](function(old) {
|
|
1659
|
-
var next = {
|
|
1660
|
-
ready: true,
|
|
1661
|
-
locked: !(data && data.locked === false),
|
|
1662
|
-
initialized: !!(data && data.initialized),
|
|
1663
|
-
error: ""
|
|
1664
|
-
};
|
|
1665
|
-
if (old.ready === next.ready && old.locked === next.locked && old.initialized === next.initialized && !old.error) return old;
|
|
1666
|
-
return next;
|
|
1667
|
-
});
|
|
1668
|
-
}).catch(function(e) {
|
|
1669
|
-
st[1](function(old) {
|
|
1670
|
-
return Object.assign({}, old, { ready: true, locked: true, error: C.errText(e) });
|
|
1671
|
-
});
|
|
1672
|
-
});
|
|
1999
|
+
module2.exports = require_vault_lock().create({
|
|
2000
|
+
prefix: "wbv",
|
|
2001
|
+
Icon: require_icons2().ICONS.lock,
|
|
2002
|
+
title: { zh: "\u4FDD\u9669\u7BB1\u5DF2\u9501\u5B9A", en: "Vault is locked" },
|
|
2003
|
+
hint: {
|
|
2004
|
+
zh: "\u8BF7\u5148\u5728\u300C\u4FDD\u9669\u7BB1\u300D\u9875\u89E3\u9501\uFF1B\u89E3\u9501\u540E\u672C\u9875\u4F1A\u81EA\u52A8\u6062\u590D\u5217\u8868\u4E0E\u8BE6\u60C5\u3002",
|
|
2005
|
+
en: "Unlock it on the Vault page first; this page recovers automatically once unlocked."
|
|
1673
2006
|
}
|
|
1674
|
-
|
|
1675
|
-
var alive = true;
|
|
1676
|
-
function poll() {
|
|
1677
|
-
if (alive) read();
|
|
1678
|
-
}
|
|
1679
|
-
poll();
|
|
1680
|
-
var timer = setInterval(poll, every);
|
|
1681
|
-
if (timer && typeof timer.unref === "function") timer.unref();
|
|
1682
|
-
return function() {
|
|
1683
|
-
alive = false;
|
|
1684
|
-
clearInterval(timer);
|
|
1685
|
-
};
|
|
1686
|
-
}, [tick[0]]);
|
|
1687
|
-
return {
|
|
1688
|
-
ready: st[0].ready,
|
|
1689
|
-
locked: st[0].locked,
|
|
1690
|
-
initialized: st[0].initialized,
|
|
1691
|
-
error: st[0].error,
|
|
1692
|
-
refresh: function() {
|
|
1693
|
-
tick[1](tick[0] + 1);
|
|
1694
|
-
}
|
|
1695
|
-
};
|
|
1696
|
-
}
|
|
1697
|
-
function Panel(props) {
|
|
1698
|
-
var h = props.h;
|
|
1699
|
-
var C = props.C;
|
|
1700
|
-
var en = props.lang === "en";
|
|
1701
|
-
return h(
|
|
1702
|
-
"div",
|
|
1703
|
-
{ className: "wbv" },
|
|
1704
|
-
h(
|
|
1705
|
-
"div",
|
|
1706
|
-
{ className: "wbv-lock-card", role: "status", "aria-live": "polite" },
|
|
1707
|
-
h(GLYPHS2.lock, { size: 22, strokeWidth: 2, "aria-hidden": "true", className: "wbv-lock-ico" }),
|
|
1708
|
-
h("div", { className: "wbv-lock-title" }, en ? "Vault is locked" : "\u4FDD\u9669\u7BB1\u5DF2\u9501\u5B9A"),
|
|
1709
|
-
h("div", { className: "wbv-muted" }, en ? "Unlock it on the Vault page first; this page recovers automatically once unlocked." : "\u8BF7\u5148\u5728\u300C\u4FDD\u9669\u7BB1\u300D\u9875\u89E3\u9501\uFF1B\u89E3\u9501\u540E\u672C\u9875\u4F1A\u81EA\u52A8\u6062\u590D\u5217\u8868\u4E0E\u8BE6\u60C5\u3002"),
|
|
1710
|
-
props.error ? h(C.Notice, { h, kind: "error", text: props.error }) : null
|
|
1711
|
-
)
|
|
1712
|
-
);
|
|
1713
|
-
}
|
|
1714
|
-
var obj = { use: useVaultLock, Panel, POLL_MS };
|
|
1715
|
-
module2.exports = obj;
|
|
2007
|
+
});
|
|
1716
2008
|
}
|
|
1717
2009
|
});
|
|
1718
2010
|
|
|
@@ -3626,13 +3918,6 @@ var require_data_style = __commonJS({
|
|
|
3626
3918
|
"." + P + "-search input:focus{border-color:var(--dsw-alias-brand-primary,currentColor);box-shadow:0 0 0 3px color-mix(in oklab,var(--dsw-alias-brand-primary,currentColor) 14%,transparent)}",
|
|
3627
3919
|
"." + P + "-select{border:1px solid var(--cfg-line);background:var(--dsw-alias-bg-base,transparent);color:inherit;border-radius:9px;padding:7px 10px;font:inherit;font-size:12px;outline:none}",
|
|
3628
3920
|
"." + P + "-select:focus{border-color:var(--dsw-alias-brand-primary,currentColor);box-shadow:0 0 0 3px color-mix(in oklab,var(--dsw-alias-brand-primary,currentColor) 14%,transparent)}",
|
|
3629
|
-
"." + P + "-switch{position:relative;display:inline-flex;align-items:center;gap:7px;cursor:pointer;font-size:12px;color:var(--cfg-muted);user-select:none;padding:4px 2px}",
|
|
3630
|
-
"." + P + "-switch input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer}",
|
|
3631
|
-
"." + P + "-track{position:relative;width:34px;height:20px;border-radius:999px;background:color-mix(in oklab,currentColor 18%,transparent);transition:background .16s ease;flex:none}",
|
|
3632
|
-
"." + P + "-track::after{content:'';position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:50%;background:var(--dsw-alias-label-primary,currentColor);transition:transform .16s ease,background .16s ease}",
|
|
3633
|
-
"." + P + "-switch input:checked+." + P + "-track{background:var(--dsw-alias-brand-primary,currentColor)}",
|
|
3634
|
-
"." + P + "-switch input:checked+." + P + "-track::after{transform:translateX(14px);background:var(--dsw-alias-label-primary-inverted,var(--dsw-alias-bg-base))}",
|
|
3635
|
-
"." + P + "-switch input:focus-visible+." + P + "-track{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
|
|
3636
3921
|
"." + P + "-btn{display:inline-flex;align-items:center;gap:5px;border:1px solid var(--cfg-line);background:transparent;color:var(--cfg-muted);border-radius:8px;padding:6px 10px;font:inherit;font-size:11.5px;cursor:pointer;white-space:nowrap;transition:background .12s ease,color .12s ease}",
|
|
3637
3922
|
"." + P + "-btn:hover{background:var(--cfg-hover);color:var(--dsw-alias-label-primary,inherit)}",
|
|
3638
3923
|
"." + P + "-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
|
|
@@ -3661,8 +3946,8 @@ var require_data_style = __commonJS({
|
|
|
3661
3946
|
"." + P + "-foot{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding-top:2px;font-size:11.5px;color:var(--cfg-muted)}",
|
|
3662
3947
|
"." + P + "-grow{flex:1}",
|
|
3663
3948
|
"." + P + "-pageinfo{font-variant-numeric:tabular-nums}",
|
|
3664
|
-
"." + P + "-jump{width:56px;
|
|
3665
|
-
"." + P + "-jump
|
|
3949
|
+
"." + P + "-jump .wbctl-num-input{width:56px;padding:4px 7px;font-size:11.5px;text-align:right}",
|
|
3950
|
+
"." + P + "-jump .wbctl-num-hint{display:none}",
|
|
3666
3951
|
"." + P + "-empty{border:1px dashed var(--cfg-line);border-radius:11px;padding:44px 16px;text-align:center;font-size:12.5px;color:var(--cfg-muted)}",
|
|
3667
3952
|
"." + P + "-err{display:flex;align-items:center;gap:10px;flex-wrap:wrap;border:1px solid color-mix(in oklab,var(--dsw-alias-state-error-primary,currentColor) 32%,var(--cfg-line));border-radius:10px;padding:9px 12px;color:var(--dsw-alias-state-error-primary,inherit);font-size:12px;line-height:1.5}",
|
|
3668
3953
|
"." + P + "-skwrap{display:flex;flex-direction:column;gap:1px;padding:2px}",
|
|
@@ -3700,7 +3985,7 @@ var require_data_style = __commonJS({
|
|
|
3700
3985
|
"." + P + "-images img{width:36px;height:36px;object-fit:cover;border-radius:5px}",
|
|
3701
3986
|
"." + P + "-gallery{display:flex;flex-direction:column;gap:12px;overflow:auto;flex:1}",
|
|
3702
3987
|
"." + P + "-gallery img{width:100%;height:auto;object-fit:contain;border-radius:8px}"
|
|
3703
|
-
].join("\n");
|
|
3988
|
+
].concat(require_switch().styles).concat(require_number_field().styles).join("\n");
|
|
3704
3989
|
if (DOMAIN === "storage") {
|
|
3705
3990
|
var buttons = "." + P + " :is(button)";
|
|
3706
3991
|
CSS += buttons + "{border:none;background:var(--wb-btn-bg);min-height:var(--wb-btn-size-sm);min-width:var(--wb-btn-size-sm)}" + buttons + ":enabled:hover{background:var(--wb-btn-hover-bg)}" + buttons + ":enabled:active{background:var(--wb-btn-active-bg)}" + buttons + ":disabled{background:var(--wb-btn-bg);color:var(--cfg-muted)}" + buttons + ":focus-visible{outline:var(--wb-btn-focus);outline-offset:var(--wb-btn-focus-offset)}." + P + "-fcell:has(button) input{padding-right:34px}";
|
|
@@ -3728,8 +4013,10 @@ var require_data_view = __commonJS({
|
|
|
3728
4013
|
"packages/addons/lib/data-view.cjs"(exports2, module2) {
|
|
3729
4014
|
"use strict";
|
|
3730
4015
|
var React = require("react");
|
|
4016
|
+
var NF = require_number_field();
|
|
3731
4017
|
var h = React.createElement;
|
|
3732
4018
|
var COPY = require_data_copy();
|
|
4019
|
+
var SW = require_switch();
|
|
3733
4020
|
module2.exports = function createDataView(options) {
|
|
3734
4021
|
var DOMAIN = options.domain;
|
|
3735
4022
|
function icon(name) {
|
|
@@ -4283,17 +4570,18 @@ var require_data_view = __commonJS({
|
|
|
4283
4570
|
h("button", { type: "button", className: P + "-btn", disabled: !data || page >= pages, onClick: function() {
|
|
4284
4571
|
setPage(Math.min(pages, page + 1));
|
|
4285
4572
|
} }, t.next + " \u203A"),
|
|
4286
|
-
h(
|
|
4573
|
+
h(NF.NumberField, {
|
|
4574
|
+
h,
|
|
4575
|
+
lang,
|
|
4287
4576
|
className: P + "-jump",
|
|
4288
|
-
|
|
4577
|
+
value: page,
|
|
4289
4578
|
min: 1,
|
|
4290
4579
|
max: pages,
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
}
|
|
4580
|
+
integer: true,
|
|
4581
|
+
ariaLabel: t.jump,
|
|
4582
|
+
hint: false,
|
|
4583
|
+
onCommit: function(next) {
|
|
4584
|
+
if (next !== null) setPage(next);
|
|
4297
4585
|
}
|
|
4298
4586
|
}),
|
|
4299
4587
|
data && data.queryMs !== void 0 ? h("span", null, fmt(t.queryTime, { n: data.queryMs })) : null
|
|
@@ -4390,25 +4678,23 @@ var require_data_view = __commonJS({
|
|
|
4390
4678
|
}
|
|
4391
4679
|
})
|
|
4392
4680
|
),
|
|
4393
|
-
h(
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4681
|
+
h(SW.Switch, {
|
|
4682
|
+
h,
|
|
4683
|
+
checked: includeDeleted,
|
|
4684
|
+
label: t.includeDeleted,
|
|
4685
|
+
onChange: function(next) {
|
|
4686
|
+
setIncludeDeleted(next);
|
|
4398
4687
|
setPage(1);
|
|
4399
|
-
}
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
h("span", { className: P + "-track" }),
|
|
4410
|
-
h("span", null, t.showSystem)
|
|
4411
|
-
),
|
|
4688
|
+
}
|
|
4689
|
+
}),
|
|
4690
|
+
h(SW.Switch, {
|
|
4691
|
+
h,
|
|
4692
|
+
checked: showSystem,
|
|
4693
|
+
label: t.showSystem,
|
|
4694
|
+
onChange: function(next) {
|
|
4695
|
+
setShowSystem(next);
|
|
4696
|
+
}
|
|
4697
|
+
}),
|
|
4412
4698
|
h("span", { className: P + "-grow" }),
|
|
4413
4699
|
h(
|
|
4414
4700
|
"label",
|
|
@@ -4566,16 +4852,13 @@ var require_action_schema_style = __commonJS({
|
|
|
4566
4852
|
"." + P + "-cardmeta{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0;min-height:24px}",
|
|
4567
4853
|
"." + P + "-cardhead code{font-weight:640;overflow-wrap:anywhere;min-width:0}",
|
|
4568
4854
|
"." + P + "-hintline{margin:0;color:var(--dsw-alias-label-tertiary,inherit);font-size:11.5px;line-height:1.5}",
|
|
4569
|
-
"." + P + "-
|
|
4570
|
-
"." + P + "-
|
|
4571
|
-
"." + P + "-
|
|
4572
|
-
|
|
4573
|
-
"." + P + "-
|
|
4574
|
-
"." + P + "-
|
|
4575
|
-
"." + P + "-
|
|
4576
|
-
"." + P + "-toggle:disabled{opacity:.6;cursor:progress}",
|
|
4577
|
-
"@media(prefers-reduced-motion:reduce){." + P + "-track::before{transition:none}}",
|
|
4578
|
-
// 安全约束(不可放开):用警示色描边,和可切换的开关区分开。
|
|
4855
|
+
"." + P + "-origins{display:inline-flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end}",
|
|
4856
|
+
"." + P + "-origins-label{font-size:11px;color:var(--wb-muted);white-space:nowrap}",
|
|
4857
|
+
"." + P + "-origin{display:inline-flex;align-items:center;gap:4px;font-size:11.5px;color:var(--wb-muted);cursor:pointer;user-select:none}",
|
|
4858
|
+
// 该 action 本身不支持的来源:整项置灰、不可点,示意「不是没开,是开不了」。
|
|
4859
|
+
"." + P + "-origin-off{opacity:.55;cursor:not-allowed}",
|
|
4860
|
+
"." + P + "-origin input[type=checkbox]{width:13px;height:13px;margin:0;accent-color:var(--wb-accent);cursor:inherit}",
|
|
4861
|
+
"." + P + "-origin input[type=checkbox]:focus-visible{outline:2px solid var(--wb-accent);outline-offset:2px}",
|
|
4579
4862
|
"." + P + "-locked{border-color:var(--wb-warn,#b7791f);color:var(--wb-warn,#b7791f)}",
|
|
4580
4863
|
"." + P + "-desc{margin:0;color:var(--dsw-alias-label-secondary,inherit);line-height:1.55;font-size:12.5px}",
|
|
4581
4864
|
// 搜索命中:用品牌色透明度叠加而不是写死浅色,深浅主题都可读;继承文字颜色、不覆盖 ::selection。
|
|
@@ -4628,15 +4911,20 @@ var require_action_schema_view = __commonJS({
|
|
|
4628
4911
|
zh: {
|
|
4629
4912
|
title: "Action",
|
|
4630
4913
|
hint: "\u8FD0\u884C\u65F6\u6CE8\u518C \xB7 \u53EA\u8BFB",
|
|
4631
|
-
switchHint: "
|
|
4632
|
-
hostHint: "\u5BBF\u4E3B action \u7684
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4914
|
+
switchHint: "\u5141\u8BB8\u6765\u6E90\u843D\u672C\u673A\u3001\u5373\u6539\u5373\u751F\u6548\uFF1A\u52FE\u4E0A\u7684\u6765\u6E90\u624D\u80FD\u8C03\u7528\u8BE5 action\uFF0C\u5176\u4F59\u4F1A\u88AB ACTION_ORIGIN_DENIED \u62E6\u4E0B\u3002",
|
|
4915
|
+
hostHint: "\u5BBF\u4E3B action \u7684\u5141\u8BB8\u6765\u6E90\uFF1B\u6807\u300C\u6765\u6E90\u56FA\u5B9A\u300D\u7684\u4E0D\u53EF\u4FEE\u6539\u3002",
|
|
4916
|
+
originsLabel: "\u5141\u8BB8\u6765\u6E90",
|
|
4917
|
+
originUi: "\u754C\u9762",
|
|
4918
|
+
originPlugin: "\u63D2\u4EF6",
|
|
4919
|
+
originAgent: "agent",
|
|
4920
|
+
originSync: "\u540C\u6B65",
|
|
4921
|
+
originsSaving: "\u4FDD\u5B58\u4E2D\u2026",
|
|
4922
|
+
originsToast: "\u5DF2\u66F4\u65B0\u5141\u8BB8\u6765\u6E90",
|
|
4923
|
+
originsFail: "\u66F4\u65B0\u5141\u8BB8\u6765\u6E90\u5931\u8D25",
|
|
4924
|
+
originsEmpty: "\u81F3\u5C11\u8981\u4FDD\u7559\u4E00\u4E2A\u6765\u6E90",
|
|
4925
|
+
originsUnsupported: "\u8BE5 action \u672C\u8EAB\u4E0D\u652F\u6301\u8FD9\u4E2A\u6765\u6E90",
|
|
4926
|
+
originsPinned: "\u6765\u6E90\u56FA\u5B9A",
|
|
4927
|
+
originsPinnedHint: "\u8BE5 action \u7684\u5141\u8BB8\u6765\u6E90\u88AB\u56FA\u5B9A\uFF08\u5B89\u5168\u7EA6\u675F\uFF09\uFF0C\u4E0D\u80FD\u4FEE\u6539",
|
|
4640
4928
|
domain: "\u57DF",
|
|
4641
4929
|
versionLabel: "\u7248\u672C",
|
|
4642
4930
|
shell: "\u5BBF\u4E3B",
|
|
@@ -4650,6 +4938,8 @@ var require_action_schema_view = __commonJS({
|
|
|
4650
4938
|
onlyOptional: "\u65E0\u5FC5\u586B\u9879",
|
|
4651
4939
|
filterType: "\u53C2\u6570\u7C7B\u578B",
|
|
4652
4940
|
allTypes: "\u5168\u90E8\u7C7B\u578B",
|
|
4941
|
+
filterOrigin: "\u5141\u8BB8\u6765\u6E90",
|
|
4942
|
+
allOrigins: "\u5168\u90E8\u6765\u6E90",
|
|
4653
4943
|
colName: "\u53C2\u6570",
|
|
4654
4944
|
colType: "\u7C7B\u578B",
|
|
4655
4945
|
colReq: "\u5FC5\u586B",
|
|
@@ -4682,15 +4972,22 @@ var require_action_schema_view = __commonJS({
|
|
|
4682
4972
|
en: {
|
|
4683
4973
|
title: "Actions",
|
|
4684
4974
|
hint: "runtime registry \xB7 read-only",
|
|
4685
|
-
switchHint: "
|
|
4686
|
-
hostHint: "
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4975
|
+
switchHint: "Allowed origins are stored locally and apply immediately: only checked origins may call the action; others get ACTION_ORIGIN_DENIED.",
|
|
4976
|
+
hostHint: "Allowed origins for host actions; items marked pinned cannot be changed.",
|
|
4977
|
+
originsLabel: "Origins",
|
|
4978
|
+
originUi: "UI",
|
|
4979
|
+
originPlugin: "Plugin",
|
|
4980
|
+
originAgent: "Agent",
|
|
4981
|
+
originSync: "Sync",
|
|
4982
|
+
originsSaving: "Saving\u2026",
|
|
4983
|
+
originsToast: "Allowed origins updated",
|
|
4984
|
+
originsFail: "Failed to update allowed origins",
|
|
4985
|
+
originsEmpty: "Keep at least one origin",
|
|
4986
|
+
originsUnsupported: "This action does not support this origin",
|
|
4987
|
+
originsPinned: "Pinned",
|
|
4988
|
+
originsPinnedHint: "Allowed origins are pinned for this action (security constraint) and cannot be changed",
|
|
4989
|
+
originsDefaultOn: "Allowed by default",
|
|
4990
|
+
originsDefaultOff: "Off by default, can be enabled",
|
|
4694
4991
|
domain: "Domain",
|
|
4695
4992
|
versionLabel: "Version",
|
|
4696
4993
|
shell: "Host",
|
|
@@ -4704,6 +5001,8 @@ var require_action_schema_view = __commonJS({
|
|
|
4704
5001
|
onlyOptional: "No required",
|
|
4705
5002
|
filterType: "Param type",
|
|
4706
5003
|
allTypes: "All types",
|
|
5004
|
+
filterOrigin: "Origins",
|
|
5005
|
+
allOrigins: "All origins",
|
|
4707
5006
|
colName: "Param",
|
|
4708
5007
|
colType: "Type",
|
|
4709
5008
|
colReq: "Required",
|
|
@@ -4847,6 +5146,8 @@ var require_action_schema_view = __commonJS({
|
|
|
4847
5146
|
var reqMode = reqState[0], setReqMode = reqState[1];
|
|
4848
5147
|
var typeState = React.useState("");
|
|
4849
5148
|
var typePick = typeState[0], setTypePick = typeState[1];
|
|
5149
|
+
var originFilterState = React.useState("");
|
|
5150
|
+
var originPick = originFilterState[0], setOriginPick = originFilterState[1];
|
|
4850
5151
|
var toastState = React.useState("");
|
|
4851
5152
|
var toast = toastState[0], setToast = toastState[1];
|
|
4852
5153
|
var savingState = React.useState("");
|
|
@@ -4902,38 +5203,53 @@ var require_action_schema_view = __commonJS({
|
|
|
4902
5203
|
plainCopy(text);
|
|
4903
5204
|
done();
|
|
4904
5205
|
}
|
|
4905
|
-
|
|
5206
|
+
var ORIGINS = ["ui", "plugin", "agent", "sync"];
|
|
5207
|
+
var originText = { ui: t.originUi, plugin: t.originPlugin, agent: t.originAgent, sync: t.originSync };
|
|
5208
|
+
function setOrigins(action, origin) {
|
|
4906
5209
|
var name = action.name;
|
|
5210
|
+
var current = Array.isArray(action.origins) ? action.origins.slice() : [];
|
|
5211
|
+
var index = current.indexOf(origin);
|
|
5212
|
+
var next = index >= 0 ? current.filter(function(o) {
|
|
5213
|
+
return o !== origin;
|
|
5214
|
+
}) : current.concat([origin]);
|
|
5215
|
+
if (next.length === 0) {
|
|
5216
|
+
setToast(t.originsEmpty);
|
|
5217
|
+
return;
|
|
5218
|
+
}
|
|
5219
|
+
next = ORIGINS.filter(function(o) {
|
|
5220
|
+
return next.indexOf(o) >= 0;
|
|
5221
|
+
});
|
|
4907
5222
|
setSaving(name);
|
|
4908
5223
|
setToast("");
|
|
4909
5224
|
var fail = function(e) {
|
|
4910
5225
|
setSaving("");
|
|
4911
|
-
setToast(t.
|
|
5226
|
+
setToast(t.originsFail + "\uFF1A" + String(e && e.message || e || ""));
|
|
4912
5227
|
};
|
|
4913
5228
|
var done = function(r) {
|
|
4914
5229
|
setSaving("");
|
|
4915
5230
|
var payload = r && typeof r === "object" && Object.prototype.hasOwnProperty.call(r, "result") ? r.result : r;
|
|
4916
5231
|
if (r && r.ok === false) {
|
|
4917
|
-
setToast(t.
|
|
5232
|
+
setToast(t.originsFail + "\uFF1A" + String(r.error || r.text || ""));
|
|
4918
5233
|
return;
|
|
4919
5234
|
}
|
|
4920
|
-
var value = payload &&
|
|
5235
|
+
var value = payload && Array.isArray(payload.origins) ? payload.origins : next;
|
|
5236
|
+
var source = payload && typeof payload.source === "string" ? payload.source : action.originsSource;
|
|
4921
5237
|
setSnap(function(prev) {
|
|
4922
5238
|
if (!prev || !Array.isArray(prev.actions)) return prev;
|
|
4923
5239
|
return Object.assign({}, prev, {
|
|
4924
5240
|
actions: prev.actions.map(function(a) {
|
|
4925
5241
|
if (!a || a.name !== name) return a;
|
|
4926
|
-
return Object.assign({}, a, {
|
|
5242
|
+
return Object.assign({}, a, { origins: value, originsSource: source });
|
|
4927
5243
|
})
|
|
4928
5244
|
});
|
|
4929
5245
|
});
|
|
4930
|
-
setToast(
|
|
5246
|
+
setToast(t.originsToast);
|
|
4931
5247
|
};
|
|
4932
5248
|
if (!api || typeof api.call !== "function") {
|
|
4933
5249
|
fail(new Error("no call api"));
|
|
4934
5250
|
return;
|
|
4935
5251
|
}
|
|
4936
|
-
Promise.resolve(api.call("actions.
|
|
5252
|
+
Promise.resolve(api.call("actions.setActionOrigins", { action: name, origins: next })).then(done, fail);
|
|
4937
5253
|
}
|
|
4938
5254
|
var all = snap && Array.isArray(snap.actions) ? snap.actions.filter(function(a) {
|
|
4939
5255
|
return a && a.domain === DOMAIN;
|
|
@@ -4968,6 +5284,7 @@ var require_action_schema_view = __commonJS({
|
|
|
4968
5284
|
if (typePick && !rows.some(function(row) {
|
|
4969
5285
|
return row.types.indexOf(typePick) >= 0;
|
|
4970
5286
|
})) return false;
|
|
5287
|
+
if (originPick && (!Array.isArray(a.origins) || a.origins.indexOf(originPick) < 0)) return false;
|
|
4971
5288
|
return true;
|
|
4972
5289
|
});
|
|
4973
5290
|
function paramRow(row) {
|
|
@@ -4983,33 +5300,45 @@ var require_action_schema_view = __commonJS({
|
|
|
4983
5300
|
h("td", null, Highlight.hit(row.description, kw))
|
|
4984
5301
|
);
|
|
4985
5302
|
}
|
|
4986
|
-
function
|
|
4987
|
-
if (action.
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
title: t.agentLockedHint,
|
|
4991
|
-
"data-agent-locked": action.name
|
|
4992
|
-
}, t.agentLocked);
|
|
5303
|
+
function originsChips(action) {
|
|
5304
|
+
if (!Array.isArray(action.origins)) return null;
|
|
5305
|
+
if (action.originsSource === "invalid") {
|
|
5306
|
+
return h("span", { className: P + "-badge " + P + "-locked", title: t.originsPinnedHint, "data-origins-invalid": action.name }, t.originsPinned);
|
|
4993
5307
|
}
|
|
4994
|
-
if (typeof action.agentEnabled !== "boolean") return null;
|
|
4995
5308
|
var busy = saving === action.name;
|
|
5309
|
+
var pinned = action.name === "actions.setActionOrigins";
|
|
5310
|
+
var supported = Array.isArray(action.originsDeclared) ? action.originsDeclared : action.origins;
|
|
4996
5311
|
return h(
|
|
4997
|
-
"
|
|
4998
|
-
{
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5312
|
+
"div",
|
|
5313
|
+
{ className: P + "-origins", "data-origins-row": action.name },
|
|
5314
|
+
h("span", { className: P + "-origins-label" }, t.originsLabel),
|
|
5315
|
+
ORIGINS.map(function(origin) {
|
|
5316
|
+
var on = action.origins.indexOf(origin) >= 0;
|
|
5317
|
+
var allowed = supported.indexOf(origin) >= 0;
|
|
5318
|
+
var preset = Array.isArray(action.originsDefault) ? action.originsDefault : supported;
|
|
5319
|
+
var byDefault = preset.indexOf(origin) >= 0;
|
|
5320
|
+
return h(
|
|
5321
|
+
"label",
|
|
5322
|
+
{
|
|
5323
|
+
key: origin,
|
|
5324
|
+
className: P + "-origin" + (allowed ? "" : " " + P + "-origin-off"),
|
|
5325
|
+
title: pinned ? t.originsPinnedHint : !allowed ? t.originsUnsupported : originText[origin] + " \xB7 " + action.name + " \xB7 " + (byDefault ? t.originsDefaultOn : t.originsDefaultOff)
|
|
5326
|
+
},
|
|
5327
|
+
h("input", {
|
|
5328
|
+
type: "checkbox",
|
|
5329
|
+
checked: on,
|
|
5330
|
+
disabled: busy || pinned || !allowed,
|
|
5331
|
+
"data-origin": origin,
|
|
5332
|
+
"data-origin-row": action.name,
|
|
5333
|
+
"data-origin-supported": allowed ? "1" : "0",
|
|
5334
|
+
onChange: function() {
|
|
5335
|
+
setOrigins(action, origin);
|
|
5336
|
+
}
|
|
5337
|
+
}),
|
|
5338
|
+
h("span", null, originText[origin])
|
|
5339
|
+
);
|
|
5340
|
+
}),
|
|
5341
|
+
busy ? h("span", { className: P + "-origins-label" }, t.originsSaving) : null
|
|
5013
5342
|
);
|
|
5014
5343
|
}
|
|
5015
5344
|
function card(action) {
|
|
@@ -5030,7 +5359,7 @@ var require_action_schema_view = __commonJS({
|
|
|
5030
5359
|
return row.required;
|
|
5031
5360
|
}) ? h("span", { className: P + "-badge " + P + "-req" }, t.required) : null
|
|
5032
5361
|
),
|
|
5033
|
-
|
|
5362
|
+
originsChips(action)
|
|
5034
5363
|
),
|
|
5035
5364
|
action.description ? h("p", { className: P + "-desc" }, Highlight.hit(action.description, kw)) : null,
|
|
5036
5365
|
rows.length ? h(
|
|
@@ -5153,6 +5482,21 @@ var require_action_schema_view = __commonJS({
|
|
|
5153
5482
|
return h("option", { value: name, key: name }, name);
|
|
5154
5483
|
})
|
|
5155
5484
|
)
|
|
5485
|
+
),
|
|
5486
|
+
h(
|
|
5487
|
+
"label",
|
|
5488
|
+
{ className: P + "-none" },
|
|
5489
|
+
t.filterOrigin + " ",
|
|
5490
|
+
h(
|
|
5491
|
+
"select",
|
|
5492
|
+
{ value: originPick, "aria-label": t.filterOrigin, "data-origin-filter": "", onChange: function(e) {
|
|
5493
|
+
setOriginPick(e.target.value);
|
|
5494
|
+
} },
|
|
5495
|
+
h("option", { value: "" }, t.allOrigins),
|
|
5496
|
+
ORIGINS.map(function(origin) {
|
|
5497
|
+
return h("option", { value: origin, key: origin }, originText[origin]);
|
|
5498
|
+
})
|
|
5499
|
+
)
|
|
5156
5500
|
)
|
|
5157
5501
|
) : null,
|
|
5158
5502
|
body,
|
|
@@ -5230,7 +5574,7 @@ var GLYPHS = require_icons2().ICONS;
|
|
|
5230
5574
|
ensureStyles();
|
|
5231
5575
|
host.registerAddon({
|
|
5232
5576
|
id: "wb-addon-vault",
|
|
5233
|
-
version: "0.3.
|
|
5577
|
+
version: "0.3.12",
|
|
5234
5578
|
icon: GLYPHS["shield-check"],
|
|
5235
5579
|
views: [
|
|
5236
5580
|
{ id: "status", icon: tabIcon("shield"), title: { zh: "\u4FDD\u9669\u7BB1", en: "Vault" }, component: withProps(require_status(), "\u4FDD\u9669\u7BB1") },
|
package/lib/domain/actions.js
CHANGED
|
@@ -23,7 +23,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
api.action("vault.setup", {
|
|
26
|
-
|
|
26
|
+
origins: ["ui"],
|
|
27
27
|
description: "首次初始化保险箱:设置口令与解锁模式 A/B/C,默认 A(每次启动锁定)。口令包裹会上云。",
|
|
28
28
|
input: {
|
|
29
29
|
type: "object",
|
|
@@ -42,7 +42,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
api.action("vault.unlock", {
|
|
45
|
-
|
|
45
|
+
origins: ["ui"],
|
|
46
46
|
description: "用主口令解锁保险箱;连续 5 次失败锁定 5 分钟。",
|
|
47
47
|
input: {
|
|
48
48
|
type: "object",
|
|
@@ -57,7 +57,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
api.action("vault.lock", {
|
|
60
|
-
|
|
60
|
+
origins: ["ui"],
|
|
61
61
|
description: "立即清除内存中的 DEK;插件后台可用它主动锁定。",
|
|
62
62
|
input: { type: "object", properties: {}, additionalProperties: false },
|
|
63
63
|
execute: (_args, ctx) => {
|
|
@@ -68,7 +68,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
api.action("vault.setUnlockMode", {
|
|
71
|
-
|
|
71
|
+
origins: ["ui"],
|
|
72
72
|
description: "切换解锁模式:A 全锁 / B 自动解锁但查看需口令 / C 自动解锁且查看免口令。",
|
|
73
73
|
input: {
|
|
74
74
|
type: "object",
|
|
@@ -86,7 +86,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
api.action("vault.changePassphrase", {
|
|
89
|
-
|
|
89
|
+
origins: ["ui"],
|
|
90
90
|
description: "修改主口令:只重包 DEK 并让 passphrase_rev 加一,不重新加密所有 secret。",
|
|
91
91
|
input: {
|
|
92
92
|
type: "object",
|
|
@@ -122,7 +122,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
122
122
|
});
|
|
123
123
|
|
|
124
124
|
api.action("vault.secretCreate", {
|
|
125
|
-
|
|
125
|
+
origins: ["ui"],
|
|
126
126
|
description: "新增凭据;secret 只在内存加密后落库,审计中该字段显示为 ***。",
|
|
127
127
|
input: {
|
|
128
128
|
type: "object",
|
|
@@ -145,7 +145,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
145
145
|
});
|
|
146
146
|
|
|
147
147
|
api.action("vault.secretUpdate", {
|
|
148
|
-
|
|
148
|
+
origins: ["ui"],
|
|
149
149
|
description: "更新名称/类型/备注或轮换明文;改名称或类型会重加密,改归属不会。",
|
|
150
150
|
input: {
|
|
151
151
|
type: "object",
|
|
@@ -168,7 +168,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
168
168
|
});
|
|
169
169
|
|
|
170
170
|
api.action("vault.secretDelete", {
|
|
171
|
-
|
|
171
|
+
origins: ["ui"],
|
|
172
172
|
description: "软删除凭据;已绑定它的连接器会在下次运行时提示凭据失效。",
|
|
173
173
|
input: {
|
|
174
174
|
type: "object",
|
|
@@ -185,7 +185,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
185
185
|
registerSetActions({ api, sets, groups, vault, only, KINDS });
|
|
186
186
|
|
|
187
187
|
api.action("vault.secretReveal", {
|
|
188
|
-
|
|
188
|
+
origins: ["ui"],
|
|
189
189
|
description: "在界面上显示一条凭据明文;B 模式必须再输口令,agent/plugin 一律拒绝。",
|
|
190
190
|
input: {
|
|
191
191
|
type: "object",
|
|
@@ -203,7 +203,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
203
203
|
});
|
|
204
204
|
|
|
205
205
|
api.action("vault.lease", {
|
|
206
|
-
|
|
206
|
+
origins: ["ui"],
|
|
207
207
|
description: "后台插件租用凭据明文,ttl 30–300 秒;只允许 plugin origin,传 subject 时校验绑定。",
|
|
208
208
|
input: {
|
|
209
209
|
type: "object",
|
|
@@ -224,7 +224,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
224
224
|
});
|
|
225
225
|
|
|
226
226
|
api.action("vault.rotateDeviceKey", {
|
|
227
|
-
|
|
227
|
+
origins: ["ui"],
|
|
228
228
|
description: "重写自动解锁的 device key 包裹;B/C 模式可用,需要主口令。",
|
|
229
229
|
input: {
|
|
230
230
|
type: "object",
|
|
@@ -252,7 +252,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
252
252
|
});
|
|
253
253
|
|
|
254
254
|
api.action("vault.groupCreate", {
|
|
255
|
-
|
|
255
|
+
origins: ["ui"],
|
|
256
256
|
description: "新建凭据分组;组名唯一。",
|
|
257
257
|
input: {
|
|
258
258
|
type: "object",
|
|
@@ -271,7 +271,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
271
271
|
});
|
|
272
272
|
|
|
273
273
|
api.action("vault.groupUpdate", {
|
|
274
|
-
|
|
274
|
+
origins: ["ui"],
|
|
275
275
|
description: "改名/描述/色标;不改动组内凭据的密文。",
|
|
276
276
|
input: {
|
|
277
277
|
type: "object",
|
|
@@ -291,7 +291,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
291
291
|
});
|
|
292
292
|
|
|
293
293
|
api.action("vault.groupDelete", {
|
|
294
|
-
|
|
294
|
+
origins: ["ui"],
|
|
295
295
|
description: "软删除分组:组内凭据移到 moveTo,未指定则移出分组;组上的绑定一并软删。",
|
|
296
296
|
input: {
|
|
297
297
|
type: "object",
|
|
@@ -309,7 +309,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
309
309
|
});
|
|
310
310
|
|
|
311
311
|
api.action("vault.subjectRegister", {
|
|
312
|
-
|
|
312
|
+
origins: ["ui"],
|
|
313
313
|
description: "业务插件注册自己的关联类型(幂等),供组详情页显示可读标题。",
|
|
314
314
|
input: {
|
|
315
315
|
type: "object",
|
|
@@ -328,7 +328,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
328
328
|
});
|
|
329
329
|
|
|
330
330
|
api.action("vault.bind", {
|
|
331
|
-
|
|
331
|
+
origins: ["ui"],
|
|
332
332
|
description: "把业务对象关联到凭据分组(重复绑定幂等);vault 不校验对象是否存在。",
|
|
333
333
|
input: {
|
|
334
334
|
type: "object",
|
|
@@ -347,7 +347,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
347
347
|
});
|
|
348
348
|
|
|
349
349
|
api.action("vault.unbind", {
|
|
350
|
-
|
|
350
|
+
origins: ["ui"],
|
|
351
351
|
description: "解除一个业务对象与分组的关联(软删)。",
|
|
352
352
|
input: {
|
|
353
353
|
type: "object",
|
|
@@ -398,7 +398,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
398
398
|
});
|
|
399
399
|
|
|
400
400
|
api.action("vault.subjectSecrets", {
|
|
401
|
-
|
|
401
|
+
origins: ["ui"],
|
|
402
402
|
description: "后台插件只读:某个业务对象经分组可见的凭据清单(不含明文),拿到 id 后再 lease。",
|
|
403
403
|
input: {
|
|
404
404
|
type: "object",
|
|
@@ -413,7 +413,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
413
413
|
});
|
|
414
414
|
|
|
415
415
|
api.action("vault.bindingPurge", {
|
|
416
|
-
|
|
416
|
+
origins: ["ui"],
|
|
417
417
|
description: "插件卸载/业务对象删除时清理自己的绑定引用(硬删)。",
|
|
418
418
|
input: {
|
|
419
419
|
type: "object",
|
|
@@ -447,7 +447,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
447
447
|
});
|
|
448
448
|
|
|
449
449
|
api.action("vault.dataTables", {
|
|
450
|
-
|
|
450
|
+
origins: ["ui"],
|
|
451
451
|
description: "只读:数据页表清单。",
|
|
452
452
|
input: { type: "object", properties: {}, additionalProperties: false },
|
|
453
453
|
execute: (_args, ctx) => {
|
|
@@ -481,7 +481,7 @@ export function registerVaultActions(api, vault, groups) {
|
|
|
481
481
|
});
|
|
482
482
|
|
|
483
483
|
api.action("vault.dataQuery", {
|
|
484
|
-
|
|
484
|
+
origins: ["ui"],
|
|
485
485
|
description: "只读:数据页查询;密文列一律掩码。",
|
|
486
486
|
input: {
|
|
487
487
|
type: "object",
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-workbench-vault",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"description": "个人工作台凭据保险箱:加密保存密码与 token,agent 只见掩码",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"addon": {
|
|
17
17
|
"id": "wb-addon-vault",
|
|
18
18
|
"title": "凭据保险箱",
|
|
19
|
-
"version": "0.3.
|
|
19
|
+
"version": "0.3.12",
|
|
20
20
|
"minShell": "0.8.0",
|
|
21
21
|
"tables": [
|
|
22
22
|
"vault_header",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"dsh-workbench-host": "^0.
|
|
71
|
+
"dsh-workbench-host": "^0.9.1"
|
|
72
72
|
},
|
|
73
73
|
"dsh": {
|
|
74
74
|
"bundle": {
|