@artenx/dshb 0.1.39 → 0.1.41
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/auth/gate.d.ts +9 -1
- package/lib/auth/gate.js +12 -5
- package/lib/auth/gate.js.map +1 -1
- package/lib/auth/index.js +42 -9
- package/lib/auth/index.js.map +1 -1
- package/lib/catalog-BPkswHoz.js +121 -0
- package/lib/catalog-BPkswHoz.js.map +1 -0
- package/lib/client.js +482 -45
- package/lib/client.js.map +1 -1
- package/lib/{connection-sIX25pkS.d.ts → connection-CDJM9aUw.d.ts} +10 -3
- package/lib/core/index.js +480 -4
- package/lib/core/index.js.map +1 -1
- package/lib/core/routes.d.ts +1 -1
- package/lib/core/sync/coordinator.d.ts +5 -5
- package/lib/core/sync/coordinator.js +39 -6
- package/lib/core/sync/coordinator.js.map +1 -1
- package/lib/core/sync/host-key.d.ts +1 -1
- package/lib/core/sync/internal-routes.d.ts +3 -3
- package/lib/core/sync/internal-routes.js +36 -3
- package/lib/core/sync/internal-routes.js.map +1 -1
- package/lib/core/sync/model.d.ts +2 -2
- package/lib/core/sync/model.js +62 -1
- package/lib/core/sync/model.js.map +1 -1
- package/lib/core/sync/node-sync.d.ts +1 -1
- package/lib/core/sync/offline-archive.d.ts +6 -4
- package/lib/core/sync/offline-archive.js +31 -8
- package/lib/core/sync/offline-archive.js.map +1 -1
- package/lib/core/sync/offline-routes.js +29 -3
- package/lib/core/sync/offline-routes.js.map +1 -1
- package/lib/core/sync/peer-manager.d.ts +2 -2
- package/lib/core/sync/peer-manager.js +2 -0
- package/lib/core/sync/peer-manager.js.map +1 -1
- package/lib/core/sync/protocol.d.ts +2 -2
- package/lib/core/sync/protocol.js +2 -1
- package/lib/core/sync/protocol.js.map +1 -1
- package/lib/core/sync/remote-helper.js +4 -2
- package/lib/core/sync/remote-helper.js.map +1 -1
- package/lib/core/sync/routes.d.ts +1 -1
- package/lib/core/sync/routes.js +26 -1
- package/lib/core/sync/routes.js.map +1 -1
- package/lib/core/sync/session-journal.d.ts +1 -1
- package/lib/core/sync/session-routes.d.ts +1 -1
- package/lib/core/sync/session-routes.js +1 -1
- package/lib/core/sync/session-routes.js.map +1 -1
- package/lib/core/sync/session-sync.d.ts +1 -1
- package/lib/core/sync/session-sync.js +1 -1
- package/lib/core/sync/ssh-transport.d.ts +1 -1
- package/lib/core/sync/ssh-transport.js +73 -3
- package/lib/core/sync/ssh-transport.js.map +1 -1
- package/lib/core/sync/stores.d.ts +1 -1
- package/lib/core/sync/stores.js +8 -2
- package/lib/core/sync/stores.js.map +1 -1
- package/lib/core/workspaces.d.ts +1 -1
- package/lib/exec-ssh/connection-pool.d.ts +1 -1
- package/lib/exec-ssh/connection.d.ts +2 -2
- package/lib/exec-ssh/connection.js +29 -12
- package/lib/exec-ssh/connection.js.map +1 -1
- package/lib/exec-ssh/executor.d.ts +10 -1
- package/lib/exec-ssh/executor.js +91 -42
- package/lib/exec-ssh/executor.js.map +1 -1
- package/lib/exec-ssh/index.d.ts +1 -1
- package/lib/{host-key-CSnpIrjq.d.ts → host-key-CjO13Ds4.d.ts} +2 -2
- package/lib/{model-CKTBf-Pl.d.ts → model-CX2TlH2E.d.ts} +70 -6
- package/lib/{node-sync-C3Ym-HDu.d.ts → node-sync-qnJ7u0TU.d.ts} +3 -3
- package/lib/{protocol-DJ0zyVlB.d.ts → protocol-DyPDIJWa.d.ts} +3 -2
- package/lib/selection-BABQH1Rt.js +48 -0
- package/lib/selection-BABQH1Rt.js.map +1 -0
- package/lib/{session-journal-VE_1tA2-.d.ts → session-journal-lum5L2ip.d.ts} +2 -2
- package/lib/{session-sync-BBCm_ou2.js → session-sync-BV1CSYic.js} +85 -2
- package/lib/session-sync-BV1CSYic.js.map +1 -0
- package/lib/{session-sync-Bw0cZ4oa.d.ts → session-sync-Be5wuYHJ.d.ts} +12 -6
- package/lib/{ssh-transport-COZe0BDr.d.ts → ssh-transport-Cevwfre9.d.ts} +25 -6
- package/lib/{stores-puyTC075.d.ts → stores-BwQLabuJ.d.ts} +2 -2
- package/package.json +3 -1
- package/lib/session-sync-BBCm_ou2.js.map +0 -1
package/lib/client.js
CHANGED
|
@@ -2189,6 +2189,267 @@ window.__ModuleLoader__.load({
|
|
|
2189
2189
|
scan();
|
|
2190
2190
|
}
|
|
2191
2191
|
//#endregion
|
|
2192
|
+
//#region src/client/sync-selection-picker.tsx
|
|
2193
|
+
function originKey(origin) {
|
|
2194
|
+
return JSON.stringify([origin.originInstanceId, origin.originEntityId]);
|
|
2195
|
+
}
|
|
2196
|
+
function workspaceKey(workspace) {
|
|
2197
|
+
return JSON.stringify([
|
|
2198
|
+
workspace.origin.originInstanceId,
|
|
2199
|
+
workspace.origin.originEntityId,
|
|
2200
|
+
workspace.remotePath
|
|
2201
|
+
]);
|
|
2202
|
+
}
|
|
2203
|
+
function hasOrigin(origins, target) {
|
|
2204
|
+
return origins.some((origin) => originKey(origin) === originKey(target));
|
|
2205
|
+
}
|
|
2206
|
+
function toggleOrigin(origins, target) {
|
|
2207
|
+
return hasOrigin(origins, target) ? origins.filter((origin) => originKey(origin) !== originKey(target)) : [...origins, target];
|
|
2208
|
+
}
|
|
2209
|
+
function sessionWorkspaceMatches(session, workspace) {
|
|
2210
|
+
return session.workspaceOrigin !== void 0 && originKey(session.workspaceOrigin) === originKey(workspace.origin) && (session.workspaceRemotePath === void 0 || session.workspaceRemotePath === workspace.remotePath);
|
|
2211
|
+
}
|
|
2212
|
+
function SyncSelectionPicker(props) {
|
|
2213
|
+
const { catalog, selection, includeSessions, disabled = false } = props;
|
|
2214
|
+
const selectedWorkspaceKeys = new Set(selection.workspaces.map((workspace) => JSON.stringify([
|
|
2215
|
+
workspace.originInstanceId,
|
|
2216
|
+
workspace.originEntityId,
|
|
2217
|
+
workspace.remotePath
|
|
2218
|
+
])));
|
|
2219
|
+
const selectedSessions = new Set(selection.sessions.map(originKey));
|
|
2220
|
+
const requiredNodes = /* @__PURE__ */ new Set();
|
|
2221
|
+
for (const workspace of catalog.workspaces) if (selectedWorkspaceKeys.has(workspaceKey(workspace))) requiredNodes.add(originKey(workspace.nodeOrigin));
|
|
2222
|
+
for (const session of catalog.sessions) if (selectedSessions.has(originKey(session.origin)) && session.nodeOrigin) requiredNodes.add(originKey(session.nodeOrigin));
|
|
2223
|
+
const setSelection = (patch) => {
|
|
2224
|
+
props.onChange({
|
|
2225
|
+
...selection,
|
|
2226
|
+
...patch
|
|
2227
|
+
});
|
|
2228
|
+
};
|
|
2229
|
+
const toggleWorkspace = (workspace) => {
|
|
2230
|
+
const key = workspaceKey(workspace);
|
|
2231
|
+
const selected = selectedWorkspaceKeys.has(key);
|
|
2232
|
+
const nextWorkspaces = selected ? selection.workspaces.filter((item) => JSON.stringify([
|
|
2233
|
+
item.originInstanceId,
|
|
2234
|
+
item.originEntityId,
|
|
2235
|
+
item.remotePath
|
|
2236
|
+
]) !== key) : [...selection.workspaces, {
|
|
2237
|
+
...workspace.origin,
|
|
2238
|
+
remotePath: workspace.remotePath
|
|
2239
|
+
}];
|
|
2240
|
+
const nextSessions = selected ? selection.sessions : selection.sessions.filter((origin) => !catalog.sessions.some((session) => originKey(session.origin) === originKey(origin) && sessionWorkspaceMatches(session, workspace)));
|
|
2241
|
+
setSelection({
|
|
2242
|
+
workspaces: nextWorkspaces,
|
|
2243
|
+
sessions: nextSessions
|
|
2244
|
+
});
|
|
2245
|
+
};
|
|
2246
|
+
const toggleSession = (session) => {
|
|
2247
|
+
setSelection({ sessions: toggleOrigin(selection.sessions, session.origin) });
|
|
2248
|
+
};
|
|
2249
|
+
const sessionsFor = (workspace) => catalog.sessions.filter((session) => !session.branchId && sessionWorkspaceMatches(session, workspace)).sort((a, b) => a.sessionId.localeCompare(b.sessionId));
|
|
2250
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2251
|
+
style: {
|
|
2252
|
+
display: "grid",
|
|
2253
|
+
gap: 10,
|
|
2254
|
+
fontSize: 12
|
|
2255
|
+
},
|
|
2256
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2257
|
+
style: {
|
|
2258
|
+
display: "flex",
|
|
2259
|
+
gap: 12,
|
|
2260
|
+
flexWrap: "wrap"
|
|
2261
|
+
},
|
|
2262
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2263
|
+
style: {
|
|
2264
|
+
display: "flex",
|
|
2265
|
+
alignItems: "center",
|
|
2266
|
+
gap: 6,
|
|
2267
|
+
cursor: disabled ? "default" : "pointer"
|
|
2268
|
+
},
|
|
2269
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2270
|
+
type: "radio",
|
|
2271
|
+
name: props.name,
|
|
2272
|
+
checked: selection.mode === "all",
|
|
2273
|
+
disabled,
|
|
2274
|
+
onChange: () => props.onChange({
|
|
2275
|
+
mode: "all",
|
|
2276
|
+
nodes: [],
|
|
2277
|
+
workspaces: [],
|
|
2278
|
+
sessions: []
|
|
2279
|
+
})
|
|
2280
|
+
}), "全部可同步内容"]
|
|
2281
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2282
|
+
style: {
|
|
2283
|
+
display: "flex",
|
|
2284
|
+
alignItems: "center",
|
|
2285
|
+
gap: 6,
|
|
2286
|
+
cursor: disabled ? "default" : "pointer"
|
|
2287
|
+
},
|
|
2288
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2289
|
+
type: "radio",
|
|
2290
|
+
name: props.name,
|
|
2291
|
+
checked: selection.mode === "selected",
|
|
2292
|
+
disabled,
|
|
2293
|
+
onChange: () => props.onChange({
|
|
2294
|
+
...selection,
|
|
2295
|
+
mode: "selected"
|
|
2296
|
+
})
|
|
2297
|
+
}), "自选范围"]
|
|
2298
|
+
})]
|
|
2299
|
+
}), selection.mode === "selected" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2300
|
+
style: {
|
|
2301
|
+
display: "grid",
|
|
2302
|
+
gap: 10,
|
|
2303
|
+
maxHeight: 320,
|
|
2304
|
+
overflowY: "auto",
|
|
2305
|
+
padding: "8px 10px",
|
|
2306
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
2307
|
+
borderRadius: 8
|
|
2308
|
+
},
|
|
2309
|
+
children: [
|
|
2310
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
2311
|
+
style: {
|
|
2312
|
+
display: "grid",
|
|
2313
|
+
gap: 6
|
|
2314
|
+
},
|
|
2315
|
+
children: [
|
|
2316
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
|
|
2317
|
+
style: { opacity: .72 },
|
|
2318
|
+
children: "工作节点"
|
|
2319
|
+
}),
|
|
2320
|
+
catalog.nodes.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2321
|
+
style: { opacity: .55 },
|
|
2322
|
+
children: "目录中没有可同步工作节点"
|
|
2323
|
+
}),
|
|
2324
|
+
catalog.nodes.map((node) => {
|
|
2325
|
+
const key = originKey(node.origin);
|
|
2326
|
+
const explicitlySelected = hasOrigin(selection.nodes, node.origin);
|
|
2327
|
+
const required = requiredNodes.has(key) && !explicitlySelected;
|
|
2328
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2329
|
+
style: {
|
|
2330
|
+
display: "flex",
|
|
2331
|
+
alignItems: "center",
|
|
2332
|
+
gap: 7,
|
|
2333
|
+
cursor: disabled ? "default" : "pointer"
|
|
2334
|
+
},
|
|
2335
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2336
|
+
type: "checkbox",
|
|
2337
|
+
checked: explicitlySelected || required,
|
|
2338
|
+
disabled: disabled || required,
|
|
2339
|
+
onChange: () => setSelection({ nodes: toggleOrigin(selection.nodes, node.origin) })
|
|
2340
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
2341
|
+
node.name,
|
|
2342
|
+
" ",
|
|
2343
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2344
|
+
style: { opacity: .55 },
|
|
2345
|
+
children: [
|
|
2346
|
+
"(",
|
|
2347
|
+
node.type,
|
|
2348
|
+
")",
|
|
2349
|
+
required ? " · 依赖自动包含" : ""
|
|
2350
|
+
]
|
|
2351
|
+
})
|
|
2352
|
+
] })]
|
|
2353
|
+
}, key);
|
|
2354
|
+
})
|
|
2355
|
+
]
|
|
2356
|
+
}),
|
|
2357
|
+
includeSessions && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
2358
|
+
style: {
|
|
2359
|
+
display: "grid",
|
|
2360
|
+
gap: 6
|
|
2361
|
+
},
|
|
2362
|
+
children: [
|
|
2363
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
|
|
2364
|
+
style: { opacity: .72 },
|
|
2365
|
+
children: "工作区与会话"
|
|
2366
|
+
}),
|
|
2367
|
+
catalog.workspaces.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2368
|
+
style: { opacity: .55 },
|
|
2369
|
+
children: "目录中没有可同步工作区"
|
|
2370
|
+
}),
|
|
2371
|
+
catalog.workspaces.map((workspace) => {
|
|
2372
|
+
const key = workspaceKey(workspace);
|
|
2373
|
+
const workspaceSelected = selectedWorkspaceKeys.has(key);
|
|
2374
|
+
const children = sessionsFor(workspace);
|
|
2375
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2376
|
+
style: {
|
|
2377
|
+
display: "grid",
|
|
2378
|
+
gap: 5,
|
|
2379
|
+
padding: "4px 0 4px 2px"
|
|
2380
|
+
},
|
|
2381
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2382
|
+
style: {
|
|
2383
|
+
display: "flex",
|
|
2384
|
+
alignItems: "flex-start",
|
|
2385
|
+
gap: 7,
|
|
2386
|
+
cursor: disabled ? "default" : "pointer"
|
|
2387
|
+
},
|
|
2388
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2389
|
+
type: "checkbox",
|
|
2390
|
+
checked: workspaceSelected,
|
|
2391
|
+
disabled,
|
|
2392
|
+
style: { marginTop: 1 },
|
|
2393
|
+
onChange: () => toggleWorkspace(workspace)
|
|
2394
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2395
|
+
style: { minWidth: 0 },
|
|
2396
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: workspace.title || workspace.remotePath }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2397
|
+
style: {
|
|
2398
|
+
display: "block",
|
|
2399
|
+
opacity: .5,
|
|
2400
|
+
overflowWrap: "anywhere"
|
|
2401
|
+
},
|
|
2402
|
+
children: [workspace.remotePath, " · 选择工作区将包含其会话"]
|
|
2403
|
+
})]
|
|
2404
|
+
})]
|
|
2405
|
+
}), children.map((session) => {
|
|
2406
|
+
const sessionSelected = selectedSessions.has(originKey(session.origin));
|
|
2407
|
+
const sessionName = session.title?.trim() || "未命名会话";
|
|
2408
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2409
|
+
style: {
|
|
2410
|
+
display: "flex",
|
|
2411
|
+
alignItems: "center",
|
|
2412
|
+
gap: 7,
|
|
2413
|
+
marginLeft: 20,
|
|
2414
|
+
cursor: disabled || workspaceSelected ? "default" : "pointer",
|
|
2415
|
+
opacity: workspaceSelected ? .55 : .82
|
|
2416
|
+
},
|
|
2417
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2418
|
+
type: "checkbox",
|
|
2419
|
+
checked: workspaceSelected || sessionSelected,
|
|
2420
|
+
disabled: disabled || workspaceSelected,
|
|
2421
|
+
onChange: () => toggleSession(session)
|
|
2422
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2423
|
+
style: {
|
|
2424
|
+
minWidth: 0,
|
|
2425
|
+
overflow: "hidden",
|
|
2426
|
+
textOverflow: "ellipsis",
|
|
2427
|
+
whiteSpace: "nowrap"
|
|
2428
|
+
},
|
|
2429
|
+
title: `${sessionName} · ${session.sessionId}`,
|
|
2430
|
+
children: [sessionName.slice(0, 48), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2431
|
+
style: {
|
|
2432
|
+
opacity: .55,
|
|
2433
|
+
marginLeft: 6
|
|
2434
|
+
},
|
|
2435
|
+
children: [session.sizeBytes === void 0 ? "未知大小" : `${session.sizeBytes.toLocaleString()} B`, session.deleted ? " · 已删除" : ""]
|
|
2436
|
+
})]
|
|
2437
|
+
})]
|
|
2438
|
+
}, `${originKey(session.origin)}:${session.branchId ?? ""}`);
|
|
2439
|
+
})]
|
|
2440
|
+
}, key);
|
|
2441
|
+
})
|
|
2442
|
+
]
|
|
2443
|
+
}),
|
|
2444
|
+
includeSessions && catalog.sessions.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2445
|
+
style: { opacity: .55 },
|
|
2446
|
+
children: "目录中没有可同步会话"
|
|
2447
|
+
})
|
|
2448
|
+
]
|
|
2449
|
+
})]
|
|
2450
|
+
});
|
|
2451
|
+
}
|
|
2452
|
+
//#endregion
|
|
2192
2453
|
//#region src/client/sync-peer-form.ts
|
|
2193
2454
|
const EMPTY_SYNC_PEER_FORM = {
|
|
2194
2455
|
name: "",
|
|
@@ -2204,7 +2465,14 @@ window.__ModuleLoader__.load({
|
|
|
2204
2465
|
remoteWebPort: "",
|
|
2205
2466
|
direction: "pull",
|
|
2206
2467
|
schedule: "manual",
|
|
2468
|
+
mode: "full",
|
|
2207
2469
|
syncSessions: false,
|
|
2470
|
+
selection: {
|
|
2471
|
+
mode: "all",
|
|
2472
|
+
nodes: [],
|
|
2473
|
+
workspaces: [],
|
|
2474
|
+
sessions: []
|
|
2475
|
+
},
|
|
2208
2476
|
enabled: true
|
|
2209
2477
|
};
|
|
2210
2478
|
function validPort(value) {
|
|
@@ -2233,7 +2501,14 @@ window.__ModuleLoader__.load({
|
|
|
2233
2501
|
remoteWebPort: peer.remoteWebPort == null ? "" : String(peer.remoteWebPort),
|
|
2234
2502
|
direction: peer.direction,
|
|
2235
2503
|
schedule: peer.schedule,
|
|
2504
|
+
mode: peer.syncSessions ? peer.mode ?? "full" : "full",
|
|
2236
2505
|
syncSessions: peer.syncSessions,
|
|
2506
|
+
selection: peer.selection ?? {
|
|
2507
|
+
mode: "all",
|
|
2508
|
+
nodes: [],
|
|
2509
|
+
workspaces: [],
|
|
2510
|
+
sessions: []
|
|
2511
|
+
},
|
|
2237
2512
|
enabled: peer.enabled
|
|
2238
2513
|
};
|
|
2239
2514
|
}
|
|
@@ -2246,7 +2521,9 @@ window.__ModuleLoader__.load({
|
|
|
2246
2521
|
authKind: form.authKind,
|
|
2247
2522
|
direction: form.direction,
|
|
2248
2523
|
schedule: form.schedule,
|
|
2524
|
+
mode: form.mode,
|
|
2249
2525
|
syncSessions: form.syncSessions,
|
|
2526
|
+
selection: form.selection,
|
|
2250
2527
|
enabled: form.enabled,
|
|
2251
2528
|
...form.remoteDshHome.trim() ? { remoteDshHome: form.remoteDshHome.trim() } : {},
|
|
2252
2529
|
...form.remoteProfile.trim() ? { remoteProfile: form.remoteProfile.trim() } : {},
|
|
@@ -2394,6 +2671,8 @@ window.__ModuleLoader__.load({
|
|
|
2394
2671
|
const [probing, setProbing] = (0, react.useState)(false);
|
|
2395
2672
|
const [probingRemote, setProbingRemote] = (0, react.useState)(false);
|
|
2396
2673
|
const [remoteProbe, setRemoteProbe] = (0, react.useState)(void 0);
|
|
2674
|
+
const [catalog, setCatalog] = (0, react.useState)(void 0);
|
|
2675
|
+
const [loadingCatalog, setLoadingCatalog] = (0, react.useState)(false);
|
|
2397
2676
|
const [syncing, setSyncing] = (0, react.useState)(false);
|
|
2398
2677
|
const [stopping, setStopping] = (0, react.useState)(false);
|
|
2399
2678
|
const [notice, setNotice] = (0, react.useState)(void 0);
|
|
@@ -2442,6 +2721,7 @@ window.__ModuleLoader__.load({
|
|
|
2442
2721
|
setSelectedId(id);
|
|
2443
2722
|
setNotice(void 0);
|
|
2444
2723
|
setHostKeyChallenge(void 0);
|
|
2724
|
+
setCatalog(void 0);
|
|
2445
2725
|
const peer = id === "new" ? void 0 : peers.find((item) => item.id === id);
|
|
2446
2726
|
setForm(peer ? toSyncPeerForm(peer) : EMPTY_SYNC_PEER_FORM);
|
|
2447
2727
|
};
|
|
@@ -2514,6 +2794,36 @@ window.__ModuleLoader__.load({
|
|
|
2514
2794
|
setProbing(false);
|
|
2515
2795
|
}
|
|
2516
2796
|
};
|
|
2797
|
+
const loadCatalog = async () => {
|
|
2798
|
+
if (selectedId === "new") return;
|
|
2799
|
+
setLoadingCatalog(true);
|
|
2800
|
+
setHostKeyChallenge(void 0);
|
|
2801
|
+
try {
|
|
2802
|
+
const response = await fetch(`/api/dshb/sync/peers/${selectedId}/catalog`);
|
|
2803
|
+
const data = await readJsonResponse(response, "读取目标节点目录失败");
|
|
2804
|
+
if (data.code === "host-key-untrusted" || data.code === "host-key-changed") {
|
|
2805
|
+
setHostKeyChallenge({
|
|
2806
|
+
code: data.code,
|
|
2807
|
+
fingerprint: data.fingerprint ?? "",
|
|
2808
|
+
...data.expected ? { expected: data.expected } : {}
|
|
2809
|
+
});
|
|
2810
|
+
return;
|
|
2811
|
+
}
|
|
2812
|
+
if (!response.ok || !data.ok || !data.catalog) throw new Error(data.error ?? "读取目标节点目录失败");
|
|
2813
|
+
setCatalog(data.catalog);
|
|
2814
|
+
setNotice({
|
|
2815
|
+
kind: "ok",
|
|
2816
|
+
text: `已读取目标节点目录:${data.catalog.nodes.length} 个工作节点、${data.catalog.workspaces.length} 个工作区、${data.catalog.sessions.length} 个会话`
|
|
2817
|
+
});
|
|
2818
|
+
} catch (error) {
|
|
2819
|
+
setNotice({
|
|
2820
|
+
kind: "error",
|
|
2821
|
+
text: error instanceof Error ? error.message : "读取目标节点目录失败"
|
|
2822
|
+
});
|
|
2823
|
+
} finally {
|
|
2824
|
+
setLoadingCatalog(false);
|
|
2825
|
+
}
|
|
2826
|
+
};
|
|
2517
2827
|
const probeRemote = async () => {
|
|
2518
2828
|
const secretReady = form.authKind === "password" ? form.password !== "" : form.privateKey !== "";
|
|
2519
2829
|
if (selectedId === "new" && (!form.host.trim() || !form.username.trim() || !secretReady)) {
|
|
@@ -3155,52 +3465,130 @@ window.__ModuleLoader__.load({
|
|
|
3155
3465
|
flexDirection: "column",
|
|
3156
3466
|
gap: 10
|
|
3157
3467
|
},
|
|
3158
|
-
children: [
|
|
3159
|
-
|
|
3160
|
-
display: "flex",
|
|
3161
|
-
alignItems: "flex-start",
|
|
3162
|
-
gap: 8,
|
|
3163
|
-
cursor: "pointer"
|
|
3164
|
-
},
|
|
3165
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3166
|
-
type: "checkbox",
|
|
3167
|
-
checked: form.syncSessions,
|
|
3168
|
-
style: { marginTop: 2 },
|
|
3169
|
-
onChange: (e) => setForm((c) => ({
|
|
3170
|
-
...c,
|
|
3171
|
-
syncSessions: e.target.checked
|
|
3172
|
-
}))
|
|
3173
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3174
|
-
style: { fontSize: 13 },
|
|
3175
|
-
children: "同步工作区会话"
|
|
3176
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3468
|
+
children: [
|
|
3469
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
3177
3470
|
style: {
|
|
3178
|
-
display: "
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3471
|
+
display: "flex",
|
|
3472
|
+
alignItems: "flex-start",
|
|
3473
|
+
gap: 8,
|
|
3474
|
+
cursor: "pointer"
|
|
3182
3475
|
},
|
|
3183
|
-
children:
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3476
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3477
|
+
type: "checkbox",
|
|
3478
|
+
checked: form.syncSessions,
|
|
3479
|
+
style: { marginTop: 2 },
|
|
3480
|
+
onChange: (e) => setForm((c) => ({
|
|
3481
|
+
...c,
|
|
3482
|
+
syncSessions: e.target.checked,
|
|
3483
|
+
...e.target.checked ? {} : { mode: "full" }
|
|
3484
|
+
}))
|
|
3485
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3486
|
+
style: { fontSize: 13 },
|
|
3487
|
+
children: "同步工作区会话"
|
|
3488
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3489
|
+
style: {
|
|
3490
|
+
display: "block",
|
|
3491
|
+
fontSize: 11,
|
|
3492
|
+
opacity: .5,
|
|
3493
|
+
marginTop: 2
|
|
3494
|
+
},
|
|
3495
|
+
children: form.mode === "metadata" ? "同步远端工作区与会话列表,通过加密通道实时访问会话内容" : "同步会话完整内容,导入后可在本机继续;保留冲突分支供恢复"
|
|
3496
|
+
})] })]
|
|
3497
|
+
}),
|
|
3498
|
+
form.syncSessions && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3499
|
+
style: {
|
|
3500
|
+
...field,
|
|
3501
|
+
margin: 0
|
|
3502
|
+
},
|
|
3503
|
+
children: [
|
|
3504
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3505
|
+
style: label,
|
|
3506
|
+
children: "同步模式"
|
|
3507
|
+
}),
|
|
3508
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
3509
|
+
style: inputStyle$1,
|
|
3510
|
+
value: form.mode,
|
|
3511
|
+
onChange: (e) => setForm((c) => ({
|
|
3512
|
+
...c,
|
|
3513
|
+
mode: e.target.value
|
|
3514
|
+
})),
|
|
3515
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
3516
|
+
value: "full",
|
|
3517
|
+
children: "全量同步"
|
|
3518
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
3519
|
+
value: "metadata",
|
|
3520
|
+
children: "元数据同步"
|
|
3521
|
+
})]
|
|
3522
|
+
}),
|
|
3523
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3524
|
+
style: hint,
|
|
3525
|
+
children: form.mode === "metadata" ? "仅同步工作节点与工作区会话列表,不传输会话内容;点击同步来的会话时,通过加密 SSH 通道读取远端内容;wss 实时事件流与发送消息将在后续版本接入。" : "将工作节点配置与工作区会话内容完整传输到对端;导入后可在本机离线继续会话,数据量大时耗时较长。"
|
|
3526
|
+
})
|
|
3527
|
+
]
|
|
3528
|
+
}),
|
|
3529
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
3530
|
+
style: {
|
|
3531
|
+
display: "flex",
|
|
3532
|
+
alignItems: "center",
|
|
3533
|
+
gap: 8,
|
|
3534
|
+
cursor: "pointer"
|
|
3535
|
+
},
|
|
3536
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3537
|
+
type: "checkbox",
|
|
3538
|
+
checked: form.enabled,
|
|
3539
|
+
onChange: (e) => setForm((c) => ({
|
|
3540
|
+
...c,
|
|
3541
|
+
enabled: e.target.checked
|
|
3542
|
+
}))
|
|
3543
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3544
|
+
style: { fontSize: 13 },
|
|
3545
|
+
children: "启用此同步节点"
|
|
3546
|
+
})]
|
|
3547
|
+
})
|
|
3548
|
+
]
|
|
3549
|
+
}),
|
|
3550
|
+
selectedPeer && form.syncSessions && form.mode === "full" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3551
|
+
style: {
|
|
3552
|
+
...field,
|
|
3553
|
+
display: "grid",
|
|
3554
|
+
gap: 8
|
|
3555
|
+
},
|
|
3556
|
+
children: [
|
|
3557
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3558
|
+
style: {
|
|
3559
|
+
display: "flex",
|
|
3560
|
+
alignItems: "center",
|
|
3561
|
+
justifyContent: "space-between",
|
|
3562
|
+
gap: 10,
|
|
3563
|
+
flexWrap: "wrap"
|
|
3564
|
+
},
|
|
3565
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3566
|
+
style: label,
|
|
3567
|
+
children: "同步范围"
|
|
3568
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3569
|
+
type: "button",
|
|
3570
|
+
style: secondaryBtn,
|
|
3571
|
+
disabled: loadingCatalog || probing || busy,
|
|
3572
|
+
onClick: () => void loadCatalog(),
|
|
3573
|
+
children: loadingCatalog ? "读取范围中…" : catalog ? "重新读取同步范围" : "读取同步范围"
|
|
3574
|
+
})]
|
|
3575
|
+
}),
|
|
3576
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3577
|
+
style: hint,
|
|
3578
|
+
children: "每次点击都会从目标同步节点实时拉取可选项。选择工作区会包含其会话;单独选择会话时会自动纳入所需的工作区与节点。"
|
|
3579
|
+
}),
|
|
3580
|
+
catalog && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SyncSelectionPicker, {
|
|
3581
|
+
catalog,
|
|
3582
|
+
selection: form.selection,
|
|
3583
|
+
name: `sync-selection-${selectedPeer.id}`,
|
|
3584
|
+
onChange: (selection) => setForm((current) => ({
|
|
3585
|
+
...current,
|
|
3586
|
+
selection
|
|
3587
|
+
})),
|
|
3588
|
+
includeSessions: form.syncSessions,
|
|
3589
|
+
disabled: busy
|
|
3590
|
+
})
|
|
3591
|
+
]
|
|
3204
3592
|
}),
|
|
3205
3593
|
selectedPeer?.hostKeyFingerprint && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3206
3594
|
style: field,
|
|
@@ -3439,6 +3827,14 @@ window.__ModuleLoader__.load({
|
|
|
3439
3827
|
const [exportPassword, setExportPassword] = (0, react.useState)("");
|
|
3440
3828
|
const [confirmPassword, setConfirmPassword] = (0, react.useState)("");
|
|
3441
3829
|
const [includeSessions, setIncludeSessions] = (0, react.useState)(false);
|
|
3830
|
+
const [selection, setSelection] = (0, react.useState)({
|
|
3831
|
+
mode: "all",
|
|
3832
|
+
nodes: [],
|
|
3833
|
+
workspaces: [],
|
|
3834
|
+
sessions: []
|
|
3835
|
+
});
|
|
3836
|
+
const [catalog, setCatalog] = (0, react.useState)(void 0);
|
|
3837
|
+
const [loadingCatalog, setLoadingCatalog] = (0, react.useState)(false);
|
|
3442
3838
|
const [importPassword, setImportPassword] = (0, react.useState)("");
|
|
3443
3839
|
const [file, setFile] = (0, react.useState)(void 0);
|
|
3444
3840
|
const [fileInputKey, setFileInputKey] = (0, react.useState)(0);
|
|
@@ -3470,7 +3866,8 @@ window.__ModuleLoader__.load({
|
|
|
3470
3866
|
headers: { "content-type": "application/json" },
|
|
3471
3867
|
body: JSON.stringify({
|
|
3472
3868
|
password: exportPassword,
|
|
3473
|
-
includeSessions
|
|
3869
|
+
includeSessions,
|
|
3870
|
+
selection
|
|
3474
3871
|
})
|
|
3475
3872
|
});
|
|
3476
3873
|
if (!response.ok) throw await responseError(response, "导出离线配置失败");
|
|
@@ -3501,6 +3898,26 @@ window.__ModuleLoader__.load({
|
|
|
3501
3898
|
setConfirmPassword("");
|
|
3502
3899
|
}
|
|
3503
3900
|
};
|
|
3901
|
+
const loadCatalog = async () => {
|
|
3902
|
+
setLoadingCatalog(true);
|
|
3903
|
+
try {
|
|
3904
|
+
const response = await fetch("/api/dshb/sync/offline/catalog");
|
|
3905
|
+
const data = await response.json();
|
|
3906
|
+
if (!response.ok || !data.ok || !data.catalog) throw new Error(data.error ?? "读取本机目录失败");
|
|
3907
|
+
setCatalog(data.catalog);
|
|
3908
|
+
setNotice({
|
|
3909
|
+
kind: "ok",
|
|
3910
|
+
text: `已读取本机目录:${data.catalog.nodes.length} 个工作节点、${data.catalog.workspaces.length} 个工作区、${data.catalog.sessions.length} 个会话`
|
|
3911
|
+
});
|
|
3912
|
+
} catch (error) {
|
|
3913
|
+
setNotice({
|
|
3914
|
+
kind: "error",
|
|
3915
|
+
text: error instanceof Error ? error.message : "读取本机目录失败"
|
|
3916
|
+
});
|
|
3917
|
+
} finally {
|
|
3918
|
+
setLoadingCatalog(false);
|
|
3919
|
+
}
|
|
3920
|
+
};
|
|
3504
3921
|
const importArchive = async () => {
|
|
3505
3922
|
const error = passwordError(importPassword);
|
|
3506
3923
|
if (error) {
|
|
@@ -3659,6 +4076,26 @@ window.__ModuleLoader__.load({
|
|
|
3659
4076
|
children: "包含会话日志与附件,导出文件可能较大。"
|
|
3660
4077
|
})] })]
|
|
3661
4078
|
}),
|
|
4079
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4080
|
+
style: {
|
|
4081
|
+
display: "grid",
|
|
4082
|
+
gap: 8
|
|
4083
|
+
},
|
|
4084
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4085
|
+
type: "button",
|
|
4086
|
+
style: buttonStyle$1,
|
|
4087
|
+
disabled: busy !== void 0 || loadingCatalog,
|
|
4088
|
+
onClick: () => void loadCatalog(),
|
|
4089
|
+
children: loadingCatalog ? "读取本机目录中…" : catalog ? "刷新本机目录" : "读取本机目录"
|
|
4090
|
+
}), catalog && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SyncSelectionPicker, {
|
|
4091
|
+
catalog,
|
|
4092
|
+
selection,
|
|
4093
|
+
name: "offline-sync-selection",
|
|
4094
|
+
onChange: setSelection,
|
|
4095
|
+
includeSessions,
|
|
4096
|
+
disabled: busy !== void 0
|
|
4097
|
+
})]
|
|
4098
|
+
}),
|
|
3662
4099
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3663
4100
|
className: "dshb-sync-offline-actions",
|
|
3664
4101
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|