dsh-browser-cdp 0.18.21 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/bin/cdp-cast-worker.mjs +16 -0
- package/dsh-plugin.json +190 -148
- package/lib/client.js +532 -45
- package/lib/index.js +544 -43
- package/package.json +27 -15
package/lib/client.js
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
window.__ModuleLoader__.load({ id: "dsh-browser-cdp", factory: (require) => {
|
|
2
2
|
var module = { exports: {} }; var exports = module.exports;
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
+
value: mod,
|
|
22
|
+
enumerable: true
|
|
23
|
+
}) : target, mod));
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
let react = require("react");
|
|
27
|
+
react = __toESM(react);
|
|
3
28
|
|
|
4
29
|
//#region src/client/fam-links.ts
|
|
5
30
|
/**
|
|
@@ -196,10 +221,190 @@ function applyProbe(links, id, outcome, at) {
|
|
|
196
221
|
});
|
|
197
222
|
}
|
|
198
223
|
|
|
224
|
+
//#endregion
|
|
225
|
+
//#region src/client/family-host.ts
|
|
226
|
+
/** 家族节固定 id 与子席位 key(与 thinking-levels 的声明严格一致)。 */
|
|
227
|
+
const FAMILY_SECTION_ID = "dsh-family";
|
|
228
|
+
const FAMILY_CHILD_KEY = "dsh-family.tab";
|
|
229
|
+
/**
|
|
230
|
+
* 接管分级——唯一真源是 `mine-dsh-plugins/_tools/family-rank.mjs`(离线实测 GitHub
|
|
231
|
+
* star + npm 周下载量加权)。延迟 = BASE + RANK * STEP;rank 越大越靠后兜底。
|
|
232
|
+
*/
|
|
233
|
+
const FAMILY_CLAIM_RANK = 5;
|
|
234
|
+
const FAMILY_CLAIM_BASE_MS = 200;
|
|
235
|
+
const FAMILY_CLAIM_STEP_MS = 900;
|
|
236
|
+
/** 派生而非硬编码:改 rank 表就自动改时刻。 */
|
|
237
|
+
const FAMILY_CLAIM_DELAY_MS = FAMILY_CLAIM_BASE_MS + FAMILY_CLAIM_RANK * FAMILY_CLAIM_STEP_MS;
|
|
238
|
+
/** 接管行的遮蔽优先级:必须大于任何正牌 owner(TL 无=0、guard=10),
|
|
239
|
+
* 这样 owner 一旦上位就自然遮蔽本兜底行(宿主规则:同 cell 最低者渲染)。 */
|
|
240
|
+
const FAMILY_HOST_PRIORITY = 50;
|
|
241
|
+
const NO_TABS = [];
|
|
242
|
+
/** 通用容器渲染:按 order 依次画出账本里每张贡献卡,不含任何"本插件特例"。 */
|
|
243
|
+
function FamilyHostSection(props) {
|
|
244
|
+
const raw = props.hooks?.tabs;
|
|
245
|
+
const [polled, setPolled] = (0, react.useState)(() => raw?.getSnapshot() ?? NO_TABS);
|
|
246
|
+
(0, react.useEffect)(() => {
|
|
247
|
+
if (props.useTabs !== void 0 || raw === void 0) return;
|
|
248
|
+
return raw.subscribe(() => setPolled(raw.getSnapshot()));
|
|
249
|
+
});
|
|
250
|
+
return (0, react.createElement)("div", { style: {
|
|
251
|
+
display: "grid",
|
|
252
|
+
gap: "12px"
|
|
253
|
+
} }, (props.useTabs !== void 0 ? props.useTabs((value) => value) : polled).map((row) => (0, react.createElement)("div", { key: row.id }, props.renderSlot ? props.renderSlot(FAMILY_CHILD_KEY, {}, {
|
|
254
|
+
only: row.id,
|
|
255
|
+
fallback: null
|
|
256
|
+
}) : props.renderContributor?.(row.id) ?? null)));
|
|
257
|
+
}
|
|
258
|
+
/** 取条目上的具名面(宿主条目是结构化对象,这里只做安全读取)。 */
|
|
259
|
+
function face(entry, key) {
|
|
260
|
+
if (entry === null || typeof entry !== "object") return void 0;
|
|
261
|
+
return entry[key];
|
|
262
|
+
}
|
|
263
|
+
/** 条目的 options 收窄(宿主侧是结构化对象,缺失时当空对象读)。 */
|
|
264
|
+
function optionsOf(entry) {
|
|
265
|
+
const raw = face(entry, "options");
|
|
266
|
+
return raw !== null && typeof raw === "object" ? raw : {};
|
|
267
|
+
}
|
|
268
|
+
/** 把账本条目投影成标题行:label 可能是函数,抛错退化成 id,绝不带崩整节。 */
|
|
269
|
+
function projectLedger(slots) {
|
|
270
|
+
return slots.entries(FAMILY_CHILD_KEY).map((rawEntry) => {
|
|
271
|
+
const options = rawEntry.options ?? {};
|
|
272
|
+
const id = String(options["id"] ?? "");
|
|
273
|
+
const rawLabel = options["label"];
|
|
274
|
+
let label = id;
|
|
275
|
+
if (typeof rawLabel === "function") try {
|
|
276
|
+
label = String(rawLabel() ?? id);
|
|
277
|
+
} catch {
|
|
278
|
+
label = id;
|
|
279
|
+
}
|
|
280
|
+
else if (typeof rawLabel === "string") label = rawLabel;
|
|
281
|
+
return {
|
|
282
|
+
id,
|
|
283
|
+
order: Number(options["order"] ?? 0),
|
|
284
|
+
label
|
|
285
|
+
};
|
|
286
|
+
}).sort((a, b) => a.order - b.order);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* 若到点仍无人声明子席位,则自己接管容器。
|
|
290
|
+
* @param slots - 客户端槽门面。
|
|
291
|
+
* @param isHeld - 探针:本插件的 tab 工厂是否已被执行(= 有人声明了子席位)。
|
|
292
|
+
* @param label - 导航标题;家族共享节的标题,不是本插件名。
|
|
293
|
+
* @param log - console 前缀(带插件名)。
|
|
294
|
+
* @returns 取消定时器与撤销接管注册的 disposer。
|
|
295
|
+
*/
|
|
296
|
+
function claimFamilyHostIfOrphaned(slots, isHeld, label, log) {
|
|
297
|
+
let disposeClaim;
|
|
298
|
+
let claimed = false;
|
|
299
|
+
const timer = setTimeout(() => {
|
|
300
|
+
if (isHeld()) return;
|
|
301
|
+
const ledger = {
|
|
302
|
+
getSnapshot: () => projectLedger(slots),
|
|
303
|
+
subscribe: (listener) => slots.subscribe ? slots.subscribe(FAMILY_CHILD_KEY, listener) : () => void 0
|
|
304
|
+
};
|
|
305
|
+
/** ≤0.1.5 壳没有 renderSlot:从账本条目现挂组件,失败一律 null。 */
|
|
306
|
+
const renderContributor = (id) => {
|
|
307
|
+
try {
|
|
308
|
+
const entry = slots.entries(FAMILY_CHILD_KEY).find((candidate) => String(optionsOf(candidate)["id"] ?? "") === id);
|
|
309
|
+
const component = entry ? face(entry, "component") : void 0;
|
|
310
|
+
const inject$1 = entry ? face(entry, "inject") : void 0;
|
|
311
|
+
if (typeof component !== "function") return null;
|
|
312
|
+
return (0, react.createElement)(component, (typeof inject$1 === "function" ? inject$1() : {}) ?? {});
|
|
313
|
+
} catch {
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
try {
|
|
318
|
+
const dispose = slots.register({
|
|
319
|
+
name: "settings.section",
|
|
320
|
+
id: FAMILY_SECTION_ID,
|
|
321
|
+
order: 40,
|
|
322
|
+
priority: FAMILY_HOST_PRIORITY,
|
|
323
|
+
label,
|
|
324
|
+
inject: () => ({
|
|
325
|
+
hooks: { tabs: ledger },
|
|
326
|
+
renderContributor
|
|
327
|
+
}),
|
|
328
|
+
children: { [FAMILY_CHILD_KEY]: {
|
|
329
|
+
kind: "list",
|
|
330
|
+
scope: "root"
|
|
331
|
+
} }
|
|
332
|
+
}, FamilyHostSection);
|
|
333
|
+
if (typeof dispose === "function") disposeClaim = dispose;
|
|
334
|
+
claimed = true;
|
|
335
|
+
console.warn(`${log} family container unclaimed — took it over (children declared)`);
|
|
336
|
+
} catch (error) {
|
|
337
|
+
console.warn(`${log} family claim lost — withdrawing (${error instanceof Error ? error.message : String(error)})`);
|
|
338
|
+
}
|
|
339
|
+
}, FAMILY_CLAIM_DELAY_MS);
|
|
340
|
+
return () => {
|
|
341
|
+
clearTimeout(timer);
|
|
342
|
+
if (claimed) disposeClaim?.();
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/client/fam-write.ts
|
|
348
|
+
const defaultSleep = (ms) => new Promise((resolve) => {
|
|
349
|
+
setTimeout(resolve, ms);
|
|
350
|
+
});
|
|
351
|
+
/**
|
|
352
|
+
* 提交一个字段写入,被拒(revision 冲突 / 瞬态故障)时有限次重试。
|
|
353
|
+
* @param scope - 任一条数据轨的 scope(`set` 同签名)。
|
|
354
|
+
* @param field - 顶层字段名。
|
|
355
|
+
* @param value - 要落的值。
|
|
356
|
+
* @param options - 预算与计时注入点。
|
|
357
|
+
* @returns 宿主最终是否接受了这次写入。
|
|
358
|
+
*/
|
|
359
|
+
function commitField(scope, field, value, options = {}) {
|
|
360
|
+
const budget = Math.max(1, options.attempts ?? 3);
|
|
361
|
+
const retryMs = options.retryMs ?? 300;
|
|
362
|
+
const sleep = options.sleep ?? defaultSleep;
|
|
363
|
+
let attempt = 0;
|
|
364
|
+
const again = () => {
|
|
365
|
+
attempt += 1;
|
|
366
|
+
if (attempt >= budget) return Promise.resolve(false);
|
|
367
|
+
return sleep(retryMs).then(once);
|
|
368
|
+
};
|
|
369
|
+
const once = () => Promise.resolve().then(() => scope.set(field, value)).then((ok) => ok === true ? true : again(), again);
|
|
370
|
+
return once();
|
|
371
|
+
}
|
|
372
|
+
|
|
199
373
|
//#endregion
|
|
200
374
|
//#region src/client/index.ts
|
|
201
375
|
var React = require("react");
|
|
202
|
-
var
|
|
376
|
+
var runtimeClient = null;
|
|
377
|
+
var createSnapshotStore = null;
|
|
378
|
+
function ensureSnapshotStoreCreator() {
|
|
379
|
+
if (createSnapshotStore !== null) return createSnapshotStore;
|
|
380
|
+
try {
|
|
381
|
+
runtimeClient = require("@deepseek-ai/dsh-client-store");
|
|
382
|
+
createSnapshotStore = runtimeClient.createSnapshotStore;
|
|
383
|
+
} catch (e) {
|
|
384
|
+
createSnapshotStore = function(initial) {
|
|
385
|
+
var value = initial;
|
|
386
|
+
var listeners = [];
|
|
387
|
+
return {
|
|
388
|
+
subscribe: function(fn) {
|
|
389
|
+
listeners.push(fn);
|
|
390
|
+
return function() {
|
|
391
|
+
listeners = listeners.filter(function(l) {
|
|
392
|
+
return l !== fn;
|
|
393
|
+
});
|
|
394
|
+
};
|
|
395
|
+
},
|
|
396
|
+
getSnapshot: function() {
|
|
397
|
+
return value;
|
|
398
|
+
},
|
|
399
|
+
update: function(fn) {
|
|
400
|
+
value = fn(value);
|
|
401
|
+
for (var i = 0; i < listeners.length; i++) listeners[i]();
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
return createSnapshotStore;
|
|
407
|
+
}
|
|
203
408
|
var useSyncExternalStore = React.useSyncExternalStore;
|
|
204
409
|
var useRef = React.useRef;
|
|
205
410
|
function bindSnapshotSelector(source) {
|
|
@@ -947,11 +1152,148 @@ const ICON_REFRESH = `<svg width="15" height="15" viewBox="0 0 24 24" fill="none
|
|
|
947
1152
|
const ICON_CLOCK = `<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"><circle cx="12" cy="12" r="9"/><path d="M12 7.5V12l3 2"/></svg>`;
|
|
948
1153
|
const ICON_CLOSE = `<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg>`;
|
|
949
1154
|
const ICON_GRIP = `<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><circle cx="8" cy="6" r="1.8"/><circle cx="16" cy="6" r="1.8"/><circle cx="8" cy="12" r="1.8"/><circle cx="16" cy="12" r="1.8"/><circle cx="8" cy="18" r="1.8"/><circle cx="16" cy="18" r="1.8"/></svg>`;
|
|
1155
|
+
var BRIDGE_ROUTES = {
|
|
1156
|
+
describe: "/api/dsh-browser-cdp/settings/describe",
|
|
1157
|
+
mutate: "/api/dsh-browser-cdp/settings/mutate"
|
|
1158
|
+
};
|
|
1159
|
+
function bridgeDescriptorPlainValue(d) {
|
|
1160
|
+
var v = d && d.value;
|
|
1161
|
+
if (v !== null && typeof v === "object" && !Array.isArray(v)) {
|
|
1162
|
+
var values = Object.keys(v);
|
|
1163
|
+
if (values.length > 0 && values.every(function(k) {
|
|
1164
|
+
var x = v[k];
|
|
1165
|
+
return x !== null && typeof x === "object" && !Array.isArray(x) && Object.keys(x).length === 0;
|
|
1166
|
+
})) {
|
|
1167
|
+
var merged = {};
|
|
1168
|
+
var pull = function(layer) {
|
|
1169
|
+
if (layer !== null && typeof layer === "object" && !Array.isArray(layer)) for (var k in layer) merged[k] = layer[k];
|
|
1170
|
+
};
|
|
1171
|
+
pull(d.base);
|
|
1172
|
+
pull(d.user);
|
|
1173
|
+
return merged;
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
return v;
|
|
1177
|
+
}
|
|
1178
|
+
function makeBridgeScope() {
|
|
1179
|
+
var listeners = [];
|
|
1180
|
+
var snapshot = {
|
|
1181
|
+
status: "loading",
|
|
1182
|
+
value: void 0,
|
|
1183
|
+
writable: true,
|
|
1184
|
+
mode: "bridge"
|
|
1185
|
+
};
|
|
1186
|
+
var revision = void 0;
|
|
1187
|
+
var retriesLeft = 4;
|
|
1188
|
+
var inflight = void 0;
|
|
1189
|
+
function notify() {
|
|
1190
|
+
for (var i = 0; i < listeners.length; i++) listeners[i]();
|
|
1191
|
+
}
|
|
1192
|
+
function applyDescriptor(d, writable) {
|
|
1193
|
+
revision = typeof d.revision === "number" ? d.revision : void 0;
|
|
1194
|
+
snapshot = {
|
|
1195
|
+
status: "ready",
|
|
1196
|
+
value: bridgeDescriptorPlainValue(d),
|
|
1197
|
+
writable,
|
|
1198
|
+
mode: "bridge"
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
function request(path, body) {
|
|
1202
|
+
return fetch(path, {
|
|
1203
|
+
method: "POST",
|
|
1204
|
+
headers: { "content-type": "application/json" },
|
|
1205
|
+
body: JSON.stringify(body ?? {})
|
|
1206
|
+
}).then(function(r) {
|
|
1207
|
+
if (!r.ok) throw new Error("bridge " + path + " HTTP " + r.status);
|
|
1208
|
+
return r.json();
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
function retryOrFail() {
|
|
1212
|
+
if (retriesLeft > 0) {
|
|
1213
|
+
retriesLeft -= 1;
|
|
1214
|
+
inflight = void 0;
|
|
1215
|
+
setTimeout(function() {
|
|
1216
|
+
refresh();
|
|
1217
|
+
}, 1500);
|
|
1218
|
+
return true;
|
|
1219
|
+
}
|
|
1220
|
+
snapshot = {
|
|
1221
|
+
status: "unavailable",
|
|
1222
|
+
value: void 0,
|
|
1223
|
+
writable: false,
|
|
1224
|
+
mode: "bridge"
|
|
1225
|
+
};
|
|
1226
|
+
return false;
|
|
1227
|
+
}
|
|
1228
|
+
function refresh() {
|
|
1229
|
+
if (inflight !== void 0) return inflight;
|
|
1230
|
+
inflight = request(BRIDGE_ROUTES.describe, {}).then(function(body) {
|
|
1231
|
+
if (body && body.ok && body.value && body.value.descriptor !== void 0) {
|
|
1232
|
+
retriesLeft = 4;
|
|
1233
|
+
applyDescriptor(body.value.descriptor, body.value.writable !== false);
|
|
1234
|
+
} else if (!(body && body.code && (body.code === "settings-unavailable" || body.code === "ns-not-registered") && retryOrFail())) snapshot = {
|
|
1235
|
+
status: "unavailable",
|
|
1236
|
+
value: void 0,
|
|
1237
|
+
writable: false,
|
|
1238
|
+
mode: "bridge"
|
|
1239
|
+
};
|
|
1240
|
+
inflight = void 0;
|
|
1241
|
+
notify();
|
|
1242
|
+
}, function() {
|
|
1243
|
+
retryOrFail();
|
|
1244
|
+
inflight = void 0;
|
|
1245
|
+
notify();
|
|
1246
|
+
});
|
|
1247
|
+
return inflight;
|
|
1248
|
+
}
|
|
1249
|
+
refresh();
|
|
1250
|
+
return {
|
|
1251
|
+
subscribe: function(listener) {
|
|
1252
|
+
listeners.push(listener);
|
|
1253
|
+
return function() {
|
|
1254
|
+
var i = listeners.indexOf(listener);
|
|
1255
|
+
if (i >= 0) listeners.splice(i, 1);
|
|
1256
|
+
};
|
|
1257
|
+
},
|
|
1258
|
+
getSnapshot: function() {
|
|
1259
|
+
return snapshot;
|
|
1260
|
+
},
|
|
1261
|
+
set: function(field, value) {
|
|
1262
|
+
return request(BRIDGE_ROUTES.mutate, {
|
|
1263
|
+
ops: [{
|
|
1264
|
+
op: "set",
|
|
1265
|
+
path: [field],
|
|
1266
|
+
value
|
|
1267
|
+
}],
|
|
1268
|
+
expectedRevision: revision
|
|
1269
|
+
}).then(function(body) {
|
|
1270
|
+
if (body && body.ok && body.value && body.value.descriptor !== void 0) {
|
|
1271
|
+
applyDescriptor(body.value.descriptor, snapshot.writable);
|
|
1272
|
+
notify();
|
|
1273
|
+
return true;
|
|
1274
|
+
}
|
|
1275
|
+
return Promise.resolve(refresh()).then(function() {
|
|
1276
|
+
return false;
|
|
1277
|
+
}, function() {
|
|
1278
|
+
return false;
|
|
1279
|
+
});
|
|
1280
|
+
}, function() {
|
|
1281
|
+
return Promise.resolve(refresh()).then(function() {
|
|
1282
|
+
return false;
|
|
1283
|
+
}, function() {
|
|
1284
|
+
return false;
|
|
1285
|
+
});
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
950
1290
|
function mountFamilySettingsCard(ctx) {
|
|
951
1291
|
var forms = typeof ctx.get === "function" ? ctx.get("configForms") : void 0;
|
|
952
|
-
|
|
953
|
-
|
|
1292
|
+
var scope = forms && typeof forms.get === "function" ? forms.get("dsh-browser-cdp") : void 0;
|
|
1293
|
+
if (!scope) scope = makeBridgeScope();
|
|
1294
|
+
var familyTabHeld = false;
|
|
954
1295
|
ctx.slots.inject("dsh-family.tab", function() {
|
|
1296
|
+
familyTabHeld = true;
|
|
955
1297
|
return ctx.slots.register({
|
|
956
1298
|
name: "dsh-family.tab",
|
|
957
1299
|
id: "dsh-browser-cdp",
|
|
@@ -964,11 +1306,19 @@ function mountFamilySettingsCard(ctx) {
|
|
|
964
1306
|
}
|
|
965
1307
|
}, FamilySettingsCard);
|
|
966
1308
|
}, "dsh-browser-cdp: family settings tab");
|
|
1309
|
+
var claim = claimFamilyHostIfOrphaned(ctx.slots, function() {
|
|
1310
|
+
return familyTabHeld;
|
|
1311
|
+
}, function() {
|
|
1312
|
+
return "起子插件设置";
|
|
1313
|
+
}, "[dsh-browser-cdp]");
|
|
1314
|
+
if (typeof ctx.effect === "function") ctx.effect(function() {
|
|
1315
|
+
return claim;
|
|
1316
|
+
}, "dsh-browser-cdp: family host backstop");
|
|
967
1317
|
}
|
|
968
1318
|
function mountPluginsPageCard(ctx) {
|
|
969
1319
|
var forms = typeof ctx.get === "function" ? ctx.get("configForms") : void 0;
|
|
970
|
-
|
|
971
|
-
|
|
1320
|
+
var scope = forms && typeof forms.get === "function" ? forms.get("dsh-browser-cdp") : void 0;
|
|
1321
|
+
if (!scope) scope = makeBridgeScope();
|
|
972
1322
|
ctx.slots.inject("plugins.bundle.config", function() {
|
|
973
1323
|
return ctx.slots.register({
|
|
974
1324
|
name: "plugins.bundle.config",
|
|
@@ -980,6 +1330,38 @@ function mountPluginsPageCard(ctx) {
|
|
|
980
1330
|
}, "dsh-browser-cdp: plugins-page config card");
|
|
981
1331
|
}
|
|
982
1332
|
var FAM_FIELD_GROUPS = [
|
|
1333
|
+
{
|
|
1334
|
+
gk: "gTools",
|
|
1335
|
+
en: "Tool sealing",
|
|
1336
|
+
zh: "工具封印",
|
|
1337
|
+
fields: [
|
|
1338
|
+
{
|
|
1339
|
+
k: "toolInjection",
|
|
1340
|
+
kind: "sel",
|
|
1341
|
+
options: ["lazy", "always"],
|
|
1342
|
+
en: ["Injection mode", "lazy (default) = only the 6 core tools stay resident; the rest are injected after the first bcdp_* call and sealed back on idle reaping. always = every tool registered at mount (historical)"],
|
|
1343
|
+
zh: ["工具注入模式", "lazy(默认)= 只常驻核心 6 个,首次 bcdp_* 调用后铺开、闲置回收时收回;always = 挂载即注册全部(历史行为)"]
|
|
1344
|
+
},
|
|
1345
|
+
{
|
|
1346
|
+
k: "toolBrowse",
|
|
1347
|
+
kind: "bool",
|
|
1348
|
+
en: ["Basic browsing tools (14)", "On (default) = registered after browser activity; off = 14 tools removed from the model tool list (click / fill / key / screenshot / read / wait ...)"],
|
|
1349
|
+
zh: ["基础操作工具(14 个)", "开(默认)= 浏览器活动后正常注册;关 = 14 个工具从模型工具列表移除(点击/填写/键鼠/截图/读取/等待…)"]
|
|
1350
|
+
},
|
|
1351
|
+
{
|
|
1352
|
+
k: "toolExtended",
|
|
1353
|
+
kind: "bool",
|
|
1354
|
+
en: ["Extended tools (13)", "On (default) = registered; off = 13 tools removed (drag / upload / download / dialog / raw CDP / script escape hatches / login import)"],
|
|
1355
|
+
zh: ["扩展能力工具(13 个)", "开(默认)= 正常注册;关 = 13 个工具移除(拖拽/上传/下载/对话框/裸 CDP/脚本逃生舱/登录导入)"]
|
|
1356
|
+
},
|
|
1357
|
+
{
|
|
1358
|
+
k: "toolJudge",
|
|
1359
|
+
kind: "bool",
|
|
1360
|
+
en: ["Judgement tools bcdp_jev_* (5)", "On still requires a JEV or Laya key — without one they can only answer \"not configured\", so they stay sealed anyway"],
|
|
1361
|
+
zh: ["评审工具 bcdp_jev_*(5 个)", "开仍需配了 JEV/Laya Key;没 Key 它们本来也只能回答「未配置」,依旧不注入"]
|
|
1362
|
+
}
|
|
1363
|
+
]
|
|
1364
|
+
},
|
|
983
1365
|
{
|
|
984
1366
|
gk: "gBasic",
|
|
985
1367
|
en: "Basics",
|
|
@@ -1378,14 +1760,12 @@ function FamField(props) {
|
|
|
1378
1760
|
color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.8))",
|
|
1379
1761
|
lineHeight: 1.5
|
|
1380
1762
|
} }, famText(f, "desc")));
|
|
1381
|
-
if (f.kind === "bool") return h(
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
}
|
|
1388
|
-
}));
|
|
1763
|
+
if (f.kind === "bool") return h(FamBoolRow, {
|
|
1764
|
+
f,
|
|
1765
|
+
value,
|
|
1766
|
+
writable,
|
|
1767
|
+
scope
|
|
1768
|
+
});
|
|
1389
1769
|
if (f.kind === "num") return h("div", { style: rowStyle }, label, h(FamNumInput, {
|
|
1390
1770
|
f,
|
|
1391
1771
|
v: value[f.k],
|
|
@@ -1404,7 +1784,7 @@ function FamField(props) {
|
|
|
1404
1784
|
padding: "4px 8px"
|
|
1405
1785
|
},
|
|
1406
1786
|
onChange: function(e) {
|
|
1407
|
-
scope
|
|
1787
|
+
commitField(scope, f.k, e.target.value);
|
|
1408
1788
|
}
|
|
1409
1789
|
}, f.options.map(function(o) {
|
|
1410
1790
|
return h("option", {
|
|
@@ -1423,6 +1803,109 @@ function FamField(props) {
|
|
|
1423
1803
|
scope
|
|
1424
1804
|
}));
|
|
1425
1805
|
}
|
|
1806
|
+
function FamSwitch(props) {
|
|
1807
|
+
var h = React.createElement;
|
|
1808
|
+
var on = props.checked === true;
|
|
1809
|
+
var busy = props.busy === true;
|
|
1810
|
+
var disabled = props.writable !== true || busy;
|
|
1811
|
+
return h("button", {
|
|
1812
|
+
type: "button",
|
|
1813
|
+
role: "switch",
|
|
1814
|
+
"aria-checked": on,
|
|
1815
|
+
"aria-label": props.ariaLabel || "",
|
|
1816
|
+
disabled,
|
|
1817
|
+
title: props.title || "",
|
|
1818
|
+
style: {
|
|
1819
|
+
flex: "0 0 auto",
|
|
1820
|
+
width: "38px",
|
|
1821
|
+
height: "22px",
|
|
1822
|
+
padding: 0,
|
|
1823
|
+
boxSizing: "border-box",
|
|
1824
|
+
position: "relative",
|
|
1825
|
+
cursor: disabled ? "default" : "pointer",
|
|
1826
|
+
borderRadius: "999px",
|
|
1827
|
+
border: "1px solid transparent",
|
|
1828
|
+
background: on ? "var(--dsw-alias-bg-brand, #3a76f0)" : "var(--dsw-alias-bg-module-platform, rgba(127,127,127,.28))",
|
|
1829
|
+
opacity: busy ? .55 : 1,
|
|
1830
|
+
transition: "background .16s ease, opacity .16s ease"
|
|
1831
|
+
},
|
|
1832
|
+
onClick: function() {
|
|
1833
|
+
props.onToggle(!on);
|
|
1834
|
+
}
|
|
1835
|
+
}, h("span", { style: {
|
|
1836
|
+
position: "absolute",
|
|
1837
|
+
top: "1px",
|
|
1838
|
+
left: "1px",
|
|
1839
|
+
width: "18px",
|
|
1840
|
+
height: "18px",
|
|
1841
|
+
borderRadius: "999px",
|
|
1842
|
+
boxSizing: "border-box",
|
|
1843
|
+
background: "var(--dsw-alias-label-inverse, #fff)",
|
|
1844
|
+
boxShadow: "0 1px 2px rgba(0,0,0,.35)",
|
|
1845
|
+
transform: on ? "translateX(16px)" : "translateX(0)",
|
|
1846
|
+
transition: "transform .16s ease"
|
|
1847
|
+
} }));
|
|
1848
|
+
}
|
|
1849
|
+
function FamBoolRow(props) {
|
|
1850
|
+
var f = props.f;
|
|
1851
|
+
var scope = props.scope;
|
|
1852
|
+
var writable = props.writable;
|
|
1853
|
+
var h = React.createElement;
|
|
1854
|
+
var host = props.value[f.k] === true;
|
|
1855
|
+
var pendingState = React.useState(void 0);
|
|
1856
|
+
var pending = pendingState[0], setPending = pendingState[1];
|
|
1857
|
+
var errState = React.useState(false);
|
|
1858
|
+
var failed = errState[0], setFailed = errState[1];
|
|
1859
|
+
React.useEffect(function() {
|
|
1860
|
+
if (pending !== void 0 && props.value[f.k] === pending) setPending(void 0);
|
|
1861
|
+
}, [props.value[f.k]]);
|
|
1862
|
+
var shown = pending === void 0 ? host : pending === true;
|
|
1863
|
+
var rowStyle = {
|
|
1864
|
+
display: "flex",
|
|
1865
|
+
alignItems: "center",
|
|
1866
|
+
justifyContent: "space-between",
|
|
1867
|
+
gap: "12px",
|
|
1868
|
+
padding: "6px 0"
|
|
1869
|
+
};
|
|
1870
|
+
var textCol = {
|
|
1871
|
+
display: "flex",
|
|
1872
|
+
flexDirection: "column",
|
|
1873
|
+
gap: "2px",
|
|
1874
|
+
minWidth: 0
|
|
1875
|
+
};
|
|
1876
|
+
var titleStyle = {
|
|
1877
|
+
fontSize: "13px",
|
|
1878
|
+
color: "var(--dsw-alias-label-primary, inherit)"
|
|
1879
|
+
};
|
|
1880
|
+
var descStyle = {
|
|
1881
|
+
fontSize: "12px",
|
|
1882
|
+
color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.8))",
|
|
1883
|
+
lineHeight: 1.5
|
|
1884
|
+
};
|
|
1885
|
+
function toggle(next) {
|
|
1886
|
+
if (writable !== true || pending !== void 0) return;
|
|
1887
|
+
setFailed(false);
|
|
1888
|
+
setPending(next);
|
|
1889
|
+
commitField(scope, f.k, next).then(function(ok) {
|
|
1890
|
+
if (ok === true) return;
|
|
1891
|
+
setPending(void 0);
|
|
1892
|
+
setFailed(true);
|
|
1893
|
+
});
|
|
1894
|
+
}
|
|
1895
|
+
return h("div", { style: {
|
|
1896
|
+
display: "grid",
|
|
1897
|
+
gap: "2px"
|
|
1898
|
+
} }, h("div", { style: rowStyle }, h("div", { style: textCol }, h("span", { style: titleStyle }, famText(f, "title")), f.desc === false || !famText(f, "desc") ? null : h("span", { style: descStyle }, famText(f, "desc"))), h(FamSwitch, {
|
|
1899
|
+
checked: shown,
|
|
1900
|
+
busy: pending !== void 0,
|
|
1901
|
+
writable,
|
|
1902
|
+
ariaLabel: famText(f, "title"),
|
|
1903
|
+
onToggle: toggle
|
|
1904
|
+
})), failed ? h("span", { style: {
|
|
1905
|
+
fontSize: "12px",
|
|
1906
|
+
color: "var(--dsw-alias-text-danger, #e5534b)"
|
|
1907
|
+
} }, _egoLocale === "zh" ? "保存未成功(已重试),开关已回到宿主当前值。" : "Save failed after retries; the switch is back to the host value.") : null);
|
|
1908
|
+
}
|
|
1426
1909
|
function FamNumInput(props) {
|
|
1427
1910
|
var f = props.f;
|
|
1428
1911
|
var h = React.createElement;
|
|
@@ -1457,7 +1940,7 @@ function FamNumInput(props) {
|
|
|
1457
1940
|
n = Math.round(n / (f.step || 1)) * (f.step || 1);
|
|
1458
1941
|
if (f.min !== void 0) n = Math.max(f.min, n);
|
|
1459
1942
|
if (f.max !== void 0) n = Math.min(f.max, n);
|
|
1460
|
-
props.scope
|
|
1943
|
+
commitField(props.scope, f.k, n);
|
|
1461
1944
|
}
|
|
1462
1945
|
});
|
|
1463
1946
|
}
|
|
@@ -1487,10 +1970,10 @@ function FamStrInput(props) {
|
|
|
1487
1970
|
setV(e.target.value);
|
|
1488
1971
|
},
|
|
1489
1972
|
onBlur: function() {
|
|
1490
|
-
props.scope
|
|
1973
|
+
commitField(props.scope, f.k, v);
|
|
1491
1974
|
},
|
|
1492
1975
|
onKeyDown: function(e) {
|
|
1493
|
-
if (e.key === "Enter") props.scope
|
|
1976
|
+
if (e.key === "Enter") commitField(props.scope, f.k, v);
|
|
1494
1977
|
}
|
|
1495
1978
|
});
|
|
1496
1979
|
}
|
|
@@ -1582,7 +2065,7 @@ function FamLinks(props) {
|
|
|
1582
2065
|
padding: "3px 8px"
|
|
1583
2066
|
};
|
|
1584
2067
|
function writeLinks(next) {
|
|
1585
|
-
|
|
2068
|
+
commitField(scope, "links", next).then(function(ok) {
|
|
1586
2069
|
if (ok === false) setErrText(wt("linksWriteFailed"));
|
|
1587
2070
|
}, function() {
|
|
1588
2071
|
setErrText(wt("linksWriteFailed"));
|
|
@@ -1605,7 +2088,7 @@ function FamLinks(props) {
|
|
|
1605
2088
|
return;
|
|
1606
2089
|
}
|
|
1607
2090
|
writeLinks(res.links);
|
|
1608
|
-
if (activeId === "") scope
|
|
2091
|
+
if (activeId === "") commitField(scope, "activeTargetId", res.links[res.links.length - 1].id);
|
|
1609
2092
|
setAddLabel("");
|
|
1610
2093
|
setAddEndpoint("");
|
|
1611
2094
|
setErrText("");
|
|
@@ -1620,7 +2103,7 @@ function FamLinks(props) {
|
|
|
1620
2103
|
return;
|
|
1621
2104
|
}
|
|
1622
2105
|
writeLinks(res.links);
|
|
1623
|
-
if (activeId === "") scope
|
|
2106
|
+
if (activeId === "") commitField(scope, "activeTargetId", res.links[res.links.length - 1].id);
|
|
1624
2107
|
setAddCliPath("");
|
|
1625
2108
|
setErrText("");
|
|
1626
2109
|
}
|
|
@@ -1634,14 +2117,14 @@ function FamLinks(props) {
|
|
|
1634
2117
|
return;
|
|
1635
2118
|
}
|
|
1636
2119
|
writeLinks(res.links);
|
|
1637
|
-
if (activeId === "") scope
|
|
2120
|
+
if (activeId === "") commitField(scope, "activeTargetId", res.links[res.links.length - 1].id);
|
|
1638
2121
|
setAddLpPath("");
|
|
1639
2122
|
setErrText("");
|
|
1640
2123
|
}
|
|
1641
2124
|
function removeOne(row) {
|
|
1642
2125
|
var res = removeRow(links, row.id);
|
|
1643
2126
|
writeLinks(res.links);
|
|
1644
|
-
if (res.removed && res.removed.id !== void 0 && res.removed.id === activeId) scope
|
|
2127
|
+
if (res.removed && res.removed.id !== void 0 && res.removed.id === activeId) commitField(scope, "activeTargetId", "");
|
|
1645
2128
|
}
|
|
1646
2129
|
function probeOne(row) {
|
|
1647
2130
|
if (probingId !== "" || !isValidEndpoint(row.endpoint)) return;
|
|
@@ -1679,13 +2162,12 @@ function FamLinks(props) {
|
|
|
1679
2162
|
alignItems: "center",
|
|
1680
2163
|
gap: "8px",
|
|
1681
2164
|
flexWrap: "wrap"
|
|
1682
|
-
} }, h(
|
|
1683
|
-
type: "checkbox",
|
|
2165
|
+
} }, h(FamSwitch, {
|
|
1684
2166
|
checked: value.allowLocalFallback === true,
|
|
1685
|
-
|
|
2167
|
+
writable,
|
|
1686
2168
|
title: wt("linksLocalEnableHint"),
|
|
1687
|
-
|
|
1688
|
-
scope
|
|
2169
|
+
onToggle: function(next) {
|
|
2170
|
+
commitField(scope, "allowLocalFallback", next);
|
|
1689
2171
|
}
|
|
1690
2172
|
}), h("span", { style: badgeStyle }, "LOCAL"), h("span", { style: {
|
|
1691
2173
|
fontSize: "13px",
|
|
@@ -1703,7 +2185,7 @@ function FamLinks(props) {
|
|
|
1703
2185
|
disabled: !writable,
|
|
1704
2186
|
style: btnStyle,
|
|
1705
2187
|
onClick: function() {
|
|
1706
|
-
scope
|
|
2188
|
+
commitField(scope, "cdpMode", "local");
|
|
1707
2189
|
}
|
|
1708
2190
|
}, wt("linksActivate"))));
|
|
1709
2191
|
return h("div", { style: {
|
|
@@ -1746,13 +2228,12 @@ function FamLinks(props) {
|
|
|
1746
2228
|
alignItems: "center",
|
|
1747
2229
|
gap: "8px",
|
|
1748
2230
|
flexWrap: "wrap"
|
|
1749
|
-
} }, h(
|
|
1750
|
-
type: "checkbox",
|
|
2231
|
+
} }, h(FamSwitch, {
|
|
1751
2232
|
checked: row.enabled === true,
|
|
1752
|
-
|
|
2233
|
+
writable,
|
|
1753
2234
|
title: wt("linksEnabled"),
|
|
1754
|
-
|
|
1755
|
-
writeLinks(updateRow(links, row.id, { enabled:
|
|
2235
|
+
onToggle: function(next) {
|
|
2236
|
+
writeLinks(updateRow(links, row.id, { enabled: next }));
|
|
1756
2237
|
}
|
|
1757
2238
|
}), h("span", { style: badgeStyle }, isCli ? "CLI" : isLp ? "LP·无头" : "CDP"), h(FamRowInput, {
|
|
1758
2239
|
v: row.label || "",
|
|
@@ -1771,8 +2252,8 @@ function FamLinks(props) {
|
|
|
1771
2252
|
title: row.enabled === false ? wt("linksDisabledHint") : void 0,
|
|
1772
2253
|
style: btnStyle,
|
|
1773
2254
|
onClick: function() {
|
|
1774
|
-
scope
|
|
1775
|
-
if (cdpMode === "local") scope
|
|
2255
|
+
commitField(scope, "activeTargetId", row.id);
|
|
2256
|
+
if (cdpMode === "local") commitField(scope, "cdpMode", "auto");
|
|
1776
2257
|
}
|
|
1777
2258
|
}, wt("linksActivate"))), h("div", { style: {
|
|
1778
2259
|
display: "flex",
|
|
@@ -1805,13 +2286,12 @@ function FamLinks(props) {
|
|
|
1805
2286
|
fontSize: "11px",
|
|
1806
2287
|
color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.7))",
|
|
1807
2288
|
flex: "0 0 auto"
|
|
1808
|
-
} }, h(
|
|
1809
|
-
type: "checkbox",
|
|
2289
|
+
} }, h(FamSwitch, {
|
|
1810
2290
|
checked: row.useSdkPath === true,
|
|
1811
|
-
|
|
2291
|
+
writable,
|
|
1812
2292
|
title: wt("linksCliSdk"),
|
|
1813
|
-
|
|
1814
|
-
writeLinks(updateRow(links, row.id, { useSdkPath:
|
|
2293
|
+
onToggle: function(next) {
|
|
2294
|
+
writeLinks(updateRow(links, row.id, { useSdkPath: next }));
|
|
1815
2295
|
}
|
|
1816
2296
|
}), wt("linksCliSdk")) : null, !isCli && !isLp ? h("button", {
|
|
1817
2297
|
type: "button",
|
|
@@ -1950,10 +2430,17 @@ function FamLinks(props) {
|
|
|
1950
2430
|
} }, errText) : null));
|
|
1951
2431
|
}
|
|
1952
2432
|
function apply(ctx) {
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
2433
|
+
var mounts = [
|
|
2434
|
+
["family settings tab", mountFamilySettingsCard],
|
|
2435
|
+
["plugins-page config card", mountPluginsPageCard],
|
|
2436
|
+
["picks dock", mountPicksDockCard],
|
|
2437
|
+
["picks badge", mountPicksBadge]
|
|
2438
|
+
];
|
|
2439
|
+
for (var mi = 0; mi < mounts.length; mi++) try {
|
|
2440
|
+
mounts[mi][1](ctx);
|
|
2441
|
+
} catch (e) {
|
|
2442
|
+
console.warn("[dsh-browser-cdp] mount failed:", mounts[mi][0], e && e.message ? e.message : String(e));
|
|
2443
|
+
}
|
|
1957
2444
|
var betterSidebarService;
|
|
1958
2445
|
try {
|
|
1959
2446
|
betterSidebarService = typeof ctx.get === "function" ? ctx.get("betterSidebar") : void 0;
|
|
@@ -3780,7 +4267,7 @@ function createPickControl(onState, deliver) {
|
|
|
3780
4267
|
}
|
|
3781
4268
|
function LivePreviewController(ctx) {
|
|
3782
4269
|
this.ctx = ctx;
|
|
3783
|
-
this.store =
|
|
4270
|
+
this.store = ensureSnapshotStoreCreator()(this._initialState());
|
|
3784
4271
|
this.frameCache = /* @__PURE__ */ new Map();
|
|
3785
4272
|
this.pageMeta = /* @__PURE__ */ new Map();
|
|
3786
4273
|
this.lastList = [];
|