@artenx/dshb 0.1.41 → 0.1.42
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 +116 -0
- package/lib/client.js.map +1 -1
- package/lib/core/index.js +343 -7
- package/lib/core/index.js.map +1 -1
- package/lib/core/sync/coordinator.d.ts +2 -2
- package/lib/core/sync/internal-routes.d.ts +1 -1
- package/lib/core/sync/offline-archive.d.ts +1 -1
- package/lib/core/sync/routes.d.ts +1 -1
- package/lib/core/sync/session-journal.d.ts +1 -1
- package/lib/core/sync/session-journal.js +10 -0
- package/lib/core/sync/session-journal.js.map +1 -1
- package/lib/core/sync/session-routes.d.ts +1 -1
- package/lib/core/sync/session-sync.d.ts +1 -1
- package/lib/core/sync/ssh-transport.d.ts +1 -1
- package/lib/{session-journal-lum5L2ip.d.ts → session-journal-ftjZuIxo.d.ts} +3 -1
- package/lib/{session-sync-Be5wuYHJ.d.ts → session-sync-AlV-M72t.d.ts} +2 -2
- package/lib/{ssh-transport-Cevwfre9.d.ts → ssh-transport-a3qXoscG.d.ts} +2 -2
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -2189,6 +2189,121 @@ window.__ModuleLoader__.load({
|
|
|
2189
2189
|
scan();
|
|
2190
2190
|
}
|
|
2191
2191
|
//#endregion
|
|
2192
|
+
//#region src/client/remote-session.tsx
|
|
2193
|
+
/** 会话行悬停按钮:该会话来自某个同步 peer 时显示「打开远端会话」。 */
|
|
2194
|
+
function RemoteSessionRowAction({ sessionId }) {
|
|
2195
|
+
const [origin, setOrigin] = (0, react.useState)(void 0);
|
|
2196
|
+
const [checked, setChecked] = (0, react.useState)(false);
|
|
2197
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
2198
|
+
const id = String(sessionId ?? "");
|
|
2199
|
+
(0, react.useEffect)(() => {
|
|
2200
|
+
let cancelled = false;
|
|
2201
|
+
setChecked(false);
|
|
2202
|
+
setOrigin(void 0);
|
|
2203
|
+
if (!id) {
|
|
2204
|
+
setChecked(true);
|
|
2205
|
+
return;
|
|
2206
|
+
}
|
|
2207
|
+
fetch(`/api/dshb/sync/session-origin?sessionId=${encodeURIComponent(id)}`, { cache: "no-store" }).then(async (res) => res.ok ? await res.json() : void 0).then((body) => {
|
|
2208
|
+
if (cancelled) return;
|
|
2209
|
+
if (body?.peerId && body.remoteSessionId) setOrigin({
|
|
2210
|
+
peerId: body.peerId,
|
|
2211
|
+
remoteSessionId: body.remoteSessionId
|
|
2212
|
+
});
|
|
2213
|
+
setChecked(true);
|
|
2214
|
+
}).catch(() => {
|
|
2215
|
+
if (!cancelled) setChecked(true);
|
|
2216
|
+
});
|
|
2217
|
+
return () => {
|
|
2218
|
+
cancelled = true;
|
|
2219
|
+
};
|
|
2220
|
+
}, [id]);
|
|
2221
|
+
if (!checked || !origin) return null;
|
|
2222
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2223
|
+
type: "button",
|
|
2224
|
+
"data-dshb-remote-session": "open",
|
|
2225
|
+
"aria-label": "打开远端会话",
|
|
2226
|
+
title: "打开远端会话(实时操作远端 DSH)",
|
|
2227
|
+
onClick: (event) => {
|
|
2228
|
+
event.stopPropagation();
|
|
2229
|
+
setOpen(true);
|
|
2230
|
+
},
|
|
2231
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
2232
|
+
width: "14",
|
|
2233
|
+
height: "14",
|
|
2234
|
+
viewBox: "0 0 16 16",
|
|
2235
|
+
fill: "none",
|
|
2236
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2237
|
+
"aria-hidden": "true",
|
|
2238
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
2239
|
+
cx: "8",
|
|
2240
|
+
cy: "8",
|
|
2241
|
+
r: "2",
|
|
2242
|
+
stroke: "currentColor",
|
|
2243
|
+
"stroke-width": "1.5"
|
|
2244
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
2245
|
+
d: "M8 3.5a4.5 4.5 0 0 1 4.5 4.5M8 3.5A4.5 4.5 0 0 0 3.5 8M8 12.5a4.5 4.5 0 0 0 3.2-1.3M8 12.5a4.5 4.5 0 0 1-3.2-1.3",
|
|
2246
|
+
stroke: "currentColor",
|
|
2247
|
+
"stroke-width": "1.5",
|
|
2248
|
+
"stroke-linecap": "round"
|
|
2249
|
+
})]
|
|
2250
|
+
})
|
|
2251
|
+
}), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RemoteSessionOverlay, {
|
|
2252
|
+
peerId: origin.peerId,
|
|
2253
|
+
onClose: () => setOpen(false)
|
|
2254
|
+
}) : null] });
|
|
2255
|
+
}
|
|
2256
|
+
const OVERLAY_STYLE = `
|
|
2257
|
+
[data-dshb-remote-overlay] { position: fixed; inset: 0; z-index: 2147483000; background: var(--dsh-bg, #0b0d10); display: flex; flex-direction: column; }
|
|
2258
|
+
[data-dshb-remote-overlay] > header { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid color-mix(in srgb, currentColor 12%, transparent); font-size: 12px; opacity: .85; }
|
|
2259
|
+
[data-dshb-remote-overlay] > header button { cursor: pointer; }
|
|
2260
|
+
[data-dshb-remote-overlay] > iframe { flex: 1; width: 100%; border: 0; background: transparent; }
|
|
2261
|
+
`;
|
|
2262
|
+
function RemoteSessionOverlay({ peerId, onClose }) {
|
|
2263
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2264
|
+
"data-dshb-remote-overlay": true,
|
|
2265
|
+
role: "dialog",
|
|
2266
|
+
"aria-label": "远端会话",
|
|
2267
|
+
children: [
|
|
2268
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: OVERLAY_STYLE }),
|
|
2269
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2270
|
+
type: "button",
|
|
2271
|
+
"aria-label": "返回本地会话",
|
|
2272
|
+
title: "返回本地会话",
|
|
2273
|
+
onClick: onClose,
|
|
2274
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
2275
|
+
width: "14",
|
|
2276
|
+
height: "14",
|
|
2277
|
+
viewBox: "0 0 16 16",
|
|
2278
|
+
fill: "none",
|
|
2279
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2280
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
2281
|
+
d: "M10 3L5 8L10 13",
|
|
2282
|
+
stroke: "currentColor",
|
|
2283
|
+
"stroke-width": "1.5",
|
|
2284
|
+
"stroke-linecap": "round",
|
|
2285
|
+
"stroke-linejoin": "round"
|
|
2286
|
+
})
|
|
2287
|
+
})
|
|
2288
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "远端会话视图 · 实时操作远端 DSH" })] }),
|
|
2289
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("iframe", {
|
|
2290
|
+
src: `/api/dshb/sync/relay/${encodeURIComponent(peerId)}/app/`,
|
|
2291
|
+
title: "远端会话"
|
|
2292
|
+
})
|
|
2293
|
+
]
|
|
2294
|
+
});
|
|
2295
|
+
}
|
|
2296
|
+
/** 注册远端会话入口(侧栏会话行悬停按钮带,位于 pin 之后)。 */
|
|
2297
|
+
function installRemoteSessionEntry(ctx) {
|
|
2298
|
+
const slots = ctx.slots;
|
|
2299
|
+
if (!slots) return;
|
|
2300
|
+
slots.inject("sidebar.workspaces.session.row.action", () => slots.register({
|
|
2301
|
+
name: "sidebar.workspaces.session.row.action",
|
|
2302
|
+
id: "dshb-remote-session",
|
|
2303
|
+
order: 300
|
|
2304
|
+
}, RemoteSessionRowAction));
|
|
2305
|
+
}
|
|
2306
|
+
//#endregion
|
|
2192
2307
|
//#region src/client/sync-selection-picker.tsx
|
|
2193
2308
|
function originKey(origin) {
|
|
2194
2309
|
return JSON.stringify([origin.originInstanceId, origin.originEntityId]);
|
|
@@ -5289,6 +5404,7 @@ window.__ModuleLoader__.load({
|
|
|
5289
5404
|
name: "sidebar.workspaces.directoryFlow",
|
|
5290
5405
|
priority: -10
|
|
5291
5406
|
}, DirectoryFlowOccupant));
|
|
5407
|
+
installRemoteSessionEntry(sub);
|
|
5292
5408
|
}
|
|
5293
5409
|
});
|
|
5294
5410
|
const ICON_SVG = {
|