dsh-local-link 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/LICENSE +21 -0
- package/README.md +180 -0
- package/SECURITY.md +7 -0
- package/cordis.patch.yml +17 -0
- package/docs/ARCHITECTURE.md +135 -0
- package/docs/DIAGNOSTICS.md +100 -0
- package/docs/SECURITY.md +64 -0
- package/docs/images/local-access-devices.jpg +0 -0
- package/docs/images/local-access-diagnostics.jpg +0 -0
- package/docs/images/local-access-qr.jpg +0 -0
- package/lib/client.js +629 -0
- package/lib/client.js.map +1 -0
- package/lib/index.d.mts +137 -0
- package/lib/index.mjs +902 -0
- package/package.json +121 -0
package/lib/client.js
ADDED
|
@@ -0,0 +1,629 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "dsh-local-link",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
//#region \0rolldown/runtime.js
|
|
8
|
+
var __create = Object.create;
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
16
|
+
key = keys[i];
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
+
get: ((k) => from[k]).bind(null, key),
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
25
|
+
value: mod,
|
|
26
|
+
enumerable: true
|
|
27
|
+
}) : target, mod));
|
|
28
|
+
//#endregion
|
|
29
|
+
let react = require("react");
|
|
30
|
+
react = __toESM(react, 1);
|
|
31
|
+
//#region src/locales/en.json
|
|
32
|
+
var en_default = {
|
|
33
|
+
nav: "Local access",
|
|
34
|
+
"footer.trigger": "Local access",
|
|
35
|
+
"connect.title": "Open on another device",
|
|
36
|
+
"connect.pairedDevices": "Paired devices",
|
|
37
|
+
"connect.description": "Scan the QR code or copy the one-time link. The device must be on the same local network.",
|
|
38
|
+
"connect.creating": "Creating a connection code…",
|
|
39
|
+
"connect.error": "Could not create a connection code.",
|
|
40
|
+
"connect.qrAlt": "QR code for local DeepSeek Harness access",
|
|
41
|
+
"connect.linkLabel": "One-time local access link",
|
|
42
|
+
"connect.copy": "Copy",
|
|
43
|
+
"connect.copied": "Copied",
|
|
44
|
+
"connect.copyError": "Could not copy the link.",
|
|
45
|
+
"connect.oneDevice": "One device only",
|
|
46
|
+
"connect.expiresIn": "Expires in",
|
|
47
|
+
"connect.expired": "Link expired",
|
|
48
|
+
"connect.regenerate": "Generate another code",
|
|
49
|
+
"devices.title": "Paired devices",
|
|
50
|
+
"devices.description": "Devices allowed to open this DeepSeek Harness instance. Revoke any device you no longer use.",
|
|
51
|
+
"devices.loading": "Loading paired devices…",
|
|
52
|
+
"devices.error": "Could not load paired devices.",
|
|
53
|
+
"devices.empty": "No paired devices yet.",
|
|
54
|
+
"devices.rename": "Rename",
|
|
55
|
+
"devices.nameLabel": "Device name",
|
|
56
|
+
"devices.save": "Save",
|
|
57
|
+
"devices.saving": "Saving…",
|
|
58
|
+
"devices.cancel": "Cancel",
|
|
59
|
+
"devices.revoke": "Revoke",
|
|
60
|
+
"devices.revoking": "Revoking…",
|
|
61
|
+
"diagnostics.title": "Diagnostics",
|
|
62
|
+
"diagnostics.subtitle": "Local, privacy-safe event history",
|
|
63
|
+
"diagnostics.description": "Recent local gateway events. Stored only on this computer and stripped of tokens, cookies, addresses, IDs, names, and request paths.",
|
|
64
|
+
"diagnostics.loading": "Loading…",
|
|
65
|
+
"diagnostics.unavailable": "Unavailable",
|
|
66
|
+
"diagnostics.events": "events",
|
|
67
|
+
"diagnostics.empty": "No diagnostic events yet.",
|
|
68
|
+
"diagnostics.error": "Could not load diagnostics.",
|
|
69
|
+
"diagnostics.refresh": "Refresh",
|
|
70
|
+
"diagnostics.copy": "Copy report",
|
|
71
|
+
"diagnostics.copied": "Report copied",
|
|
72
|
+
"diagnostics.copyError": "Could not copy the report.",
|
|
73
|
+
"diagnostics.clear": "Clear",
|
|
74
|
+
"diagnostics.clearing": "Clearing…",
|
|
75
|
+
"diagnostics.clearConfirm": "Clear all local diagnostic events?"
|
|
76
|
+
};
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/locales/zh.json
|
|
79
|
+
var zh_default = {
|
|
80
|
+
nav: "本地访问",
|
|
81
|
+
"footer.trigger": "本地访问",
|
|
82
|
+
"connect.title": "在其他设备上打开",
|
|
83
|
+
"connect.pairedDevices": "已配对设备",
|
|
84
|
+
"connect.description": "扫描二维码或复制一次性链接。设备必须连接到同一个本地网络。",
|
|
85
|
+
"connect.creating": "正在创建连接二维码…",
|
|
86
|
+
"connect.error": "无法创建连接二维码。",
|
|
87
|
+
"connect.qrAlt": "用于本地访问 DeepSeek Harness 的二维码",
|
|
88
|
+
"connect.linkLabel": "一次性本地访问链接",
|
|
89
|
+
"connect.copy": "复制",
|
|
90
|
+
"connect.copied": "已复制",
|
|
91
|
+
"connect.copyError": "无法复制链接。",
|
|
92
|
+
"connect.oneDevice": "仅限一台设备",
|
|
93
|
+
"connect.expiresIn": "有效期剩余",
|
|
94
|
+
"connect.expired": "链接已过期",
|
|
95
|
+
"connect.regenerate": "生成新二维码",
|
|
96
|
+
"devices.title": "已配对设备",
|
|
97
|
+
"devices.description": "这些设备可以打开此 DeepSeek Harness 实例。不再使用的设备可在此撤销。",
|
|
98
|
+
"devices.loading": "正在加载已配对设备…",
|
|
99
|
+
"devices.error": "无法加载已配对设备。",
|
|
100
|
+
"devices.empty": "尚无已配对设备。",
|
|
101
|
+
"devices.rename": "重命名",
|
|
102
|
+
"devices.nameLabel": "设备名称",
|
|
103
|
+
"devices.save": "保存",
|
|
104
|
+
"devices.saving": "正在保存…",
|
|
105
|
+
"devices.cancel": "取消",
|
|
106
|
+
"devices.revoke": "撤销",
|
|
107
|
+
"devices.revoking": "正在撤销…",
|
|
108
|
+
"diagnostics.title": "诊断",
|
|
109
|
+
"diagnostics.subtitle": "本地隐私安全事件记录",
|
|
110
|
+
"diagnostics.description": "最近的本地网关事件。仅存储在此计算机上,不包含令牌、Cookie、地址、ID、名称或请求路径。",
|
|
111
|
+
"diagnostics.loading": "正在加载…",
|
|
112
|
+
"diagnostics.unavailable": "不可用",
|
|
113
|
+
"diagnostics.events": "条事件",
|
|
114
|
+
"diagnostics.empty": "暂无诊断事件。",
|
|
115
|
+
"diagnostics.error": "无法加载诊断信息。",
|
|
116
|
+
"diagnostics.refresh": "刷新",
|
|
117
|
+
"diagnostics.copy": "复制报告",
|
|
118
|
+
"diagnostics.copied": "报告已复制",
|
|
119
|
+
"diagnostics.copyError": "无法复制报告。",
|
|
120
|
+
"diagnostics.clear": "清除",
|
|
121
|
+
"diagnostics.clearing": "正在清除…",
|
|
122
|
+
"diagnostics.clearConfirm": "清除所有本地诊断事件?"
|
|
123
|
+
};
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/client.tsx
|
|
126
|
+
const NS = "dsh.localLink";
|
|
127
|
+
function desktopOrigin() {
|
|
128
|
+
return location.hostname === "localhost" || location.hostname === "127.0.0.1" || location.hostname === "::1";
|
|
129
|
+
}
|
|
130
|
+
function secondsUntil(iso) {
|
|
131
|
+
return Math.max(0, Math.ceil((Date.parse(iso) - Date.now()) / 1e3));
|
|
132
|
+
}
|
|
133
|
+
function formatCountdown(seconds) {
|
|
134
|
+
return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`;
|
|
135
|
+
}
|
|
136
|
+
function payloadText(value, fallback) {
|
|
137
|
+
return typeof value === "string" && value.trim() !== "" ? value : fallback;
|
|
138
|
+
}
|
|
139
|
+
function legacyDeviceType(label) {
|
|
140
|
+
if (typeof label !== "string") return "Computer";
|
|
141
|
+
if (/ipad|tablet/iu.test(label)) return "Tablet";
|
|
142
|
+
if (/iphone|android|mobile|phone|linux\s+arm/iu.test(label)) return "Phone";
|
|
143
|
+
return "Computer";
|
|
144
|
+
}
|
|
145
|
+
function normalizeDevices(payload) {
|
|
146
|
+
if (!Array.isArray(payload.devices)) return [];
|
|
147
|
+
return payload.devices.flatMap((value) => {
|
|
148
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return [];
|
|
149
|
+
const device = value;
|
|
150
|
+
if (typeof device.id !== "string") return [];
|
|
151
|
+
return [{
|
|
152
|
+
id: device.id,
|
|
153
|
+
name: payloadText(device.name, "My device"),
|
|
154
|
+
deviceType: payloadText(device.deviceType, legacyDeviceType(device.label)),
|
|
155
|
+
browser: payloadText(device.browser, "Browser")
|
|
156
|
+
}];
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function normalizeDiagnostics(payload) {
|
|
160
|
+
if (!Array.isArray(payload.events)) return [];
|
|
161
|
+
return payload.events.flatMap((value) => {
|
|
162
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return [];
|
|
163
|
+
const event = value;
|
|
164
|
+
if (typeof event.id !== "string" || typeof event.at !== "string" || typeof event.code !== "string" || event.level !== "warn" && event.level !== "error") return [];
|
|
165
|
+
const context = event.context !== null && typeof event.context === "object" && !Array.isArray(event.context) ? Object.fromEntries(Object.entries(event.context).filter((entry) => {
|
|
166
|
+
const item = entry[1];
|
|
167
|
+
return typeof item === "string" || typeof item === "number" || typeof item === "boolean";
|
|
168
|
+
})) : void 0;
|
|
169
|
+
return [{
|
|
170
|
+
id: event.id,
|
|
171
|
+
at: event.at,
|
|
172
|
+
level: event.level,
|
|
173
|
+
code: event.code,
|
|
174
|
+
...context === void 0 ? {} : { context }
|
|
175
|
+
}];
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
function openSettingsSection(label) {
|
|
179
|
+
const trigger = document.querySelector("button[aria-haspopup=\"dialog\"][aria-expanded]");
|
|
180
|
+
if (trigger === null) return;
|
|
181
|
+
trigger.click();
|
|
182
|
+
let attempts = 0;
|
|
183
|
+
const selectSection = () => {
|
|
184
|
+
const dialog = document.querySelector("[role=\"dialog\"]");
|
|
185
|
+
const target = dialog === null ? void 0 : [...dialog.querySelectorAll("nav button")].find((button) => button.textContent?.trim() === label);
|
|
186
|
+
if (target !== void 0) {
|
|
187
|
+
target.click();
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
attempts += 1;
|
|
191
|
+
if (attempts < 10) window.requestAnimationFrame(selectSection);
|
|
192
|
+
};
|
|
193
|
+
window.requestAnimationFrame(selectSection);
|
|
194
|
+
}
|
|
195
|
+
async function jsonRequest(path, init) {
|
|
196
|
+
const response = await fetch(path, {
|
|
197
|
+
...init,
|
|
198
|
+
headers: {
|
|
199
|
+
"content-type": "application/json",
|
|
200
|
+
...init?.headers
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
const body = await response.json();
|
|
204
|
+
if (!response.ok) throw new Error(body.error ?? `HTTP ${response.status}`);
|
|
205
|
+
return body;
|
|
206
|
+
}
|
|
207
|
+
function reportActionError(code) {
|
|
208
|
+
fetch("/__dsh-local-link/admin/diagnostics/event", {
|
|
209
|
+
method: "POST",
|
|
210
|
+
headers: { "content-type": "application/json" },
|
|
211
|
+
body: JSON.stringify({ code })
|
|
212
|
+
}).catch(() => void 0);
|
|
213
|
+
}
|
|
214
|
+
const styles = `
|
|
215
|
+
.dsh-local-link{box-sizing:border-box;width:100%;max-width:760px;padding:4px 4px 32px;color:var(--dsw-alias-label-primary,#16181d)}
|
|
216
|
+
.dsh-local-link h2{margin:0 0 5px;font-size:20px}.dsh-local-link>p{margin:0;color:var(--dsw-alias-label-secondary,#66707c);line-height:1.5}
|
|
217
|
+
.dsh-local-link button{display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;min-height:32px;padding:6px 10px;border:1px solid var(--dsw-alias-border-normal,#cbd2dc);border-radius:8px;background:transparent;color:inherit;font:600 12px/1.2 system-ui;cursor:pointer}.dsh-local-link button:hover{background:var(--dsw-alias-interactive-bg-hover,#e8ebef)}.dsh-local-link button:disabled{opacity:.55;cursor:wait}
|
|
218
|
+
.dsh-local-link__devices{display:grid;margin-top:12px;border-block:1px solid var(--dsw-alias-border-subtle,#dce1e8)}.dsh-local-link__devices>p{margin:0;padding:12px 0;color:var(--dsw-alias-label-secondary,#66707c);line-height:1.45}.dsh-local-link__device{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:12px;padding:8px 0;border-top:1px solid var(--dsw-alias-border-subtle,#dce1e8)}.dsh-local-link__device:first-child{border-top:0}.dsh-local-link__device-info{display:grid;min-width:0;gap:2px}.dsh-local-link__device-info strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font:600 14px/1.25 system-ui}.dsh-local-link__device-info small{overflow:hidden;color:var(--dsw-alias-label-secondary,#66707c);font:12px/1.3 system-ui;text-overflow:ellipsis;white-space:nowrap}.dsh-local-link__device-actions{display:flex;gap:6px}.dsh-local-link__device-editor{display:grid;grid-column:1/-1;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:6px}.dsh-local-link__device-editor input{box-sizing:border-box;min-width:0;height:32px;padding:6px 9px;border:1px solid var(--dsw-alias-border-normal,#cbd2dc);border-radius:8px;background:var(--dsw-alias-bg-layer-2,#eef1f5);color:inherit;font:14px/1.2 system-ui;outline:none}.dsh-local-link__device-editor input:focus{border-color:var(--dsw-alias-border-focus,#2878ff)}@media(max-width:440px){.dsh-local-link__device{grid-template-columns:minmax(0,1fr) auto;gap:8px}.dsh-local-link__device-actions{gap:4px}.dsh-local-link button{padding-inline:8px}.dsh-local-link__device-editor{grid-template-columns:1fr auto}.dsh-local-link__device-editor input{grid-column:1/-1}}
|
|
219
|
+
.dsh-local-link__diagnostics{margin-top:30px;overflow:hidden;border:1px solid var(--dsw-alias-border-l2,#45484d);border-radius:12px;background:var(--dsw-alias-bg-layer-3,#303236);transition:border-color .16s,background .16s}.dsh-local-link__diagnostics:hover{border-color:var(--dsw-alias-label-dimmed,#74777d)}.dsh-local-link__diagnostics[open]{border-color:var(--dsw-alias-label-dimmed,#74777d);background:var(--dsw-alias-bg-layer-2,#282a2e)}.dsh-local-link__diagnostics summary{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;padding:14px 16px;box-sizing:border-box;cursor:pointer;list-style:none}.dsh-local-link__diagnostics summary::-webkit-details-marker{display:none}.dsh-local-link__diagnostics summary:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#2878ff);outline-offset:-2px}.dsh-local-link__diagnostics-summary-main,.dsh-local-link__diagnostics-summary-meta{display:flex;align-items:center;min-width:0}.dsh-local-link__diagnostics-summary-main{flex:1;gap:11px}.dsh-local-link__diagnostics-summary-meta{flex:none;gap:12px}.dsh-local-link__diagnostics-icon{display:grid;place-items:center;flex:none;width:34px;height:34px;border-radius:9px;background:color-mix(in srgb,var(--dsw-alias-brand-primary,#2878ff) 14%,transparent);color:var(--dsw-alias-brand-primary,#2878ff)}.dsh-local-link__diagnostics-copy{display:flex;flex:1;flex-direction:column;min-width:0;gap:4px}.dsh-local-link__diagnostics-copy strong{color:var(--dsw-alias-label-primary,#f2f3f5);font:600 15px/1.4 system-ui}.dsh-local-link__diagnostics-copy small{overflow:hidden;color:var(--dsw-alias-label-tertiary,#a6a8ad);font:13px/1.5 system-ui;text-overflow:ellipsis;white-space:nowrap}.dsh-local-link__diagnostics-badge{padding:0;color:var(--dsw-alias-label-tertiary,#a6a8ad);font:400 12px/1.3 system-ui;white-space:nowrap}.dsh-local-link__diagnostics-chevron{flex:none;color:var(--dsw-alias-label-tertiary,#a6a8ad);transition:transform .16s}.dsh-local-link__diagnostics[open] .dsh-local-link__diagnostics-chevron{transform:rotate(180deg)}.dsh-local-link__diagnostics-body{margin:0 16px;padding:12px 0 8px;border-top:1px solid var(--dsw-alias-border-l2,#45484d)}.dsh-local-link__diagnostics-body>p{margin:0 0 12px;color:var(--dsw-alias-label-tertiary,#a6a8ad);font:12px/1.5 system-ui}.dsh-local-link__diagnostics-actions{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:12px}.dsh-local-link__diagnostic-list{display:grid;overflow:hidden;border:1px solid var(--dsw-alias-border-l2,#45484d);border-radius:9px;background:var(--dsw-alias-bg-layer-3,#303236)}.dsh-local-link__diagnostic{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:baseline;gap:8px;padding:8px 10px;border-top:1px solid var(--dsw-alias-border-l2,#45484d);font:12px/1.35 system-ui}.dsh-local-link__diagnostic:first-child{border-top:0}.dsh-local-link__diagnostic-level{width:7px;height:7px;border-radius:50%;background:#6b7280}.dsh-local-link__diagnostic-level--warn{background:#d28b15}.dsh-local-link__diagnostic-level--error{background:#dc4c4c}.dsh-local-link__diagnostic code{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font:600 11px/1.3 ui-monospace,SFMono-Regular,Consolas,monospace}.dsh-local-link__diagnostic time{color:var(--dsw-alias-label-tertiary,#a6a8ad);font-size:11px;white-space:nowrap}.dsh-local-link__diagnostic-context{grid-column:2/-1;overflow:hidden;color:var(--dsw-alias-label-tertiary,#a6a8ad);font:11px/1.35 ui-monospace,SFMono-Regular,Consolas,monospace;text-overflow:ellipsis;white-space:nowrap}@media(max-width:540px){.dsh-local-link__diagnostics-copy small{display:none}.dsh-local-link__diagnostics summary{padding-inline:12px}.dsh-local-link__diagnostics-badge{max-width:92px;overflow:hidden;text-overflow:ellipsis}}
|
|
220
|
+
.dsh-local-link-footer{position:relative;width:100%;min-width:0}:where(div):has(> .dsh-local-link-footer),:where(div):has(> :where(div) > .dsh-local-link-footer){flex-direction:column;gap:4px}:where(div):has(> .dsh-local-link-footer)>.dsh-local-link-footer+:where(div){margin-block-start:0!important}.dsh-local-link-trigger{box-sizing:border-box;display:flex;align-items:center;gap:8px;width:calc(100% + 4px);height:42px;margin:0 -2px;padding:0 10px 0 8px;border:0;border-radius:12px;background:transparent;color:var(--dsw-alias-label-primary,#16181d);font:400 14px/22px inherit;cursor:pointer;overflow:hidden}.dsh-local-link-trigger:hover{background:var(--dsw-alias-interactive-bg-hover,#e8ebef)}.dsh-local-link-trigger--rail{justify-content:center;gap:0;width:36px;height:36px;margin:0;padding:0;border-radius:50%}.dsh-local-link-trigger__label{white-space:nowrap;overflow:hidden}
|
|
221
|
+
.dsh-local-link-popover{position:fixed;z-index:10000;box-sizing:border-box;width:min(360px,calc(100vw - 24px));height:min(453px,calc(100vh - 24px));padding:16px;overflow:auto;overscroll-behavior:contain;border:1px solid var(--dsw-alias-border-subtle,#dce1e8);border-radius:14px;background:var(--dsw-alias-bg-layer-1,#fff);color:var(--dsw-alias-label-primary,#16181d);box-shadow:0 18px 55px #0004}.dsh-local-link-popover__header{display:flex;align-items:center;justify-content:space-between;gap:12px}.dsh-local-link-popover strong{font-size:15px}.dsh-local-link-popover__manage{flex:none;padding:4px 6px;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary,#66707c);font:600 11px/1.2 system-ui;cursor:pointer}.dsh-local-link-popover__manage:hover{background:var(--dsw-alias-interactive-bg-hover,#e8ebef);color:inherit}.dsh-local-link-popover p{margin:8px 0;color:var(--dsw-alias-label-secondary,#66707c);font:13px/1.45 system-ui}.dsh-local-link-popover__qr{display:block;width:200px;height:200px;margin:12px auto 0;padding:7px;border-radius:12px;background:#fff;transition:opacity .2s,filter .2s}.dsh-local-link-popover__qr--expired{opacity:.3;filter:grayscale(1)}.dsh-local-link-popover__link{display:flex;align-items:stretch;min-width:0;height:40px;margin-top:12px;border:1px solid var(--dsw-alias-border-normal,#cbd2dc);border-radius:10px;overflow:hidden;background:var(--dsw-alias-bg-layer-2,#eef1f5)}.dsh-local-link-popover__link-value{position:relative;display:flex;align-items:center;flex:1;min-width:0;padding:0 8px 0 10px;overflow:hidden;white-space:nowrap;font:11px/1.4 ui-monospace,SFMono-Regular,Consolas,monospace;mask-image:linear-gradient(to right,#000 76%,transparent 98%);-webkit-mask-image:linear-gradient(to right,#000 76%,transparent 98%)}.dsh-local-link-popover__copy,.dsh-local-link-popover__regenerate{border:0;background:transparent;color:inherit;font:600 12px/1.2 system-ui;cursor:pointer}.dsh-local-link-popover__copy{min-width:76px;padding:0 11px;border-left:1px solid var(--dsw-alias-border-normal,#cbd2dc);transition:background .18s,color .18s}.dsh-local-link-popover__copy:hover,.dsh-local-link-popover__regenerate:hover{background:var(--dsw-alias-interactive-bg-hover,#e8ebef)}.dsh-local-link-popover__copy--copied{background:#16803a22;color:#39a85b}.dsh-local-link-popover__copy:disabled{opacity:.45;cursor:not-allowed}.dsh-local-link-popover__meta{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-top:9px;color:var(--dsw-alias-label-secondary,#66707c);font:11px/1.35 system-ui}.dsh-local-link-popover__regenerate{display:block;width:100%;min-height:38px;margin-top:10px;border:1px solid var(--dsw-alias-border-normal,#cbd2dc);border-radius:10px}.dsh-local-link-popover__error{color:#c53030!important}
|
|
222
|
+
`;
|
|
223
|
+
function LocalLinkFooter({ wide, t, getCurrentSessionId }) {
|
|
224
|
+
const desktop = desktopOrigin();
|
|
225
|
+
const root = (0, react.useRef)(null);
|
|
226
|
+
const popover = (0, react.useRef)(null);
|
|
227
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
228
|
+
const [popoverPosition, setPopoverPosition] = (0, react.useState)();
|
|
229
|
+
const [pairing, setPairing] = (0, react.useState)();
|
|
230
|
+
const [remaining, setRemaining] = (0, react.useState)(0);
|
|
231
|
+
const [copyState, setCopyState] = (0, react.useState)("idle");
|
|
232
|
+
const [error, setError] = (0, react.useState)(false);
|
|
233
|
+
const copyReset = (0, react.useRef)(void 0);
|
|
234
|
+
const createLink = (0, react.useCallback)(async () => {
|
|
235
|
+
setPairing(void 0);
|
|
236
|
+
setRemaining(0);
|
|
237
|
+
setCopyState("idle");
|
|
238
|
+
setError(false);
|
|
239
|
+
try {
|
|
240
|
+
const nextPairing = await jsonRequest("/__dsh-local-link/admin/pairing", {
|
|
241
|
+
method: "POST",
|
|
242
|
+
body: JSON.stringify({ sessionId: getCurrentSessionId() })
|
|
243
|
+
});
|
|
244
|
+
setPairing(nextPairing);
|
|
245
|
+
setRemaining(secondsUntil(nextPairing.expiresAt));
|
|
246
|
+
} catch {
|
|
247
|
+
setError(true);
|
|
248
|
+
}
|
|
249
|
+
}, [getCurrentSessionId]);
|
|
250
|
+
const copyLink = (0, react.useCallback)(async () => {
|
|
251
|
+
if (pairing === void 0 || remaining === 0) return;
|
|
252
|
+
try {
|
|
253
|
+
await navigator.clipboard.writeText(pairing.url);
|
|
254
|
+
setCopyState("copied");
|
|
255
|
+
if (copyReset.current !== void 0) window.clearTimeout(copyReset.current);
|
|
256
|
+
copyReset.current = window.setTimeout(() => setCopyState("idle"), 1800);
|
|
257
|
+
} catch {
|
|
258
|
+
setCopyState("error");
|
|
259
|
+
reportActionError("CLIPBOARD_COPY_FAILED");
|
|
260
|
+
}
|
|
261
|
+
}, [pairing, remaining]);
|
|
262
|
+
(0, react.useEffect)(() => {
|
|
263
|
+
if (!open || pairing === void 0) return;
|
|
264
|
+
let disposed = false;
|
|
265
|
+
const update = () => setRemaining(secondsUntil(pairing.expiresAt));
|
|
266
|
+
const check = async () => {
|
|
267
|
+
try {
|
|
268
|
+
const result = await jsonRequest(`/__dsh-local-link/admin/pairing/status?id=${encodeURIComponent(pairing.id)}`);
|
|
269
|
+
if (!disposed && result.status === "consumed") setOpen(false);
|
|
270
|
+
} catch {}
|
|
271
|
+
};
|
|
272
|
+
update();
|
|
273
|
+
check();
|
|
274
|
+
const countdownTimer = window.setInterval(update, 1e3);
|
|
275
|
+
const statusTimer = window.setInterval(() => void check(), 2e3);
|
|
276
|
+
return () => {
|
|
277
|
+
disposed = true;
|
|
278
|
+
window.clearInterval(countdownTimer);
|
|
279
|
+
window.clearInterval(statusTimer);
|
|
280
|
+
};
|
|
281
|
+
}, [open, pairing]);
|
|
282
|
+
(0, react.useEffect)(() => () => {
|
|
283
|
+
if (copyReset.current !== void 0) window.clearTimeout(copyReset.current);
|
|
284
|
+
}, []);
|
|
285
|
+
(0, react.useEffect)(() => {
|
|
286
|
+
if (!open) return;
|
|
287
|
+
const close = (event) => {
|
|
288
|
+
if (!root.current?.contains(event.target)) setOpen(false);
|
|
289
|
+
};
|
|
290
|
+
const escape = (event) => {
|
|
291
|
+
if (event.key === "Escape") setOpen(false);
|
|
292
|
+
};
|
|
293
|
+
document.addEventListener("pointerdown", close);
|
|
294
|
+
window.addEventListener("keydown", escape);
|
|
295
|
+
return () => {
|
|
296
|
+
document.removeEventListener("pointerdown", close);
|
|
297
|
+
window.removeEventListener("keydown", escape);
|
|
298
|
+
};
|
|
299
|
+
}, [open]);
|
|
300
|
+
(0, react.useEffect)(() => {
|
|
301
|
+
if (!open) {
|
|
302
|
+
setPopoverPosition(void 0);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
const position = () => {
|
|
306
|
+
const anchorRect = root.current?.getBoundingClientRect();
|
|
307
|
+
const popoverRect = popover.current?.getBoundingClientRect();
|
|
308
|
+
if (anchorRect === void 0 || popoverRect === void 0) return;
|
|
309
|
+
const viewportGutter = 12;
|
|
310
|
+
const preferredLeft = anchorRect.right + 20;
|
|
311
|
+
const left = preferredLeft + popoverRect.width <= window.innerWidth - viewportGutter ? preferredLeft : Math.max(viewportGutter, window.innerWidth - popoverRect.width - viewportGutter);
|
|
312
|
+
const top = Math.max(viewportGutter, Math.round((window.innerHeight - popoverRect.height) / 2));
|
|
313
|
+
setPopoverPosition({
|
|
314
|
+
left: Math.round(left),
|
|
315
|
+
top
|
|
316
|
+
});
|
|
317
|
+
};
|
|
318
|
+
const frame = window.requestAnimationFrame(position);
|
|
319
|
+
const observer = new ResizeObserver(position);
|
|
320
|
+
if (popover.current !== null) observer.observe(popover.current);
|
|
321
|
+
window.addEventListener("resize", position);
|
|
322
|
+
return () => {
|
|
323
|
+
window.cancelAnimationFrame(frame);
|
|
324
|
+
observer.disconnect();
|
|
325
|
+
window.removeEventListener("resize", position);
|
|
326
|
+
};
|
|
327
|
+
}, [open]);
|
|
328
|
+
if (!desktop) return null;
|
|
329
|
+
return /* @__PURE__ */ react.default.createElement("div", {
|
|
330
|
+
className: "dsh-local-link-footer",
|
|
331
|
+
ref: root
|
|
332
|
+
}, /* @__PURE__ */ react.default.createElement("button", {
|
|
333
|
+
className: `dsh-local-link-trigger${wide ? "" : " dsh-local-link-trigger--rail"}`,
|
|
334
|
+
type: "button",
|
|
335
|
+
title: t("footer.trigger"),
|
|
336
|
+
"aria-label": t("footer.trigger"),
|
|
337
|
+
"aria-expanded": open,
|
|
338
|
+
onClick: () => {
|
|
339
|
+
const next = !open;
|
|
340
|
+
setOpen(next);
|
|
341
|
+
if (next) createLink();
|
|
342
|
+
}
|
|
343
|
+
}, /* @__PURE__ */ react.default.createElement("svg", {
|
|
344
|
+
"aria-hidden": "true",
|
|
345
|
+
width: wide ? 16 : 18,
|
|
346
|
+
height: wide ? 16 : 18,
|
|
347
|
+
viewBox: "0 0 24 24",
|
|
348
|
+
fill: "none",
|
|
349
|
+
stroke: "currentColor",
|
|
350
|
+
strokeWidth: "1.8"
|
|
351
|
+
}, /* @__PURE__ */ react.default.createElement("rect", {
|
|
352
|
+
x: "5",
|
|
353
|
+
y: "2.5",
|
|
354
|
+
width: "14",
|
|
355
|
+
height: "19",
|
|
356
|
+
rx: "2.5"
|
|
357
|
+
}), /* @__PURE__ */ react.default.createElement("path", { d: "M9 5.5h6M11 18.5h2" })), wide && /* @__PURE__ */ react.default.createElement("span", { className: "dsh-local-link-trigger__label" }, t("footer.trigger"))), open && /* @__PURE__ */ react.default.createElement("section", {
|
|
358
|
+
className: "dsh-local-link-popover",
|
|
359
|
+
ref: popover,
|
|
360
|
+
style: popoverPosition ?? { visibility: "hidden" },
|
|
361
|
+
"aria-label": t("connect.title")
|
|
362
|
+
}, /* @__PURE__ */ react.default.createElement("div", { className: "dsh-local-link-popover__header" }, /* @__PURE__ */ react.default.createElement("strong", null, t("connect.title")), /* @__PURE__ */ react.default.createElement("button", {
|
|
363
|
+
className: "dsh-local-link-popover__manage",
|
|
364
|
+
type: "button",
|
|
365
|
+
onClick: () => {
|
|
366
|
+
setOpen(false);
|
|
367
|
+
openSettingsSection(t("nav"));
|
|
368
|
+
}
|
|
369
|
+
}, t("connect.pairedDevices"))), /* @__PURE__ */ react.default.createElement("p", null, t("connect.description")), !pairing && !error && /* @__PURE__ */ react.default.createElement("p", null, t("connect.creating")), error && /* @__PURE__ */ react.default.createElement("p", { className: "dsh-local-link-popover__error" }, t("connect.error")), pairing && /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("img", {
|
|
370
|
+
className: `dsh-local-link-popover__qr${remaining === 0 ? " dsh-local-link-popover__qr--expired" : ""}`,
|
|
371
|
+
src: pairing.qrDataUrl,
|
|
372
|
+
alt: t("connect.qrAlt")
|
|
373
|
+
}), /* @__PURE__ */ react.default.createElement("div", {
|
|
374
|
+
className: "dsh-local-link-popover__link",
|
|
375
|
+
"aria-label": t("connect.linkLabel")
|
|
376
|
+
}, /* @__PURE__ */ react.default.createElement("code", {
|
|
377
|
+
className: "dsh-local-link-popover__link-value",
|
|
378
|
+
title: pairing.url
|
|
379
|
+
}, pairing.url), /* @__PURE__ */ react.default.createElement("button", {
|
|
380
|
+
className: `dsh-local-link-popover__copy${copyState === "copied" ? " dsh-local-link-popover__copy--copied" : ""}`,
|
|
381
|
+
disabled: remaining === 0,
|
|
382
|
+
type: "button",
|
|
383
|
+
onClick: () => void copyLink()
|
|
384
|
+
}, copyState === "copied" ? t("connect.copied") : t("connect.copy"))), copyState === "error" && /* @__PURE__ */ react.default.createElement("p", { className: "dsh-local-link-popover__error" }, t("connect.copyError")), /* @__PURE__ */ react.default.createElement("div", { className: "dsh-local-link-popover__meta" }, /* @__PURE__ */ react.default.createElement("span", null, t("connect.oneDevice")), /* @__PURE__ */ react.default.createElement("span", null, remaining === 0 ? t("connect.expired") : `${t("connect.expiresIn")} ${formatCountdown(remaining)}`)), /* @__PURE__ */ react.default.createElement("button", {
|
|
385
|
+
className: "dsh-local-link-popover__regenerate",
|
|
386
|
+
type: "button",
|
|
387
|
+
onClick: () => void createLink()
|
|
388
|
+
}, t("connect.regenerate")))));
|
|
389
|
+
}
|
|
390
|
+
function LocalLinkSettings({ t }) {
|
|
391
|
+
const [status, setStatus] = (0, react.useState)();
|
|
392
|
+
const [diagnostics, setDiagnostics] = (0, react.useState)();
|
|
393
|
+
const [busyId, setBusyId] = (0, react.useState)();
|
|
394
|
+
const [editingId, setEditingId] = (0, react.useState)();
|
|
395
|
+
const [draftName, setDraftName] = (0, react.useState)("");
|
|
396
|
+
const [error, setError] = (0, react.useState)(false);
|
|
397
|
+
const [diagnosticsError, setDiagnosticsError] = (0, react.useState)(false);
|
|
398
|
+
const [diagnosticsBusy, setDiagnosticsBusy] = (0, react.useState)(false);
|
|
399
|
+
const [reportState, setReportState] = (0, react.useState)("idle");
|
|
400
|
+
const loadDevices = (0, react.useCallback)(async () => {
|
|
401
|
+
try {
|
|
402
|
+
const payload = await jsonRequest("/__dsh-local-link/admin/devices");
|
|
403
|
+
setStatus({ devices: normalizeDevices(payload) });
|
|
404
|
+
setError(false);
|
|
405
|
+
} catch {
|
|
406
|
+
setError(true);
|
|
407
|
+
}
|
|
408
|
+
}, []);
|
|
409
|
+
const loadDiagnostics = (0, react.useCallback)(async () => {
|
|
410
|
+
try {
|
|
411
|
+
const payload = await jsonRequest("/__dsh-local-link/admin/diagnostics");
|
|
412
|
+
setDiagnostics(normalizeDiagnostics(payload));
|
|
413
|
+
setDiagnosticsError(false);
|
|
414
|
+
} catch {
|
|
415
|
+
setDiagnosticsError(true);
|
|
416
|
+
}
|
|
417
|
+
}, []);
|
|
418
|
+
(0, react.useEffect)(() => {
|
|
419
|
+
loadDevices();
|
|
420
|
+
loadDiagnostics();
|
|
421
|
+
}, [loadDevices, loadDiagnostics]);
|
|
422
|
+
const revoke = async (id) => {
|
|
423
|
+
setBusyId(id);
|
|
424
|
+
try {
|
|
425
|
+
await jsonRequest("/__dsh-local-link/admin/revoke", {
|
|
426
|
+
method: "POST",
|
|
427
|
+
body: JSON.stringify({ id })
|
|
428
|
+
});
|
|
429
|
+
await loadDevices();
|
|
430
|
+
} catch {
|
|
431
|
+
setError(true);
|
|
432
|
+
reportActionError("DEVICE_REVOKE_FAILED");
|
|
433
|
+
} finally {
|
|
434
|
+
setBusyId(void 0);
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
const rename = async (id) => {
|
|
438
|
+
setBusyId(id);
|
|
439
|
+
try {
|
|
440
|
+
await jsonRequest("/__dsh-local-link/admin/rename", {
|
|
441
|
+
method: "POST",
|
|
442
|
+
body: JSON.stringify({
|
|
443
|
+
id,
|
|
444
|
+
name: draftName
|
|
445
|
+
})
|
|
446
|
+
});
|
|
447
|
+
setEditingId(void 0);
|
|
448
|
+
await loadDevices();
|
|
449
|
+
} catch {
|
|
450
|
+
setError(true);
|
|
451
|
+
reportActionError("DEVICE_RENAME_FAILED");
|
|
452
|
+
} finally {
|
|
453
|
+
setBusyId(void 0);
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
const copyDiagnostics = async () => {
|
|
457
|
+
try {
|
|
458
|
+
await navigator.clipboard.writeText(JSON.stringify({
|
|
459
|
+
schemaVersion: 1,
|
|
460
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
461
|
+
events: diagnostics ?? []
|
|
462
|
+
}, null, 2));
|
|
463
|
+
setReportState("copied");
|
|
464
|
+
} catch {
|
|
465
|
+
setReportState("error");
|
|
466
|
+
}
|
|
467
|
+
};
|
|
468
|
+
const clearDiagnostics = async () => {
|
|
469
|
+
if (!window.confirm(t("diagnostics.clearConfirm"))) return;
|
|
470
|
+
setDiagnosticsBusy(true);
|
|
471
|
+
try {
|
|
472
|
+
await jsonRequest("/__dsh-local-link/admin/diagnostics/clear", {
|
|
473
|
+
method: "POST",
|
|
474
|
+
body: "{}"
|
|
475
|
+
});
|
|
476
|
+
setDiagnostics([]);
|
|
477
|
+
setDiagnosticsError(false);
|
|
478
|
+
setReportState("idle");
|
|
479
|
+
} catch {
|
|
480
|
+
setDiagnosticsError(true);
|
|
481
|
+
} finally {
|
|
482
|
+
setDiagnosticsBusy(false);
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
return /* @__PURE__ */ react.default.createElement("section", { className: "dsh-local-link" }, /* @__PURE__ */ react.default.createElement("h2", null, t("devices.title")), /* @__PURE__ */ react.default.createElement("p", null, t("devices.description")), /* @__PURE__ */ react.default.createElement("div", {
|
|
486
|
+
className: "dsh-local-link__devices",
|
|
487
|
+
role: "list"
|
|
488
|
+
}, error ? /* @__PURE__ */ react.default.createElement("p", null, t("devices.error")) : status === void 0 ? /* @__PURE__ */ react.default.createElement("p", null, t("devices.loading")) : status.devices.length ? status.devices.map((device) => /* @__PURE__ */ react.default.createElement("div", {
|
|
489
|
+
className: "dsh-local-link__device",
|
|
490
|
+
key: device.id,
|
|
491
|
+
role: "listitem"
|
|
492
|
+
}, editingId === device.id ? /* @__PURE__ */ react.default.createElement("div", { className: "dsh-local-link__device-editor" }, /* @__PURE__ */ react.default.createElement("input", {
|
|
493
|
+
autoFocus: true,
|
|
494
|
+
"aria-label": t("devices.nameLabel"),
|
|
495
|
+
maxLength: 64,
|
|
496
|
+
value: draftName,
|
|
497
|
+
onChange: (event) => setDraftName(event.target.value),
|
|
498
|
+
onKeyDown: (event) => {
|
|
499
|
+
if (event.key === "Enter") rename(device.id);
|
|
500
|
+
if (event.key === "Escape") setEditingId(void 0);
|
|
501
|
+
}
|
|
502
|
+
}), /* @__PURE__ */ react.default.createElement("button", {
|
|
503
|
+
disabled: busyId !== void 0,
|
|
504
|
+
type: "button",
|
|
505
|
+
onClick: () => void rename(device.id)
|
|
506
|
+
}, busyId === device.id ? t("devices.saving") : t("devices.save")), /* @__PURE__ */ react.default.createElement("button", {
|
|
507
|
+
disabled: busyId !== void 0,
|
|
508
|
+
type: "button",
|
|
509
|
+
onClick: () => setEditingId(void 0)
|
|
510
|
+
}, t("devices.cancel"))) : /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", { className: "dsh-local-link__device-info" }, /* @__PURE__ */ react.default.createElement("strong", null, device.name), /* @__PURE__ */ react.default.createElement("small", null, device.deviceType, " · ", device.browser)), /* @__PURE__ */ react.default.createElement("div", { className: "dsh-local-link__device-actions" }, /* @__PURE__ */ react.default.createElement("button", {
|
|
511
|
+
disabled: busyId !== void 0,
|
|
512
|
+
type: "button",
|
|
513
|
+
onClick: () => {
|
|
514
|
+
setEditingId(device.id);
|
|
515
|
+
setDraftName(device.name);
|
|
516
|
+
}
|
|
517
|
+
}, t("devices.rename")), /* @__PURE__ */ react.default.createElement("button", {
|
|
518
|
+
disabled: busyId !== void 0,
|
|
519
|
+
type: "button",
|
|
520
|
+
onClick: () => void revoke(device.id)
|
|
521
|
+
}, busyId === device.id ? t("devices.revoking") : t("devices.revoke")))))) : /* @__PURE__ */ react.default.createElement("p", null, t("devices.empty"))), /* @__PURE__ */ react.default.createElement("details", { className: "dsh-local-link__diagnostics" }, /* @__PURE__ */ react.default.createElement("summary", null, /* @__PURE__ */ react.default.createElement("span", { className: "dsh-local-link__diagnostics-summary-main" }, /* @__PURE__ */ react.default.createElement("span", {
|
|
522
|
+
className: "dsh-local-link__diagnostics-icon",
|
|
523
|
+
"aria-hidden": "true"
|
|
524
|
+
}, /* @__PURE__ */ react.default.createElement("svg", {
|
|
525
|
+
width: "18",
|
|
526
|
+
height: "18",
|
|
527
|
+
viewBox: "0 0 24 24",
|
|
528
|
+
fill: "none",
|
|
529
|
+
stroke: "currentColor",
|
|
530
|
+
strokeWidth: "1.8",
|
|
531
|
+
strokeLinecap: "round",
|
|
532
|
+
strokeLinejoin: "round"
|
|
533
|
+
}, /* @__PURE__ */ react.default.createElement("path", { d: "M3 12h4l2.2-6 4.2 12 2.1-6H21" }))), /* @__PURE__ */ react.default.createElement("span", { className: "dsh-local-link__diagnostics-copy" }, /* @__PURE__ */ react.default.createElement("strong", null, t("diagnostics.title")), /* @__PURE__ */ react.default.createElement("small", null, t("diagnostics.subtitle")))), /* @__PURE__ */ react.default.createElement("span", { className: "dsh-local-link__diagnostics-summary-meta" }, /* @__PURE__ */ react.default.createElement("span", { className: "dsh-local-link__diagnostics-badge" }, diagnosticsError ? t("diagnostics.unavailable") : diagnostics === void 0 ? t("diagnostics.loading") : `${diagnostics.length} ${t("diagnostics.events")}`), /* @__PURE__ */ react.default.createElement("svg", {
|
|
534
|
+
className: "dsh-local-link__diagnostics-chevron",
|
|
535
|
+
"aria-hidden": "true",
|
|
536
|
+
width: "16",
|
|
537
|
+
height: "16",
|
|
538
|
+
viewBox: "0 0 24 24",
|
|
539
|
+
fill: "none",
|
|
540
|
+
stroke: "currentColor",
|
|
541
|
+
strokeWidth: "2",
|
|
542
|
+
strokeLinecap: "round",
|
|
543
|
+
strokeLinejoin: "round"
|
|
544
|
+
}, /* @__PURE__ */ react.default.createElement("path", { d: "m6 9 6 6 6-6" })))), /* @__PURE__ */ react.default.createElement("div", { className: "dsh-local-link__diagnostics-body" }, /* @__PURE__ */ react.default.createElement("p", null, t("diagnostics.description")), /* @__PURE__ */ react.default.createElement("div", { className: "dsh-local-link__diagnostics-actions" }, /* @__PURE__ */ react.default.createElement("button", {
|
|
545
|
+
disabled: diagnosticsBusy,
|
|
546
|
+
type: "button",
|
|
547
|
+
onClick: () => void loadDiagnostics()
|
|
548
|
+
}, t("diagnostics.refresh")), /* @__PURE__ */ react.default.createElement("button", {
|
|
549
|
+
disabled: diagnosticsBusy || diagnostics === void 0,
|
|
550
|
+
type: "button",
|
|
551
|
+
onClick: () => void copyDiagnostics()
|
|
552
|
+
}, reportState === "copied" ? t("diagnostics.copied") : t("diagnostics.copy")), /* @__PURE__ */ react.default.createElement("button", {
|
|
553
|
+
disabled: diagnosticsBusy || diagnostics === void 0 || diagnostics.length === 0,
|
|
554
|
+
type: "button",
|
|
555
|
+
onClick: () => void clearDiagnostics()
|
|
556
|
+
}, diagnosticsBusy ? t("diagnostics.clearing") : t("diagnostics.clear"))), reportState === "error" && /* @__PURE__ */ react.default.createElement("p", null, t("diagnostics.copyError")), diagnosticsError ? /* @__PURE__ */ react.default.createElement("p", null, t("diagnostics.error")) : diagnostics === void 0 ? /* @__PURE__ */ react.default.createElement("p", null, t("diagnostics.loading")) : diagnostics.length === 0 ? /* @__PURE__ */ react.default.createElement("p", null, t("diagnostics.empty")) : /* @__PURE__ */ react.default.createElement("div", {
|
|
557
|
+
className: "dsh-local-link__diagnostic-list",
|
|
558
|
+
role: "list"
|
|
559
|
+
}, diagnostics.slice(0, 12).map((event) => /* @__PURE__ */ react.default.createElement("div", {
|
|
560
|
+
className: "dsh-local-link__diagnostic",
|
|
561
|
+
key: event.id,
|
|
562
|
+
role: "listitem"
|
|
563
|
+
}, /* @__PURE__ */ react.default.createElement("span", {
|
|
564
|
+
className: `dsh-local-link__diagnostic-level dsh-local-link__diagnostic-level--${event.level}`,
|
|
565
|
+
title: event.level
|
|
566
|
+
}), /* @__PURE__ */ react.default.createElement("code", null, event.code), /* @__PURE__ */ react.default.createElement("time", { dateTime: event.at }, new Date(event.at).toLocaleTimeString()), event.context !== void 0 && /* @__PURE__ */ react.default.createElement("span", {
|
|
567
|
+
className: "dsh-local-link__diagnostic-context",
|
|
568
|
+
title: JSON.stringify(event.context)
|
|
569
|
+
}, Object.entries(event.context).map(([key, value]) => `${key}=${String(value)}`).join(" · "))))))));
|
|
570
|
+
}
|
|
571
|
+
const inject = [
|
|
572
|
+
"connection",
|
|
573
|
+
"slots",
|
|
574
|
+
"locale",
|
|
575
|
+
"sessions"
|
|
576
|
+
];
|
|
577
|
+
function apply(ctx) {
|
|
578
|
+
ctx.effect(() => ctx.locale.register(NS, {
|
|
579
|
+
en: en_default,
|
|
580
|
+
zh: zh_default
|
|
581
|
+
}), "dsh-local-link: locale dictionaries");
|
|
582
|
+
ctx.effect(() => {
|
|
583
|
+
if (window.__DSH_LOCAL_LINK_AUTHENTICATED__ !== true) return () => void 0;
|
|
584
|
+
const connection = ctx.get("connection");
|
|
585
|
+
const previous = connection.isLoopback;
|
|
586
|
+
connection.isLoopback = true;
|
|
587
|
+
return () => {
|
|
588
|
+
connection.isLoopback = previous;
|
|
589
|
+
};
|
|
590
|
+
}, "dsh-local-link: paired gateway trust hint");
|
|
591
|
+
ctx.effect(() => {
|
|
592
|
+
const style = document.createElement("style");
|
|
593
|
+
style.dataset.plugin = "dsh-local-link";
|
|
594
|
+
style.textContent = styles;
|
|
595
|
+
document.head.append(style);
|
|
596
|
+
return () => style.remove();
|
|
597
|
+
}, "dsh-local-link: interface styles");
|
|
598
|
+
ctx.effect(() => {
|
|
599
|
+
const getCurrentSessionId = () => ctx.sessions.list.getSnapshot().current;
|
|
600
|
+
const Footer = (props) => /* @__PURE__ */ react.default.createElement(LocalLinkFooter, {
|
|
601
|
+
...props,
|
|
602
|
+
getCurrentSessionId
|
|
603
|
+
});
|
|
604
|
+
return ctx.slots.inject("sidebar.footer.action", () => ctx.slots.register({
|
|
605
|
+
name: "sidebar.footer.action",
|
|
606
|
+
id: "local-link-connect",
|
|
607
|
+
order: -10,
|
|
608
|
+
locale: NS
|
|
609
|
+
}, Footer));
|
|
610
|
+
}, "dsh-local-link: sidebar connection action");
|
|
611
|
+
ctx.effect(() => {
|
|
612
|
+
if (!desktopOrigin()) return () => void 0;
|
|
613
|
+
return ctx.slots.inject("settings.section", () => ctx.slots.register({
|
|
614
|
+
name: "settings.section",
|
|
615
|
+
id: "local-access-devices",
|
|
616
|
+
order: 12,
|
|
617
|
+
label: () => ctx.locale.bind(NS)("nav"),
|
|
618
|
+
locale: NS
|
|
619
|
+
}, LocalLinkSettings));
|
|
620
|
+
}, "dsh-local-link: paired devices settings");
|
|
621
|
+
}
|
|
622
|
+
//#endregion
|
|
623
|
+
exports.apply = apply;
|
|
624
|
+
exports.inject = inject;
|
|
625
|
+
return module.exports;
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
//# sourceMappingURL=client.js.map
|