@linxin666/dsh-remote-bridge 0.4.8 → 0.4.10
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.i18n.yaml +2 -2
- package/README.md +75 -18
- package/README.zh.md +74 -18
- package/lib/client.js +783 -260
- package/lib/client.js.map +1 -1
- package/lib/index.js +15849 -2913
- package/lib/types/client/PairEntry.d.ts +2 -2
- package/lib/types/client/PairPanel.d.ts +10 -2
- package/lib/types/client/UiPresentRow.d.ts +13 -0
- package/lib/types/client/icons.d.ts +5 -13
- package/lib/types/client/index.d.ts +4 -0
- package/lib/types/client/locales.d.ts +24 -15
- package/lib/types/client/semantic.d.ts +9 -5
- package/lib/types/client/toolview-slot.d.ts +68 -0
- package/lib/types/client/ui-card.d.ts +160 -0
- package/lib/types/core/commands.d.ts +59 -0
- package/lib/types/core/connection.d.ts +106 -0
- package/lib/types/core/devices.d.ts +102 -2
- package/lib/types/core/extension.d.ts +13 -0
- package/lib/types/core/hub.d.ts +129 -15
- package/lib/types/core/liveactivity.d.ts +324 -0
- package/lib/types/core/protocol.d.ts +328 -5
- package/lib/types/core/push.d.ts +186 -0
- package/lib/types/core/questions.d.ts +61 -9
- package/lib/types/core/session-meta.d.ts +55 -1
- package/lib/types/core/squads.d.ts +130 -0
- package/lib/types/core/turn-end-quiet.d.ts +135 -0
- package/lib/types/core/ui.d.ts +238 -0
- package/lib/types/core/usage-stats.d.ts +160 -0
- package/lib/types/core/usage.d.ts +294 -0
- package/lib/types/host/apns.d.ts +151 -0
- package/lib/types/host/squads-ledger.d.ts +39 -0
- package/lib/types/host/squads.d.ts +77 -0
- package/lib/types/host/ui-tools.d.ts +80 -0
- package/lib/types/host/usage-stats.d.ts +75 -0
- package/lib/types/host/watchers.d.ts +95 -0
- package/lib/types/index.d.ts +47 -3
- package/package.json +15 -14
- package/src/client/PairEntry.tsx +58 -31
- package/src/client/PairPanel.tsx +181 -97
- package/src/client/UiPresentRow.tsx +149 -0
- package/src/client/icons.tsx +17 -60
- package/src/client/index.ts +11 -0
- package/src/client/locales.ts +36 -24
- package/src/client/panel.module.css +239 -186
- package/src/client/semantic.ts +10 -6
- package/src/client/toolview-slot.ts +84 -0
- package/src/client/ui-card.ts +368 -0
- package/src/client/ui-present.module.css +87 -0
- package/src/core/commands.ts +95 -0
- package/src/core/connection.ts +811 -12
- package/src/core/devices.ts +337 -5
- package/src/core/extension.ts +20 -0
- package/src/core/hub.ts +518 -43
- package/src/core/liveactivity.ts +833 -0
- package/src/core/protocol.ts +370 -5
- package/src/core/push.ts +385 -0
- package/src/core/questions.ts +81 -10
- package/src/core/session-meta.ts +73 -1
- package/src/core/squads.ts +345 -0
- package/src/core/turn-end-quiet.ts +388 -0
- package/src/core/ui.ts +398 -0
- package/src/core/usage-stats.ts +424 -0
- package/src/core/usage.ts +937 -0
- package/src/core/wire.ts +8 -0
- package/src/host/apns.ts +320 -0
- package/src/host/squads-ledger.ts +105 -0
- package/src/host/squads.ts +206 -0
- package/src/host/ui-tools.ts +233 -0
- package/src/host/usage-stats.ts +155 -0
- package/src/host/watchers.ts +296 -0
- package/src/index.ts +327 -10
package/lib/client.js
CHANGED
|
@@ -29,7 +29,6 @@ window.__ModuleLoader__.load({
|
|
|
29
29
|
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
30
30
|
let react = require("react");
|
|
31
31
|
react = __toESM(react, 1);
|
|
32
|
-
let react_dom = require("react-dom");
|
|
33
32
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
34
33
|
//#region ../../node_modules/.pnpm/qrcode.react@4.2.0_react@18.3.1/node_modules/qrcode.react/lib/esm/index.js
|
|
35
34
|
var __defProp = Object.defineProperty;
|
|
@@ -1212,64 +1211,6 @@ window.__ModuleLoader__.load({
|
|
|
1212
1211
|
});
|
|
1213
1212
|
QRCodeSVG.displayName = "QRCodeSVG";
|
|
1214
1213
|
//#endregion
|
|
1215
|
-
//#region src/client/icons.tsx
|
|
1216
|
-
/** Shared svg attrs for the 16px stroke icon family. */
|
|
1217
|
-
function iconProps(props) {
|
|
1218
|
-
return {
|
|
1219
|
-
width: 16,
|
|
1220
|
-
height: 16,
|
|
1221
|
-
viewBox: "0 0 16 16",
|
|
1222
|
-
fill: "none",
|
|
1223
|
-
stroke: "currentColor",
|
|
1224
|
-
strokeWidth: 1.3,
|
|
1225
|
-
strokeLinecap: "round",
|
|
1226
|
-
strokeLinejoin: "round",
|
|
1227
|
-
"aria-hidden": true,
|
|
1228
|
-
...props
|
|
1229
|
-
};
|
|
1230
|
-
}
|
|
1231
|
-
/** A QR-symbol glyph: three finder squares plus a payload dot. */
|
|
1232
|
-
function QrIcon(props) {
|
|
1233
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
1234
|
-
...iconProps(props),
|
|
1235
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M2.5 2.5h4v4h-4zM9.5 2.5h4v4h-4zM2.5 9.5h4v4h-4z" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M9.5 9.5h1.6v1.6H9.5zM12.4 9.5h1.1M9.5 12.4v1.1M12 13.5h1.5v-1.5h-1.5z" })]
|
|
1236
|
-
});
|
|
1237
|
-
}
|
|
1238
|
-
/** Copy glyph. */
|
|
1239
|
-
function CopyIcon(props) {
|
|
1240
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
1241
|
-
...iconProps(props),
|
|
1242
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
|
|
1243
|
-
x: "5.5",
|
|
1244
|
-
y: "5.5",
|
|
1245
|
-
width: "9",
|
|
1246
|
-
height: "9",
|
|
1247
|
-
rx: "1.5"
|
|
1248
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M2.5 10.5v-7A1.5 1.5 0 0 1 4 2h5.5" })]
|
|
1249
|
-
});
|
|
1250
|
-
}
|
|
1251
|
-
/** Check glyph for the transient copied state. */
|
|
1252
|
-
function CheckIcon(props) {
|
|
1253
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
1254
|
-
...iconProps(props),
|
|
1255
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M3 8.5 6.5 12l6.5-8" })
|
|
1256
|
-
});
|
|
1257
|
-
}
|
|
1258
|
-
/** Close glyph for the panel header. */
|
|
1259
|
-
function CloseIcon(props) {
|
|
1260
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
1261
|
-
...iconProps(props),
|
|
1262
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M4 4l8 8M12 4l-8 8" })
|
|
1263
|
-
});
|
|
1264
|
-
}
|
|
1265
|
-
/** Refresh glyph for the mint-again action. */
|
|
1266
|
-
function RefreshIcon(props) {
|
|
1267
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
1268
|
-
...iconProps(props),
|
|
1269
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M13 8a5 5 0 1 1-1.8-3.85" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M13.2 2.4V5.6H10" })]
|
|
1270
|
-
});
|
|
1271
|
-
}
|
|
1272
|
-
//#endregion
|
|
1273
1214
|
//#region src/client/semantic.ts
|
|
1274
1215
|
/**
|
|
1275
1216
|
* Semantic attribute values for the protocol v1 pairing panel (contract:
|
|
@@ -1283,59 +1224,62 @@ window.__ModuleLoader__.load({
|
|
|
1283
1224
|
const PART_ENTRY = "entry";
|
|
1284
1225
|
/** The modal panel root. */
|
|
1285
1226
|
const PART_PANEL = "panel";
|
|
1286
|
-
/** A state notice: the origin warning, or a refusal the host raised. */
|
|
1287
|
-
const PART_NOTICE = "notice";
|
|
1288
1227
|
//#endregion
|
|
1289
1228
|
//#region \0dsh-css:packages/dsh-remote-bridge/src/client/panel.module.css.mjs
|
|
1290
|
-
const css = ".sd7VOG_trigger{width:
|
|
1291
|
-
const tagId = "@linxin666/dsh-remote-bridge/packages/dsh-remote-bridge/src/client/panel.module.css";
|
|
1292
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
1229
|
+
const css$1 = ".sd7VOG_panel,.sd7VOG_trigger,.sd7VOG_dialog{--pair-space-1:4px;--pair-space-2:8px;--pair-space-3:12px;--pair-space-4:24px;--pair-title-size:15px;--pair-title-line:24px;--pair-text-size:13px;--pair-text-line:20px;--pair-state-size:12px;--pair-state-line:18px;--pair-qr:184px;--pair-bar:4px;--pair-seat:36px;--pair-close:28px;--pair-hit:44px;--pair-width:460px;--pair-faded:.35;--pair-focus-offset:2px;--pair-status:calc(var(--pair-state-line) + var(--pair-space-1) + var(--pair-bar));--pair-address:calc(var(--pair-text-line) * 2)}.sd7VOG_trigger{width:var(--pair-seat);height:var(--pair-seat);color:var(--dsw-alias-label-secondary);cursor:pointer;transition:background-color var(--ds-transition-duration) ease, color var(--ds-transition-duration) ease;background:0 0;border:none;border-radius:50%;flex:none;order:-1;justify-content:center;align-items:center;padding:0;display:inline-flex;position:relative}.sd7VOG_trigger:after{content:\"\";inset:calc((var(--pair-hit) - var(--pair-seat)) / -2);border-radius:50%;position:absolute}.sd7VOG_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.sd7VOG_trigger:active:not(:disabled){background:var(--dsw-alias-interactive-bg-active)}.sd7VOG_trigger:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:var(--pair-focus-offset)}[class*=footerActions]:has([data-dsh-plugin=remote-bridge][data-wide=rail]){align-items:center;gap:var(--pair-space-1,4px);flex-direction:column}.sd7VOG_dialog.sd7VOG_dialog{width:min(var(--pair-width), 100%);max-height:100%;padding:var(--pair-space-4);overflow:auto}.sd7VOG_panel{gap:var(--pair-space-3);box-sizing:border-box;width:100%;max-width:100%;color:var(--dsw-alias-label-primary);font-size:var(--pair-text-size);line-height:var(--pair-text-line);transition:opacity var(--ds-transition-duration) var(--ds-ease-in-out);flex-direction:column;display:flex}.sd7VOG_panel[data-closing]{opacity:0;animation:var(--pair-exit-name,none) var(--ds-transition-duration) var(--ds-ease-in-out) reverse both}@media (prefers-reduced-motion:reduce){.sd7VOG_panel[data-closing]{animation:none}}.sd7VOG_header{align-items:flex-start;gap:var(--pair-space-3);display:flex}.sd7VOG_heading{flex:1;min-width:0}.sd7VOG_title{font-size:var(--pair-title-size);font-weight:600;line-height:var(--pair-title-line);margin:0}.sd7VOG_subtitle{margin:var(--pair-space-1) 0 0;color:var(--dsw-alias-label-secondary);font-size:var(--pair-text-size);line-height:var(--pair-text-line)}.sd7VOG_close{width:var(--pair-close);color:var(--dsw-alias-label-secondary);flex:none;padding:0;position:relative}.sd7VOG_close:after{content:\"\";inset:calc((var(--pair-hit) - var(--pair-close)) / -2);border-radius:50%;position:absolute}.sd7VOG_body{gap:var(--pair-space-2);flex-direction:column;display:flex}.sd7VOG_qrCard{align-items:center;gap:var(--pair-space-2);padding:var(--pair-space-3);border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-layer-1);flex-direction:column;display:flex}.sd7VOG_qrSlot{width:var(--pair-qr);height:var(--pair-qr);justify-content:center;align-items:center;display:flex}.sd7VOG_qrSlot[data-expired]{opacity:var(--pair-faded)}.sd7VOG_skeleton{width:var(--pair-qr);height:var(--pair-qr);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-interactive-bg-hover);display:block}.sd7VOG_status{justify-content:center;align-items:center;gap:var(--pair-space-1);box-sizing:border-box;width:100%;height:var(--pair-status);flex-direction:column;display:flex}.sd7VOG_statusText{color:var(--dsw-alias-label-secondary);font-size:var(--pair-state-size);line-height:var(--pair-state-line);font-variant-numeric:tabular-nums;margin:0}.sd7VOG_bar{width:100%;height:var(--pair-bar);border-radius:var(--dsw-radius-xs);background:var(--dsw-alias-interactive-bg-hover);display:block;overflow:hidden}.sd7VOG_barFill{border-radius:var(--dsw-radius-xs);background:var(--dsw-alias-brand-primary);height:100%;transition:width var(--ds-transition-duration) linear;display:block}.sd7VOG_address{min-height:var(--pair-address);color:var(--dsw-alias-label-secondary);font-size:var(--pair-text-size);line-height:var(--pair-text-line);align-items:center;margin:0;display:flex}.sd7VOG_address[data-tone=warning]{color:var(--dsw-alias-state-warn-primary)}.sd7VOG_hint{color:var(--dsw-alias-label-tertiary);font-size:var(--pair-text-size);line-height:var(--pair-text-line);margin:0}.sd7VOG_notice{align-items:flex-start;gap:var(--pair-space-2);padding:var(--pair-space-3);border:1px solid var(--dsw-alias-state-error-primary);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-1);display:flex}.sd7VOG_noticeIcon{color:var(--dsw-alias-state-error-primary);flex:none;display:inline-flex}.sd7VOG_noticeCopy{min-width:0}.sd7VOG_noticeTitle{font-size:var(--pair-text-size);font-weight:600;line-height:var(--pair-text-line);margin:0}.sd7VOG_noticeText{margin:var(--pair-space-1) 0 0;color:var(--dsw-alias-label-secondary);font-size:var(--pair-text-size);line-height:var(--pair-text-line)}.sd7VOG_actions{justify-content:flex-end;align-items:center;gap:var(--pair-space-2);display:flex}.sd7VOG_labels{display:grid}.sd7VOG_label{grid-area:1/1}.sd7VOG_label[data-visible=false]{visibility:hidden}.sd7VOG_announce{clip:rect(0, 0, 0, 0);clip-path:inset(0);width:0;height:0;margin:0;position:absolute;overflow:hidden}";
|
|
1230
|
+
const tagId$1 = "@linxin666/dsh-remote-bridge/packages/dsh-remote-bridge/src/client/panel.module.css";
|
|
1231
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
|
|
1293
1232
|
const tag = document.createElement("style");
|
|
1294
1233
|
tag.dataset.plugin = "@linxin666/dsh-remote-bridge";
|
|
1295
|
-
tag.dataset.pluginCss = tagId;
|
|
1296
|
-
tag.textContent = css;
|
|
1234
|
+
tag.dataset.pluginCss = tagId$1;
|
|
1235
|
+
tag.textContent = css$1;
|
|
1297
1236
|
document.head.appendChild(tag);
|
|
1298
1237
|
}
|
|
1299
1238
|
var panel_module_css_default = {
|
|
1300
1239
|
"actions": "sd7VOG_actions",
|
|
1240
|
+
"address": "sd7VOG_address",
|
|
1241
|
+
"announce": "sd7VOG_announce",
|
|
1301
1242
|
"bar": "sd7VOG_bar",
|
|
1302
1243
|
"barFill": "sd7VOG_barFill",
|
|
1303
|
-
"
|
|
1304
|
-
"
|
|
1305
|
-
"
|
|
1306
|
-
"countdownText": "sd7VOG_countdownText",
|
|
1244
|
+
"body": "sd7VOG_body",
|
|
1245
|
+
"close": "sd7VOG_close",
|
|
1246
|
+
"dialog": "sd7VOG_dialog",
|
|
1307
1247
|
"header": "sd7VOG_header",
|
|
1308
1248
|
"heading": "sd7VOG_heading",
|
|
1309
1249
|
"hint": "sd7VOG_hint",
|
|
1310
|
-
"
|
|
1250
|
+
"label": "sd7VOG_label",
|
|
1251
|
+
"labels": "sd7VOG_labels",
|
|
1311
1252
|
"notice": "sd7VOG_notice",
|
|
1312
|
-
"
|
|
1253
|
+
"noticeCopy": "sd7VOG_noticeCopy",
|
|
1254
|
+
"noticeIcon": "sd7VOG_noticeIcon",
|
|
1255
|
+
"noticeText": "sd7VOG_noticeText",
|
|
1313
1256
|
"noticeTitle": "sd7VOG_noticeTitle",
|
|
1314
|
-
"overlay": "sd7VOG_overlay",
|
|
1315
1257
|
"panel": "sd7VOG_panel",
|
|
1316
|
-
"qr": "sd7VOG_qr",
|
|
1317
1258
|
"qrCard": "sd7VOG_qrCard",
|
|
1318
|
-
"
|
|
1319
|
-
"
|
|
1259
|
+
"qrSlot": "sd7VOG_qrSlot",
|
|
1260
|
+
"skeleton": "sd7VOG_skeleton",
|
|
1261
|
+
"status": "sd7VOG_status",
|
|
1262
|
+
"statusText": "sd7VOG_statusText",
|
|
1320
1263
|
"subtitle": "sd7VOG_subtitle",
|
|
1321
1264
|
"title": "sd7VOG_title",
|
|
1322
|
-
"token": "sd7VOG_token",
|
|
1323
|
-
"tokenLabel": "sd7VOG_tokenLabel",
|
|
1324
|
-
"tokenRow": "sd7VOG_tokenRow",
|
|
1325
1265
|
"trigger": "sd7VOG_trigger"
|
|
1326
1266
|
};
|
|
1327
1267
|
//#endregion
|
|
1328
1268
|
//#region src/client/PairPanel.tsx
|
|
1329
1269
|
/**
|
|
1330
|
-
* The protocol v1 pairing panel
|
|
1331
|
-
*
|
|
1332
|
-
*
|
|
1333
|
-
* relay (never this machine's loopback address), and the code is one-shot.
|
|
1270
|
+
* The protocol v1 pairing panel: the QR symbol, the countdown with its expiry
|
|
1271
|
+
* state, the one address fact the reader must not miss, and the two actions that
|
|
1272
|
+
* keep a fresh code on screen.
|
|
1334
1273
|
*
|
|
1335
|
-
*
|
|
1336
|
-
*
|
|
1337
|
-
*
|
|
1274
|
+
* The shell is the official headless `Modal` and every action is the official
|
|
1275
|
+
* `Button`, so the overlay, the mask, the card, the focus trap, the Escape
|
|
1276
|
+
* command and the interaction states belong to the library. This file owns the
|
|
1277
|
+
* information order and the state presentation only: every state and action
|
|
1278
|
+
* arrives through props, and the clock is a prop, so the expiry flip is
|
|
1279
|
+
* deterministic instead of read from `Date.now()` here.
|
|
1338
1280
|
*/
|
|
1281
|
+
/** The custom property carrying the dialog's own enter keyframe name. */
|
|
1282
|
+
const EXIT_NAME_VAR = "--pair-exit-name";
|
|
1339
1283
|
/**
|
|
1340
1284
|
* The QR symbol, memoized on the secret: the countdown re-renders the panel
|
|
1341
1285
|
* every second, and qrcode.react rebuilds the whole module path on each render.
|
|
@@ -1353,50 +1297,59 @@ window.__ModuleLoader__.load({
|
|
|
1353
1297
|
"aria-label": label
|
|
1354
1298
|
});
|
|
1355
1299
|
});
|
|
1356
|
-
/**
|
|
1357
|
-
function
|
|
1358
|
-
return
|
|
1359
|
-
className: panel_module_css_default.notice,
|
|
1360
|
-
"data-dsh-part": PART_NOTICE,
|
|
1361
|
-
"data-tone": tone,
|
|
1362
|
-
role: tone === "plain" ? "status" : "alert",
|
|
1363
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1364
|
-
className: panel_module_css_default.noticeTitle,
|
|
1365
|
-
children: title
|
|
1366
|
-
}), body !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1367
|
-
className: panel_module_css_default.noticeBody,
|
|
1368
|
-
children: body
|
|
1369
|
-
})]
|
|
1370
|
-
});
|
|
1300
|
+
/** The one string the panel hands out: what the symbol encodes, what copy copies. */
|
|
1301
|
+
function payloadOf(state) {
|
|
1302
|
+
return state.kind === "ready" ? state.pairingUrl ?? state.token : "";
|
|
1371
1303
|
}
|
|
1372
1304
|
/**
|
|
1373
1305
|
* Render the pairing panel.
|
|
1374
1306
|
* @param props - locale seat, view state, clock, page host and actions.
|
|
1375
1307
|
* @returns the panel element tree.
|
|
1376
1308
|
*/
|
|
1377
|
-
function PairPanel({ t, state, now, host, copy, onClose, onRefresh, onCopy }) {
|
|
1378
|
-
const
|
|
1379
|
-
const
|
|
1309
|
+
function PairPanel({ t, state, now, host, copy, showing, closing, id, onClose, onExited, onRefresh, onCopy }) {
|
|
1310
|
+
const panel = (0, react.useRef)(null);
|
|
1311
|
+
const ready = state.kind === "ready";
|
|
1312
|
+
const remainingMs = ready ? Math.max(0, state.expiresAt - now) : 0;
|
|
1313
|
+
const expired = ready && remainingMs <= 0;
|
|
1380
1314
|
const seconds = Math.ceil(remainingMs / 1e3);
|
|
1381
|
-
const windowMs =
|
|
1315
|
+
const windowMs = ready ? Math.max(1, state.expiresAt - state.issuedAt) : 1;
|
|
1382
1316
|
const percent = Math.min(100, Math.max(0, Math.round(remainingMs / windowMs * 100)));
|
|
1383
|
-
const payload = state
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1317
|
+
const payload = payloadOf(state);
|
|
1318
|
+
const canCopy = !expired && payload !== "";
|
|
1319
|
+
const primaryLabel = state.kind === "failed" || state.kind === "unreachable" ? t("action.retry") : t("pair.refresh");
|
|
1320
|
+
const located = ready && state.pairingUrl !== null;
|
|
1321
|
+
(0, react.useLayoutEffect)(() => {
|
|
1322
|
+
const element = panel.current;
|
|
1323
|
+
if (element === null) return;
|
|
1324
|
+
if (!closing) {
|
|
1325
|
+
element.style.removeProperty(EXIT_NAME_VAR);
|
|
1326
|
+
return;
|
|
1327
|
+
}
|
|
1328
|
+
const dialog = element.parentElement;
|
|
1329
|
+
const enter = dialog === null ? "" : window.getComputedStyle(dialog).animationName;
|
|
1330
|
+
if (enter !== "" && enter !== "none") element.style.setProperty(EXIT_NAME_VAR, enter);
|
|
1331
|
+
}, [closing]);
|
|
1332
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
|
|
1333
|
+
open: showing,
|
|
1334
|
+
onClose,
|
|
1335
|
+
title: t("title"),
|
|
1336
|
+
headless: true,
|
|
1337
|
+
className: panel_module_css_default.dialog,
|
|
1338
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1339
|
+
ref: panel,
|
|
1340
|
+
id,
|
|
1392
1341
|
className: panel_module_css_default.panel,
|
|
1393
|
-
role: "dialog",
|
|
1394
|
-
"aria-modal": "true",
|
|
1395
|
-
"aria-label": t("title"),
|
|
1396
1342
|
"data-dsh-plugin": PLUGIN_ATTR,
|
|
1397
1343
|
"data-dsh-part": PART_PANEL,
|
|
1344
|
+
"data-closing": closing || void 0,
|
|
1345
|
+
onAnimationEnd: (event) => {
|
|
1346
|
+
if (closing && event.target === event.currentTarget) onExited();
|
|
1347
|
+
},
|
|
1348
|
+
onTransitionEnd: (event) => {
|
|
1349
|
+
if (closing && event.target === event.currentTarget && event.propertyName === "opacity") onExited();
|
|
1350
|
+
},
|
|
1398
1351
|
children: [
|
|
1399
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
1352
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
|
|
1400
1353
|
className: panel_module_css_default.header,
|
|
1401
1354
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1402
1355
|
className: panel_module_css_default.heading,
|
|
@@ -1407,106 +1360,165 @@ window.__ModuleLoader__.load({
|
|
|
1407
1360
|
className: panel_module_css_default.subtitle,
|
|
1408
1361
|
children: t("subtitle")
|
|
1409
1362
|
})]
|
|
1410
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1411
|
-
|
|
1412
|
-
|
|
1363
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1364
|
+
className: panel_module_css_default.close,
|
|
1365
|
+
variant: "ghost",
|
|
1366
|
+
size: "sm",
|
|
1413
1367
|
"aria-label": t("action.close"),
|
|
1414
|
-
|
|
1415
|
-
|
|
1368
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCloseOutlineRegular, {}),
|
|
1369
|
+
onClick: onClose
|
|
1416
1370
|
})]
|
|
1417
1371
|
}),
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
body: t("forbidden.body")
|
|
1426
|
-
}),
|
|
1427
|
-
state.kind === "failed" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Notice, {
|
|
1428
|
-
tone: "alert",
|
|
1429
|
-
title: t("failed.title"),
|
|
1430
|
-
body: t("failed.body", { status: String(state.status) })
|
|
1431
|
-
}),
|
|
1432
|
-
state.kind === "unreachable" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Notice, {
|
|
1433
|
-
tone: "alert",
|
|
1434
|
-
title: t("unreachable.title"),
|
|
1435
|
-
body: t("unreachable.body")
|
|
1436
|
-
}),
|
|
1437
|
-
state.kind === "ready" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1438
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1439
|
-
className: panel_module_css_default.qrCard,
|
|
1440
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1441
|
-
className: panel_module_css_default.qrWrap,
|
|
1442
|
-
"data-dsh-part": "qr",
|
|
1443
|
-
["data-dsh-qr-value"]: payload,
|
|
1444
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PairQrCode, {
|
|
1445
|
-
value: payload,
|
|
1446
|
-
label: t("pair.qrLabel")
|
|
1447
|
-
})
|
|
1448
|
-
}), expired ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Notice, {
|
|
1449
|
-
tone: "alert",
|
|
1450
|
-
title: t("pair.expired"),
|
|
1451
|
-
body: t("pair.expiredHint")
|
|
1452
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1453
|
-
className: panel_module_css_default.countdown,
|
|
1454
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1455
|
-
className: panel_module_css_default.countdownText,
|
|
1456
|
-
children: t("pair.countdown", { s: String(seconds) })
|
|
1457
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1458
|
-
className: panel_module_css_default.bar,
|
|
1459
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1460
|
-
className: panel_module_css_default.barFill,
|
|
1461
|
-
style: { width: `${String(percent)}%` }
|
|
1462
|
-
})
|
|
1463
|
-
})]
|
|
1464
|
-
})]
|
|
1465
|
-
}),
|
|
1466
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1467
|
-
className: panel_module_css_default.tokenRow,
|
|
1468
|
-
"data-dsh-part": "token",
|
|
1372
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1373
|
+
className: panel_module_css_default.body,
|
|
1374
|
+
children: [(state.kind === "forbidden" || state.kind === "failed" || state.kind === "unreachable") && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1375
|
+
className: panel_module_css_default.notice,
|
|
1376
|
+
"data-dsh-part": "notice",
|
|
1377
|
+
"data-tone": "alert",
|
|
1378
|
+
role: "alert",
|
|
1469
1379
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1470
|
-
className: panel_module_css_default.
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1380
|
+
className: panel_module_css_default.noticeIcon,
|
|
1381
|
+
"aria-hidden": "true",
|
|
1382
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconWarningOutlineRegular, {})
|
|
1383
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1384
|
+
className: panel_module_css_default.noticeCopy,
|
|
1385
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
1386
|
+
className: panel_module_css_default.noticeTitle,
|
|
1387
|
+
children: [
|
|
1388
|
+
state.kind === "forbidden" && t("forbidden.title"),
|
|
1389
|
+
state.kind === "failed" && t("failed.title"),
|
|
1390
|
+
state.kind === "unreachable" && t("unreachable.title")
|
|
1391
|
+
]
|
|
1392
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
1393
|
+
className: panel_module_css_default.noticeText,
|
|
1394
|
+
children: [
|
|
1395
|
+
state.kind === "forbidden" && t("forbidden.body"),
|
|
1396
|
+
state.kind === "failed" && t("failed.body", { status: String(state.status) }),
|
|
1397
|
+
state.kind === "unreachable" && t("unreachable.body")
|
|
1398
|
+
]
|
|
1399
|
+
})]
|
|
1475
1400
|
})]
|
|
1476
|
-
}),
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1401
|
+
}), (state.kind === "reading" || ready) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1402
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1403
|
+
className: panel_module_css_default.qrCard,
|
|
1404
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1405
|
+
className: panel_module_css_default.qrSlot,
|
|
1406
|
+
"data-dsh-part": "qr",
|
|
1407
|
+
["data-dsh-qr-value"]: payload,
|
|
1408
|
+
["data-expired"]: expired || void 0,
|
|
1409
|
+
children: ready ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PairQrCode, {
|
|
1410
|
+
value: payload,
|
|
1411
|
+
label: t("pair.qrLabel")
|
|
1412
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1413
|
+
className: panel_module_css_default.skeleton,
|
|
1414
|
+
"aria-hidden": "true"
|
|
1415
|
+
})
|
|
1416
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1417
|
+
className: panel_module_css_default.status,
|
|
1418
|
+
children: [
|
|
1419
|
+
!ready && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1420
|
+
className: panel_module_css_default.statusText,
|
|
1421
|
+
children: t("state.reading")
|
|
1422
|
+
}),
|
|
1423
|
+
ready && expired && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1424
|
+
className: panel_module_css_default.statusText,
|
|
1425
|
+
role: "status",
|
|
1426
|
+
children: t("pair.expired")
|
|
1427
|
+
}),
|
|
1428
|
+
ready && !expired && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1429
|
+
className: panel_module_css_default.statusText,
|
|
1430
|
+
children: t("pair.countdown", { s: String(seconds) })
|
|
1431
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1432
|
+
className: panel_module_css_default.bar,
|
|
1433
|
+
"aria-hidden": "true",
|
|
1434
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1435
|
+
className: panel_module_css_default.barFill,
|
|
1436
|
+
style: { width: `${String(percent)}%` }
|
|
1437
|
+
})
|
|
1438
|
+
})] })
|
|
1439
|
+
]
|
|
1440
|
+
})]
|
|
1441
|
+
}),
|
|
1442
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
1443
|
+
className: panel_module_css_default.address,
|
|
1444
|
+
"data-tone": located ? "plain" : "warning",
|
|
1445
|
+
children: [ready && located && t("origin.located", { origin: state.origin ?? "" }), ready && !located && t("origin.missing", { host })]
|
|
1446
|
+
}),
|
|
1447
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1448
|
+
className: panel_module_css_default.hint,
|
|
1449
|
+
children: t("pair.usedHint")
|
|
1450
|
+
})
|
|
1451
|
+
] })]
|
|
1452
|
+
}),
|
|
1453
|
+
state.kind !== "forbidden" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("footer", {
|
|
1454
|
+
className: panel_module_css_default.actions,
|
|
1455
|
+
children: [ready && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1456
|
+
variant: "outline",
|
|
1457
|
+
size: "sm",
|
|
1480
1458
|
"data-dsh-part": "copy",
|
|
1481
|
-
|
|
1482
|
-
|
|
1459
|
+
disabled: !canCopy,
|
|
1460
|
+
icon: copy === "copied" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutlineRegular, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCopyOutlineRegular, {}),
|
|
1483
1461
|
onClick: () => {
|
|
1484
1462
|
onCopy(payload);
|
|
1485
1463
|
},
|
|
1486
|
-
children:
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1464
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1465
|
+
className: panel_module_css_default.labels,
|
|
1466
|
+
children: [
|
|
1467
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1468
|
+
className: panel_module_css_default.label,
|
|
1469
|
+
"data-visible": copy === "idle",
|
|
1470
|
+
"aria-hidden": copy !== "idle",
|
|
1471
|
+
children: t("action.copy")
|
|
1472
|
+
}),
|
|
1473
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1474
|
+
className: panel_module_css_default.label,
|
|
1475
|
+
"data-visible": copy === "copied",
|
|
1476
|
+
"aria-hidden": copy !== "copied",
|
|
1477
|
+
children: t("action.copied")
|
|
1478
|
+
}),
|
|
1479
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1480
|
+
className: panel_module_css_default.label,
|
|
1481
|
+
"data-visible": copy === "failed",
|
|
1482
|
+
"aria-hidden": copy !== "failed",
|
|
1483
|
+
children: t("action.copyFailed")
|
|
1484
|
+
})
|
|
1485
|
+
]
|
|
1486
|
+
})
|
|
1487
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1488
|
+
variant: "primary",
|
|
1489
|
+
size: "sm",
|
|
1503
1490
|
"data-dsh-part": "refresh",
|
|
1491
|
+
disabled: state.kind === "reading",
|
|
1492
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRefreshOutlineRegular, {}),
|
|
1504
1493
|
onClick: onRefresh,
|
|
1505
|
-
children:
|
|
1506
|
-
})
|
|
1494
|
+
children: primaryLabel
|
|
1495
|
+
})]
|
|
1496
|
+
}),
|
|
1497
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1498
|
+
className: panel_module_css_default.announce,
|
|
1499
|
+
role: "status",
|
|
1500
|
+
children: [copy === "copied" && t("action.copied"), copy === "failed" && t("action.copyFailed")]
|
|
1507
1501
|
})
|
|
1508
1502
|
]
|
|
1509
|
-
})
|
|
1503
|
+
})
|
|
1504
|
+
});
|
|
1505
|
+
}
|
|
1506
|
+
//#endregion
|
|
1507
|
+
//#region src/client/icons.tsx
|
|
1508
|
+
/** A QR-symbol glyph: three finder squares plus a payload dot. */
|
|
1509
|
+
function QrIcon(props) {
|
|
1510
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
1511
|
+
width: 16,
|
|
1512
|
+
height: 16,
|
|
1513
|
+
viewBox: "0 0 16 16",
|
|
1514
|
+
fill: "none",
|
|
1515
|
+
stroke: "currentColor",
|
|
1516
|
+
strokeWidth: 1.3,
|
|
1517
|
+
strokeLinecap: "round",
|
|
1518
|
+
strokeLinejoin: "round",
|
|
1519
|
+
"aria-hidden": "true",
|
|
1520
|
+
...props,
|
|
1521
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M2.5 2.5h4v4h-4zM9.5 2.5h4v4h-4zM2.5 9.5h4v4h-4z" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M9.5 9.5h1.6v1.6H9.5zM12.4 9.5h1.1M9.5 12.4v1.1M12 13.5h1.5v-1.5h-1.5z" })]
|
|
1510
1522
|
});
|
|
1511
1523
|
}
|
|
1512
1524
|
//#endregion
|
|
@@ -1518,16 +1530,23 @@ window.__ModuleLoader__.load({
|
|
|
1518
1530
|
* (declared by ui-sidebar — the same seat dsh-remote-web-ui and dsh-update
|
|
1519
1531
|
* share).
|
|
1520
1532
|
*
|
|
1521
|
-
* This component owns the panel's behavior: one read per open, one
|
|
1522
|
-
* while a live code is on screen, the mint-again action,
|
|
1523
|
-
*
|
|
1524
|
-
*
|
|
1525
|
-
*
|
|
1533
|
+
* This component owns the panel's presence and behavior: one read per open, one
|
|
1534
|
+
* clock tick while a live code is on screen, the mint-again action, the copy
|
|
1535
|
+
* action, and the leave leg that keeps the modal mounted until its exit reports
|
|
1536
|
+
* completion. The wire call and the clipboard are injected (see the plugin
|
|
1537
|
+
* entry), so the rendered tree carries no closure-factory bundle import and both
|
|
1538
|
+
* can be driven by a test without patching a module.
|
|
1526
1539
|
*/
|
|
1527
1540
|
/** How long the transient "copied" / "copy failed" label stays up. */
|
|
1528
1541
|
const COPY_FEEDBACK_MS = 1500;
|
|
1529
1542
|
/** The countdown's tick; one second is the resolution the panel shows. */
|
|
1530
1543
|
const TICK_MS = 1e3;
|
|
1544
|
+
/**
|
|
1545
|
+
* Upper bound on the leave leg. The card reports its own animation end, and the
|
|
1546
|
+
* reduced-motion fade reports a transition end; this only ends the presence of a
|
|
1547
|
+
* browser that reports neither, just past var(--ds-transition-duration).
|
|
1548
|
+
*/
|
|
1549
|
+
const EXIT_TIMEOUT_MS = 260;
|
|
1531
1550
|
/** Map a read outcome onto the panel's view state. */
|
|
1532
1551
|
function panelStateOf(outcome, issuedAt) {
|
|
1533
1552
|
switch (outcome.kind) {
|
|
@@ -1548,15 +1567,16 @@ window.__ModuleLoader__.load({
|
|
|
1548
1567
|
}
|
|
1549
1568
|
}
|
|
1550
1569
|
/**
|
|
1551
|
-
* Render the pairing seat trigger and,
|
|
1570
|
+
* Render the pairing seat trigger and, while it is open or leaving, the panel.
|
|
1552
1571
|
* @param props - the footer seat's column state, the injected actions and the locale seat.
|
|
1553
|
-
* @returns the trigger and the panel
|
|
1572
|
+
* @returns the trigger and, when present, the official Modal holding the panel.
|
|
1554
1573
|
*/
|
|
1555
1574
|
function PairEntry({ wide, read, copy, t }) {
|
|
1556
|
-
const [
|
|
1575
|
+
const [presence, setPresence] = (0, react.useState)("closed");
|
|
1557
1576
|
const [state, setState] = (0, react.useState)({ kind: "reading" });
|
|
1558
1577
|
const [copyState, setCopyState] = (0, react.useState)("idle");
|
|
1559
1578
|
const [now, setNow] = (0, react.useState)(() => Date.now());
|
|
1579
|
+
const panelId = (0, react.useId)();
|
|
1560
1580
|
const generation = (0, react.useRef)(0);
|
|
1561
1581
|
const mint = (0, react.useCallback)(() => {
|
|
1562
1582
|
const request = ++generation.current;
|
|
@@ -1569,16 +1589,30 @@ window.__ModuleLoader__.load({
|
|
|
1569
1589
|
});
|
|
1570
1590
|
}, [read]);
|
|
1571
1591
|
const openPanel = (0, react.useCallback)(() => {
|
|
1572
|
-
|
|
1592
|
+
setPresence("open");
|
|
1573
1593
|
setCopyState("idle");
|
|
1574
1594
|
mint();
|
|
1575
1595
|
}, [mint]);
|
|
1576
|
-
const
|
|
1596
|
+
const requestClose = (0, react.useCallback)(() => {
|
|
1577
1597
|
generation.current += 1;
|
|
1578
|
-
|
|
1598
|
+
setPresence((current) => current === "closed" ? "closed" : "closing");
|
|
1599
|
+
}, []);
|
|
1600
|
+
const finishClose = (0, react.useCallback)(() => {
|
|
1601
|
+
setPresence((current) => current === "closing" ? "closed" : current);
|
|
1579
1602
|
}, []);
|
|
1603
|
+
const closing = presence === "closing";
|
|
1604
|
+
const showing = presence !== "closed";
|
|
1580
1605
|
(0, react.useEffect)(() => {
|
|
1581
|
-
if (!
|
|
1606
|
+
if (!closing) return;
|
|
1607
|
+
const timer = window.setTimeout(() => {
|
|
1608
|
+
finishClose();
|
|
1609
|
+
}, EXIT_TIMEOUT_MS);
|
|
1610
|
+
return () => {
|
|
1611
|
+
window.clearTimeout(timer);
|
|
1612
|
+
};
|
|
1613
|
+
}, [closing, finishClose]);
|
|
1614
|
+
(0, react.useEffect)(() => {
|
|
1615
|
+
if (presence !== "open" || state.kind !== "ready") return;
|
|
1582
1616
|
const deadline = state.expiresAt;
|
|
1583
1617
|
const timer = window.setInterval(() => {
|
|
1584
1618
|
const current = Date.now();
|
|
@@ -1588,19 +1622,9 @@ window.__ModuleLoader__.load({
|
|
|
1588
1622
|
return () => {
|
|
1589
1623
|
window.clearInterval(timer);
|
|
1590
1624
|
};
|
|
1591
|
-
}, [
|
|
1592
|
-
(0, react.
|
|
1593
|
-
|
|
1594
|
-
const onKey = (event) => {
|
|
1595
|
-
if (event.key === "Escape") closePanel();
|
|
1596
|
-
};
|
|
1597
|
-
window.addEventListener("keydown", onKey);
|
|
1598
|
-
return () => {
|
|
1599
|
-
window.removeEventListener("keydown", onKey);
|
|
1600
|
-
};
|
|
1601
|
-
}, [open, closePanel]);
|
|
1602
|
-
const handleCopy = (0, react.useCallback)((token) => {
|
|
1603
|
-
copy(token).then((ok) => {
|
|
1625
|
+
}, [presence, state]);
|
|
1626
|
+
const handleCopy = (0, react.useCallback)((payload) => {
|
|
1627
|
+
copy(payload).then((ok) => {
|
|
1604
1628
|
setCopyState(ok ? "copied" : "failed");
|
|
1605
1629
|
window.setTimeout(() => {
|
|
1606
1630
|
setCopyState("idle");
|
|
@@ -1614,20 +1638,25 @@ window.__ModuleLoader__.load({
|
|
|
1614
1638
|
"data-dsh-part": PART_ENTRY,
|
|
1615
1639
|
"data-wide": wide ? "wide" : "rail",
|
|
1616
1640
|
"aria-label": t("entry.label"),
|
|
1617
|
-
"aria-expanded":
|
|
1641
|
+
"aria-expanded": showing,
|
|
1642
|
+
"aria-controls": showing ? panelId : void 0,
|
|
1618
1643
|
title: t("entry.label"),
|
|
1619
1644
|
onClick: openPanel,
|
|
1620
1645
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(QrIcon, {})
|
|
1621
|
-
}),
|
|
1646
|
+
}), showing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PairPanel, {
|
|
1647
|
+
id: panelId,
|
|
1622
1648
|
t,
|
|
1623
1649
|
state,
|
|
1624
1650
|
now,
|
|
1625
1651
|
host: window.location.host,
|
|
1626
1652
|
copy: copyState,
|
|
1627
|
-
|
|
1653
|
+
showing,
|
|
1654
|
+
closing,
|
|
1655
|
+
onClose: requestClose,
|
|
1656
|
+
onExited: finishClose,
|
|
1628
1657
|
onRefresh: mint,
|
|
1629
1658
|
onCopy: handleCopy
|
|
1630
|
-
})
|
|
1659
|
+
})] });
|
|
1631
1660
|
}
|
|
1632
1661
|
//#endregion
|
|
1633
1662
|
//#region src/client/pair-token.ts
|
|
@@ -1713,33 +1742,516 @@ window.__ModuleLoader__.load({
|
|
|
1713
1742
|
};
|
|
1714
1743
|
}
|
|
1715
1744
|
//#endregion
|
|
1745
|
+
//#region src/core/ui.ts
|
|
1746
|
+
/** Upper bound of one card's document, in UTF-8 bytes (§35.2). */
|
|
1747
|
+
const UI_HTML_MAX_BYTES = 262144;
|
|
1748
|
+
//#endregion
|
|
1749
|
+
//#region src/client/ui-card.ts
|
|
1750
|
+
/**
|
|
1751
|
+
* The transcript reading of one `ui.present` call (protocol §35.10, §35.11):
|
|
1752
|
+
* what the desktop row draws, decided without touching the DOM.
|
|
1753
|
+
*
|
|
1754
|
+
* A card has two sources and neither may be dropped. While the call is still
|
|
1755
|
+
* running the arguments are the only material on the wire, so the page comes out
|
|
1756
|
+
* of `args` and the header says the operator has not acted yet. Once the result
|
|
1757
|
+
* lands, the presentation payload `meta.ui` is the card's own record — its
|
|
1758
|
+
* `state`, its `title` and the very document that crossed — and the arguments
|
|
1759
|
+
* are only the fallback for a result that carries no payload.
|
|
1760
|
+
*
|
|
1761
|
+
* The argument view is read by shape rather than by import: a toolview receives a
|
|
1762
|
+
* lazy `PartialArguments` when the call arrived as argument text and a plain
|
|
1763
|
+
* payload when the call was dispatched as an object, and §35.10 fixes neither. A
|
|
1764
|
+
* field reader therefore answers from all three shapes it can meet (lazy view,
|
|
1765
|
+
* JSON text, parsed object) so a page is never lost to a shape this row did not
|
|
1766
|
+
* anticipate.
|
|
1767
|
+
*
|
|
1768
|
+
* Two rules live here rather than in the renderer. A document above 256 KiB is
|
|
1769
|
+
* never handed to a frame (§35.2 caps it on this side too), and a frame message is
|
|
1770
|
+
* read by shape alone: the sandboxed document has an opaque origin, so identity
|
|
1771
|
+
* comes from the frame element the row owns, never from what the message claims.
|
|
1772
|
+
* Nothing read here is forwarded anywhere — the desktop renders and does not
|
|
1773
|
+
* answer (§35.11).
|
|
1774
|
+
* @module dsh-remote-bridge/client/ui-card
|
|
1775
|
+
*/
|
|
1776
|
+
/**
|
|
1777
|
+
* The theme tokens a card inherits from the GUI's own root element.
|
|
1778
|
+
*
|
|
1779
|
+
* Four roles and no more: the page needs a text colour it can trust, a quieter
|
|
1780
|
+
* one, a surface and a border. A token the running theme does not define is
|
|
1781
|
+
* simply not injected — the page then falls back to its own CSS, which is why an
|
|
1782
|
+
* unreadable theme is a degraded look rather than a broken card.
|
|
1783
|
+
*/
|
|
1784
|
+
const CARD_THEME_TOKENS = [
|
|
1785
|
+
"--dsw-alias-label-primary",
|
|
1786
|
+
"--dsw-alias-label-secondary",
|
|
1787
|
+
"--dsw-alias-bg-layer-1",
|
|
1788
|
+
"--dsw-alias-border-l2"
|
|
1789
|
+
];
|
|
1790
|
+
/** The one sandbox value a card frame is allowed (§35.7, §35.11). */
|
|
1791
|
+
const FRAME_SANDBOX = "allow-scripts";
|
|
1792
|
+
/**
|
|
1793
|
+
* The permissions a card frame is explicitly denied.
|
|
1794
|
+
*
|
|
1795
|
+
* §35.7 refuses camera, microphone, location and clipboard reads on both ends.
|
|
1796
|
+
* A sandboxed document already has an opaque origin, and this policy states the
|
|
1797
|
+
* denial where the browser enforces it rather than leaving it to the default.
|
|
1798
|
+
*/
|
|
1799
|
+
const FRAME_PERMISSIONS = [
|
|
1800
|
+
"camera 'none'",
|
|
1801
|
+
"microphone 'none'",
|
|
1802
|
+
"geolocation 'none'",
|
|
1803
|
+
"clipboard-read 'none'"
|
|
1804
|
+
].join("; ");
|
|
1805
|
+
/** The message type the injected reporter uses to publish the content height. */
|
|
1806
|
+
const FRAME_HEIGHT_CHANNEL = "dsh-ui-card-height";
|
|
1807
|
+
/**
|
|
1808
|
+
* Read one field as text out of every argument shape a toolview can receive.
|
|
1809
|
+
* @param args - the lazy view, finished JSON text, or a parsed payload.
|
|
1810
|
+
* @param name - the top-level field name.
|
|
1811
|
+
* @returns the field's decoded string, or undefined when absent or not a string.
|
|
1812
|
+
*/
|
|
1813
|
+
function fieldText(args, name) {
|
|
1814
|
+
if (typeof args === "string") {
|
|
1815
|
+
const parsed = parseJson(args);
|
|
1816
|
+
return parsed === void 0 ? void 0 : fieldText(parsed, name);
|
|
1817
|
+
}
|
|
1818
|
+
if (typeof args !== "object" || args === null) return void 0;
|
|
1819
|
+
const view = args;
|
|
1820
|
+
if (typeof view.text === "function") {
|
|
1821
|
+
const read = view.text.call(args, name);
|
|
1822
|
+
return typeof read === "string" ? read : void 0;
|
|
1823
|
+
}
|
|
1824
|
+
const direct = view[name];
|
|
1825
|
+
return typeof direct === "string" ? direct : void 0;
|
|
1826
|
+
}
|
|
1827
|
+
/**
|
|
1828
|
+
* Read one field as any completed value out of the same three shapes.
|
|
1829
|
+
* @param args - the lazy view, finished JSON text, or a parsed payload.
|
|
1830
|
+
* @param name - the top-level field name.
|
|
1831
|
+
* @returns the value, or undefined when absent.
|
|
1832
|
+
*/
|
|
1833
|
+
function fieldValue(args, name) {
|
|
1834
|
+
if (typeof args === "string") {
|
|
1835
|
+
const parsed = parseJson(args);
|
|
1836
|
+
return parsed === void 0 ? void 0 : fieldValue(parsed, name);
|
|
1837
|
+
}
|
|
1838
|
+
if (typeof args !== "object" || args === null) return void 0;
|
|
1839
|
+
const view = args;
|
|
1840
|
+
if (typeof view.value === "function") return view.value.call(args, name);
|
|
1841
|
+
return view[name];
|
|
1842
|
+
}
|
|
1843
|
+
/** @returns the parsed payload, or undefined when the text is not one object. */
|
|
1844
|
+
function parseJson(text) {
|
|
1845
|
+
try {
|
|
1846
|
+
return JSON.parse(text);
|
|
1847
|
+
} catch {
|
|
1848
|
+
return;
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
/** @returns one suggested height as a whole number of CSS pixels, when usable. */
|
|
1852
|
+
function heightOf(raw) {
|
|
1853
|
+
if (typeof raw !== "number" || !Number.isFinite(raw) || raw <= 0) return void 0;
|
|
1854
|
+
return Math.ceil(raw);
|
|
1855
|
+
}
|
|
1856
|
+
/**
|
|
1857
|
+
* Read the presentation payload a settled call carries (§35.10).
|
|
1858
|
+
*
|
|
1859
|
+
* The payload is the card's own record, so it is read only when it is one: a
|
|
1860
|
+
* `html` that is not a string is no card at all, which keeps a malformed payload
|
|
1861
|
+
* from becoming an empty frame. `state` outside the frozen pair reads as
|
|
1862
|
+
* `settled` — a result-phase payload is a finished card by definition, and the
|
|
1863
|
+
* `open` arm exists for a presenter that answers before its first event.
|
|
1864
|
+
* @param meta - the result's `meta` value, carried verbatim.
|
|
1865
|
+
* @returns the card, or undefined when this result carries no presentation.
|
|
1866
|
+
*/
|
|
1867
|
+
function readPresentation(meta) {
|
|
1868
|
+
if (typeof meta !== "object" || meta === null) return void 0;
|
|
1869
|
+
const ui = meta.ui;
|
|
1870
|
+
if (typeof ui !== "object" || ui === null) return void 0;
|
|
1871
|
+
const record = ui;
|
|
1872
|
+
const html = record.html;
|
|
1873
|
+
if (typeof html !== "string") return void 0;
|
|
1874
|
+
const title = record.title;
|
|
1875
|
+
const key = record.key;
|
|
1876
|
+
const height = heightOf(record.height);
|
|
1877
|
+
return {
|
|
1878
|
+
html,
|
|
1879
|
+
state: record.state === "open" ? "open" : "settled",
|
|
1880
|
+
...typeof title === "string" ? { title } : {},
|
|
1881
|
+
...height === void 0 ? {} : { height },
|
|
1882
|
+
...typeof key === "string" ? { key } : {}
|
|
1883
|
+
};
|
|
1884
|
+
}
|
|
1885
|
+
/**
|
|
1886
|
+
* Build the card a running call shows from its own arguments.
|
|
1887
|
+
* @param block - the call material of the current stage.
|
|
1888
|
+
* @returns the card, or undefined when the arguments carry no page.
|
|
1889
|
+
*/
|
|
1890
|
+
function argumentCard(block) {
|
|
1891
|
+
const html = fieldText(block.args, "html") ?? fieldText(block.argsRaw, "html");
|
|
1892
|
+
if (html === void 0) return void 0;
|
|
1893
|
+
const title = fieldText(block.args, "title") ?? fieldText(block.argsRaw, "title");
|
|
1894
|
+
const height = heightOf(fieldValue(block.args, "height") ?? fieldValue(block.argsRaw, "height"));
|
|
1895
|
+
return {
|
|
1896
|
+
html,
|
|
1897
|
+
state: "open",
|
|
1898
|
+
...title === void 0 ? {} : { title },
|
|
1899
|
+
...height === void 0 ? {} : { height }
|
|
1900
|
+
};
|
|
1901
|
+
}
|
|
1902
|
+
/** @returns whether one document is within {@link UI_HTML_MAX_BYTES}. */
|
|
1903
|
+
function cardHtmlFits(html) {
|
|
1904
|
+
return new TextEncoder().encode(html).length <= UI_HTML_MAX_BYTES;
|
|
1905
|
+
}
|
|
1906
|
+
/**
|
|
1907
|
+
* Decide what the row draws at one stage of the call.
|
|
1908
|
+
*
|
|
1909
|
+
* The settled stage prefers `meta.ui`, because that payload is the presentation
|
|
1910
|
+
* the host published and carries its ending. A result without the payload falls
|
|
1911
|
+
* back to the arguments — and then the card is still over, so it reads
|
|
1912
|
+
* `settled`: the stage decides that, not a field that is absent.
|
|
1913
|
+
* @param phase - the stage the Tool slot published.
|
|
1914
|
+
* @param block - the call material of that stage.
|
|
1915
|
+
* @returns a card, a refusal, or the neutral line.
|
|
1916
|
+
*/
|
|
1917
|
+
function presentReadOf(phase, block) {
|
|
1918
|
+
if (typeof block !== "object" || block === null) return { kind: "empty" };
|
|
1919
|
+
const material = block;
|
|
1920
|
+
const card = phase === "result" ? readPresentation(material.meta) ?? settledFromArguments(material) : argumentCard(material);
|
|
1921
|
+
if (card === void 0) return { kind: "empty" };
|
|
1922
|
+
return cardHtmlFits(card.html) ? {
|
|
1923
|
+
kind: "card",
|
|
1924
|
+
card
|
|
1925
|
+
} : { kind: "oversize" };
|
|
1926
|
+
}
|
|
1927
|
+
/** @returns the argument page of a settled call, as a finished card. */
|
|
1928
|
+
function settledFromArguments(material) {
|
|
1929
|
+
const card = argumentCard(material);
|
|
1930
|
+
return card === void 0 ? void 0 : {
|
|
1931
|
+
...card,
|
|
1932
|
+
state: "settled"
|
|
1933
|
+
};
|
|
1934
|
+
}
|
|
1935
|
+
/**
|
|
1936
|
+
* Read the theme tokens off a computed style, skipping the ones it does not carry.
|
|
1937
|
+
* @param style - the GUI root element's computed style.
|
|
1938
|
+
* @returns the tokens, in {@link CARD_THEME_TOKENS} order.
|
|
1939
|
+
*/
|
|
1940
|
+
function cardThemeTokens(style) {
|
|
1941
|
+
const tokens = [];
|
|
1942
|
+
for (const name of CARD_THEME_TOKENS) {
|
|
1943
|
+
let value = "";
|
|
1944
|
+
try {
|
|
1945
|
+
value = style.getPropertyValue(name);
|
|
1946
|
+
} catch {
|
|
1947
|
+
value = "";
|
|
1948
|
+
}
|
|
1949
|
+
const trimmed = value.trim();
|
|
1950
|
+
if (trimmed !== "") tokens.push([name, trimmed]);
|
|
1951
|
+
}
|
|
1952
|
+
return tokens;
|
|
1953
|
+
}
|
|
1954
|
+
/** @returns the `<style>` handing the theme tokens to a card's document. */
|
|
1955
|
+
function themeStyle(tokens) {
|
|
1956
|
+
if (tokens.length === 0) return "";
|
|
1957
|
+
return `<style data-dsh-card-theme>:root{${tokens.map(([name, value]) => `${name}:${value}`).join(";")}}</style>`;
|
|
1958
|
+
}
|
|
1959
|
+
/**
|
|
1960
|
+
* The reporter a card's document runs to publish its own content height.
|
|
1961
|
+
*
|
|
1962
|
+
* The frame cannot be measured from the outside — the document is opaque and
|
|
1963
|
+
* cross-origin — so the measurement has to be pushed out. It is deliberately the
|
|
1964
|
+
* only code this row adds to a page: it reads a height and posts a number, and a
|
|
1965
|
+
* page that removes it only loses the measurement, never the card.
|
|
1966
|
+
* @param channel - the message type the parent listens for.
|
|
1967
|
+
* @returns one script element as text.
|
|
1968
|
+
*/
|
|
1969
|
+
function heightReporter(channel) {
|
|
1970
|
+
return [
|
|
1971
|
+
"<script data-dsh-card-frame>(function(){",
|
|
1972
|
+
"function post(){try{",
|
|
1973
|
+
"var d=document.documentElement,b=document.body;",
|
|
1974
|
+
"var h=Math.max(d?d.scrollHeight:0,b?b.scrollHeight:0);",
|
|
1975
|
+
"if(h>0){parent.postMessage({type:" + JSON.stringify(channel) + ",height:h},\"*\")}",
|
|
1976
|
+
"}catch(e){}}",
|
|
1977
|
+
"window.addEventListener(\"load\",post);",
|
|
1978
|
+
"document.addEventListener(\"DOMContentLoaded\",post);",
|
|
1979
|
+
"try{if(typeof ResizeObserver===\"function\"){var ro=new ResizeObserver(post);",
|
|
1980
|
+
"if(document.documentElement)ro.observe(document.documentElement);",
|
|
1981
|
+
"if(document.body)ro.observe(document.body)}}catch(e){}",
|
|
1982
|
+
"post()})()<\/script>"
|
|
1983
|
+
].join("");
|
|
1984
|
+
}
|
|
1985
|
+
/**
|
|
1986
|
+
* Put one snippet inside an existing element rather than before the document.
|
|
1987
|
+
* @param html - the card document.
|
|
1988
|
+
* @param closingTag - the tag to insert ahead of, lower case.
|
|
1989
|
+
* @param snippet - the markup to insert.
|
|
1990
|
+
* @returns the document with the snippet inside it.
|
|
1991
|
+
*/
|
|
1992
|
+
function injectBefore(html, closingTag, snippet) {
|
|
1993
|
+
if (snippet === "") return html;
|
|
1994
|
+
const at = html.toLowerCase().lastIndexOf(closingTag);
|
|
1995
|
+
return at < 0 ? html + snippet : html.slice(0, at) + snippet + html.slice(at);
|
|
1996
|
+
}
|
|
1997
|
+
/**
|
|
1998
|
+
* Build the document handed to a card's frame.
|
|
1999
|
+
*
|
|
2000
|
+
* The agent's page stays byte for byte what crossed; this only adds the theme
|
|
2001
|
+
* variables its CSS may use and the height reporter. Insertion happens ahead of
|
|
2002
|
+
* the closing tags rather than at the start of the string, because a snippet
|
|
2003
|
+
* placed before `<!doctype html>` would put the document into quirks mode.
|
|
2004
|
+
* @param html - the card document as the presenter wrote it.
|
|
2005
|
+
* @param tokens - the theme tokens to hand the page.
|
|
2006
|
+
* @param channel - the message type the reporter publishes on.
|
|
2007
|
+
* @returns the frame document; the original page when it takes no injection.
|
|
2008
|
+
*/
|
|
2009
|
+
function frameDocument(html, tokens, channel = FRAME_HEIGHT_CHANNEL) {
|
|
2010
|
+
const style = themeStyle(tokens);
|
|
2011
|
+
return injectBefore(style === "" ? html : injectBefore(html, "</head>", style), "</body>", heightReporter(channel));
|
|
2012
|
+
}
|
|
2013
|
+
/**
|
|
2014
|
+
* Read one message a card's frame posted.
|
|
2015
|
+
*
|
|
2016
|
+
* Only the shape is read. The frame's origin is opaque, so the parent identifies
|
|
2017
|
+
* the sender by the frame element it owns; what is left to decide here is what
|
|
2018
|
+
* the payload means, and a page's own `{type, payload}` action means nothing
|
|
2019
|
+
* beyond "the operator tried to act here".
|
|
2020
|
+
* @param data - the message payload.
|
|
2021
|
+
* @returns the event, or undefined when the message is not one this row reads.
|
|
2022
|
+
*/
|
|
2023
|
+
function frameEventOf(data) {
|
|
2024
|
+
if (typeof data !== "object" || data === null || Array.isArray(data)) return void 0;
|
|
2025
|
+
const record = data;
|
|
2026
|
+
if (record.type === "dsh-ui-card-height") {
|
|
2027
|
+
const height = record.height;
|
|
2028
|
+
if (typeof height !== "number" || !Number.isFinite(height) || height <= 0) return void 0;
|
|
2029
|
+
return {
|
|
2030
|
+
kind: "height",
|
|
2031
|
+
height: Math.ceil(height)
|
|
2032
|
+
};
|
|
2033
|
+
}
|
|
2034
|
+
return typeof record.type === "string" && record.type !== "" ? { kind: "interaction" } : void 0;
|
|
2035
|
+
}
|
|
2036
|
+
/**
|
|
2037
|
+
* Hold a measured height inside the range a card may occupy.
|
|
2038
|
+
* @param height - the content height the frame reported, in CSS pixels.
|
|
2039
|
+
* @returns the height the card takes.
|
|
2040
|
+
*/
|
|
2041
|
+
function clampCardHeight(height) {
|
|
2042
|
+
if (!Number.isFinite(height)) return 320;
|
|
2043
|
+
return Math.min(720, Math.max(96, Math.ceil(height)));
|
|
2044
|
+
}
|
|
2045
|
+
//#endregion
|
|
2046
|
+
//#region \0dsh-css:packages/dsh-remote-bridge/src/client/ui-present.module.css.mjs
|
|
2047
|
+
const css = ".g4_deW_card,.g4_deW_row{--card-space-1:4px;--card-space-2:8px;--card-space-3:12px;--card-title-size:13px;--card-title-line:20px;--card-state-size:12px;--card-state-line:18px;--card-radius:8px;--card-edge:1px;--card-default-height:320px}.g4_deW_card{margin:var(--card-space-1) 0;border:var(--card-edge) solid var(--dsw-alias-border-l2);border-radius:var(--card-radius);background:var(--dsw-alias-bg-layer-1);flex-direction:column;gap:0;display:flex;overflow:hidden}.g4_deW_head{align-items:center;gap:var(--card-space-2);min-height:calc(var(--card-title-line) + var(--card-space-2) * 2);padding:var(--card-space-2) var(--card-space-3);border-bottom:var(--card-edge) solid var(--dsw-alias-border-l2);display:flex}.g4_deW_title{min-width:0;color:var(--dsw-alias-label-primary);font-size:var(--card-title-size);line-height:var(--card-title-line);text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.g4_deW_badge{color:var(--dsw-alias-label-secondary);font-size:var(--card-state-size);line-height:var(--card-state-line);flex:none;margin-inline-start:auto}.g4_deW_frame{width:100%;min-height:var(--card-default-height);background:0 0;border:0;display:block}.g4_deW_notice{padding:var(--card-space-2) var(--card-space-3);border-top:var(--card-edge) solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);font-size:var(--card-state-size);line-height:var(--card-state-line);margin:0}.g4_deW_row{margin:var(--card-space-1) 0}";
|
|
2048
|
+
const tagId = "@linxin666/dsh-remote-bridge/packages/dsh-remote-bridge/src/client/ui-present.module.css";
|
|
2049
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
2050
|
+
const tag = document.createElement("style");
|
|
2051
|
+
tag.dataset.plugin = "@linxin666/dsh-remote-bridge";
|
|
2052
|
+
tag.dataset.pluginCss = tagId;
|
|
2053
|
+
tag.textContent = css;
|
|
2054
|
+
document.head.appendChild(tag);
|
|
2055
|
+
}
|
|
2056
|
+
var ui_present_module_css_default = {
|
|
2057
|
+
"badge": "g4_deW_badge",
|
|
2058
|
+
"card": "g4_deW_card",
|
|
2059
|
+
"frame": "g4_deW_frame",
|
|
2060
|
+
"head": "g4_deW_head",
|
|
2061
|
+
"notice": "g4_deW_notice",
|
|
2062
|
+
"row": "g4_deW_row",
|
|
2063
|
+
"title": "g4_deW_title"
|
|
2064
|
+
};
|
|
2065
|
+
//#endregion
|
|
2066
|
+
//#region src/client/UiPresentRow.tsx
|
|
2067
|
+
/**
|
|
2068
|
+
* The transcript row of one `ui.present` call: the whole page an agent handed
|
|
2069
|
+
* into the session, drawn in a controlled frame (protocol §35.11).
|
|
2070
|
+
*
|
|
2071
|
+
* The row renders and does not answer. The frame carries `srcdoc` and the one
|
|
2072
|
+
* sandbox value §35.7 allows — never `allow-same-origin`, which is what turns a
|
|
2073
|
+
* sandboxed document back into a same-origin one and would hand an agent page the
|
|
2074
|
+
* GUI's own storage and cookies. There is no host request on any path here: an
|
|
2075
|
+
* action the page posts arrives as one visible sentence telling the operator to
|
|
2076
|
+
* answer on the phone, and nothing is forwarded, stored or sent.
|
|
2077
|
+
*
|
|
2078
|
+
* Height is measured from the inside because the frame is opaque from the
|
|
2079
|
+
* outside: the injected reporter posts the document's own content height, the
|
|
2080
|
+
* presenter's suggested `height` carries the first frame, and the measurement
|
|
2081
|
+
* replaces it as soon as one arrives. The theme is handed in as variables read
|
|
2082
|
+
* off the GUI root, so a card follows the running theme without importing one;
|
|
2083
|
+
* a theme that cannot be read costs the injected variables, never the card.
|
|
2084
|
+
*/
|
|
2085
|
+
/** @returns the GUI root's theme tokens, or none when the theme cannot be read. */
|
|
2086
|
+
function readThemeTokens() {
|
|
2087
|
+
try {
|
|
2088
|
+
return cardThemeTokens(getComputedStyle(document.documentElement));
|
|
2089
|
+
} catch {
|
|
2090
|
+
return [];
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
/**
|
|
2094
|
+
* Render one card, or the neutral line of a call that carries no page.
|
|
2095
|
+
* @param props - the stage, the call material and the locale seat.
|
|
2096
|
+
* @returns the card body placed inside the official tool row.
|
|
2097
|
+
*/
|
|
2098
|
+
function UiPresentRow({ phase, block, t }) {
|
|
2099
|
+
const read = (0, react.useMemo)(() => presentReadOf(phase, block), [phase, block]);
|
|
2100
|
+
const card = read.kind === "card" ? read.card : void 0;
|
|
2101
|
+
const frame = (0, react.useRef)(null);
|
|
2102
|
+
const [tokens, setTokens] = (0, react.useState)(readThemeTokens);
|
|
2103
|
+
const [measured, setMeasured] = (0, react.useState)(void 0);
|
|
2104
|
+
const [interacted, setInteracted] = (0, react.useState)(false);
|
|
2105
|
+
(0, react.useEffect)(() => {
|
|
2106
|
+
let media;
|
|
2107
|
+
try {
|
|
2108
|
+
media = window.matchMedia("(prefers-color-scheme: dark)");
|
|
2109
|
+
} catch {
|
|
2110
|
+
return;
|
|
2111
|
+
}
|
|
2112
|
+
const sync = () => {
|
|
2113
|
+
setTokens(readThemeTokens());
|
|
2114
|
+
};
|
|
2115
|
+
if (typeof media.addEventListener === "function") {
|
|
2116
|
+
media.addEventListener("change", sync);
|
|
2117
|
+
return () => {
|
|
2118
|
+
media.removeEventListener("change", sync);
|
|
2119
|
+
};
|
|
2120
|
+
}
|
|
2121
|
+
media.addListener(sync);
|
|
2122
|
+
return () => {
|
|
2123
|
+
media.removeListener(sync);
|
|
2124
|
+
};
|
|
2125
|
+
}, []);
|
|
2126
|
+
const html = card?.html;
|
|
2127
|
+
(0, react.useEffect)(() => {
|
|
2128
|
+
setMeasured(void 0);
|
|
2129
|
+
setInteracted(false);
|
|
2130
|
+
}, [html]);
|
|
2131
|
+
(0, react.useEffect)(() => {
|
|
2132
|
+
const onMessage = (event) => {
|
|
2133
|
+
const element = frame.current;
|
|
2134
|
+
if (element === null || element.contentWindow === null || event.source !== element.contentWindow) return;
|
|
2135
|
+
const frameEvent = frameEventOf(event.data);
|
|
2136
|
+
if (frameEvent === void 0) return;
|
|
2137
|
+
if (frameEvent.kind === "height") {
|
|
2138
|
+
setMeasured(clampCardHeight(frameEvent.height));
|
|
2139
|
+
return;
|
|
2140
|
+
}
|
|
2141
|
+
setInteracted(true);
|
|
2142
|
+
};
|
|
2143
|
+
window.addEventListener("message", onMessage);
|
|
2144
|
+
return () => {
|
|
2145
|
+
window.removeEventListener("message", onMessage);
|
|
2146
|
+
};
|
|
2147
|
+
}, []);
|
|
2148
|
+
const srcdoc = (0, react.useMemo)(() => card === void 0 ? "" : frameDocument(card.html, tokens, FRAME_HEIGHT_CHANNEL), [card, tokens]);
|
|
2149
|
+
if (card === void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2150
|
+
className: ui_present_module_css_default.row,
|
|
2151
|
+
"data-dsh-plugin": PLUGIN_ATTR,
|
|
2152
|
+
"data-tone": read.kind,
|
|
2153
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2154
|
+
className: ui_present_module_css_default.notice,
|
|
2155
|
+
role: "status",
|
|
2156
|
+
children: read.kind === "oversize" ? t("card.oversize") : t("card.empty")
|
|
2157
|
+
})
|
|
2158
|
+
});
|
|
2159
|
+
const height = measured ?? clampCardHeight(card.height ?? 320);
|
|
2160
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
2161
|
+
className: ui_present_module_css_default.card,
|
|
2162
|
+
"data-dsh-plugin": PLUGIN_ATTR,
|
|
2163
|
+
"data-state": card.state,
|
|
2164
|
+
children: [
|
|
2165
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
|
|
2166
|
+
className: ui_present_module_css_default.head,
|
|
2167
|
+
children: [card.title !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2168
|
+
className: ui_present_module_css_default.title,
|
|
2169
|
+
children: card.title
|
|
2170
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2171
|
+
className: ui_present_module_css_default.badge,
|
|
2172
|
+
children: card.state === "open" ? t("card.waiting") : t("card.settled")
|
|
2173
|
+
})]
|
|
2174
|
+
}),
|
|
2175
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("iframe", {
|
|
2176
|
+
ref: frame,
|
|
2177
|
+
className: ui_present_module_css_default.frame,
|
|
2178
|
+
style: { height: `${height}px` },
|
|
2179
|
+
title: card.title ?? t("card.frameLabel"),
|
|
2180
|
+
srcDoc: srcdoc,
|
|
2181
|
+
sandbox: FRAME_SANDBOX,
|
|
2182
|
+
allow: FRAME_PERMISSIONS,
|
|
2183
|
+
referrerPolicy: "no-referrer"
|
|
2184
|
+
}),
|
|
2185
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2186
|
+
className: ui_present_module_css_default.notice,
|
|
2187
|
+
role: "status",
|
|
2188
|
+
children: interacted ? t("card.interacted") : t("card.answerOnPhone")
|
|
2189
|
+
})
|
|
2190
|
+
]
|
|
2191
|
+
});
|
|
2192
|
+
}
|
|
2193
|
+
//#endregion
|
|
2194
|
+
//#region src/client/toolview-slot.ts
|
|
2195
|
+
/** The keyed Tool view slot the official row dispatches into. */
|
|
2196
|
+
const TOOLVIEW_SLOT = "tool.call.toolview";
|
|
2197
|
+
/** The wire Tool name this package renders: the keyed cell it claims. */
|
|
2198
|
+
const PRESENT_TOOL = "ui.present";
|
|
2199
|
+
/**
|
|
2200
|
+
* Contribute the `ui.present` card into the Tool row.
|
|
2201
|
+
*
|
|
2202
|
+
* The contribution is declaration-aware: `inject` waits for the official slot
|
|
2203
|
+
* declaration, so a GUI composed without a Tool layer has no keyed cell and thus
|
|
2204
|
+
* no card — that is the capability being absent, not an error to report. A
|
|
2205
|
+
* registration refused by the registry (an occupied cell at the same priority)
|
|
2206
|
+
* is swallowed the same way it is for this package's other seat, so one occupied
|
|
2207
|
+
* slot never takes the sidebar entry down with it.
|
|
2208
|
+
* @param host - the client Context.
|
|
2209
|
+
* @param locale - the dictionary namespace this package registered.
|
|
2210
|
+
*/
|
|
2211
|
+
function registerPresentToolview(host, locale) {
|
|
2212
|
+
const slots = host.slots;
|
|
2213
|
+
slots.inject(TOOLVIEW_SLOT, () => {
|
|
2214
|
+
try {
|
|
2215
|
+
return slots.register({
|
|
2216
|
+
name: TOOLVIEW_SLOT,
|
|
2217
|
+
key: PRESENT_TOOL,
|
|
2218
|
+
locale
|
|
2219
|
+
}, UiPresentRow);
|
|
2220
|
+
} catch {
|
|
2221
|
+
return () => {};
|
|
2222
|
+
}
|
|
2223
|
+
});
|
|
2224
|
+
}
|
|
2225
|
+
//#endregion
|
|
1716
2226
|
//#region src/client/locales.ts
|
|
1717
2227
|
/**
|
|
1718
|
-
* `remote-bridge` namespace dictionaries: the protocol v1 pairing panel copy
|
|
2228
|
+
* `remote-bridge` namespace dictionaries: the protocol v1 pairing panel copy and
|
|
2229
|
+
* the header of an interactive card (§35.11).
|
|
2230
|
+
*
|
|
2231
|
+
* The panel has one job — put the live one-shot code in front of the operator as
|
|
2232
|
+
* a QR symbol — so its copy carries exactly four things: what to do with the
|
|
2233
|
+
* symbol, how long it lives, which address the phone will actually dial, and why
|
|
2234
|
+
* the code is single-use. No key states how the host finds its public address:
|
|
2235
|
+
* that is an implementation fact the reader cannot act on.
|
|
1719
2236
|
*
|
|
1720
|
-
* The
|
|
1721
|
-
*
|
|
1722
|
-
*
|
|
1723
|
-
*
|
|
1724
|
-
* use, or a fresh mint).
|
|
2237
|
+
* The card's keys say only what the transcript row can act on: whether the page
|
|
2238
|
+
* is still waiting for the operator, that it is over, that this desktop renders
|
|
2239
|
+
* without answering, and that a page carrying nothing or too much draws a
|
|
2240
|
+
* sentence instead of a frame.
|
|
1725
2241
|
*/
|
|
1726
2242
|
/** Simplified Chinese dictionary (the key-set source of truth). */
|
|
1727
2243
|
const zh = {
|
|
1728
2244
|
"entry.label": "配对手机(协议 v1)",
|
|
1729
2245
|
"title": "协议 v1 配对",
|
|
1730
|
-
"subtitle": "用手机 App
|
|
2246
|
+
"subtitle": "用手机 App 扫描二维码,即可让手机以协议 v1 连上这台宿主。配对码由本机签发,只在本机显示。",
|
|
1731
2247
|
"state.reading": "正在取配对码…",
|
|
1732
2248
|
"pair.qrLabel": "配对二维码",
|
|
1733
|
-
"pair.payloadLabel": "二维码内容(可复制后粘贴到手机)",
|
|
1734
2249
|
"pair.countdown": "剩余 {s} 秒",
|
|
1735
|
-
"pair.expired": "
|
|
1736
|
-
"pair.expiredHint": "过期的配对码不会被手机接受,请重新取码。",
|
|
1737
|
-
"pair.usedHint": "配对码一次性:手机调用 pair.begin 的瞬间即作废,重新取码也会作废上一张。",
|
|
2250
|
+
"pair.expired": "配对码已过期",
|
|
1738
2251
|
"pair.refresh": "重新取码",
|
|
1739
|
-
"
|
|
1740
|
-
"origin.
|
|
1741
|
-
"origin.
|
|
1742
|
-
"origin.located.body": "二维码里已经带上 {origin}:手机扫一次就同时设好连接地址与配对码,不需要手填任何东西。",
|
|
2252
|
+
"pair.usedHint": "配对码一次性有效:手机一开始配对即作废,重新取码也会作废上一张。",
|
|
2253
|
+
"origin.located": "手机将连到 {origin}",
|
|
2254
|
+
"origin.missing": "没有找到公网地址:请先在手机里把连接地址填成你的公网中继,再扫码。本页的 {host} 只有本机能连。",
|
|
1743
2255
|
"forbidden.title": "这个页面不是从本机打开的",
|
|
1744
2256
|
"forbidden.body": "配对码只能在本机 Web UI 上取。请在本机浏览器打开 http://127.0.0.1:<端口> 后重试。",
|
|
1745
2257
|
"failed.title": "取配对码失败",
|
|
@@ -1750,25 +2262,28 @@ window.__ModuleLoader__.load({
|
|
|
1750
2262
|
"action.copy": "复制配对码",
|
|
1751
2263
|
"action.copied": "已复制",
|
|
1752
2264
|
"action.copyFailed": "复制失败",
|
|
1753
|
-
"action.retry": "重试"
|
|
2265
|
+
"action.retry": "重试",
|
|
2266
|
+
"card.waiting": "等你操作",
|
|
2267
|
+
"card.settled": "已结算",
|
|
2268
|
+
"card.answerOnPhone": "在手机上作答",
|
|
2269
|
+
"card.interacted": "已收到页面上的操作,但桌面端不作答:在手机上作答",
|
|
2270
|
+
"card.frameLabel": "整页卡片",
|
|
2271
|
+
"card.empty": "这次调用没有可渲染的页面",
|
|
2272
|
+
"card.oversize": "页面超出大小上限,未渲染"
|
|
1754
2273
|
};
|
|
1755
2274
|
/** English dictionary, key-for-key with the zh source. */
|
|
1756
2275
|
const en = {
|
|
1757
2276
|
"entry.label": "Pair a phone (protocol v1)",
|
|
1758
2277
|
"title": "Protocol v1 pairing",
|
|
1759
|
-
"subtitle": "Scan the QR code with the phone app to
|
|
2278
|
+
"subtitle": "Scan the QR code with the phone app to let the phone reach this host over protocol v1. The code is minted by this machine and shown only here.",
|
|
1760
2279
|
"state.reading": "Requesting a pairing code…",
|
|
1761
2280
|
"pair.qrLabel": "Pairing QR code",
|
|
1762
|
-
"pair.payloadLabel": "What the QR encodes (copy it to paste on the phone)",
|
|
1763
2281
|
"pair.countdown": "{s} s left",
|
|
1764
|
-
"pair.expired": "The pairing code expired
|
|
1765
|
-
"pair.expiredHint": "An expired code is never accepted; request a new one.",
|
|
1766
|
-
"pair.usedHint": "The code is single-use: the phone spends it the moment it calls pair.begin, and requesting a new one voids the previous code.",
|
|
2282
|
+
"pair.expired": "The pairing code expired",
|
|
1767
2283
|
"pair.refresh": "New code",
|
|
1768
|
-
"
|
|
1769
|
-
"origin.
|
|
1770
|
-
"origin.
|
|
1771
|
-
"origin.located.body": "The QR carries {origin}: one scan sets both the connection address and the pairing code, with nothing to type.",
|
|
2284
|
+
"pair.usedHint": "The code is single-use: pairing spends it, and a new code voids the previous one.",
|
|
2285
|
+
"origin.located": "The phone will dial {origin}",
|
|
2286
|
+
"origin.missing": "No public address found: set the phone app to your public relay first, then scan. {host} (this page) is reachable only from this machine.",
|
|
1772
2287
|
"forbidden.title": "This page is not open on this machine",
|
|
1773
2288
|
"forbidden.body": "Pairing codes can only be read from the machine itself. Open http://127.0.0.1:<port> in a browser on this machine and retry.",
|
|
1774
2289
|
"failed.title": "Could not read a pairing code",
|
|
@@ -1779,7 +2294,14 @@ window.__ModuleLoader__.load({
|
|
|
1779
2294
|
"action.copy": "Copy pairing code",
|
|
1780
2295
|
"action.copied": "Copied",
|
|
1781
2296
|
"action.copyFailed": "Copy failed",
|
|
1782
|
-
"action.retry": "Retry"
|
|
2297
|
+
"action.retry": "Retry",
|
|
2298
|
+
"card.waiting": "Waiting for you",
|
|
2299
|
+
"card.settled": "Settled",
|
|
2300
|
+
"card.answerOnPhone": "Answer on the phone",
|
|
2301
|
+
"card.interacted": "The page sent an action, but this desktop does not answer: answer on the phone",
|
|
2302
|
+
"card.frameLabel": "Page card",
|
|
2303
|
+
"card.empty": "This call carried no page to render",
|
|
2304
|
+
"card.oversize": "The page is over the size limit and was not rendered"
|
|
1783
2305
|
};
|
|
1784
2306
|
//#endregion
|
|
1785
2307
|
//#region src/client/index.ts
|
|
@@ -1819,6 +2341,7 @@ window.__ModuleLoader__.load({
|
|
|
1819
2341
|
return () => {};
|
|
1820
2342
|
}
|
|
1821
2343
|
});
|
|
2344
|
+
registerPresentToolview(ctx, NS);
|
|
1822
2345
|
}
|
|
1823
2346
|
//#endregion
|
|
1824
2347
|
exports.apply = apply;
|