@tianacloud/dsh-remote 0.0.0-stage → 0.2.1
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/LICENSE +204 -0
- package/README.md +44 -2
- package/cli.js +347 -0
- package/client.js +1501 -0
- package/cordis.patch.yml +3 -0
- package/host-main.js +628 -0
- package/icon.svg +7 -0
- package/locale/en-US.json +9 -0
- package/locale/zh-CN.json +9 -0
- package/package.json +89 -4
- package/relay-go/go.mod +3 -0
- package/relay-go/main.go +1711 -0
- package/scripts/build-web-dist.mjs +46 -0
- package/src/clipboard.js +94 -0
- package/src/connect.js +599 -0
- package/src/dsh-packages.js +46 -0
- package/src/frontend-assets.js +405 -0
- package/src/host-bridge.js +1412 -0
- package/src/local-transport.js +496 -0
- package/src/protocol.js +124 -0
- package/src/remote-api.js +433 -0
- package/src/state.js +379 -0
- package/src/tiana-cli.js +929 -0
- package/web-src/dsh-remote-entry.mjs +2692 -0
- package/web-src/dsh-remote-sw.js +593 -0
- package/web-src/e2ee.js +460 -0
- package/web-src/frontend-loader.js +450 -0
- package/web-src/multipath.js +375 -0
- package/web-src/peer-path.js +265 -0
- package/web-src/shell-ui.js +280 -0
- package/web-src/ws-fragments.js +46 -0
package/client.js
ADDED
|
@@ -0,0 +1,1501 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client sidebar panel for `@tianacloud/dsh-remote`.
|
|
3
|
+
*
|
|
4
|
+
* Adapts automatically between:
|
|
5
|
+
* - Local Host Mode (`!isRemote`): full management dashboard backed by local-only
|
|
6
|
+
* `/api/tiana-remote/admin/*` endpoints (unbound bind/create onboarding with live
|
|
7
|
+
* provision-status logs, status hero card + real ISO/IEC 18004 scannable QR code,
|
|
8
|
+
* masked E2EE key with reveal/copy/rotate, active sessions + Function token expiry
|
|
9
|
+
* & manual renew, rebind cloud app, P2P/STUN/plugin allowlist with draft protection).
|
|
10
|
+
* - Remote Tunnel Mode (`isRemote`): restricted session status & device controls
|
|
11
|
+
* backed by `globalThis.__DSH_REMOTE_SHELL__` and redacted `/api/tiana-remote/public-status`
|
|
12
|
+
* (zero pairing keys, zero admin controls).
|
|
13
|
+
*/
|
|
14
|
+
(function registerDshRemoteClient() {
|
|
15
|
+
// ---- Zero-dependency ISO/IEC 18004 QR Code Encoder (Byte Mode, EC Level M, Versions 1..10) ----
|
|
16
|
+
const QR_GF_EXP = new Uint8Array(512);
|
|
17
|
+
const QR_GF_LOG = new Uint8Array(256);
|
|
18
|
+
(function initQrGalois() {
|
|
19
|
+
let x = 1;
|
|
20
|
+
for (let i = 0; i < 255; i += 1) {
|
|
21
|
+
QR_GF_EXP[i] = x;
|
|
22
|
+
QR_GF_LOG[x] = i;
|
|
23
|
+
x <<= 1;
|
|
24
|
+
if (x & 0x100) x ^= 0x11d;
|
|
25
|
+
}
|
|
26
|
+
for (let i = 255; i < 512; i += 1) {
|
|
27
|
+
QR_GF_EXP[i] = QR_GF_EXP[i - 255];
|
|
28
|
+
}
|
|
29
|
+
})();
|
|
30
|
+
|
|
31
|
+
function qrGfMul(a, b) {
|
|
32
|
+
if (a === 0 || b === 0) return 0;
|
|
33
|
+
return QR_GF_EXP[QR_GF_LOG[a] + QR_GF_LOG[b]];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function qrRsGeneratorPoly(degree) {
|
|
37
|
+
let poly = [1];
|
|
38
|
+
for (let i = 0; i < degree; i += 1) {
|
|
39
|
+
const next = new Array(poly.length + 1).fill(0);
|
|
40
|
+
const factor = QR_GF_EXP[i];
|
|
41
|
+
for (let j = 0; j < poly.length; j += 1) {
|
|
42
|
+
next[j] ^= poly[j];
|
|
43
|
+
next[j + 1] ^= qrGfMul(poly[j], factor);
|
|
44
|
+
}
|
|
45
|
+
poly = next;
|
|
46
|
+
}
|
|
47
|
+
return poly;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function qrRsComputeEc(data, ecCount) {
|
|
51
|
+
const gen = qrRsGeneratorPoly(ecCount);
|
|
52
|
+
const rem = new Uint8Array(ecCount);
|
|
53
|
+
for (let i = 0; i < data.length; i += 1) {
|
|
54
|
+
const factor = data[i] ^ rem[0];
|
|
55
|
+
for (let j = 0; j < ecCount - 1; j += 1) {
|
|
56
|
+
rem[j] = rem[j + 1] ^ qrGfMul(gen[j + 1], factor);
|
|
57
|
+
}
|
|
58
|
+
rem[ecCount - 1] = qrGfMul(gen[ecCount], factor);
|
|
59
|
+
}
|
|
60
|
+
return rem;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// ISO/IEC 18004 Table 9 specs for Error Correction Level M (Versions 1..10, max 213 UTF-8 bytes)
|
|
64
|
+
const QR_VERSION_SPECS_M = [
|
|
65
|
+
null,
|
|
66
|
+
{ ver: 1, totalData: 16, ecPerBlock: 10, g1Blocks: 1, g1Data: 16, g2Blocks: 0, g2Data: 0, align: [] },
|
|
67
|
+
{ ver: 2, totalData: 28, ecPerBlock: 16, g1Blocks: 1, g1Data: 28, g2Blocks: 0, g2Data: 0, align: [6, 18] },
|
|
68
|
+
{ ver: 3, totalData: 44, ecPerBlock: 26, g1Blocks: 1, g1Data: 44, g2Blocks: 0, g2Data: 0, align: [6, 22] },
|
|
69
|
+
{ ver: 4, totalData: 64, ecPerBlock: 18, g1Blocks: 2, g1Data: 32, g2Blocks: 0, g2Data: 0, align: [6, 26] },
|
|
70
|
+
{ ver: 5, totalData: 86, ecPerBlock: 24, g1Blocks: 2, g1Data: 43, g2Blocks: 0, g2Data: 0, align: [6, 30] },
|
|
71
|
+
{ ver: 6, totalData: 108, ecPerBlock: 16, g1Blocks: 4, g1Data: 27, g2Blocks: 0, g2Data: 0, align: [6, 34] },
|
|
72
|
+
{ ver: 7, totalData: 124, ecPerBlock: 18, g1Blocks: 4, g1Data: 31, g2Blocks: 0, g2Data: 0, align: [6, 22, 38] },
|
|
73
|
+
{ ver: 8, totalData: 154, ecPerBlock: 22, g1Blocks: 2, g1Data: 38, g2Blocks: 2, g2Data: 39, align: [6, 24, 42] },
|
|
74
|
+
{ ver: 9, totalData: 182, ecPerBlock: 22, g1Blocks: 3, g1Data: 36, g2Blocks: 2, g2Data: 37, align: [6, 26, 46] },
|
|
75
|
+
{ ver: 10, totalData: 216, ecPerBlock: 26, g1Blocks: 4, g1Data: 43, g2Blocks: 1, g2Data: 44, align: [6, 28, 50] },
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
function qrFormatBitsM(maskPattern) {
|
|
79
|
+
// EC Level M = 0b00
|
|
80
|
+
const data = maskPattern & 0x07;
|
|
81
|
+
let rem = data << 10;
|
|
82
|
+
for (let i = 4; i >= 0; i -= 1) {
|
|
83
|
+
if (rem & (1 << (i + 10))) {
|
|
84
|
+
rem ^= 0x537 << i;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return ((data << 10) | rem) ^ 0x5412;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function qrVersionBits(version) {
|
|
91
|
+
let rem = version << 12;
|
|
92
|
+
for (let i = 5; i >= 0; i -= 1) {
|
|
93
|
+
if (rem & (1 << (i + 12))) {
|
|
94
|
+
rem ^= 0x1f25 << i;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return (version << 12) | rem;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function qrMaskPredicate(mask, r, c) {
|
|
101
|
+
switch (mask) {
|
|
102
|
+
case 0: return (r + c) % 2 === 0;
|
|
103
|
+
case 1: return r % 2 === 0;
|
|
104
|
+
case 2: return c % 3 === 0;
|
|
105
|
+
case 3: return (r + c) % 3 === 0;
|
|
106
|
+
case 4: return (Math.floor(r / 2) + Math.floor(c / 3)) % 2 === 0;
|
|
107
|
+
case 5: return ((r * c) % 2) + ((r * c) % 3) === 0;
|
|
108
|
+
case 6: return (((r * c) % 2) + ((r * c) % 3)) % 2 === 0;
|
|
109
|
+
case 7: return (((r + c) % 2) + ((r * c) % 3)) % 2 === 0;
|
|
110
|
+
default: return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function qrPenaltyScore(matrix) {
|
|
115
|
+
const n = matrix.length;
|
|
116
|
+
let score = 0;
|
|
117
|
+
|
|
118
|
+
// Rule 1: 5+ consecutive same-color modules in row or column
|
|
119
|
+
for (let r = 0; r < n; r += 1) {
|
|
120
|
+
let runLen = 1;
|
|
121
|
+
for (let c = 1; c < n; c += 1) {
|
|
122
|
+
if (matrix[r][c] === matrix[r][c - 1]) {
|
|
123
|
+
runLen += 1;
|
|
124
|
+
} else {
|
|
125
|
+
if (runLen >= 5) score += 3 + (runLen - 5);
|
|
126
|
+
runLen = 1;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (runLen >= 5) score += 3 + (runLen - 5);
|
|
130
|
+
}
|
|
131
|
+
for (let c = 0; c < n; c += 1) {
|
|
132
|
+
let runLen = 1;
|
|
133
|
+
for (let r = 1; r < n; r += 1) {
|
|
134
|
+
if (matrix[r][c] === matrix[r - 1][c]) {
|
|
135
|
+
runLen += 1;
|
|
136
|
+
} else {
|
|
137
|
+
if (runLen >= 5) score += 3 + (runLen - 5);
|
|
138
|
+
runLen = 1;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (runLen >= 5) score += 3 + (runLen - 5);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Rule 2: 2x2 blocks of same color
|
|
145
|
+
for (let r = 0; r < n - 1; r += 1) {
|
|
146
|
+
for (let c = 0; c < n - 1; c += 1) {
|
|
147
|
+
const v = matrix[r][c];
|
|
148
|
+
if (v === matrix[r][c + 1] && v === matrix[r + 1][c] && v === matrix[r + 1][c + 1]) {
|
|
149
|
+
score += 3;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Rule 3: finder-like 1:1:3:1:1 with 4 light modules on either side
|
|
155
|
+
const matchFinderLike = (arr) => {
|
|
156
|
+
let hits = 0;
|
|
157
|
+
for (let i = 0; i <= arr.length - 11; i += 1) {
|
|
158
|
+
const p1 = arr[i] && !arr[i + 1] && arr[i + 2] && arr[i + 3] && arr[i + 4] && !arr[i + 5] && arr[i + 6] &&
|
|
159
|
+
!arr[i + 7] && !arr[i + 8] && !arr[i + 9] && !arr[i + 10];
|
|
160
|
+
const p2 = !arr[i] && !arr[i + 1] && !arr[i + 2] && !arr[i + 3] && arr[i + 4] && !arr[i + 5] && arr[i + 6] &&
|
|
161
|
+
arr[i + 7] && arr[i + 8] && !arr[i + 9] && arr[i + 10];
|
|
162
|
+
if (p1 || p2) hits += 40;
|
|
163
|
+
}
|
|
164
|
+
return hits;
|
|
165
|
+
};
|
|
166
|
+
for (let r = 0; r < n; r += 1) {
|
|
167
|
+
score += matchFinderLike(matrix[r]);
|
|
168
|
+
}
|
|
169
|
+
const colBuf = new Array(n);
|
|
170
|
+
for (let c = 0; c < n; c += 1) {
|
|
171
|
+
for (let r = 0; r < n; r += 1) colBuf[r] = matrix[r][c];
|
|
172
|
+
score += matchFinderLike(colBuf);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Rule 4: dark/light balance
|
|
176
|
+
let dark = 0;
|
|
177
|
+
for (let r = 0; r < n; r += 1) {
|
|
178
|
+
for (let c = 0; c < n; c += 1) {
|
|
179
|
+
if (matrix[r][c]) dark += 1;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const pct = (dark * 100) / (n * n);
|
|
183
|
+
const k = Math.floor(Math.abs(pct - 50) / 5);
|
|
184
|
+
score += k * 10;
|
|
185
|
+
return score;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function encodeQrMatrix(text) {
|
|
189
|
+
const bytes = new TextEncoder().encode(String(text || ''));
|
|
190
|
+
let spec = null;
|
|
191
|
+
for (let v = 1; v < QR_VERSION_SPECS_M.length; v += 1) {
|
|
192
|
+
const candidate = QR_VERSION_SPECS_M[v];
|
|
193
|
+
const countBits = v <= 9 ? 8 : 16;
|
|
194
|
+
const neededBits = 4 + countBits + bytes.length * 8;
|
|
195
|
+
if (neededBits <= candidate.totalData * 8) {
|
|
196
|
+
spec = candidate;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (!spec) {
|
|
201
|
+
throw new Error(`QR payload too long (${bytes.length} bytes, max 213)`);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// 1. Encode Byte-mode bitstream + terminator + padding
|
|
205
|
+
const bits = [];
|
|
206
|
+
const pushBits = (val, len) => {
|
|
207
|
+
for (let i = len - 1; i >= 0; i -= 1) {
|
|
208
|
+
bits.push((val >>> i) & 1);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
pushBits(0b0100, 4); // Byte mode
|
|
212
|
+
pushBits(bytes.length, spec.ver <= 9 ? 8 : 16);
|
|
213
|
+
for (let i = 0; i < bytes.length; i += 1) {
|
|
214
|
+
pushBits(bytes[i], 8);
|
|
215
|
+
}
|
|
216
|
+
const totalDataBits = spec.totalData * 8;
|
|
217
|
+
const terminator = Math.min(4, totalDataBits - bits.length);
|
|
218
|
+
for (let i = 0; i < terminator; i += 1) bits.push(0);
|
|
219
|
+
while (bits.length % 8 !== 0) bits.push(0);
|
|
220
|
+
|
|
221
|
+
const dataCodewords = new Uint8Array(spec.totalData);
|
|
222
|
+
let cwIdx = 0;
|
|
223
|
+
for (let i = 0; i < bits.length; i += 8) {
|
|
224
|
+
let b = 0;
|
|
225
|
+
for (let j = 0; j < 8; j += 1) b = (b << 1) | bits[i + j];
|
|
226
|
+
dataCodewords[cwIdx++] = b;
|
|
227
|
+
}
|
|
228
|
+
let padToggle = 0;
|
|
229
|
+
while (cwIdx < spec.totalData) {
|
|
230
|
+
dataCodewords[cwIdx++] = padToggle === 0 ? 0xec : 0x11;
|
|
231
|
+
padToggle ^= 1;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// 2. Split into RS blocks & compute EC codewords
|
|
235
|
+
const dataBlocks = [];
|
|
236
|
+
const ecBlocks = [];
|
|
237
|
+
let offset = 0;
|
|
238
|
+
for (let i = 0; i < spec.g1Blocks; i += 1) {
|
|
239
|
+
const blk = dataCodewords.subarray(offset, offset + spec.g1Data);
|
|
240
|
+
offset += spec.g1Data;
|
|
241
|
+
dataBlocks.push(blk);
|
|
242
|
+
ecBlocks.push(qrRsComputeEc(blk, spec.ecPerBlock));
|
|
243
|
+
}
|
|
244
|
+
for (let i = 0; i < spec.g2Blocks; i += 1) {
|
|
245
|
+
const blk = dataCodewords.subarray(offset, offset + spec.g2Data);
|
|
246
|
+
offset += spec.g2Data;
|
|
247
|
+
dataBlocks.push(blk);
|
|
248
|
+
ecBlocks.push(qrRsComputeEc(blk, spec.ecPerBlock));
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// 3. Interleave data & EC codewords
|
|
252
|
+
const finalBytes = [];
|
|
253
|
+
const maxDataLen = Math.max(spec.g1Data, spec.g2Data);
|
|
254
|
+
for (let i = 0; i < maxDataLen; i += 1) {
|
|
255
|
+
for (let b = 0; b < dataBlocks.length; b += 1) {
|
|
256
|
+
if (i < dataBlocks[b].length) finalBytes.push(dataBlocks[b][i]);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
for (let i = 0; i < spec.ecPerBlock; i += 1) {
|
|
260
|
+
for (let b = 0; b < ecBlocks.length; b += 1) {
|
|
261
|
+
finalBytes.push(ecBlocks[b][i]);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// 4. Construct base matrix with function patterns
|
|
266
|
+
const size = spec.ver * 4 + 17;
|
|
267
|
+
const base = Array.from({ length: size }, () => Array(size).fill(false));
|
|
268
|
+
const isFunc = Array.from({ length: size }, () => Array(size).fill(false));
|
|
269
|
+
const setFunc = (r, c, dark) => {
|
|
270
|
+
if (r < 0 || r >= size || c < 0 || c >= size) return;
|
|
271
|
+
base[r][c] = dark;
|
|
272
|
+
isFunc[r][c] = true;
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
// Finder patterns + separators
|
|
276
|
+
const drawFinder = (r0, c0) => {
|
|
277
|
+
for (let dr = -1; dr <= 7; dr += 1) {
|
|
278
|
+
for (let dc = -1; dc <= 7; dc += 1) {
|
|
279
|
+
const r = r0 + dr;
|
|
280
|
+
const c = c0 + dc;
|
|
281
|
+
if (r < 0 || r >= size || c < 0 || c >= size) continue;
|
|
282
|
+
const inBox = dr >= 0 && dr <= 6 && dc >= 0 && dc <= 6;
|
|
283
|
+
const border = dr === 0 || dr === 6 || dc === 0 || dc === 6;
|
|
284
|
+
const core = dr >= 2 && dr <= 4 && dc >= 2 && dc <= 4;
|
|
285
|
+
setFunc(r, c, inBox && (border || core));
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
drawFinder(0, 0);
|
|
290
|
+
drawFinder(0, size - 7);
|
|
291
|
+
drawFinder(size - 7, 0);
|
|
292
|
+
|
|
293
|
+
// Alignment patterns
|
|
294
|
+
const centers = spec.align;
|
|
295
|
+
for (let i = 0; i < centers.length; i += 1) {
|
|
296
|
+
for (let j = 0; j < centers.length; j += 1) {
|
|
297
|
+
const cr = centers[i];
|
|
298
|
+
const cc = centers[j];
|
|
299
|
+
if (isFunc[cr][cc]) continue;
|
|
300
|
+
for (let dr = -2; dr <= 2; dr += 1) {
|
|
301
|
+
for (let dc = -2; dc <= 2; dc += 1) {
|
|
302
|
+
const dark = Math.max(Math.abs(dr), Math.abs(dc)) !== 1;
|
|
303
|
+
setFunc(cr + dr, cc + dc, dark);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// Timing patterns
|
|
310
|
+
for (let i = 8; i < size - 8; i += 1) {
|
|
311
|
+
if (!isFunc[6][i]) setFunc(6, i, i % 2 === 0);
|
|
312
|
+
if (!isFunc[i][6]) setFunc(i, 6, i % 2 === 0);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Reserve format info areas & dark module
|
|
316
|
+
const drawFormatInfo = (mat, maskPattern) => {
|
|
317
|
+
const fmt = qrFormatBitsM(maskPattern);
|
|
318
|
+
// Copy 1
|
|
319
|
+
for (let i = 0; i <= 5; i += 1) mat[8][i] = Boolean((fmt >>> (14 - i)) & 1);
|
|
320
|
+
mat[8][7] = Boolean((fmt >>> 8) & 1);
|
|
321
|
+
mat[8][8] = Boolean((fmt >>> 7) & 1);
|
|
322
|
+
mat[7][8] = Boolean((fmt >>> 6) & 1);
|
|
323
|
+
for (let i = 0; i <= 5; i += 1) mat[5 - i][8] = Boolean((fmt >>> (5 - i)) & 1);
|
|
324
|
+
// Copy 2
|
|
325
|
+
for (let i = 0; i <= 6; i += 1) mat[size - 1 - i][8] = Boolean((fmt >>> (14 - i)) & 1);
|
|
326
|
+
for (let i = 0; i <= 7; i += 1) mat[8][size - 8 + i] = Boolean((fmt >>> (7 - i)) & 1);
|
|
327
|
+
mat[size - 8][8] = true; // fixed dark module
|
|
328
|
+
};
|
|
329
|
+
for (let i = 0; i <= 8; i += 1) {
|
|
330
|
+
if (!isFunc[8][i]) isFunc[8][i] = true;
|
|
331
|
+
if (!isFunc[i][8]) isFunc[i][8] = true;
|
|
332
|
+
}
|
|
333
|
+
for (let i = 0; i < 8; i += 1) {
|
|
334
|
+
isFunc[8][size - 1 - i] = true;
|
|
335
|
+
isFunc[size - 1 - i][8] = true;
|
|
336
|
+
}
|
|
337
|
+
setFunc(size - 8, 8, true);
|
|
338
|
+
|
|
339
|
+
// Version info for V7+
|
|
340
|
+
if (spec.ver >= 7) {
|
|
341
|
+
const vBits = qrVersionBits(spec.ver);
|
|
342
|
+
for (let i = 0; i < 18; i += 1) {
|
|
343
|
+
const dark = Boolean((vBits >>> i) & 1);
|
|
344
|
+
const a = Math.floor(i / 3);
|
|
345
|
+
const b = size - 11 + (i % 3);
|
|
346
|
+
setFunc(b, a, dark);
|
|
347
|
+
setFunc(a, b, dark);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// 5. Place data bits in standard zig-zag order
|
|
352
|
+
const allBits = [];
|
|
353
|
+
for (let i = 0; i < finalBytes.length; i += 1) {
|
|
354
|
+
const byte = finalBytes[i];
|
|
355
|
+
for (let b = 7; b >= 0; b -= 1) allBits.push(Boolean((byte >>> b) & 1));
|
|
356
|
+
}
|
|
357
|
+
let bitIdx = 0;
|
|
358
|
+
let upward = true;
|
|
359
|
+
for (let right = size - 1; right >= 1; right -= 2) {
|
|
360
|
+
if (right === 6) right = 5; // skip vertical timing column
|
|
361
|
+
for (let step = 0; step < size; step += 1) {
|
|
362
|
+
const r = upward ? size - 1 - step : step;
|
|
363
|
+
for (let dx = 0; dx < 2; dx += 1) {
|
|
364
|
+
const c = right - dx;
|
|
365
|
+
if (!isFunc[r][c]) {
|
|
366
|
+
base[r][c] = bitIdx < allBits.length ? allBits[bitIdx++] : false;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
upward = !upward;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// 6. Evaluate all 8 mask patterns & choose lowest penalty
|
|
374
|
+
let bestMatrix = null;
|
|
375
|
+
let bestScore = Infinity;
|
|
376
|
+
let bestMask = 0;
|
|
377
|
+
for (let mask = 0; mask < 8; mask += 1) {
|
|
378
|
+
const candidate = base.map((row, r) =>
|
|
379
|
+
row.map((val, c) => (isFunc[r][c] ? val : (qrMaskPredicate(mask, r, c) ? !val : val))),
|
|
380
|
+
);
|
|
381
|
+
drawFormatInfo(candidate, mask);
|
|
382
|
+
const score = qrPenaltyScore(candidate);
|
|
383
|
+
if (score < bestScore) {
|
|
384
|
+
bestScore = score;
|
|
385
|
+
bestMatrix = candidate;
|
|
386
|
+
bestMask = mask;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
return { version: spec.ver, size, mask: bestMask, ecLevel: 'M', matrix: bestMatrix };
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function factory(require) {
|
|
394
|
+
const React = require('react');
|
|
395
|
+
const h = React.createElement;
|
|
396
|
+
const { useEffect, useRef, useState, useCallback } = React;
|
|
397
|
+
|
|
398
|
+
const NS = 'tiana-remote';
|
|
399
|
+
const PANEL_ID = 'tiana-remote';
|
|
400
|
+
|
|
401
|
+
const zh = {
|
|
402
|
+
panel: 'Tiana Remote',
|
|
403
|
+
title: 'Tiana Remote',
|
|
404
|
+
subtitleLocal: '零公网 IP 端到端加密远程访问管理',
|
|
405
|
+
subtitleRemote: '当前正在通过端到端加密隧道访问远程主机',
|
|
406
|
+
statusOnline: '在线运行中',
|
|
407
|
+
statusPaused: '已暂停监听',
|
|
408
|
+
statusUnconfigured: '尚未绑定',
|
|
409
|
+
statusReconnecting: '正在重连 Relay…',
|
|
410
|
+
toggleLabel: '启用远程访问',
|
|
411
|
+
remoteUrl: '托管访问地址',
|
|
412
|
+
copy: '复制',
|
|
413
|
+
copied: '已复制',
|
|
414
|
+
open: '打开',
|
|
415
|
+
qrCode: '扫码打开',
|
|
416
|
+
qrTitle: '扫码访问远程工作台',
|
|
417
|
+
qrHint: '使用手机或平板相机扫描此标准二维码(二维码不含密钥,打开后粘贴配对密钥解锁)。',
|
|
418
|
+
close: '关闭',
|
|
419
|
+
cancel: '取消',
|
|
420
|
+
e2eeTitle: '端到端加密配对密钥(E2EE)',
|
|
421
|
+
e2eeFingerprint: '密钥指纹',
|
|
422
|
+
revealKey: '显示密钥',
|
|
423
|
+
hideKey: '隐藏密钥',
|
|
424
|
+
copyKey: '复制配对密钥',
|
|
425
|
+
rotateKey: '轮换密钥',
|
|
426
|
+
rotateConfirmTitle: '确认轮换端到端配对密钥?',
|
|
427
|
+
rotateConfirmBody: '轮换后,所有已连接的远端浏览器会话将被立即断开(4001 key_rotated),需要使用新密钥重新解锁。',
|
|
428
|
+
rotateConfirmBtn: '确认轮换',
|
|
429
|
+
sessionsTitle: '活跃远端会话与实例凭据',
|
|
430
|
+
sessionsEmpty: '当前没有活跃的远端浏览器会话',
|
|
431
|
+
disconnect: '断开',
|
|
432
|
+
disconnectAll: '断开全部',
|
|
433
|
+
settingsTitle: '主机、换绑与网络插件策略',
|
|
434
|
+
hostName: '主机显示名',
|
|
435
|
+
p2pToggle: '启用 WebRTC P2P 直连优先',
|
|
436
|
+
stunUrls: 'STUN 服务器(逗号分隔)',
|
|
437
|
+
allowedPlugins: '远端放行的第三方 Web 插件(未勾选时仅放行内置核心与 Tiana Remote)',
|
|
438
|
+
saveSettings: '保存设置',
|
|
439
|
+
resetDraft: '放弃未保存更改',
|
|
440
|
+
saving: '保存中…',
|
|
441
|
+
saved: '已保存',
|
|
442
|
+
repairBtn: '重推静态壳层修复',
|
|
443
|
+
repairing: '正在修复重推…',
|
|
444
|
+
repaired: '静态壳层已重新同步',
|
|
445
|
+
tokenExpiry: 'Function 实例 Token 到期',
|
|
446
|
+
tokenRenewing: '续期中…',
|
|
447
|
+
tokenRenewed: '实例 Token 已续期(30 天有效)',
|
|
448
|
+
renewToken: '立即续期',
|
|
449
|
+
remoteChannel: '当前连接通道',
|
|
450
|
+
remoteP2p: 'WebRTC P2P 直连',
|
|
451
|
+
remoteRelay: 'Tiana Relay 加密中继',
|
|
452
|
+
remoteReconnecting: '正在重连…',
|
|
453
|
+
remoteRtt: '往返延迟 (RTT)',
|
|
454
|
+
remoteSecurityNote: '安全边界说明:当前处于远端隧道受限视图。配对密钥查看/轮换与主机管理接口仅限本机回环访问,远端隧道严格返回 403 拦截。',
|
|
455
|
+
clearCacheBtn: '刷新前端模块缓存',
|
|
456
|
+
lockForgetBtn: '锁定并清除此设备密钥',
|
|
457
|
+
onboardTitle: '绑定或新建云端 DSH Remote 应用',
|
|
458
|
+
onboardBindTab: '绑定已有 Tiana 应用',
|
|
459
|
+
onboardCreateTab: '在当前空间新建 DSH Remote 应用',
|
|
460
|
+
webIdLabel: 'Tiana Web 应用 ID(12 位,如 abc123456789)',
|
|
461
|
+
webNameLabel: '新建应用名称',
|
|
462
|
+
rebindForceLabel: '若该应用已绑定其他电脑,强制换绑到本机',
|
|
463
|
+
bindSubmitBtn: '立即免编译绑定',
|
|
464
|
+
createSubmitBtn: '立即创建并配置',
|
|
465
|
+
rebindSectionTitle: '切换/换绑云端应用',
|
|
466
|
+
rebindBtn: '切换并换绑应用',
|
|
467
|
+
provisionRunning: '正在执行配置任务…',
|
|
468
|
+
provisionDone: '配置已完成',
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
const en = {
|
|
472
|
+
panel: 'Tiana Remote',
|
|
473
|
+
title: 'Tiana Remote',
|
|
474
|
+
subtitleLocal: 'End-to-end encrypted remote access for this DSH host',
|
|
475
|
+
subtitleRemote: 'Connected to your local DSH host via E2EE tunnel',
|
|
476
|
+
statusOnline: 'Online',
|
|
477
|
+
statusPaused: 'Paused',
|
|
478
|
+
statusUnconfigured: 'Not configured',
|
|
479
|
+
statusReconnecting: 'Reconnecting…',
|
|
480
|
+
toggleLabel: 'Enable Remote Access',
|
|
481
|
+
remoteUrl: 'Hosted Remote URL',
|
|
482
|
+
copy: 'Copy',
|
|
483
|
+
copied: 'Copied',
|
|
484
|
+
open: 'Open',
|
|
485
|
+
qrCode: 'QR Code',
|
|
486
|
+
qrTitle: 'Open via QR Code',
|
|
487
|
+
qrHint: 'Scan this standard QR code with your phone camera (pairing key is never embedded in the URL).',
|
|
488
|
+
close: 'Close',
|
|
489
|
+
cancel: 'Cancel',
|
|
490
|
+
e2eeTitle: 'End-to-End Pairing Key (E2EE)',
|
|
491
|
+
e2eeFingerprint: 'Key Fingerprint',
|
|
492
|
+
revealKey: 'Reveal',
|
|
493
|
+
hideKey: 'Hide',
|
|
494
|
+
copyKey: 'Copy Pairing Key',
|
|
495
|
+
rotateKey: 'Rotate Key',
|
|
496
|
+
rotateConfirmTitle: 'Rotate E2EE pairing key?',
|
|
497
|
+
rotateConfirmBody: 'All active remote sessions will be immediately disconnected (4001 key_rotated) and must unlock with the new key.',
|
|
498
|
+
rotateConfirmBtn: 'Confirm Rotate',
|
|
499
|
+
sessionsTitle: 'Active Remote Sessions & Instance Token',
|
|
500
|
+
sessionsEmpty: 'No active remote sessions',
|
|
501
|
+
disconnect: 'Disconnect',
|
|
502
|
+
disconnectAll: 'Disconnect All',
|
|
503
|
+
settingsTitle: 'Host, Rebind & Network Policy',
|
|
504
|
+
hostName: 'Host Display Name',
|
|
505
|
+
p2pToggle: 'Prefer WebRTC P2P Direct Connection',
|
|
506
|
+
stunUrls: 'STUN Servers (comma-separated)',
|
|
507
|
+
allowedPlugins: 'Allowed Third-Party Web Plugins (unchecked = core + Tiana Remote only)',
|
|
508
|
+
saveSettings: 'Save Settings',
|
|
509
|
+
resetDraft: 'Discard Unsaved Edits',
|
|
510
|
+
saving: 'Saving…',
|
|
511
|
+
saved: 'Saved',
|
|
512
|
+
repairBtn: 'Repair / Republish Static Shell',
|
|
513
|
+
repairing: 'Republishing…',
|
|
514
|
+
repaired: 'Static shell synchronized',
|
|
515
|
+
tokenExpiry: 'Function Token Expiry',
|
|
516
|
+
tokenRenewing: 'Renewing…',
|
|
517
|
+
tokenRenewed: 'Function token renewed (30 days)',
|
|
518
|
+
renewToken: 'Renew Now',
|
|
519
|
+
remoteChannel: 'Active Transport Channel',
|
|
520
|
+
remoteP2p: 'WebRTC P2P Direct',
|
|
521
|
+
remoteRelay: 'Tiana Encrypted Relay',
|
|
522
|
+
remoteReconnecting: 'Reconnecting…',
|
|
523
|
+
remoteRtt: 'Round-Trip Latency (RTT)',
|
|
524
|
+
remoteSecurityNote: 'Security Isolation: You are viewing the restricted remote session panel. Pairing keys and host admin APIs are strictly blocked (403) over the remote tunnel.',
|
|
525
|
+
clearCacheBtn: 'Refresh Frontend Module Cache',
|
|
526
|
+
lockForgetBtn: 'Lock & Forget Key on This Device',
|
|
527
|
+
onboardTitle: 'Bind or Create a Tiana DSH Remote App',
|
|
528
|
+
onboardBindTab: 'Bind Existing Tiana App',
|
|
529
|
+
onboardCreateTab: 'Create New DSH Remote App',
|
|
530
|
+
webIdLabel: 'Tiana Web App ID (12 chars, e.g. abc123456789)',
|
|
531
|
+
webNameLabel: 'New Web App Name',
|
|
532
|
+
rebindForceLabel: 'Force rebind to this machine if bound to another host',
|
|
533
|
+
bindSubmitBtn: 'Bind Now (Zero Recompile)',
|
|
534
|
+
createSubmitBtn: 'Create & Provision',
|
|
535
|
+
rebindSectionTitle: 'Switch / Rebind Cloud App',
|
|
536
|
+
rebindBtn: 'Switch & Rebind App',
|
|
537
|
+
provisionRunning: 'Provisioning in progress…',
|
|
538
|
+
provisionDone: 'Provisioning completed',
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
const STYLES = `
|
|
542
|
+
.dshr-root {
|
|
543
|
+
box-sizing: border-box;
|
|
544
|
+
height: 100%;
|
|
545
|
+
overflow: auto;
|
|
546
|
+
padding: 24px;
|
|
547
|
+
color: var(--dsw-alias-label-primary, #e5edf9);
|
|
548
|
+
background: var(--dsw-alias-bg-layer-1, transparent);
|
|
549
|
+
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
550
|
+
}
|
|
551
|
+
.dshr-wrap { max-width: 880px; margin: 0 auto; display: grid; gap: 16px; }
|
|
552
|
+
.dshr-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
|
|
553
|
+
.dshr-title { margin: 0; font-size: 20px; font-weight: 600; color: var(--dsw-alias-label-primary, inherit); }
|
|
554
|
+
.dshr-sub { margin: 4px 0 0; font-size: 13px; color: var(--dsw-alias-label-secondary, #94a3b8); }
|
|
555
|
+
.dshr-card {
|
|
556
|
+
background: var(--dsw-alias-bg-layer-2, rgba(30, 41, 59, 0.55));
|
|
557
|
+
border: 1px solid var(--dsw-alias-border-l1, rgba(148, 163, 184, 0.22));
|
|
558
|
+
border-radius: 12px;
|
|
559
|
+
padding: 18px 20px;
|
|
560
|
+
display: grid;
|
|
561
|
+
gap: 14px;
|
|
562
|
+
}
|
|
563
|
+
.dshr-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
|
|
564
|
+
.dshr-card-title { margin: 0; font-size: 15px; font-weight: 600; }
|
|
565
|
+
.dshr-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
|
|
566
|
+
.dshr-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
|
|
567
|
+
.dshr-tab {
|
|
568
|
+
padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer;
|
|
569
|
+
border: 1px solid var(--dsw-alias-border-l1, rgba(148, 163, 184, 0.3));
|
|
570
|
+
background: transparent; color: var(--dsw-alias-label-secondary, #94a3b8);
|
|
571
|
+
}
|
|
572
|
+
.dshr-tab[aria-selected="true"] {
|
|
573
|
+
background: var(--dsw-alias-brand-primary, #2563eb); border-color: transparent; color: #fff;
|
|
574
|
+
}
|
|
575
|
+
.dshr-badge {
|
|
576
|
+
display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
|
|
577
|
+
font-size: 12px; font-weight: 500;
|
|
578
|
+
background: var(--dsw-alias-bg-layer-3, rgba(15, 23, 42, 0.6));
|
|
579
|
+
border: 1px solid var(--dsw-alias-border-l1, rgba(148, 163, 184, 0.25));
|
|
580
|
+
}
|
|
581
|
+
.dshr-dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
|
|
582
|
+
.dshr-dot.is-online { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25); }
|
|
583
|
+
.dshr-dot.is-warn { background: #f59e0b; }
|
|
584
|
+
.dshr-mono {
|
|
585
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
586
|
+
font-size: 13px; padding: 8px 12px; border-radius: 8px; flex: 1; min-width: 200px;
|
|
587
|
+
background: var(--dsw-alias-bg-layer-1, rgba(15, 23, 42, 0.7));
|
|
588
|
+
border: 1px solid var(--dsw-alias-border-l1, rgba(148, 163, 184, 0.25));
|
|
589
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
590
|
+
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
591
|
+
}
|
|
592
|
+
.dshr-logs {
|
|
593
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
594
|
+
font-size: 12px; line-height: 1.5; padding: 10px 12px; border-radius: 8px;
|
|
595
|
+
max-height: 160px; overflow: auto; white-space: pre-wrap; margin: 0;
|
|
596
|
+
background: var(--dsw-alias-bg-layer-1, rgba(15, 23, 42, 0.75));
|
|
597
|
+
border: 1px solid var(--dsw-alias-border-l1, rgba(148, 163, 184, 0.25));
|
|
598
|
+
}
|
|
599
|
+
.dshr-btn {
|
|
600
|
+
display: inline-flex; align-items: center; justify-content: center; gap: 6px;
|
|
601
|
+
padding: 7px 13px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer;
|
|
602
|
+
border: 1px solid var(--dsw-alias-border-l1, rgba(148, 163, 184, 0.3));
|
|
603
|
+
background: var(--dsw-alias-bg-layer-3, rgba(30, 41, 59, 0.9));
|
|
604
|
+
color: var(--dsw-alias-label-primary, #f8fafc);
|
|
605
|
+
}
|
|
606
|
+
.dshr-btn:hover:not(:disabled) { filter: brightness(1.08); }
|
|
607
|
+
.dshr-btn:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
608
|
+
.dshr-btn-primary {
|
|
609
|
+
background: var(--dsw-alias-brand-primary, #2563eb); border-color: transparent; color: #fff;
|
|
610
|
+
}
|
|
611
|
+
.dshr-btn-danger {
|
|
612
|
+
background: rgba(220, 38, 38, 0.16); border-color: rgba(248, 113, 113, 0.45); color: #f87171;
|
|
613
|
+
}
|
|
614
|
+
.dshr-input {
|
|
615
|
+
box-sizing: border-box; width: 100%; padding: 8px 12px; border-radius: 8px; font-size: 13px;
|
|
616
|
+
border: 1px solid var(--dsw-alias-border-l1, rgba(148, 163, 184, 0.3));
|
|
617
|
+
background: var(--dsw-alias-bg-layer-1, rgba(15, 23, 42, 0.7));
|
|
618
|
+
color: var(--dsw-alias-label-primary, inherit);
|
|
619
|
+
}
|
|
620
|
+
.dshr-field { display: grid; gap: 6px; font-size: 13px; }
|
|
621
|
+
.dshr-label { color: var(--dsw-alias-label-secondary, #94a3b8); font-size: 12px; }
|
|
622
|
+
.dshr-session-item {
|
|
623
|
+
display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
|
|
624
|
+
padding: 10px 12px; border-radius: 8px;
|
|
625
|
+
background: var(--dsw-alias-bg-layer-1, rgba(15, 23, 42, 0.45));
|
|
626
|
+
border: 1px solid var(--dsw-alias-border-l1, rgba(148, 163, 184, 0.18));
|
|
627
|
+
}
|
|
628
|
+
.dshr-divider { height: 1px; background: var(--dsw-alias-border-l1, rgba(148, 163, 184, 0.18)); }
|
|
629
|
+
.dshr-notice {
|
|
630
|
+
padding: 12px 14px; border-radius: 10px; font-size: 13px; line-height: 1.5;
|
|
631
|
+
background: rgba(59, 130, 246, 0.12); border: 1px solid rgba(96, 165, 250, 0.35);
|
|
632
|
+
}
|
|
633
|
+
.dshr-err {
|
|
634
|
+
padding: 10px 12px; border-radius: 8px; font-size: 13px; line-height: 1.45;
|
|
635
|
+
background: rgba(220, 38, 38, 0.14); border: 1px solid rgba(248, 113, 113, 0.45); color: #f87171;
|
|
636
|
+
}
|
|
637
|
+
.dshr-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; font-weight: 500; }
|
|
638
|
+
dialog.dshr-dialog {
|
|
639
|
+
padding: 20px 22px; border-radius: 14px; max-width: 420px; width: calc(100vw - 32px);
|
|
640
|
+
background: var(--dsw-alias-bg-layer-2, #1e293b);
|
|
641
|
+
color: var(--dsw-alias-label-primary, #f8fafc);
|
|
642
|
+
border: 1px solid var(--dsw-alias-border-l1, rgba(148, 163, 184, 0.3));
|
|
643
|
+
box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
|
|
644
|
+
}
|
|
645
|
+
dialog.dshr-dialog:modal { overscroll-behavior: contain; }
|
|
646
|
+
dialog.dshr-dialog::backdrop {
|
|
647
|
+
background: rgba(2, 6, 23, 0.65);
|
|
648
|
+
overflow: hidden;
|
|
649
|
+
overscroll-behavior: contain;
|
|
650
|
+
}
|
|
651
|
+
`;
|
|
652
|
+
|
|
653
|
+
function ensureStyleTag() {
|
|
654
|
+
if (typeof document === 'undefined') return;
|
|
655
|
+
if (document.getElementById('dsh-remote-panel-styles')) return;
|
|
656
|
+
const el = document.createElement('style');
|
|
657
|
+
el.id = 'dsh-remote-panel-styles';
|
|
658
|
+
el.textContent = STYLES;
|
|
659
|
+
document.head.appendChild(el);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* Render a genuine ISO/IEC 18004 scannable QR Code SVG (quiet zone = 4 modules, EC Level M).
|
|
664
|
+
*/
|
|
665
|
+
function buildQrSvgData(text) {
|
|
666
|
+
const qr = encodeQrMatrix(text);
|
|
667
|
+
const quiet = 4;
|
|
668
|
+
const total = qr.size + quiet * 2;
|
|
669
|
+
const parts = [];
|
|
670
|
+
for (let r = 0; r < qr.size; r += 1) {
|
|
671
|
+
for (let c = 0; c < qr.size; c += 1) {
|
|
672
|
+
if (qr.matrix[r][c]) {
|
|
673
|
+
parts.push(`M${c + quiet},${r + quiet}h1v1h-1z`);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
return h('svg', {
|
|
678
|
+
viewBox: `0 0 ${total} ${total}`,
|
|
679
|
+
width: 220,
|
|
680
|
+
height: 220,
|
|
681
|
+
shapeRendering: 'crispEdges',
|
|
682
|
+
role: 'img',
|
|
683
|
+
'aria-label': text,
|
|
684
|
+
'data-qr-version': String(qr.version),
|
|
685
|
+
'data-qr-size': String(qr.size),
|
|
686
|
+
'data-qr-ec': qr.ecLevel,
|
|
687
|
+
style: { background: '#ffffff', borderRadius: 10, display: 'block', margin: '0 auto' },
|
|
688
|
+
},
|
|
689
|
+
h('rect', { x: 0, y: 0, width: total, height: total, fill: '#ffffff' }),
|
|
690
|
+
h('path', { d: parts.join(''), fill: '#000000' }),
|
|
691
|
+
);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
function RemoteIcon() {
|
|
695
|
+
return h('svg', {
|
|
696
|
+
width: 18, height: 18, viewBox: '0 0 24 24', fill: 'none',
|
|
697
|
+
stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round',
|
|
698
|
+
},
|
|
699
|
+
h('path', { d: 'M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z' }),
|
|
700
|
+
h('path', { d: 'M12 13v4' }),
|
|
701
|
+
h('circle', { cx: 12, cy: 11, r: 1 }),
|
|
702
|
+
);
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
function formatDuration(ms) {
|
|
706
|
+
const sec = Math.max(0, Math.floor((ms || 0) / 1000));
|
|
707
|
+
if (sec < 60) return `${sec}s`;
|
|
708
|
+
const min = Math.floor(sec / 60);
|
|
709
|
+
if (min < 60) return `${min}m ${sec % 60}s`;
|
|
710
|
+
return `${Math.floor(min / 60)}h ${min % 60}m`;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
function formatTokenExpiry(expiresAtSec, isZh) {
|
|
714
|
+
if (!expiresAtSec || !Number.isFinite(expiresAtSec)) return '—';
|
|
715
|
+
const remainingSec = Math.floor(expiresAtSec - Date.now() / 1000);
|
|
716
|
+
if (remainingSec <= 0) {
|
|
717
|
+
return isZh ? '已过期(请立即续期)' : 'Expired (renew now)';
|
|
718
|
+
}
|
|
719
|
+
const days = Math.ceil(remainingSec / 86400);
|
|
720
|
+
return isZh
|
|
721
|
+
? `剩余 ${days} 天(到期前 7 天自动续期)`
|
|
722
|
+
: `${days}d remaining (auto-renews < 7d)`;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
function pickStrings(locale) {
|
|
726
|
+
const isZh = typeof locale === 'string'
|
|
727
|
+
? locale.toLowerCase().startsWith('zh')
|
|
728
|
+
: (typeof navigator !== 'undefined' && String(navigator.language || '').toLowerCase().startsWith('zh'));
|
|
729
|
+
return { strings: isZh ? zh : en, isZh };
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
function TianaRemotePanel({ t: boundT, forceMode } = {}) {
|
|
733
|
+
ensureStyleTag();
|
|
734
|
+
const { strings, isZh } = pickStrings();
|
|
735
|
+
const t = (key) => (typeof boundT === 'function' ? boundT(key) : strings[key] || key);
|
|
736
|
+
const isRemote = forceMode
|
|
737
|
+
? forceMode === 'remote'
|
|
738
|
+
: Boolean(globalThis.__DSH_REMOTE_SHELL__?.isRemote || globalThis.__DSH_TRANSPORT__?.ownsHost);
|
|
739
|
+
|
|
740
|
+
const [overview, setOverview] = useState(null);
|
|
741
|
+
const [publicStatus, setPublicStatus] = useState(null);
|
|
742
|
+
const [shellSnap, setShellSnap] = useState(() => globalThis.__DSH_REMOTE_SHELL__?.getStatusSnapshot?.() || null);
|
|
743
|
+
const [revealedKey, setRevealedKey] = useState('');
|
|
744
|
+
const [copiedTag, setCopiedTag] = useState('');
|
|
745
|
+
const [busy, setBusy] = useState('');
|
|
746
|
+
const [toast, setToast] = useState('');
|
|
747
|
+
|
|
748
|
+
// Draft fields protected from 4s background poll overwrite while dirty
|
|
749
|
+
const [hostNameDraft, setHostNameDraft] = useState('');
|
|
750
|
+
const [p2pDraft, setP2pDraft] = useState(true);
|
|
751
|
+
const [stunDraft, setStunDraft] = useState('');
|
|
752
|
+
const [pluginsDraft, setPluginsDraft] = useState([]);
|
|
753
|
+
const settingsDirtyRef = useRef(false);
|
|
754
|
+
const [settingsDirty, setSettingsDirty] = useState(false);
|
|
755
|
+
|
|
756
|
+
// Provision / Onboarding / Rebind state
|
|
757
|
+
const [onboardTab, setOnboardTab] = useState('bind');
|
|
758
|
+
const [bindWebId, setBindWebId] = useState('');
|
|
759
|
+
const [bindHostName, setBindHostName] = useState('');
|
|
760
|
+
const [bindForceRebind, setBindForceRebind] = useState(false);
|
|
761
|
+
const [createWebName, setCreateWebName] = useState('DSH Remote');
|
|
762
|
+
const [rebindWebId, setRebindWebId] = useState('');
|
|
763
|
+
const [provisionStatus, setProvisionStatus] = useState(null);
|
|
764
|
+
|
|
765
|
+
const rotateDialogRef = useRef(null);
|
|
766
|
+
const qrDialogRef = useRef(null);
|
|
767
|
+
|
|
768
|
+
const hydrateDraftsFromOverview = useCallback((data) => {
|
|
769
|
+
if (!data) return;
|
|
770
|
+
setHostNameDraft(data.host?.hostName || '');
|
|
771
|
+
setP2pDraft(data.network?.p2pEnabled !== false);
|
|
772
|
+
setStunDraft((data.network?.stunUrls || []).join(','));
|
|
773
|
+
setPluginsDraft(Array.isArray(data.allowedWebPlugins) ? data.allowedWebPlugins : []);
|
|
774
|
+
}, []);
|
|
775
|
+
|
|
776
|
+
const markDirty = () => {
|
|
777
|
+
settingsDirtyRef.current = true;
|
|
778
|
+
setSettingsDirty(true);
|
|
779
|
+
};
|
|
780
|
+
|
|
781
|
+
const fetchState = useCallback(async () => {
|
|
782
|
+
try {
|
|
783
|
+
if (isRemote) {
|
|
784
|
+
const resp = await fetch('/api/tiana-remote/public-status', { cache: 'no-store' });
|
|
785
|
+
if (resp.ok) setPublicStatus(await resp.json());
|
|
786
|
+
const snap = globalThis.__DSH_REMOTE_SHELL__?.getStatusSnapshot?.();
|
|
787
|
+
if (snap) setShellSnap(snap);
|
|
788
|
+
} else {
|
|
789
|
+
const resp = await fetch('/api/tiana-remote/admin/overview', { cache: 'no-store' });
|
|
790
|
+
if (resp.ok) {
|
|
791
|
+
const data = await resp.json();
|
|
792
|
+
setOverview(data);
|
|
793
|
+
// NEVER overwrite user's in-progress form edits during background polling
|
|
794
|
+
if (!settingsDirtyRef.current) {
|
|
795
|
+
hydrateDraftsFromOverview(data);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
} catch {
|
|
800
|
+
// ignore transient poll errors
|
|
801
|
+
}
|
|
802
|
+
}, [isRemote, hydrateDraftsFromOverview]);
|
|
803
|
+
|
|
804
|
+
const pollProvisionStatus = useCallback(async () => {
|
|
805
|
+
if (isRemote) return;
|
|
806
|
+
try {
|
|
807
|
+
const resp = await fetch('/api/tiana-remote/admin/provision-status', { cache: 'no-store' });
|
|
808
|
+
if (resp.ok) {
|
|
809
|
+
const st = await resp.json();
|
|
810
|
+
setProvisionStatus(st);
|
|
811
|
+
if (!st.running && st.step === 'done') {
|
|
812
|
+
await fetchState();
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
} catch {
|
|
816
|
+
// ignore
|
|
817
|
+
}
|
|
818
|
+
}, [isRemote, fetchState]);
|
|
819
|
+
|
|
820
|
+
useEffect(() => {
|
|
821
|
+
void fetchState();
|
|
822
|
+
const timer = setInterval(() => void fetchState(), 4000);
|
|
823
|
+
let unsub = null;
|
|
824
|
+
if (isRemote && typeof globalThis.__DSH_REMOTE_SHELL__?.subscribe === 'function') {
|
|
825
|
+
unsub = globalThis.__DSH_REMOTE_SHELL__.subscribe((snap) => setShellSnap(snap));
|
|
826
|
+
}
|
|
827
|
+
return () => {
|
|
828
|
+
clearInterval(timer);
|
|
829
|
+
if (typeof unsub === 'function') unsub();
|
|
830
|
+
};
|
|
831
|
+
}, [fetchState, isRemote]);
|
|
832
|
+
|
|
833
|
+
useEffect(() => {
|
|
834
|
+
if (!provisionStatus?.running) return undefined;
|
|
835
|
+
const timer = setInterval(() => void pollProvisionStatus(), 1000);
|
|
836
|
+
return () => clearInterval(timer);
|
|
837
|
+
}, [provisionStatus?.running, pollProvisionStatus]);
|
|
838
|
+
|
|
839
|
+
const copyText = async (tag, value) => {
|
|
840
|
+
try {
|
|
841
|
+
await navigator.clipboard.writeText(value);
|
|
842
|
+
setCopiedTag(tag);
|
|
843
|
+
setTimeout(() => setCopiedTag(''), 1800);
|
|
844
|
+
} catch {
|
|
845
|
+
setToast('Clipboard write unavailable');
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
|
|
849
|
+
// ---- Remote Restricted Session View ----
|
|
850
|
+
if (isRemote) {
|
|
851
|
+
const mode = shellSnap?.transportState || shellSnap?.transport || 'Relay';
|
|
852
|
+
const isP2p = String(mode).toLowerCase() === 'p2p';
|
|
853
|
+
const isReconnecting = String(mode).toLowerCase().includes('reconnect') || String(mode).includes('重连');
|
|
854
|
+
const rttText = typeof shellSnap?.rttMs === 'number' ? `${shellSnap.rttMs} ms` : '—';
|
|
855
|
+
const hostName = shellSnap?.hostName || publicStatus?.hostName || publicStatus?.hostId || 'Local DSH';
|
|
856
|
+
const fingerprint = shellSnap?.fingerprint || publicStatus?.e2eeFingerprint || '—';
|
|
857
|
+
|
|
858
|
+
return h('div', { className: 'dshr-root', 'data-dshr-mode': 'remote' },
|
|
859
|
+
h('div', { className: 'dshr-wrap' },
|
|
860
|
+
h('div', { className: 'dshr-header' },
|
|
861
|
+
h('div', null,
|
|
862
|
+
h('h2', { className: 'dshr-title' }, t('title')),
|
|
863
|
+
h('p', { className: 'dshr-sub' }, t('subtitleRemote')),
|
|
864
|
+
),
|
|
865
|
+
h('span', { className: 'dshr-badge' },
|
|
866
|
+
h('span', { className: `dshr-dot ${isReconnecting ? 'is-warn' : 'is-online'}` }),
|
|
867
|
+
isReconnecting ? t('remoteReconnecting') : (isP2p ? t('remoteP2p') : t('remoteRelay')),
|
|
868
|
+
),
|
|
869
|
+
),
|
|
870
|
+
h('div', { className: 'dshr-card' },
|
|
871
|
+
h('div', { className: 'dshr-card-head' },
|
|
872
|
+
h('h3', { className: 'dshr-card-title' }, `${t('remoteChannel')} · ${hostName}`),
|
|
873
|
+
h('span', { className: 'dshr-label' }, `${t('remoteRtt')}: ${rttText}`),
|
|
874
|
+
),
|
|
875
|
+
h('div', { className: 'dshr-row' },
|
|
876
|
+
h('span', { className: 'dshr-badge' }, `${t('e2eeFingerprint')}: ${fingerprint}`),
|
|
877
|
+
h('span', { className: 'dshr-badge' }, isP2p ? t('remoteP2p') : t('remoteRelay')),
|
|
878
|
+
),
|
|
879
|
+
h('div', { className: 'dshr-notice' }, t('remoteSecurityNote')),
|
|
880
|
+
h('div', { className: 'dshr-row' },
|
|
881
|
+
h('button', {
|
|
882
|
+
type: 'button',
|
|
883
|
+
className: 'dshr-btn',
|
|
884
|
+
id: 'dshr-remote-clear-cache',
|
|
885
|
+
onClick: () => void globalThis.__DSH_REMOTE_SHELL__?.clearFrontendCache?.(),
|
|
886
|
+
}, t('clearCacheBtn')),
|
|
887
|
+
h('button', {
|
|
888
|
+
type: 'button',
|
|
889
|
+
className: 'dshr-btn dshr-btn-danger',
|
|
890
|
+
id: 'dshr-remote-lock-forget',
|
|
891
|
+
onClick: () => void globalThis.__DSH_REMOTE_SHELL__?.lockAndForget?.(),
|
|
892
|
+
}, t('lockForgetBtn')),
|
|
893
|
+
),
|
|
894
|
+
),
|
|
895
|
+
),
|
|
896
|
+
);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
// ---- Local Host Full Management View ----
|
|
900
|
+
const configured = Boolean(overview?.configured);
|
|
901
|
+
const enabled = Boolean(overview?.enabled);
|
|
902
|
+
const relayConnected = Boolean(overview?.bridge?.relayConnected);
|
|
903
|
+
const sessions = overview?.bridge?.sessions || [];
|
|
904
|
+
const endpoint = overview?.web?.endpoint || '';
|
|
905
|
+
const installedPlugins = overview?.installedWebPlugins || [];
|
|
906
|
+
const tokenExpiresAt = overview?.function?.expiresAt;
|
|
907
|
+
|
|
908
|
+
const startProvisionRequest = async (payload) => {
|
|
909
|
+
setBusy('provision');
|
|
910
|
+
try {
|
|
911
|
+
const resp = await fetch('/api/tiana-remote/admin/provision', {
|
|
912
|
+
method: 'POST',
|
|
913
|
+
headers: { 'content-type': 'application/json' },
|
|
914
|
+
body: JSON.stringify(payload),
|
|
915
|
+
});
|
|
916
|
+
const data = await resp.json().catch(() => ({}));
|
|
917
|
+
if (!resp.ok) {
|
|
918
|
+
setProvisionStatus({ running: false, step: 'error', logs: [], error: data.error || `HTTP ${resp.status}` });
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
setProvisionStatus({ running: true, step: data.step || 'starting', logs: [], error: null });
|
|
922
|
+
await pollProvisionStatus();
|
|
923
|
+
} finally {
|
|
924
|
+
setBusy('');
|
|
925
|
+
}
|
|
926
|
+
};
|
|
927
|
+
|
|
928
|
+
const handleToggle = async (nextEnabled) => {
|
|
929
|
+
setBusy('toggle');
|
|
930
|
+
try {
|
|
931
|
+
await fetch('/api/tiana-remote/admin/toggle', {
|
|
932
|
+
method: 'POST',
|
|
933
|
+
headers: { 'content-type': 'application/json' },
|
|
934
|
+
body: JSON.stringify({ enabled: nextEnabled }),
|
|
935
|
+
});
|
|
936
|
+
await fetchState();
|
|
937
|
+
} finally {
|
|
938
|
+
setBusy('');
|
|
939
|
+
}
|
|
940
|
+
};
|
|
941
|
+
|
|
942
|
+
const handleRevealOrHide = async () => {
|
|
943
|
+
if (revealedKey) {
|
|
944
|
+
setRevealedKey('');
|
|
945
|
+
return;
|
|
946
|
+
}
|
|
947
|
+
setBusy('reveal');
|
|
948
|
+
try {
|
|
949
|
+
const resp = await fetch('/api/tiana-remote/admin/pairing-key/reveal', {
|
|
950
|
+
method: 'POST',
|
|
951
|
+
headers: { 'content-type': 'application/json' },
|
|
952
|
+
body: '{}',
|
|
953
|
+
});
|
|
954
|
+
if (resp.ok) {
|
|
955
|
+
const data = await resp.json();
|
|
956
|
+
setRevealedKey(data.pairingKey || '');
|
|
957
|
+
}
|
|
958
|
+
} finally {
|
|
959
|
+
setBusy('');
|
|
960
|
+
}
|
|
961
|
+
};
|
|
962
|
+
|
|
963
|
+
const handleCopyKey = async () => {
|
|
964
|
+
let keyToCopy = revealedKey;
|
|
965
|
+
if (!keyToCopy) {
|
|
966
|
+
const resp = await fetch('/api/tiana-remote/admin/pairing-key/reveal', {
|
|
967
|
+
method: 'POST',
|
|
968
|
+
headers: { 'content-type': 'application/json' },
|
|
969
|
+
body: '{}',
|
|
970
|
+
});
|
|
971
|
+
if (resp.ok) keyToCopy = (await resp.json()).pairingKey || '';
|
|
972
|
+
}
|
|
973
|
+
if (keyToCopy) await copyText('key', keyToCopy);
|
|
974
|
+
};
|
|
975
|
+
|
|
976
|
+
const handleConfirmRotate = async () => {
|
|
977
|
+
setBusy('rotate');
|
|
978
|
+
try {
|
|
979
|
+
const resp = await fetch('/api/tiana-remote/admin/pairing-key/rotate', {
|
|
980
|
+
method: 'POST',
|
|
981
|
+
headers: { 'content-type': 'application/json' },
|
|
982
|
+
body: JSON.stringify({ confirm: true }),
|
|
983
|
+
});
|
|
984
|
+
if (resp.ok) {
|
|
985
|
+
const data = await resp.json();
|
|
986
|
+
setRevealedKey(data.pairingKey || '');
|
|
987
|
+
setToast('E2EE pairing key rotated; all remote sessions disconnected.');
|
|
988
|
+
await fetchState();
|
|
989
|
+
}
|
|
990
|
+
} finally {
|
|
991
|
+
setBusy('');
|
|
992
|
+
}
|
|
993
|
+
};
|
|
994
|
+
|
|
995
|
+
const handleRenewToken = async () => {
|
|
996
|
+
setBusy('renew');
|
|
997
|
+
try {
|
|
998
|
+
const resp = await fetch('/api/tiana-remote/admin/token/renew', {
|
|
999
|
+
method: 'POST',
|
|
1000
|
+
headers: { 'content-type': 'application/json' },
|
|
1001
|
+
body: '{}',
|
|
1002
|
+
});
|
|
1003
|
+
const data = await resp.json().catch(() => ({}));
|
|
1004
|
+
if (resp.ok) {
|
|
1005
|
+
setToast(t('tokenRenewed'));
|
|
1006
|
+
await fetchState();
|
|
1007
|
+
} else {
|
|
1008
|
+
setToast(data.error || `Token renew failed (HTTP ${resp.status})`);
|
|
1009
|
+
}
|
|
1010
|
+
} finally {
|
|
1011
|
+
setBusy('');
|
|
1012
|
+
}
|
|
1013
|
+
};
|
|
1014
|
+
|
|
1015
|
+
const handleSaveSettings = async (ev) => {
|
|
1016
|
+
ev.preventDefault();
|
|
1017
|
+
setBusy('settings');
|
|
1018
|
+
try {
|
|
1019
|
+
const stunUrls = stunDraft.split(',').map((s) => s.trim()).filter(Boolean);
|
|
1020
|
+
const resp = await fetch('/api/tiana-remote/admin/settings', {
|
|
1021
|
+
method: 'POST',
|
|
1022
|
+
headers: { 'content-type': 'application/json' },
|
|
1023
|
+
body: JSON.stringify({
|
|
1024
|
+
hostName: hostNameDraft.trim(),
|
|
1025
|
+
p2pEnabled: p2pDraft,
|
|
1026
|
+
stunUrls: stunUrls.length ? stunUrls : 'none',
|
|
1027
|
+
allowedWebPlugins: pluginsDraft,
|
|
1028
|
+
}),
|
|
1029
|
+
});
|
|
1030
|
+
if (resp.ok) {
|
|
1031
|
+
settingsDirtyRef.current = false;
|
|
1032
|
+
setSettingsDirty(false);
|
|
1033
|
+
setToast(t('saved'));
|
|
1034
|
+
await fetchState();
|
|
1035
|
+
}
|
|
1036
|
+
} finally {
|
|
1037
|
+
setBusy('');
|
|
1038
|
+
}
|
|
1039
|
+
};
|
|
1040
|
+
|
|
1041
|
+
const handleDiscardDrafts = () => {
|
|
1042
|
+
settingsDirtyRef.current = false;
|
|
1043
|
+
setSettingsDirty(false);
|
|
1044
|
+
hydrateDraftsFromOverview(overview);
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
const handleRepair = async () => {
|
|
1048
|
+
setBusy('repair');
|
|
1049
|
+
try {
|
|
1050
|
+
const resp = await fetch('/api/tiana-remote/admin/repair', {
|
|
1051
|
+
method: 'POST',
|
|
1052
|
+
headers: { 'content-type': 'application/json' },
|
|
1053
|
+
body: '{}',
|
|
1054
|
+
});
|
|
1055
|
+
if (resp.ok) setToast(t('repaired'));
|
|
1056
|
+
} finally {
|
|
1057
|
+
setBusy('');
|
|
1058
|
+
}
|
|
1059
|
+
};
|
|
1060
|
+
|
|
1061
|
+
const handleDisconnectSession = async (sessionId) => {
|
|
1062
|
+
await fetch('/api/tiana-remote/admin/sessions/disconnect', {
|
|
1063
|
+
method: 'POST',
|
|
1064
|
+
headers: { 'content-type': 'application/json' },
|
|
1065
|
+
body: JSON.stringify(sessionId ? { sessionId } : { all: true }),
|
|
1066
|
+
});
|
|
1067
|
+
await fetchState();
|
|
1068
|
+
};
|
|
1069
|
+
|
|
1070
|
+
const renderProvisionProgress = () => {
|
|
1071
|
+
if (!provisionStatus) return null;
|
|
1072
|
+
return h('div', { id: 'dshr-provision-progress', style: { display: 'grid', gap: 8 } },
|
|
1073
|
+
h('div', { className: 'dshr-row' },
|
|
1074
|
+
h('span', { className: 'dshr-badge' },
|
|
1075
|
+
provisionStatus.running ? t('provisionRunning') : (provisionStatus.step === 'done' ? t('provisionDone') : `Status: ${provisionStatus.step}`),
|
|
1076
|
+
),
|
|
1077
|
+
),
|
|
1078
|
+
provisionStatus.error && h('div', { className: 'dshr-err' }, provisionStatus.error),
|
|
1079
|
+
Array.isArray(provisionStatus.logs) && provisionStatus.logs.length > 0 &&
|
|
1080
|
+
h('pre', { className: 'dshr-logs' }, provisionStatus.logs.join('\n')),
|
|
1081
|
+
);
|
|
1082
|
+
};
|
|
1083
|
+
|
|
1084
|
+
const statusLabel = !configured
|
|
1085
|
+
? t('statusUnconfigured')
|
|
1086
|
+
: !enabled
|
|
1087
|
+
? t('statusPaused')
|
|
1088
|
+
: relayConnected
|
|
1089
|
+
? t('statusOnline')
|
|
1090
|
+
: t('statusReconnecting');
|
|
1091
|
+
|
|
1092
|
+
return h('div', { className: 'dshr-root', 'data-dshr-mode': 'local' },
|
|
1093
|
+
h('div', { className: 'dshr-wrap' },
|
|
1094
|
+
h('div', { className: 'dshr-header' },
|
|
1095
|
+
h('div', null,
|
|
1096
|
+
h('h2', { className: 'dshr-title' }, t('title')),
|
|
1097
|
+
h('p', { className: 'dshr-sub' }, t('subtitleLocal')),
|
|
1098
|
+
),
|
|
1099
|
+
h('div', { className: 'dshr-row' },
|
|
1100
|
+
h('span', { className: 'dshr-badge', id: 'dshr-local-status-badge' },
|
|
1101
|
+
h('span', { className: `dshr-dot ${enabled && relayConnected ? 'is-online' : enabled ? 'is-warn' : ''}` }),
|
|
1102
|
+
statusLabel,
|
|
1103
|
+
),
|
|
1104
|
+
configured && h('label', { className: 'dshr-switch' },
|
|
1105
|
+
h('input', {
|
|
1106
|
+
type: 'checkbox',
|
|
1107
|
+
id: 'dshr-enable-toggle',
|
|
1108
|
+
checked: enabled,
|
|
1109
|
+
disabled: busy === 'toggle',
|
|
1110
|
+
onChange: (e) => void handleToggle(e.target.checked),
|
|
1111
|
+
}),
|
|
1112
|
+
t('toggleLabel'),
|
|
1113
|
+
),
|
|
1114
|
+
),
|
|
1115
|
+
),
|
|
1116
|
+
|
|
1117
|
+
toast && h('div', { className: 'dshr-notice', role: 'status' }, toast),
|
|
1118
|
+
|
|
1119
|
+
// Unconfigured interactive onboarding card (Bind existing OR Create new Tiana app)
|
|
1120
|
+
!configured && h('div', { className: 'dshr-card', id: 'dshr-unconfigured-card' },
|
|
1121
|
+
h('div', { className: 'dshr-card-head' },
|
|
1122
|
+
h('h3', { className: 'dshr-card-title' }, t('onboardTitle')),
|
|
1123
|
+
),
|
|
1124
|
+
h('div', { className: 'dshr-tabs', role: 'tablist' },
|
|
1125
|
+
h('button', {
|
|
1126
|
+
type: 'button',
|
|
1127
|
+
role: 'tab',
|
|
1128
|
+
className: 'dshr-tab',
|
|
1129
|
+
id: 'dshr-tab-bind',
|
|
1130
|
+
'aria-selected': onboardTab === 'bind' ? 'true' : 'false',
|
|
1131
|
+
onClick: () => setOnboardTab('bind'),
|
|
1132
|
+
}, t('onboardBindTab')),
|
|
1133
|
+
h('button', {
|
|
1134
|
+
type: 'button',
|
|
1135
|
+
role: 'tab',
|
|
1136
|
+
className: 'dshr-tab',
|
|
1137
|
+
id: 'dshr-tab-create',
|
|
1138
|
+
'aria-selected': onboardTab === 'create' ? 'true' : 'false',
|
|
1139
|
+
onClick: () => setOnboardTab('create'),
|
|
1140
|
+
}, t('onboardCreateTab')),
|
|
1141
|
+
),
|
|
1142
|
+
onboardTab === 'bind'
|
|
1143
|
+
? h('form', {
|
|
1144
|
+
id: 'dshr-bind-form',
|
|
1145
|
+
style: { display: 'grid', gap: 12 },
|
|
1146
|
+
onSubmit: (e) => {
|
|
1147
|
+
e.preventDefault();
|
|
1148
|
+
if (!bindWebId.trim()) return;
|
|
1149
|
+
void startProvisionRequest({
|
|
1150
|
+
mode: 'bind',
|
|
1151
|
+
webId: bindWebId.trim(),
|
|
1152
|
+
hostName: bindHostName.trim() || undefined,
|
|
1153
|
+
rebind: bindForceRebind,
|
|
1154
|
+
});
|
|
1155
|
+
},
|
|
1156
|
+
},
|
|
1157
|
+
h('label', { className: 'dshr-field' },
|
|
1158
|
+
h('span', { className: 'dshr-label' }, t('webIdLabel')),
|
|
1159
|
+
h('input', {
|
|
1160
|
+
id: 'dshr-bind-web-id',
|
|
1161
|
+
className: 'dshr-input',
|
|
1162
|
+
value: bindWebId,
|
|
1163
|
+
placeholder: 'abc123456789',
|
|
1164
|
+
onChange: (e) => setBindWebId(e.target.value),
|
|
1165
|
+
}),
|
|
1166
|
+
),
|
|
1167
|
+
h('label', { className: 'dshr-field' },
|
|
1168
|
+
h('span', { className: 'dshr-label' }, t('hostName')),
|
|
1169
|
+
h('input', {
|
|
1170
|
+
className: 'dshr-input',
|
|
1171
|
+
value: bindHostName,
|
|
1172
|
+
placeholder: 'My-Workstation',
|
|
1173
|
+
onChange: (e) => setBindHostName(e.target.value),
|
|
1174
|
+
}),
|
|
1175
|
+
),
|
|
1176
|
+
h('label', { className: 'dshr-switch' },
|
|
1177
|
+
h('input', {
|
|
1178
|
+
type: 'checkbox',
|
|
1179
|
+
checked: bindForceRebind,
|
|
1180
|
+
onChange: (e) => setBindForceRebind(e.target.checked),
|
|
1181
|
+
}),
|
|
1182
|
+
t('rebindForceLabel'),
|
|
1183
|
+
),
|
|
1184
|
+
h('div', { className: 'dshr-row' },
|
|
1185
|
+
h('button', {
|
|
1186
|
+
type: 'submit',
|
|
1187
|
+
id: 'dshr-bind-submit',
|
|
1188
|
+
className: 'dshr-btn dshr-btn-primary',
|
|
1189
|
+
disabled: busy === 'provision' || Boolean(provisionStatus?.running) || !bindWebId.trim(),
|
|
1190
|
+
}, t('bindSubmitBtn')),
|
|
1191
|
+
),
|
|
1192
|
+
)
|
|
1193
|
+
: h('form', {
|
|
1194
|
+
id: 'dshr-create-form',
|
|
1195
|
+
style: { display: 'grid', gap: 12 },
|
|
1196
|
+
onSubmit: (e) => {
|
|
1197
|
+
e.preventDefault();
|
|
1198
|
+
void startProvisionRequest({
|
|
1199
|
+
mode: 'create',
|
|
1200
|
+
webName: createWebName.trim() || 'DSH Remote',
|
|
1201
|
+
hostName: bindHostName.trim() || undefined,
|
|
1202
|
+
});
|
|
1203
|
+
},
|
|
1204
|
+
},
|
|
1205
|
+
h('label', { className: 'dshr-field' },
|
|
1206
|
+
h('span', { className: 'dshr-label' }, t('webNameLabel')),
|
|
1207
|
+
h('input', {
|
|
1208
|
+
id: 'dshr-create-web-name',
|
|
1209
|
+
className: 'dshr-input',
|
|
1210
|
+
value: createWebName,
|
|
1211
|
+
onChange: (e) => setCreateWebName(e.target.value),
|
|
1212
|
+
}),
|
|
1213
|
+
),
|
|
1214
|
+
h('label', { className: 'dshr-field' },
|
|
1215
|
+
h('span', { className: 'dshr-label' }, t('hostName')),
|
|
1216
|
+
h('input', {
|
|
1217
|
+
className: 'dshr-input',
|
|
1218
|
+
value: bindHostName,
|
|
1219
|
+
placeholder: 'My-Workstation',
|
|
1220
|
+
onChange: (e) => setBindHostName(e.target.value),
|
|
1221
|
+
}),
|
|
1222
|
+
),
|
|
1223
|
+
h('div', { className: 'dshr-row' },
|
|
1224
|
+
h('button', {
|
|
1225
|
+
type: 'submit',
|
|
1226
|
+
id: 'dshr-create-submit',
|
|
1227
|
+
className: 'dshr-btn dshr-btn-primary',
|
|
1228
|
+
disabled: busy === 'provision' || Boolean(provisionStatus?.running),
|
|
1229
|
+
}, t('createSubmitBtn')),
|
|
1230
|
+
),
|
|
1231
|
+
),
|
|
1232
|
+
renderProvisionProgress(),
|
|
1233
|
+
),
|
|
1234
|
+
|
|
1235
|
+
// Card 1: Remote URL & QR
|
|
1236
|
+
configured && h('div', { className: 'dshr-card' },
|
|
1237
|
+
h('div', { className: 'dshr-card-head' },
|
|
1238
|
+
h('h3', { className: 'dshr-card-title' }, t('remoteUrl')),
|
|
1239
|
+
h('span', { className: 'dshr-label' }, overview?.host?.hostName || overview?.host?.hostId),
|
|
1240
|
+
),
|
|
1241
|
+
h('div', { className: 'dshr-row' },
|
|
1242
|
+
h('div', { className: 'dshr-mono', title: endpoint }, endpoint),
|
|
1243
|
+
h('button', { type: 'button', className: 'dshr-btn', onClick: () => void copyText('url', endpoint) },
|
|
1244
|
+
copiedTag === 'url' ? t('copied') : t('copy')),
|
|
1245
|
+
h('a', { className: 'dshr-btn dshr-btn-primary', href: endpoint, target: '_blank', rel: 'noopener noreferrer', style: { textDecoration: 'none' } }, t('open')),
|
|
1246
|
+
h('button', {
|
|
1247
|
+
type: 'button', className: 'dshr-btn', id: 'dshr-qr-btn',
|
|
1248
|
+
onClick: () => qrDialogRef.current?.showModal?.(),
|
|
1249
|
+
}, t('qrCode')),
|
|
1250
|
+
),
|
|
1251
|
+
),
|
|
1252
|
+
|
|
1253
|
+
// Card 2: E2EE Pairing Key
|
|
1254
|
+
configured && h('div', { className: 'dshr-card' },
|
|
1255
|
+
h('div', { className: 'dshr-card-head' },
|
|
1256
|
+
h('h3', { className: 'dshr-card-title' }, t('e2eeTitle')),
|
|
1257
|
+
h('span', { className: 'dshr-badge' }, `${t('e2eeFingerprint')}: ${overview?.e2ee?.fingerprint || '—'}`),
|
|
1258
|
+
),
|
|
1259
|
+
h('div', { className: 'dshr-row' },
|
|
1260
|
+
h('div', { className: 'dshr-mono', id: 'dshr-pairing-key-display' },
|
|
1261
|
+
revealedKey || 'dshk1_•••••••••••••••••••••••••••••••••••••••••••'),
|
|
1262
|
+
h('button', {
|
|
1263
|
+
type: 'button', className: 'dshr-btn', id: 'dshr-reveal-key-btn',
|
|
1264
|
+
disabled: busy === 'reveal',
|
|
1265
|
+
onClick: () => void handleRevealOrHide(),
|
|
1266
|
+
}, revealedKey ? t('hideKey') : t('revealKey')),
|
|
1267
|
+
h('button', {
|
|
1268
|
+
type: 'button', className: 'dshr-btn', id: 'dshr-copy-key-btn',
|
|
1269
|
+
onClick: () => void handleCopyKey(),
|
|
1270
|
+
}, copiedTag === 'key' ? t('copied') : t('copyKey')),
|
|
1271
|
+
h('button', {
|
|
1272
|
+
type: 'button', className: 'dshr-btn dshr-btn-danger', id: 'dshr-rotate-key-btn',
|
|
1273
|
+
disabled: busy === 'rotate',
|
|
1274
|
+
onClick: () => rotateDialogRef.current?.showModal?.(),
|
|
1275
|
+
}, t('rotateKey')),
|
|
1276
|
+
),
|
|
1277
|
+
),
|
|
1278
|
+
|
|
1279
|
+
// Card 3: Active Sessions & Function Token Expiry / Renew
|
|
1280
|
+
configured && h('div', { className: 'dshr-card' },
|
|
1281
|
+
h('div', { className: 'dshr-card-head' },
|
|
1282
|
+
h('h3', { className: 'dshr-card-title' }, `${t('sessionsTitle')} (${sessions.length})`),
|
|
1283
|
+
sessions.length > 0 && h('button', {
|
|
1284
|
+
type: 'button', className: 'dshr-btn dshr-btn-danger',
|
|
1285
|
+
onClick: () => void handleDisconnectSession(null),
|
|
1286
|
+
}, t('disconnectAll')),
|
|
1287
|
+
),
|
|
1288
|
+
sessions.length === 0
|
|
1289
|
+
? h('div', { className: 'dshr-label' }, t('sessionsEmpty'))
|
|
1290
|
+
: sessions.map((s) => h('div', { key: s.id, className: 'dshr-session-item' },
|
|
1291
|
+
h('div', { className: 'dshr-row' },
|
|
1292
|
+
h('strong', { style: { fontSize: 13 } }, s.sessionId),
|
|
1293
|
+
h('span', { className: 'dshr-badge' }, String(s.transport || 'relay').toUpperCase()),
|
|
1294
|
+
h('span', { className: 'dshr-label' }, `RTT: ${s.rttMs != null ? `${s.rttMs} ms` : '—'}`),
|
|
1295
|
+
h('span', { className: 'dshr-label' }, formatDuration(s.connectedDurationMs)),
|
|
1296
|
+
),
|
|
1297
|
+
h('button', {
|
|
1298
|
+
type: 'button', className: 'dshr-btn dshr-btn-danger',
|
|
1299
|
+
onClick: () => void handleDisconnectSession(s.id),
|
|
1300
|
+
}, t('disconnect')),
|
|
1301
|
+
)),
|
|
1302
|
+
h('div', { className: 'dshr-divider' }),
|
|
1303
|
+
h('div', { className: 'dshr-card-head' },
|
|
1304
|
+
h('div', { className: 'dshr-row' },
|
|
1305
|
+
h('span', { className: 'dshr-label' }, `${t('tokenExpiry')}:`),
|
|
1306
|
+
h('span', { className: 'dshr-badge', id: 'dshr-token-expiry' }, formatTokenExpiry(tokenExpiresAt, isZh)),
|
|
1307
|
+
),
|
|
1308
|
+
h('button', {
|
|
1309
|
+
type: 'button',
|
|
1310
|
+
className: 'dshr-btn',
|
|
1311
|
+
id: 'dshr-renew-token-btn',
|
|
1312
|
+
disabled: busy === 'renew',
|
|
1313
|
+
onClick: () => void handleRenewToken(),
|
|
1314
|
+
}, busy === 'renew' ? t('tokenRenewing') : t('renewToken')),
|
|
1315
|
+
),
|
|
1316
|
+
),
|
|
1317
|
+
|
|
1318
|
+
// Card 4: Host, Network, Plugin Allowlist & Switch/Rebind Cloud App
|
|
1319
|
+
configured && h('div', { className: 'dshr-card' },
|
|
1320
|
+
h('form', { style: { display: 'grid', gap: 14 }, onSubmit: handleSaveSettings },
|
|
1321
|
+
h('div', { className: 'dshr-card-head' },
|
|
1322
|
+
h('h3', { className: 'dshr-card-title' }, t('settingsTitle')),
|
|
1323
|
+
h('button', {
|
|
1324
|
+
type: 'button', className: 'dshr-btn', id: 'dshr-repair-btn',
|
|
1325
|
+
disabled: busy === 'repair',
|
|
1326
|
+
onClick: () => void handleRepair(),
|
|
1327
|
+
}, busy === 'repair' ? t('repairing') : t('repairBtn')),
|
|
1328
|
+
),
|
|
1329
|
+
h('label', { className: 'dshr-field' },
|
|
1330
|
+
h('span', { className: 'dshr-label' }, t('hostName')),
|
|
1331
|
+
h('input', {
|
|
1332
|
+
id: 'dshr-hostname-input',
|
|
1333
|
+
className: 'dshr-input', value: hostNameDraft, maxLength: 128,
|
|
1334
|
+
onChange: (e) => { markDirty(); setHostNameDraft(e.target.value); },
|
|
1335
|
+
}),
|
|
1336
|
+
),
|
|
1337
|
+
h('label', { className: 'dshr-switch' },
|
|
1338
|
+
h('input', {
|
|
1339
|
+
id: 'dshr-p2p-checkbox',
|
|
1340
|
+
type: 'checkbox', checked: p2pDraft,
|
|
1341
|
+
onChange: (e) => { markDirty(); setP2pDraft(e.target.checked); },
|
|
1342
|
+
}),
|
|
1343
|
+
t('p2pToggle'),
|
|
1344
|
+
),
|
|
1345
|
+
h('label', { className: 'dshr-field' },
|
|
1346
|
+
h('span', { className: 'dshr-label' }, t('stunUrls')),
|
|
1347
|
+
h('input', {
|
|
1348
|
+
id: 'dshr-stun-input',
|
|
1349
|
+
className: 'dshr-input', value: stunDraft,
|
|
1350
|
+
placeholder: 'stun:stun.cloudflare.com:3478',
|
|
1351
|
+
onChange: (e) => { markDirty(); setStunDraft(e.target.value); },
|
|
1352
|
+
}),
|
|
1353
|
+
),
|
|
1354
|
+
installedPlugins.length > 0 && h('div', { className: 'dshr-field' },
|
|
1355
|
+
h('span', { className: 'dshr-label' }, t('allowedPlugins')),
|
|
1356
|
+
h('div', { className: 'dshr-row' },
|
|
1357
|
+
installedPlugins.map((pkg) => h('label', { key: pkg, className: 'dshr-badge', style: { cursor: 'pointer' } },
|
|
1358
|
+
h('input', {
|
|
1359
|
+
type: 'checkbox',
|
|
1360
|
+
checked: pluginsDraft.includes(pkg),
|
|
1361
|
+
onChange: (e) => {
|
|
1362
|
+
markDirty();
|
|
1363
|
+
setPluginsDraft((prev) => e.target.checked
|
|
1364
|
+
? [...new Set([...prev, pkg])]
|
|
1365
|
+
: prev.filter((item) => item !== pkg));
|
|
1366
|
+
},
|
|
1367
|
+
}),
|
|
1368
|
+
pkg,
|
|
1369
|
+
)),
|
|
1370
|
+
),
|
|
1371
|
+
),
|
|
1372
|
+
h('div', { className: 'dshr-row' },
|
|
1373
|
+
h('button', { type: 'submit', id: 'dshr-save-settings-btn', className: 'dshr-btn dshr-btn-primary', disabled: busy === 'settings' },
|
|
1374
|
+
busy === 'settings' ? t('saving') : t('saveSettings')),
|
|
1375
|
+
settingsDirty && h('button', { type: 'button', className: 'dshr-btn', onClick: handleDiscardDrafts },
|
|
1376
|
+
t('resetDraft')),
|
|
1377
|
+
),
|
|
1378
|
+
),
|
|
1379
|
+
|
|
1380
|
+
h('div', { className: 'dshr-divider' }),
|
|
1381
|
+
|
|
1382
|
+
// Rebind / switch cloud app inline form
|
|
1383
|
+
h('form', {
|
|
1384
|
+
id: 'dshr-rebind-form',
|
|
1385
|
+
style: { display: 'grid', gap: 10 },
|
|
1386
|
+
onSubmit: (e) => {
|
|
1387
|
+
e.preventDefault();
|
|
1388
|
+
if (!rebindWebId.trim()) return;
|
|
1389
|
+
void startProvisionRequest({
|
|
1390
|
+
mode: 'bind',
|
|
1391
|
+
webId: rebindWebId.trim(),
|
|
1392
|
+
hostName: hostNameDraft.trim() || undefined,
|
|
1393
|
+
rebind: true,
|
|
1394
|
+
});
|
|
1395
|
+
},
|
|
1396
|
+
},
|
|
1397
|
+
h('span', { className: 'dshr-label', style: { fontWeight: 600 } }, t('rebindSectionTitle')),
|
|
1398
|
+
h('div', { className: 'dshr-row' },
|
|
1399
|
+
h('input', {
|
|
1400
|
+
id: 'dshr-rebind-web-id',
|
|
1401
|
+
className: 'dshr-input',
|
|
1402
|
+
style: { flex: 1, minWidth: 200 },
|
|
1403
|
+
value: rebindWebId,
|
|
1404
|
+
placeholder: t('webIdLabel'),
|
|
1405
|
+
onChange: (e) => setRebindWebId(e.target.value),
|
|
1406
|
+
}),
|
|
1407
|
+
h('button', {
|
|
1408
|
+
type: 'submit',
|
|
1409
|
+
id: 'dshr-rebind-submit',
|
|
1410
|
+
className: 'dshr-btn',
|
|
1411
|
+
disabled: busy === 'provision' || Boolean(provisionStatus?.running) || !rebindWebId.trim(),
|
|
1412
|
+
}, t('rebindBtn')),
|
|
1413
|
+
),
|
|
1414
|
+
renderProvisionProgress(),
|
|
1415
|
+
),
|
|
1416
|
+
),
|
|
1417
|
+
|
|
1418
|
+
// Native modal <dialog> for destructive key rotation (autofocus on safe Cancel action)
|
|
1419
|
+
h('dialog', {
|
|
1420
|
+
ref: rotateDialogRef,
|
|
1421
|
+
className: 'dshr-dialog',
|
|
1422
|
+
'aria-labelledby': 'dshr-rotate-title',
|
|
1423
|
+
onClose: (e) => {
|
|
1424
|
+
const dialog = e.currentTarget;
|
|
1425
|
+
const val = dialog.returnValue;
|
|
1426
|
+
dialog.returnValue = '';
|
|
1427
|
+
if (val === 'confirm') void handleConfirmRotate();
|
|
1428
|
+
},
|
|
1429
|
+
},
|
|
1430
|
+
h('h3', { id: 'dshr-rotate-title', style: { margin: '0 0 8px', fontSize: 16 } }, t('rotateConfirmTitle')),
|
|
1431
|
+
h('p', { style: { margin: '0 0 16px', fontSize: 13, lineHeight: 1.5, opacity: 0.85 } }, t('rotateConfirmBody')),
|
|
1432
|
+
h('form', { method: 'dialog', className: 'dshr-row', style: { justifyContent: 'flex-end' } },
|
|
1433
|
+
h('button', { type: 'submit', value: 'cancel', autoFocus: true, className: 'dshr-btn' }, t('cancel')),
|
|
1434
|
+
h('button', { type: 'submit', value: 'confirm', className: 'dshr-btn dshr-btn-danger' }, t('rotateConfirmBtn')),
|
|
1435
|
+
),
|
|
1436
|
+
),
|
|
1437
|
+
|
|
1438
|
+
// Native modal <dialog> for Real Scannable QR Code
|
|
1439
|
+
h('dialog', {
|
|
1440
|
+
ref: qrDialogRef,
|
|
1441
|
+
className: 'dshr-dialog',
|
|
1442
|
+
id: 'dshr-qr-dialog',
|
|
1443
|
+
'aria-labelledby': 'dshr-qr-title',
|
|
1444
|
+
onClose: (e) => { e.currentTarget.returnValue = ''; },
|
|
1445
|
+
},
|
|
1446
|
+
h('h3', { id: 'dshr-qr-title', style: { margin: '0 0 10px', fontSize: 16 } }, t('qrTitle')),
|
|
1447
|
+
endpoint && buildQrSvgData(endpoint),
|
|
1448
|
+
h('p', { style: { margin: '12px 0 14px', fontSize: 12, lineHeight: 1.5, opacity: 0.85 } }, t('qrHint')),
|
|
1449
|
+
h('form', { method: 'dialog', className: 'dshr-row', style: { justifyContent: 'flex-end' } },
|
|
1450
|
+
h('button', { type: 'submit', value: 'close', autoFocus: true, className: 'dshr-btn' }, t('close')),
|
|
1451
|
+
),
|
|
1452
|
+
),
|
|
1453
|
+
),
|
|
1454
|
+
);
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
return {
|
|
1458
|
+
inject: ['slots', 'locale'],
|
|
1459
|
+
TianaRemotePanel,
|
|
1460
|
+
encodeQrMatrix,
|
|
1461
|
+
apply(ctx) {
|
|
1462
|
+
if (ctx.locale?.register) {
|
|
1463
|
+
ctx.effect(() => ctx.locale.register(NS, { en, zh }), 'tiana-remote:locale');
|
|
1464
|
+
}
|
|
1465
|
+
const t = ctx.locale?.bind ? ctx.locale.bind(NS) : (k) => zh[k] || k;
|
|
1466
|
+
|
|
1467
|
+
ctx.slots.inject('main', () =>
|
|
1468
|
+
ctx.slots.register(
|
|
1469
|
+
{ name: 'main', key: PANEL_ID, locale: NS },
|
|
1470
|
+
(props) => h(TianaRemotePanel, { ...props, t }),
|
|
1471
|
+
),
|
|
1472
|
+
);
|
|
1473
|
+
|
|
1474
|
+
ctx.slots.inject('sidebar.panellist', () =>
|
|
1475
|
+
ctx.slots.register(
|
|
1476
|
+
{
|
|
1477
|
+
name: 'sidebar.panellist',
|
|
1478
|
+
id: PANEL_ID,
|
|
1479
|
+
order: 13,
|
|
1480
|
+
priority: 65,
|
|
1481
|
+
locale: NS,
|
|
1482
|
+
label: () => t('panel'),
|
|
1483
|
+
},
|
|
1484
|
+
RemoteIcon,
|
|
1485
|
+
),
|
|
1486
|
+
);
|
|
1487
|
+
},
|
|
1488
|
+
};
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
if (typeof globalThis !== 'undefined') {
|
|
1492
|
+
globalThis.__DSH_REMOTE_QR_ENCODE__ = encodeQrMatrix;
|
|
1493
|
+
globalThis.__DSH_REMOTE_CLIENT_FACTORY__ = factory;
|
|
1494
|
+
if (globalThis.__ModuleLoader__ && typeof globalThis.__ModuleLoader__.load === 'function') {
|
|
1495
|
+
globalThis.__ModuleLoader__.load({
|
|
1496
|
+
id: '@tianacloud/dsh-remote',
|
|
1497
|
+
factory,
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
})();
|