ds-harness-remote 0.3.8
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 +21 -0
- package/README.md +103 -0
- package/cordis.patch.yml +7 -0
- package/dist/adapters/agent-adapter.d.ts +35 -0
- package/dist/adapters/agent-adapter.d.ts.map +1 -0
- package/dist/adapters/agent-adapter.js +80 -0
- package/dist/adapters/agent-adapter.js.map +1 -0
- package/dist/adapters/permission-adapter.d.ts +13 -0
- package/dist/adapters/permission-adapter.d.ts.map +1 -0
- package/dist/adapters/permission-adapter.js +67 -0
- package/dist/adapters/permission-adapter.js.map +1 -0
- package/dist/adapters/session-adapter.d.ts +38 -0
- package/dist/adapters/session-adapter.d.ts.map +1 -0
- package/dist/adapters/session-adapter.js +230 -0
- package/dist/adapters/session-adapter.js.map +1 -0
- package/dist/adapters/workspace-adapter.d.ts +13 -0
- package/dist/adapters/workspace-adapter.d.ts.map +1 -0
- package/dist/adapters/workspace-adapter.js +21 -0
- package/dist/adapters/workspace-adapter.js.map +1 -0
- package/dist/api-proxy-switch.d.ts +33 -0
- package/dist/api-proxy-switch.d.ts.map +1 -0
- package/dist/api-proxy-switch.js +107 -0
- package/dist/api-proxy-switch.js.map +1 -0
- package/dist/bin/doctor.d.ts +3 -0
- package/dist/bin/doctor.d.ts.map +1 -0
- package/dist/bin/doctor.js +13 -0
- package/dist/bin/doctor.js.map +1 -0
- package/dist/client-runtime.d.ts +98 -0
- package/dist/client-runtime.d.ts.map +1 -0
- package/dist/client-runtime.js +421 -0
- package/dist/client-runtime.js.map +1 -0
- package/dist/client-secure-transport.d.ts +22 -0
- package/dist/client-secure-transport.d.ts.map +1 -0
- package/dist/client-secure-transport.js +129 -0
- package/dist/client-secure-transport.js.map +1 -0
- package/dist/client.d.ts +12 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.github.js +2938 -0
- package/dist/client.js +2938 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +33 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +80 -0
- package/dist/config.js.map +1 -0
- package/dist/connection-controller.d.ts +39 -0
- package/dist/connection-controller.d.ts.map +1 -0
- package/dist/connection-controller.js +170 -0
- package/dist/connection-controller.js.map +1 -0
- package/dist/control-runtime.d.ts +36 -0
- package/dist/control-runtime.d.ts.map +1 -0
- package/dist/control-runtime.js +265 -0
- package/dist/control-runtime.js.map +1 -0
- package/dist/event-sequencer.d.ts +23 -0
- package/dist/event-sequencer.d.ts.map +1 -0
- package/dist/event-sequencer.js +54 -0
- package/dist/event-sequencer.js.map +1 -0
- package/dist/harness-api-bridge.d.ts +55 -0
- package/dist/harness-api-bridge.d.ts.map +1 -0
- package/dist/harness-api-bridge.js +387 -0
- package/dist/harness-api-bridge.js.map +1 -0
- package/dist/identity-store.d.ts +45 -0
- package/dist/identity-store.d.ts.map +1 -0
- package/dist/identity-store.js +183 -0
- package/dist/identity-store.js.map +1 -0
- package/dist/ids.d.ts +2 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +17 -0
- package/dist/ids.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16091 -0
- package/dist/index.js.map +7 -0
- package/dist/logging.d.ts +18 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +30 -0
- package/dist/logging.js.map +1 -0
- package/dist/pairing-controller.d.ts +52 -0
- package/dist/pairing-controller.d.ts.map +1 -0
- package/dist/pairing-controller.js +73 -0
- package/dist/pairing-controller.js.map +1 -0
- package/dist/pending-approvals.d.ts +14 -0
- package/dist/pending-approvals.d.ts.map +1 -0
- package/dist/pending-approvals.js +52 -0
- package/dist/pending-approvals.js.map +1 -0
- package/dist/remote-api-proxy.d.ts +12 -0
- package/dist/remote-api-proxy.d.ts.map +1 -0
- package/dist/remote-api-proxy.js +191 -0
- package/dist/remote-api-proxy.js.map +1 -0
- package/dist/remote-directory-browser.d.ts +16 -0
- package/dist/remote-directory-browser.d.ts.map +1 -0
- package/dist/remote-directory-browser.js +48 -0
- package/dist/remote-directory-browser.js.map +1 -0
- package/dist/rpc-router.d.ts +21 -0
- package/dist/rpc-router.d.ts.map +1 -0
- package/dist/rpc-router.js +93 -0
- package/dist/rpc-router.js.map +1 -0
- package/dist/server-api.d.ts +80 -0
- package/dist/server-api.d.ts.map +1 -0
- package/dist/server-api.js +405 -0
- package/dist/server-api.js.map +1 -0
- package/dist/server-connection.d.ts +70 -0
- package/dist/server-connection.d.ts.map +1 -0
- package/dist/server-connection.js +759 -0
- package/dist/server-connection.js.map +1 -0
- package/dist/server-credentials.d.ts +46 -0
- package/dist/server-credentials.d.ts.map +1 -0
- package/dist/server-credentials.js +71 -0
- package/dist/server-credentials.js.map +1 -0
- package/dist/service.d.ts +56 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +162 -0
- package/dist/service.js.map +1 -0
- package/dist/typert-gateway-switch.d.ts +19 -0
- package/dist/typert-gateway-switch.d.ts.map +1 -0
- package/dist/typert-gateway-switch.js +41 -0
- package/dist/typert-gateway-switch.js.map +1 -0
- package/dist/types.d.ts +20 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +12 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +12 -0
- package/dist/version.js.map +1 -0
- package/dist/werift-rtc.d.ts +85 -0
- package/dist/werift-rtc.d.ts.map +1 -0
- package/dist/werift-rtc.js +164 -0
- package/dist/werift-rtc.js.map +1 -0
- package/package.json +98 -0
- package/public.d.ts +19 -0
|
@@ -0,0 +1,2938 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js
|
|
27
|
+
var require_can_promise = __commonJS({
|
|
28
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js"(exports, module) {
|
|
29
|
+
module.exports = function() {
|
|
30
|
+
return typeof Promise == "function" && Promise.prototype && Promise.prototype.then;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js
|
|
36
|
+
var require_utils = __commonJS({
|
|
37
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"(exports) {
|
|
38
|
+
var toSJISFunction, CODEWORDS_COUNT = [
|
|
39
|
+
0,
|
|
40
|
+
// Not used
|
|
41
|
+
26,
|
|
42
|
+
44,
|
|
43
|
+
70,
|
|
44
|
+
100,
|
|
45
|
+
134,
|
|
46
|
+
172,
|
|
47
|
+
196,
|
|
48
|
+
242,
|
|
49
|
+
292,
|
|
50
|
+
346,
|
|
51
|
+
404,
|
|
52
|
+
466,
|
|
53
|
+
532,
|
|
54
|
+
581,
|
|
55
|
+
655,
|
|
56
|
+
733,
|
|
57
|
+
815,
|
|
58
|
+
901,
|
|
59
|
+
991,
|
|
60
|
+
1085,
|
|
61
|
+
1156,
|
|
62
|
+
1258,
|
|
63
|
+
1364,
|
|
64
|
+
1474,
|
|
65
|
+
1588,
|
|
66
|
+
1706,
|
|
67
|
+
1828,
|
|
68
|
+
1921,
|
|
69
|
+
2051,
|
|
70
|
+
2185,
|
|
71
|
+
2323,
|
|
72
|
+
2465,
|
|
73
|
+
2611,
|
|
74
|
+
2761,
|
|
75
|
+
2876,
|
|
76
|
+
3034,
|
|
77
|
+
3196,
|
|
78
|
+
3362,
|
|
79
|
+
3532,
|
|
80
|
+
3706
|
|
81
|
+
];
|
|
82
|
+
exports.getSymbolSize = function(version) {
|
|
83
|
+
if (!version) throw new Error('"version" cannot be null or undefined');
|
|
84
|
+
if (version < 1 || version > 40) throw new Error('"version" should be in range from 1 to 40');
|
|
85
|
+
return version * 4 + 17;
|
|
86
|
+
};
|
|
87
|
+
exports.getSymbolTotalCodewords = function(version) {
|
|
88
|
+
return CODEWORDS_COUNT[version];
|
|
89
|
+
};
|
|
90
|
+
exports.getBCHDigit = function(data) {
|
|
91
|
+
let digit = 0;
|
|
92
|
+
for (; data !== 0; )
|
|
93
|
+
digit++, data >>>= 1;
|
|
94
|
+
return digit;
|
|
95
|
+
};
|
|
96
|
+
exports.setToSJISFunction = function(f) {
|
|
97
|
+
if (typeof f != "function")
|
|
98
|
+
throw new Error('"toSJISFunc" is not a valid function.');
|
|
99
|
+
toSJISFunction = f;
|
|
100
|
+
};
|
|
101
|
+
exports.isKanjiModeEnabled = function() {
|
|
102
|
+
return typeof toSJISFunction < "u";
|
|
103
|
+
};
|
|
104
|
+
exports.toSJIS = function(kanji) {
|
|
105
|
+
return toSJISFunction(kanji);
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js
|
|
111
|
+
var require_error_correction_level = __commonJS({
|
|
112
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js"(exports) {
|
|
113
|
+
exports.L = { bit: 1 };
|
|
114
|
+
exports.M = { bit: 0 };
|
|
115
|
+
exports.Q = { bit: 3 };
|
|
116
|
+
exports.H = { bit: 2 };
|
|
117
|
+
function fromString(string) {
|
|
118
|
+
if (typeof string != "string")
|
|
119
|
+
throw new Error("Param is not a string");
|
|
120
|
+
switch (string.toLowerCase()) {
|
|
121
|
+
case "l":
|
|
122
|
+
case "low":
|
|
123
|
+
return exports.L;
|
|
124
|
+
case "m":
|
|
125
|
+
case "medium":
|
|
126
|
+
return exports.M;
|
|
127
|
+
case "q":
|
|
128
|
+
case "quartile":
|
|
129
|
+
return exports.Q;
|
|
130
|
+
case "h":
|
|
131
|
+
case "high":
|
|
132
|
+
return exports.H;
|
|
133
|
+
default:
|
|
134
|
+
throw new Error("Unknown EC Level: " + string);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.isValid = function(level) {
|
|
138
|
+
return level && typeof level.bit < "u" && level.bit >= 0 && level.bit < 4;
|
|
139
|
+
};
|
|
140
|
+
exports.from = function(value, defaultValue) {
|
|
141
|
+
if (exports.isValid(value))
|
|
142
|
+
return value;
|
|
143
|
+
try {
|
|
144
|
+
return fromString(value);
|
|
145
|
+
} catch {
|
|
146
|
+
return defaultValue;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js
|
|
153
|
+
var require_bit_buffer = __commonJS({
|
|
154
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js"(exports, module) {
|
|
155
|
+
function BitBuffer() {
|
|
156
|
+
this.buffer = [], this.length = 0;
|
|
157
|
+
}
|
|
158
|
+
BitBuffer.prototype = {
|
|
159
|
+
get: function(index) {
|
|
160
|
+
let bufIndex = Math.floor(index / 8);
|
|
161
|
+
return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) === 1;
|
|
162
|
+
},
|
|
163
|
+
put: function(num, length) {
|
|
164
|
+
for (let i = 0; i < length; i++)
|
|
165
|
+
this.putBit((num >>> length - i - 1 & 1) === 1);
|
|
166
|
+
},
|
|
167
|
+
getLengthInBits: function() {
|
|
168
|
+
return this.length;
|
|
169
|
+
},
|
|
170
|
+
putBit: function(bit) {
|
|
171
|
+
let bufIndex = Math.floor(this.length / 8);
|
|
172
|
+
this.buffer.length <= bufIndex && this.buffer.push(0), bit && (this.buffer[bufIndex] |= 128 >>> this.length % 8), this.length++;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
module.exports = BitBuffer;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js
|
|
180
|
+
var require_bit_matrix = __commonJS({
|
|
181
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js"(exports, module) {
|
|
182
|
+
function BitMatrix(size) {
|
|
183
|
+
if (!size || size < 1)
|
|
184
|
+
throw new Error("BitMatrix size must be defined and greater than 0");
|
|
185
|
+
this.size = size, this.data = new Uint8Array(size * size), this.reservedBit = new Uint8Array(size * size);
|
|
186
|
+
}
|
|
187
|
+
BitMatrix.prototype.set = function(row, col, value, reserved) {
|
|
188
|
+
let index = row * this.size + col;
|
|
189
|
+
this.data[index] = value, reserved && (this.reservedBit[index] = !0);
|
|
190
|
+
};
|
|
191
|
+
BitMatrix.prototype.get = function(row, col) {
|
|
192
|
+
return this.data[row * this.size + col];
|
|
193
|
+
};
|
|
194
|
+
BitMatrix.prototype.xor = function(row, col, value) {
|
|
195
|
+
this.data[row * this.size + col] ^= value;
|
|
196
|
+
};
|
|
197
|
+
BitMatrix.prototype.isReserved = function(row, col) {
|
|
198
|
+
return this.reservedBit[row * this.size + col];
|
|
199
|
+
};
|
|
200
|
+
module.exports = BitMatrix;
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js
|
|
205
|
+
var require_alignment_pattern = __commonJS({
|
|
206
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js"(exports) {
|
|
207
|
+
var getSymbolSize = require_utils().getSymbolSize;
|
|
208
|
+
exports.getRowColCoords = function(version) {
|
|
209
|
+
if (version === 1) return [];
|
|
210
|
+
let posCount = Math.floor(version / 7) + 2, size = getSymbolSize(version), intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2, positions = [size - 7];
|
|
211
|
+
for (let i = 1; i < posCount - 1; i++)
|
|
212
|
+
positions[i] = positions[i - 1] - intervals;
|
|
213
|
+
return positions.push(6), positions.reverse();
|
|
214
|
+
};
|
|
215
|
+
exports.getPositions = function(version) {
|
|
216
|
+
let coords = [], pos = exports.getRowColCoords(version), posLength = pos.length;
|
|
217
|
+
for (let i = 0; i < posLength; i++)
|
|
218
|
+
for (let j = 0; j < posLength; j++)
|
|
219
|
+
i === 0 && j === 0 || // top-left
|
|
220
|
+
i === 0 && j === posLength - 1 || // bottom-left
|
|
221
|
+
i === posLength - 1 && j === 0 || coords.push([pos[i], pos[j]]);
|
|
222
|
+
return coords;
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js
|
|
228
|
+
var require_finder_pattern = __commonJS({
|
|
229
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js"(exports) {
|
|
230
|
+
var getSymbolSize = require_utils().getSymbolSize, FINDER_PATTERN_SIZE = 7;
|
|
231
|
+
exports.getPositions = function(version) {
|
|
232
|
+
let size = getSymbolSize(version);
|
|
233
|
+
return [
|
|
234
|
+
// top-left
|
|
235
|
+
[0, 0],
|
|
236
|
+
// top-right
|
|
237
|
+
[size - FINDER_PATTERN_SIZE, 0],
|
|
238
|
+
// bottom-left
|
|
239
|
+
[0, size - FINDER_PATTERN_SIZE]
|
|
240
|
+
];
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js
|
|
246
|
+
var require_mask_pattern = __commonJS({
|
|
247
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js"(exports) {
|
|
248
|
+
exports.Patterns = {
|
|
249
|
+
PATTERN000: 0,
|
|
250
|
+
PATTERN001: 1,
|
|
251
|
+
PATTERN010: 2,
|
|
252
|
+
PATTERN011: 3,
|
|
253
|
+
PATTERN100: 4,
|
|
254
|
+
PATTERN101: 5,
|
|
255
|
+
PATTERN110: 6,
|
|
256
|
+
PATTERN111: 7
|
|
257
|
+
};
|
|
258
|
+
var PenaltyScores = {
|
|
259
|
+
N1: 3,
|
|
260
|
+
N2: 3,
|
|
261
|
+
N3: 40,
|
|
262
|
+
N4: 10
|
|
263
|
+
};
|
|
264
|
+
exports.isValid = function(mask) {
|
|
265
|
+
return mask != null && mask !== "" && !isNaN(mask) && mask >= 0 && mask <= 7;
|
|
266
|
+
};
|
|
267
|
+
exports.from = function(value) {
|
|
268
|
+
return exports.isValid(value) ? parseInt(value, 10) : void 0;
|
|
269
|
+
};
|
|
270
|
+
exports.getPenaltyN1 = function(data) {
|
|
271
|
+
let size = data.size, points = 0, sameCountCol = 0, sameCountRow = 0, lastCol = null, lastRow = null;
|
|
272
|
+
for (let row = 0; row < size; row++) {
|
|
273
|
+
sameCountCol = sameCountRow = 0, lastCol = lastRow = null;
|
|
274
|
+
for (let col = 0; col < size; col++) {
|
|
275
|
+
let module2 = data.get(row, col);
|
|
276
|
+
module2 === lastCol ? sameCountCol++ : (sameCountCol >= 5 && (points += PenaltyScores.N1 + (sameCountCol - 5)), lastCol = module2, sameCountCol = 1), module2 = data.get(col, row), module2 === lastRow ? sameCountRow++ : (sameCountRow >= 5 && (points += PenaltyScores.N1 + (sameCountRow - 5)), lastRow = module2, sameCountRow = 1);
|
|
277
|
+
}
|
|
278
|
+
sameCountCol >= 5 && (points += PenaltyScores.N1 + (sameCountCol - 5)), sameCountRow >= 5 && (points += PenaltyScores.N1 + (sameCountRow - 5));
|
|
279
|
+
}
|
|
280
|
+
return points;
|
|
281
|
+
};
|
|
282
|
+
exports.getPenaltyN2 = function(data) {
|
|
283
|
+
let size = data.size, points = 0;
|
|
284
|
+
for (let row = 0; row < size - 1; row++)
|
|
285
|
+
for (let col = 0; col < size - 1; col++) {
|
|
286
|
+
let last = data.get(row, col) + data.get(row, col + 1) + data.get(row + 1, col) + data.get(row + 1, col + 1);
|
|
287
|
+
(last === 4 || last === 0) && points++;
|
|
288
|
+
}
|
|
289
|
+
return points * PenaltyScores.N2;
|
|
290
|
+
};
|
|
291
|
+
exports.getPenaltyN3 = function(data) {
|
|
292
|
+
let size = data.size, points = 0, bitsCol = 0, bitsRow = 0;
|
|
293
|
+
for (let row = 0; row < size; row++) {
|
|
294
|
+
bitsCol = bitsRow = 0;
|
|
295
|
+
for (let col = 0; col < size; col++)
|
|
296
|
+
bitsCol = bitsCol << 1 & 2047 | data.get(row, col), col >= 10 && (bitsCol === 1488 || bitsCol === 93) && points++, bitsRow = bitsRow << 1 & 2047 | data.get(col, row), col >= 10 && (bitsRow === 1488 || bitsRow === 93) && points++;
|
|
297
|
+
}
|
|
298
|
+
return points * PenaltyScores.N3;
|
|
299
|
+
};
|
|
300
|
+
exports.getPenaltyN4 = function(data) {
|
|
301
|
+
let darkCount = 0, modulesCount = data.data.length;
|
|
302
|
+
for (let i = 0; i < modulesCount; i++) darkCount += data.data[i];
|
|
303
|
+
return Math.abs(Math.ceil(darkCount * 100 / modulesCount / 5) - 10) * PenaltyScores.N4;
|
|
304
|
+
};
|
|
305
|
+
function getMaskAt(maskPattern, i, j) {
|
|
306
|
+
switch (maskPattern) {
|
|
307
|
+
case exports.Patterns.PATTERN000:
|
|
308
|
+
return (i + j) % 2 === 0;
|
|
309
|
+
case exports.Patterns.PATTERN001:
|
|
310
|
+
return i % 2 === 0;
|
|
311
|
+
case exports.Patterns.PATTERN010:
|
|
312
|
+
return j % 3 === 0;
|
|
313
|
+
case exports.Patterns.PATTERN011:
|
|
314
|
+
return (i + j) % 3 === 0;
|
|
315
|
+
case exports.Patterns.PATTERN100:
|
|
316
|
+
return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0;
|
|
317
|
+
case exports.Patterns.PATTERN101:
|
|
318
|
+
return i * j % 2 + i * j % 3 === 0;
|
|
319
|
+
case exports.Patterns.PATTERN110:
|
|
320
|
+
return (i * j % 2 + i * j % 3) % 2 === 0;
|
|
321
|
+
case exports.Patterns.PATTERN111:
|
|
322
|
+
return (i * j % 3 + (i + j) % 2) % 2 === 0;
|
|
323
|
+
default:
|
|
324
|
+
throw new Error("bad maskPattern:" + maskPattern);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
exports.applyMask = function(pattern, data) {
|
|
328
|
+
let size = data.size;
|
|
329
|
+
for (let col = 0; col < size; col++)
|
|
330
|
+
for (let row = 0; row < size; row++)
|
|
331
|
+
data.isReserved(row, col) || data.xor(row, col, getMaskAt(pattern, row, col));
|
|
332
|
+
};
|
|
333
|
+
exports.getBestMask = function(data, setupFormatFunc) {
|
|
334
|
+
let numPatterns = Object.keys(exports.Patterns).length, bestPattern = 0, lowerPenalty = 1 / 0;
|
|
335
|
+
for (let p = 0; p < numPatterns; p++) {
|
|
336
|
+
setupFormatFunc(p), exports.applyMask(p, data);
|
|
337
|
+
let penalty = exports.getPenaltyN1(data) + exports.getPenaltyN2(data) + exports.getPenaltyN3(data) + exports.getPenaltyN4(data);
|
|
338
|
+
exports.applyMask(p, data), penalty < lowerPenalty && (lowerPenalty = penalty, bestPattern = p);
|
|
339
|
+
}
|
|
340
|
+
return bestPattern;
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js
|
|
346
|
+
var require_error_correction_code = __commonJS({
|
|
347
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js"(exports) {
|
|
348
|
+
var ECLevel = require_error_correction_level(), EC_BLOCKS_TABLE = [
|
|
349
|
+
// L M Q H
|
|
350
|
+
1,
|
|
351
|
+
1,
|
|
352
|
+
1,
|
|
353
|
+
1,
|
|
354
|
+
1,
|
|
355
|
+
1,
|
|
356
|
+
1,
|
|
357
|
+
1,
|
|
358
|
+
1,
|
|
359
|
+
1,
|
|
360
|
+
2,
|
|
361
|
+
2,
|
|
362
|
+
1,
|
|
363
|
+
2,
|
|
364
|
+
2,
|
|
365
|
+
4,
|
|
366
|
+
1,
|
|
367
|
+
2,
|
|
368
|
+
4,
|
|
369
|
+
4,
|
|
370
|
+
2,
|
|
371
|
+
4,
|
|
372
|
+
4,
|
|
373
|
+
4,
|
|
374
|
+
2,
|
|
375
|
+
4,
|
|
376
|
+
6,
|
|
377
|
+
5,
|
|
378
|
+
2,
|
|
379
|
+
4,
|
|
380
|
+
6,
|
|
381
|
+
6,
|
|
382
|
+
2,
|
|
383
|
+
5,
|
|
384
|
+
8,
|
|
385
|
+
8,
|
|
386
|
+
4,
|
|
387
|
+
5,
|
|
388
|
+
8,
|
|
389
|
+
8,
|
|
390
|
+
4,
|
|
391
|
+
5,
|
|
392
|
+
8,
|
|
393
|
+
11,
|
|
394
|
+
4,
|
|
395
|
+
8,
|
|
396
|
+
10,
|
|
397
|
+
11,
|
|
398
|
+
4,
|
|
399
|
+
9,
|
|
400
|
+
12,
|
|
401
|
+
16,
|
|
402
|
+
4,
|
|
403
|
+
9,
|
|
404
|
+
16,
|
|
405
|
+
16,
|
|
406
|
+
6,
|
|
407
|
+
10,
|
|
408
|
+
12,
|
|
409
|
+
18,
|
|
410
|
+
6,
|
|
411
|
+
10,
|
|
412
|
+
17,
|
|
413
|
+
16,
|
|
414
|
+
6,
|
|
415
|
+
11,
|
|
416
|
+
16,
|
|
417
|
+
19,
|
|
418
|
+
6,
|
|
419
|
+
13,
|
|
420
|
+
18,
|
|
421
|
+
21,
|
|
422
|
+
7,
|
|
423
|
+
14,
|
|
424
|
+
21,
|
|
425
|
+
25,
|
|
426
|
+
8,
|
|
427
|
+
16,
|
|
428
|
+
20,
|
|
429
|
+
25,
|
|
430
|
+
8,
|
|
431
|
+
17,
|
|
432
|
+
23,
|
|
433
|
+
25,
|
|
434
|
+
9,
|
|
435
|
+
17,
|
|
436
|
+
23,
|
|
437
|
+
34,
|
|
438
|
+
9,
|
|
439
|
+
18,
|
|
440
|
+
25,
|
|
441
|
+
30,
|
|
442
|
+
10,
|
|
443
|
+
20,
|
|
444
|
+
27,
|
|
445
|
+
32,
|
|
446
|
+
12,
|
|
447
|
+
21,
|
|
448
|
+
29,
|
|
449
|
+
35,
|
|
450
|
+
12,
|
|
451
|
+
23,
|
|
452
|
+
34,
|
|
453
|
+
37,
|
|
454
|
+
12,
|
|
455
|
+
25,
|
|
456
|
+
34,
|
|
457
|
+
40,
|
|
458
|
+
13,
|
|
459
|
+
26,
|
|
460
|
+
35,
|
|
461
|
+
42,
|
|
462
|
+
14,
|
|
463
|
+
28,
|
|
464
|
+
38,
|
|
465
|
+
45,
|
|
466
|
+
15,
|
|
467
|
+
29,
|
|
468
|
+
40,
|
|
469
|
+
48,
|
|
470
|
+
16,
|
|
471
|
+
31,
|
|
472
|
+
43,
|
|
473
|
+
51,
|
|
474
|
+
17,
|
|
475
|
+
33,
|
|
476
|
+
45,
|
|
477
|
+
54,
|
|
478
|
+
18,
|
|
479
|
+
35,
|
|
480
|
+
48,
|
|
481
|
+
57,
|
|
482
|
+
19,
|
|
483
|
+
37,
|
|
484
|
+
51,
|
|
485
|
+
60,
|
|
486
|
+
19,
|
|
487
|
+
38,
|
|
488
|
+
53,
|
|
489
|
+
63,
|
|
490
|
+
20,
|
|
491
|
+
40,
|
|
492
|
+
56,
|
|
493
|
+
66,
|
|
494
|
+
21,
|
|
495
|
+
43,
|
|
496
|
+
59,
|
|
497
|
+
70,
|
|
498
|
+
22,
|
|
499
|
+
45,
|
|
500
|
+
62,
|
|
501
|
+
74,
|
|
502
|
+
24,
|
|
503
|
+
47,
|
|
504
|
+
65,
|
|
505
|
+
77,
|
|
506
|
+
25,
|
|
507
|
+
49,
|
|
508
|
+
68,
|
|
509
|
+
81
|
|
510
|
+
], EC_CODEWORDS_TABLE = [
|
|
511
|
+
// L M Q H
|
|
512
|
+
7,
|
|
513
|
+
10,
|
|
514
|
+
13,
|
|
515
|
+
17,
|
|
516
|
+
10,
|
|
517
|
+
16,
|
|
518
|
+
22,
|
|
519
|
+
28,
|
|
520
|
+
15,
|
|
521
|
+
26,
|
|
522
|
+
36,
|
|
523
|
+
44,
|
|
524
|
+
20,
|
|
525
|
+
36,
|
|
526
|
+
52,
|
|
527
|
+
64,
|
|
528
|
+
26,
|
|
529
|
+
48,
|
|
530
|
+
72,
|
|
531
|
+
88,
|
|
532
|
+
36,
|
|
533
|
+
64,
|
|
534
|
+
96,
|
|
535
|
+
112,
|
|
536
|
+
40,
|
|
537
|
+
72,
|
|
538
|
+
108,
|
|
539
|
+
130,
|
|
540
|
+
48,
|
|
541
|
+
88,
|
|
542
|
+
132,
|
|
543
|
+
156,
|
|
544
|
+
60,
|
|
545
|
+
110,
|
|
546
|
+
160,
|
|
547
|
+
192,
|
|
548
|
+
72,
|
|
549
|
+
130,
|
|
550
|
+
192,
|
|
551
|
+
224,
|
|
552
|
+
80,
|
|
553
|
+
150,
|
|
554
|
+
224,
|
|
555
|
+
264,
|
|
556
|
+
96,
|
|
557
|
+
176,
|
|
558
|
+
260,
|
|
559
|
+
308,
|
|
560
|
+
104,
|
|
561
|
+
198,
|
|
562
|
+
288,
|
|
563
|
+
352,
|
|
564
|
+
120,
|
|
565
|
+
216,
|
|
566
|
+
320,
|
|
567
|
+
384,
|
|
568
|
+
132,
|
|
569
|
+
240,
|
|
570
|
+
360,
|
|
571
|
+
432,
|
|
572
|
+
144,
|
|
573
|
+
280,
|
|
574
|
+
408,
|
|
575
|
+
480,
|
|
576
|
+
168,
|
|
577
|
+
308,
|
|
578
|
+
448,
|
|
579
|
+
532,
|
|
580
|
+
180,
|
|
581
|
+
338,
|
|
582
|
+
504,
|
|
583
|
+
588,
|
|
584
|
+
196,
|
|
585
|
+
364,
|
|
586
|
+
546,
|
|
587
|
+
650,
|
|
588
|
+
224,
|
|
589
|
+
416,
|
|
590
|
+
600,
|
|
591
|
+
700,
|
|
592
|
+
224,
|
|
593
|
+
442,
|
|
594
|
+
644,
|
|
595
|
+
750,
|
|
596
|
+
252,
|
|
597
|
+
476,
|
|
598
|
+
690,
|
|
599
|
+
816,
|
|
600
|
+
270,
|
|
601
|
+
504,
|
|
602
|
+
750,
|
|
603
|
+
900,
|
|
604
|
+
300,
|
|
605
|
+
560,
|
|
606
|
+
810,
|
|
607
|
+
960,
|
|
608
|
+
312,
|
|
609
|
+
588,
|
|
610
|
+
870,
|
|
611
|
+
1050,
|
|
612
|
+
336,
|
|
613
|
+
644,
|
|
614
|
+
952,
|
|
615
|
+
1110,
|
|
616
|
+
360,
|
|
617
|
+
700,
|
|
618
|
+
1020,
|
|
619
|
+
1200,
|
|
620
|
+
390,
|
|
621
|
+
728,
|
|
622
|
+
1050,
|
|
623
|
+
1260,
|
|
624
|
+
420,
|
|
625
|
+
784,
|
|
626
|
+
1140,
|
|
627
|
+
1350,
|
|
628
|
+
450,
|
|
629
|
+
812,
|
|
630
|
+
1200,
|
|
631
|
+
1440,
|
|
632
|
+
480,
|
|
633
|
+
868,
|
|
634
|
+
1290,
|
|
635
|
+
1530,
|
|
636
|
+
510,
|
|
637
|
+
924,
|
|
638
|
+
1350,
|
|
639
|
+
1620,
|
|
640
|
+
540,
|
|
641
|
+
980,
|
|
642
|
+
1440,
|
|
643
|
+
1710,
|
|
644
|
+
570,
|
|
645
|
+
1036,
|
|
646
|
+
1530,
|
|
647
|
+
1800,
|
|
648
|
+
570,
|
|
649
|
+
1064,
|
|
650
|
+
1590,
|
|
651
|
+
1890,
|
|
652
|
+
600,
|
|
653
|
+
1120,
|
|
654
|
+
1680,
|
|
655
|
+
1980,
|
|
656
|
+
630,
|
|
657
|
+
1204,
|
|
658
|
+
1770,
|
|
659
|
+
2100,
|
|
660
|
+
660,
|
|
661
|
+
1260,
|
|
662
|
+
1860,
|
|
663
|
+
2220,
|
|
664
|
+
720,
|
|
665
|
+
1316,
|
|
666
|
+
1950,
|
|
667
|
+
2310,
|
|
668
|
+
750,
|
|
669
|
+
1372,
|
|
670
|
+
2040,
|
|
671
|
+
2430
|
|
672
|
+
];
|
|
673
|
+
exports.getBlocksCount = function(version, errorCorrectionLevel) {
|
|
674
|
+
switch (errorCorrectionLevel) {
|
|
675
|
+
case ECLevel.L:
|
|
676
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 0];
|
|
677
|
+
case ECLevel.M:
|
|
678
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 1];
|
|
679
|
+
case ECLevel.Q:
|
|
680
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 2];
|
|
681
|
+
case ECLevel.H:
|
|
682
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 3];
|
|
683
|
+
default:
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
exports.getTotalCodewordsCount = function(version, errorCorrectionLevel) {
|
|
688
|
+
switch (errorCorrectionLevel) {
|
|
689
|
+
case ECLevel.L:
|
|
690
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0];
|
|
691
|
+
case ECLevel.M:
|
|
692
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1];
|
|
693
|
+
case ECLevel.Q:
|
|
694
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2];
|
|
695
|
+
case ECLevel.H:
|
|
696
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3];
|
|
697
|
+
default:
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
|
|
704
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js
|
|
705
|
+
var require_galois_field = __commonJS({
|
|
706
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js"(exports) {
|
|
707
|
+
var EXP_TABLE = new Uint8Array(512), LOG_TABLE = new Uint8Array(256);
|
|
708
|
+
(function() {
|
|
709
|
+
let x = 1;
|
|
710
|
+
for (let i = 0; i < 255; i++)
|
|
711
|
+
EXP_TABLE[i] = x, LOG_TABLE[x] = i, x <<= 1, x & 256 && (x ^= 285);
|
|
712
|
+
for (let i = 255; i < 512; i++)
|
|
713
|
+
EXP_TABLE[i] = EXP_TABLE[i - 255];
|
|
714
|
+
})();
|
|
715
|
+
exports.log = function(n) {
|
|
716
|
+
if (n < 1) throw new Error("log(" + n + ")");
|
|
717
|
+
return LOG_TABLE[n];
|
|
718
|
+
};
|
|
719
|
+
exports.exp = function(n) {
|
|
720
|
+
return EXP_TABLE[n];
|
|
721
|
+
};
|
|
722
|
+
exports.mul = function(x, y) {
|
|
723
|
+
return x === 0 || y === 0 ? 0 : EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]];
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
|
|
728
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js
|
|
729
|
+
var require_polynomial = __commonJS({
|
|
730
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js"(exports) {
|
|
731
|
+
var GF = require_galois_field();
|
|
732
|
+
exports.mul = function(p1, p2) {
|
|
733
|
+
let coeff = new Uint8Array(p1.length + p2.length - 1);
|
|
734
|
+
for (let i = 0; i < p1.length; i++)
|
|
735
|
+
for (let j = 0; j < p2.length; j++)
|
|
736
|
+
coeff[i + j] ^= GF.mul(p1[i], p2[j]);
|
|
737
|
+
return coeff;
|
|
738
|
+
};
|
|
739
|
+
exports.mod = function(divident, divisor) {
|
|
740
|
+
let result = new Uint8Array(divident);
|
|
741
|
+
for (; result.length - divisor.length >= 0; ) {
|
|
742
|
+
let coeff = result[0];
|
|
743
|
+
for (let i = 0; i < divisor.length; i++)
|
|
744
|
+
result[i] ^= GF.mul(divisor[i], coeff);
|
|
745
|
+
let offset = 0;
|
|
746
|
+
for (; offset < result.length && result[offset] === 0; ) offset++;
|
|
747
|
+
result = result.slice(offset);
|
|
748
|
+
}
|
|
749
|
+
return result;
|
|
750
|
+
};
|
|
751
|
+
exports.generateECPolynomial = function(degree) {
|
|
752
|
+
let poly = new Uint8Array([1]);
|
|
753
|
+
for (let i = 0; i < degree; i++)
|
|
754
|
+
poly = exports.mul(poly, new Uint8Array([1, GF.exp(i)]));
|
|
755
|
+
return poly;
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
|
|
760
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js
|
|
761
|
+
var require_reed_solomon_encoder = __commonJS({
|
|
762
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js"(exports, module) {
|
|
763
|
+
var Polynomial = require_polynomial();
|
|
764
|
+
function ReedSolomonEncoder(degree) {
|
|
765
|
+
this.genPoly = void 0, this.degree = degree, this.degree && this.initialize(this.degree);
|
|
766
|
+
}
|
|
767
|
+
ReedSolomonEncoder.prototype.initialize = function(degree) {
|
|
768
|
+
this.degree = degree, this.genPoly = Polynomial.generateECPolynomial(this.degree);
|
|
769
|
+
};
|
|
770
|
+
ReedSolomonEncoder.prototype.encode = function(data) {
|
|
771
|
+
if (!this.genPoly)
|
|
772
|
+
throw new Error("Encoder not initialized");
|
|
773
|
+
let paddedData = new Uint8Array(data.length + this.degree);
|
|
774
|
+
paddedData.set(data);
|
|
775
|
+
let remainder = Polynomial.mod(paddedData, this.genPoly), start = this.degree - remainder.length;
|
|
776
|
+
if (start > 0) {
|
|
777
|
+
let buff = new Uint8Array(this.degree);
|
|
778
|
+
return buff.set(remainder, start), buff;
|
|
779
|
+
}
|
|
780
|
+
return remainder;
|
|
781
|
+
};
|
|
782
|
+
module.exports = ReedSolomonEncoder;
|
|
783
|
+
}
|
|
784
|
+
});
|
|
785
|
+
|
|
786
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js
|
|
787
|
+
var require_version_check = __commonJS({
|
|
788
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js"(exports) {
|
|
789
|
+
exports.isValid = function(version) {
|
|
790
|
+
return !isNaN(version) && version >= 1 && version <= 40;
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
|
|
795
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js
|
|
796
|
+
var require_regex = __commonJS({
|
|
797
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js"(exports) {
|
|
798
|
+
var numeric = "[0-9]+", alphanumeric = "[A-Z $%*+\\-./:]+", kanji = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";
|
|
799
|
+
kanji = kanji.replace(/u/g, "\\u");
|
|
800
|
+
var byte = "(?:(?![A-Z0-9 $%*+\\-./:]|" + kanji + `)(?:.|[\r
|
|
801
|
+
]))+`;
|
|
802
|
+
exports.KANJI = new RegExp(kanji, "g");
|
|
803
|
+
exports.BYTE_KANJI = new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g");
|
|
804
|
+
exports.BYTE = new RegExp(byte, "g");
|
|
805
|
+
exports.NUMERIC = new RegExp(numeric, "g");
|
|
806
|
+
exports.ALPHANUMERIC = new RegExp(alphanumeric, "g");
|
|
807
|
+
var TEST_KANJI = new RegExp("^" + kanji + "$"), TEST_NUMERIC = new RegExp("^" + numeric + "$"), TEST_ALPHANUMERIC = new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
|
|
808
|
+
exports.testKanji = function(str) {
|
|
809
|
+
return TEST_KANJI.test(str);
|
|
810
|
+
};
|
|
811
|
+
exports.testNumeric = function(str) {
|
|
812
|
+
return TEST_NUMERIC.test(str);
|
|
813
|
+
};
|
|
814
|
+
exports.testAlphanumeric = function(str) {
|
|
815
|
+
return TEST_ALPHANUMERIC.test(str);
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
|
|
820
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js
|
|
821
|
+
var require_mode = __commonJS({
|
|
822
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"(exports) {
|
|
823
|
+
var VersionCheck = require_version_check(), Regex = require_regex();
|
|
824
|
+
exports.NUMERIC = {
|
|
825
|
+
id: "Numeric",
|
|
826
|
+
bit: 1,
|
|
827
|
+
ccBits: [10, 12, 14]
|
|
828
|
+
};
|
|
829
|
+
exports.ALPHANUMERIC = {
|
|
830
|
+
id: "Alphanumeric",
|
|
831
|
+
bit: 2,
|
|
832
|
+
ccBits: [9, 11, 13]
|
|
833
|
+
};
|
|
834
|
+
exports.BYTE = {
|
|
835
|
+
id: "Byte",
|
|
836
|
+
bit: 4,
|
|
837
|
+
ccBits: [8, 16, 16]
|
|
838
|
+
};
|
|
839
|
+
exports.KANJI = {
|
|
840
|
+
id: "Kanji",
|
|
841
|
+
bit: 8,
|
|
842
|
+
ccBits: [8, 10, 12]
|
|
843
|
+
};
|
|
844
|
+
exports.MIXED = {
|
|
845
|
+
bit: -1
|
|
846
|
+
};
|
|
847
|
+
exports.getCharCountIndicator = function(mode, version) {
|
|
848
|
+
if (!mode.ccBits) throw new Error("Invalid mode: " + mode);
|
|
849
|
+
if (!VersionCheck.isValid(version))
|
|
850
|
+
throw new Error("Invalid version: " + version);
|
|
851
|
+
return version >= 1 && version < 10 ? mode.ccBits[0] : version < 27 ? mode.ccBits[1] : mode.ccBits[2];
|
|
852
|
+
};
|
|
853
|
+
exports.getBestModeForData = function(dataStr) {
|
|
854
|
+
return Regex.testNumeric(dataStr) ? exports.NUMERIC : Regex.testAlphanumeric(dataStr) ? exports.ALPHANUMERIC : Regex.testKanji(dataStr) ? exports.KANJI : exports.BYTE;
|
|
855
|
+
};
|
|
856
|
+
exports.toString = function(mode) {
|
|
857
|
+
if (mode && mode.id) return mode.id;
|
|
858
|
+
throw new Error("Invalid mode");
|
|
859
|
+
};
|
|
860
|
+
exports.isValid = function(mode) {
|
|
861
|
+
return mode && mode.bit && mode.ccBits;
|
|
862
|
+
};
|
|
863
|
+
function fromString(string) {
|
|
864
|
+
if (typeof string != "string")
|
|
865
|
+
throw new Error("Param is not a string");
|
|
866
|
+
switch (string.toLowerCase()) {
|
|
867
|
+
case "numeric":
|
|
868
|
+
return exports.NUMERIC;
|
|
869
|
+
case "alphanumeric":
|
|
870
|
+
return exports.ALPHANUMERIC;
|
|
871
|
+
case "kanji":
|
|
872
|
+
return exports.KANJI;
|
|
873
|
+
case "byte":
|
|
874
|
+
return exports.BYTE;
|
|
875
|
+
default:
|
|
876
|
+
throw new Error("Unknown mode: " + string);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
exports.from = function(value, defaultValue) {
|
|
880
|
+
if (exports.isValid(value))
|
|
881
|
+
return value;
|
|
882
|
+
try {
|
|
883
|
+
return fromString(value);
|
|
884
|
+
} catch {
|
|
885
|
+
return defaultValue;
|
|
886
|
+
}
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
});
|
|
890
|
+
|
|
891
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js
|
|
892
|
+
var require_version = __commonJS({
|
|
893
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js"(exports) {
|
|
894
|
+
var Utils = require_utils(), ECCode = require_error_correction_code(), ECLevel = require_error_correction_level(), Mode = require_mode(), VersionCheck = require_version_check(), G18 = 7973, G18_BCH = Utils.getBCHDigit(G18);
|
|
895
|
+
function getBestVersionForDataLength(mode, length, errorCorrectionLevel) {
|
|
896
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++)
|
|
897
|
+
if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode))
|
|
898
|
+
return currentVersion;
|
|
899
|
+
}
|
|
900
|
+
function getReservedBitsCount(mode, version) {
|
|
901
|
+
return Mode.getCharCountIndicator(mode, version) + 4;
|
|
902
|
+
}
|
|
903
|
+
function getTotalBitsFromDataArray(segments, version) {
|
|
904
|
+
let totalBits = 0;
|
|
905
|
+
return segments.forEach(function(data) {
|
|
906
|
+
let reservedBits = getReservedBitsCount(data.mode, version);
|
|
907
|
+
totalBits += reservedBits + data.getBitsLength();
|
|
908
|
+
}), totalBits;
|
|
909
|
+
}
|
|
910
|
+
function getBestVersionForMixedData(segments, errorCorrectionLevel) {
|
|
911
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++)
|
|
912
|
+
if (getTotalBitsFromDataArray(segments, currentVersion) <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED))
|
|
913
|
+
return currentVersion;
|
|
914
|
+
}
|
|
915
|
+
exports.from = function(value, defaultValue) {
|
|
916
|
+
return VersionCheck.isValid(value) ? parseInt(value, 10) : defaultValue;
|
|
917
|
+
};
|
|
918
|
+
exports.getCapacity = function(version, errorCorrectionLevel, mode) {
|
|
919
|
+
if (!VersionCheck.isValid(version))
|
|
920
|
+
throw new Error("Invalid QR Code version");
|
|
921
|
+
typeof mode > "u" && (mode = Mode.BYTE);
|
|
922
|
+
let totalCodewords = Utils.getSymbolTotalCodewords(version), ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel), dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
|
|
923
|
+
if (mode === Mode.MIXED) return dataTotalCodewordsBits;
|
|
924
|
+
let usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version);
|
|
925
|
+
switch (mode) {
|
|
926
|
+
case Mode.NUMERIC:
|
|
927
|
+
return Math.floor(usableBits / 10 * 3);
|
|
928
|
+
case Mode.ALPHANUMERIC:
|
|
929
|
+
return Math.floor(usableBits / 11 * 2);
|
|
930
|
+
case Mode.KANJI:
|
|
931
|
+
return Math.floor(usableBits / 13);
|
|
932
|
+
case Mode.BYTE:
|
|
933
|
+
default:
|
|
934
|
+
return Math.floor(usableBits / 8);
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
exports.getBestVersionForData = function(data, errorCorrectionLevel) {
|
|
938
|
+
let seg, ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M);
|
|
939
|
+
if (Array.isArray(data)) {
|
|
940
|
+
if (data.length > 1)
|
|
941
|
+
return getBestVersionForMixedData(data, ecl);
|
|
942
|
+
if (data.length === 0)
|
|
943
|
+
return 1;
|
|
944
|
+
seg = data[0];
|
|
945
|
+
} else
|
|
946
|
+
seg = data;
|
|
947
|
+
return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl);
|
|
948
|
+
};
|
|
949
|
+
exports.getEncodedBits = function(version) {
|
|
950
|
+
if (!VersionCheck.isValid(version) || version < 7)
|
|
951
|
+
throw new Error("Invalid QR Code version");
|
|
952
|
+
let d = version << 12;
|
|
953
|
+
for (; Utils.getBCHDigit(d) - G18_BCH >= 0; )
|
|
954
|
+
d ^= G18 << Utils.getBCHDigit(d) - G18_BCH;
|
|
955
|
+
return version << 12 | d;
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
});
|
|
959
|
+
|
|
960
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js
|
|
961
|
+
var require_format_info = __commonJS({
|
|
962
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js"(exports) {
|
|
963
|
+
var Utils = require_utils(), G15 = 1335, G15_MASK = 21522, G15_BCH = Utils.getBCHDigit(G15);
|
|
964
|
+
exports.getEncodedBits = function(errorCorrectionLevel, mask) {
|
|
965
|
+
let data = errorCorrectionLevel.bit << 3 | mask, d = data << 10;
|
|
966
|
+
for (; Utils.getBCHDigit(d) - G15_BCH >= 0; )
|
|
967
|
+
d ^= G15 << Utils.getBCHDigit(d) - G15_BCH;
|
|
968
|
+
return (data << 10 | d) ^ G15_MASK;
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
});
|
|
972
|
+
|
|
973
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js
|
|
974
|
+
var require_numeric_data = __commonJS({
|
|
975
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js"(exports, module) {
|
|
976
|
+
var Mode = require_mode();
|
|
977
|
+
function NumericData(data) {
|
|
978
|
+
this.mode = Mode.NUMERIC, this.data = data.toString();
|
|
979
|
+
}
|
|
980
|
+
NumericData.getBitsLength = function(length) {
|
|
981
|
+
return 10 * Math.floor(length / 3) + (length % 3 ? length % 3 * 3 + 1 : 0);
|
|
982
|
+
};
|
|
983
|
+
NumericData.prototype.getLength = function() {
|
|
984
|
+
return this.data.length;
|
|
985
|
+
};
|
|
986
|
+
NumericData.prototype.getBitsLength = function() {
|
|
987
|
+
return NumericData.getBitsLength(this.data.length);
|
|
988
|
+
};
|
|
989
|
+
NumericData.prototype.write = function(bitBuffer) {
|
|
990
|
+
let i, group, value;
|
|
991
|
+
for (i = 0; i + 3 <= this.data.length; i += 3)
|
|
992
|
+
group = this.data.substr(i, 3), value = parseInt(group, 10), bitBuffer.put(value, 10);
|
|
993
|
+
let remainingNum = this.data.length - i;
|
|
994
|
+
remainingNum > 0 && (group = this.data.substr(i), value = parseInt(group, 10), bitBuffer.put(value, remainingNum * 3 + 1));
|
|
995
|
+
};
|
|
996
|
+
module.exports = NumericData;
|
|
997
|
+
}
|
|
998
|
+
});
|
|
999
|
+
|
|
1000
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js
|
|
1001
|
+
var require_alphanumeric_data = __commonJS({
|
|
1002
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js"(exports, module) {
|
|
1003
|
+
var Mode = require_mode(), ALPHA_NUM_CHARS = [
|
|
1004
|
+
"0",
|
|
1005
|
+
"1",
|
|
1006
|
+
"2",
|
|
1007
|
+
"3",
|
|
1008
|
+
"4",
|
|
1009
|
+
"5",
|
|
1010
|
+
"6",
|
|
1011
|
+
"7",
|
|
1012
|
+
"8",
|
|
1013
|
+
"9",
|
|
1014
|
+
"A",
|
|
1015
|
+
"B",
|
|
1016
|
+
"C",
|
|
1017
|
+
"D",
|
|
1018
|
+
"E",
|
|
1019
|
+
"F",
|
|
1020
|
+
"G",
|
|
1021
|
+
"H",
|
|
1022
|
+
"I",
|
|
1023
|
+
"J",
|
|
1024
|
+
"K",
|
|
1025
|
+
"L",
|
|
1026
|
+
"M",
|
|
1027
|
+
"N",
|
|
1028
|
+
"O",
|
|
1029
|
+
"P",
|
|
1030
|
+
"Q",
|
|
1031
|
+
"R",
|
|
1032
|
+
"S",
|
|
1033
|
+
"T",
|
|
1034
|
+
"U",
|
|
1035
|
+
"V",
|
|
1036
|
+
"W",
|
|
1037
|
+
"X",
|
|
1038
|
+
"Y",
|
|
1039
|
+
"Z",
|
|
1040
|
+
" ",
|
|
1041
|
+
"$",
|
|
1042
|
+
"%",
|
|
1043
|
+
"*",
|
|
1044
|
+
"+",
|
|
1045
|
+
"-",
|
|
1046
|
+
".",
|
|
1047
|
+
"/",
|
|
1048
|
+
":"
|
|
1049
|
+
];
|
|
1050
|
+
function AlphanumericData(data) {
|
|
1051
|
+
this.mode = Mode.ALPHANUMERIC, this.data = data;
|
|
1052
|
+
}
|
|
1053
|
+
AlphanumericData.getBitsLength = function(length) {
|
|
1054
|
+
return 11 * Math.floor(length / 2) + 6 * (length % 2);
|
|
1055
|
+
};
|
|
1056
|
+
AlphanumericData.prototype.getLength = function() {
|
|
1057
|
+
return this.data.length;
|
|
1058
|
+
};
|
|
1059
|
+
AlphanumericData.prototype.getBitsLength = function() {
|
|
1060
|
+
return AlphanumericData.getBitsLength(this.data.length);
|
|
1061
|
+
};
|
|
1062
|
+
AlphanumericData.prototype.write = function(bitBuffer) {
|
|
1063
|
+
let i;
|
|
1064
|
+
for (i = 0; i + 2 <= this.data.length; i += 2) {
|
|
1065
|
+
let value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45;
|
|
1066
|
+
value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1]), bitBuffer.put(value, 11);
|
|
1067
|
+
}
|
|
1068
|
+
this.data.length % 2 && bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6);
|
|
1069
|
+
};
|
|
1070
|
+
module.exports = AlphanumericData;
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1073
|
+
|
|
1074
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js
|
|
1075
|
+
var require_byte_data = __commonJS({
|
|
1076
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js"(exports, module) {
|
|
1077
|
+
var Mode = require_mode();
|
|
1078
|
+
function ByteData(data) {
|
|
1079
|
+
this.mode = Mode.BYTE, typeof data == "string" ? this.data = new TextEncoder().encode(data) : this.data = new Uint8Array(data);
|
|
1080
|
+
}
|
|
1081
|
+
ByteData.getBitsLength = function(length) {
|
|
1082
|
+
return length * 8;
|
|
1083
|
+
};
|
|
1084
|
+
ByteData.prototype.getLength = function() {
|
|
1085
|
+
return this.data.length;
|
|
1086
|
+
};
|
|
1087
|
+
ByteData.prototype.getBitsLength = function() {
|
|
1088
|
+
return ByteData.getBitsLength(this.data.length);
|
|
1089
|
+
};
|
|
1090
|
+
ByteData.prototype.write = function(bitBuffer) {
|
|
1091
|
+
for (let i = 0, l = this.data.length; i < l; i++)
|
|
1092
|
+
bitBuffer.put(this.data[i], 8);
|
|
1093
|
+
};
|
|
1094
|
+
module.exports = ByteData;
|
|
1095
|
+
}
|
|
1096
|
+
});
|
|
1097
|
+
|
|
1098
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js
|
|
1099
|
+
var require_kanji_data = __commonJS({
|
|
1100
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js"(exports, module) {
|
|
1101
|
+
var Mode = require_mode(), Utils = require_utils();
|
|
1102
|
+
function KanjiData(data) {
|
|
1103
|
+
this.mode = Mode.KANJI, this.data = data;
|
|
1104
|
+
}
|
|
1105
|
+
KanjiData.getBitsLength = function(length) {
|
|
1106
|
+
return length * 13;
|
|
1107
|
+
};
|
|
1108
|
+
KanjiData.prototype.getLength = function() {
|
|
1109
|
+
return this.data.length;
|
|
1110
|
+
};
|
|
1111
|
+
KanjiData.prototype.getBitsLength = function() {
|
|
1112
|
+
return KanjiData.getBitsLength(this.data.length);
|
|
1113
|
+
};
|
|
1114
|
+
KanjiData.prototype.write = function(bitBuffer) {
|
|
1115
|
+
let i;
|
|
1116
|
+
for (i = 0; i < this.data.length; i++) {
|
|
1117
|
+
let value = Utils.toSJIS(this.data[i]);
|
|
1118
|
+
if (value >= 33088 && value <= 40956)
|
|
1119
|
+
value -= 33088;
|
|
1120
|
+
else if (value >= 57408 && value <= 60351)
|
|
1121
|
+
value -= 49472;
|
|
1122
|
+
else
|
|
1123
|
+
throw new Error(
|
|
1124
|
+
"Invalid SJIS character: " + this.data[i] + `
|
|
1125
|
+
Make sure your charset is UTF-8`
|
|
1126
|
+
);
|
|
1127
|
+
value = (value >>> 8 & 255) * 192 + (value & 255), bitBuffer.put(value, 13);
|
|
1128
|
+
}
|
|
1129
|
+
};
|
|
1130
|
+
module.exports = KanjiData;
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1133
|
+
|
|
1134
|
+
// ../../node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js
|
|
1135
|
+
var require_dijkstra = __commonJS({
|
|
1136
|
+
"../../node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js"(exports, module) {
|
|
1137
|
+
"use strict";
|
|
1138
|
+
var dijkstra = {
|
|
1139
|
+
single_source_shortest_paths: function(graph, s, d) {
|
|
1140
|
+
var predecessors = {}, costs = {};
|
|
1141
|
+
costs[s] = 0;
|
|
1142
|
+
var open = dijkstra.PriorityQueue.make();
|
|
1143
|
+
open.push(s, 0);
|
|
1144
|
+
for (var closest, u, v, cost_of_s_to_u, adjacent_nodes, cost_of_e, cost_of_s_to_u_plus_cost_of_e, cost_of_s_to_v, first_visit; !open.empty(); ) {
|
|
1145
|
+
closest = open.pop(), u = closest.value, cost_of_s_to_u = closest.cost, adjacent_nodes = graph[u] || {};
|
|
1146
|
+
for (v in adjacent_nodes)
|
|
1147
|
+
adjacent_nodes.hasOwnProperty(v) && (cost_of_e = adjacent_nodes[v], cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e, cost_of_s_to_v = costs[v], first_visit = typeof costs[v] > "u", (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) && (costs[v] = cost_of_s_to_u_plus_cost_of_e, open.push(v, cost_of_s_to_u_plus_cost_of_e), predecessors[v] = u));
|
|
1148
|
+
}
|
|
1149
|
+
if (typeof d < "u" && typeof costs[d] > "u") {
|
|
1150
|
+
var msg = ["Could not find a path from ", s, " to ", d, "."].join("");
|
|
1151
|
+
throw new Error(msg);
|
|
1152
|
+
}
|
|
1153
|
+
return predecessors;
|
|
1154
|
+
},
|
|
1155
|
+
extract_shortest_path_from_predecessor_list: function(predecessors, d) {
|
|
1156
|
+
for (var nodes = [], u = d, predecessor; u; )
|
|
1157
|
+
nodes.push(u), predecessor = predecessors[u], u = predecessors[u];
|
|
1158
|
+
return nodes.reverse(), nodes;
|
|
1159
|
+
},
|
|
1160
|
+
find_path: function(graph, s, d) {
|
|
1161
|
+
var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
|
|
1162
|
+
return dijkstra.extract_shortest_path_from_predecessor_list(
|
|
1163
|
+
predecessors,
|
|
1164
|
+
d
|
|
1165
|
+
);
|
|
1166
|
+
},
|
|
1167
|
+
/**
|
|
1168
|
+
* A very naive priority queue implementation.
|
|
1169
|
+
*/
|
|
1170
|
+
PriorityQueue: {
|
|
1171
|
+
make: function(opts) {
|
|
1172
|
+
var T = dijkstra.PriorityQueue, t = {}, key;
|
|
1173
|
+
opts = opts || {};
|
|
1174
|
+
for (key in T)
|
|
1175
|
+
T.hasOwnProperty(key) && (t[key] = T[key]);
|
|
1176
|
+
return t.queue = [], t.sorter = opts.sorter || T.default_sorter, t;
|
|
1177
|
+
},
|
|
1178
|
+
default_sorter: function(a, b) {
|
|
1179
|
+
return a.cost - b.cost;
|
|
1180
|
+
},
|
|
1181
|
+
/**
|
|
1182
|
+
* Add a new item to the queue and ensure the highest priority element
|
|
1183
|
+
* is at the front of the queue.
|
|
1184
|
+
*/
|
|
1185
|
+
push: function(value, cost) {
|
|
1186
|
+
var item = { value, cost };
|
|
1187
|
+
this.queue.push(item), this.queue.sort(this.sorter);
|
|
1188
|
+
},
|
|
1189
|
+
/**
|
|
1190
|
+
* Return the highest priority element in the queue.
|
|
1191
|
+
*/
|
|
1192
|
+
pop: function() {
|
|
1193
|
+
return this.queue.shift();
|
|
1194
|
+
},
|
|
1195
|
+
empty: function() {
|
|
1196
|
+
return this.queue.length === 0;
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
};
|
|
1200
|
+
typeof module < "u" && (module.exports = dijkstra);
|
|
1201
|
+
}
|
|
1202
|
+
});
|
|
1203
|
+
|
|
1204
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js
|
|
1205
|
+
var require_segments = __commonJS({
|
|
1206
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js"(exports) {
|
|
1207
|
+
var Mode = require_mode(), NumericData = require_numeric_data(), AlphanumericData = require_alphanumeric_data(), ByteData = require_byte_data(), KanjiData = require_kanji_data(), Regex = require_regex(), Utils = require_utils(), dijkstra = require_dijkstra();
|
|
1208
|
+
function getStringByteLength(str) {
|
|
1209
|
+
return unescape(encodeURIComponent(str)).length;
|
|
1210
|
+
}
|
|
1211
|
+
function getSegments(regex, mode, str) {
|
|
1212
|
+
let segments = [], result;
|
|
1213
|
+
for (; (result = regex.exec(str)) !== null; )
|
|
1214
|
+
segments.push({
|
|
1215
|
+
data: result[0],
|
|
1216
|
+
index: result.index,
|
|
1217
|
+
mode,
|
|
1218
|
+
length: result[0].length
|
|
1219
|
+
});
|
|
1220
|
+
return segments;
|
|
1221
|
+
}
|
|
1222
|
+
function getSegmentsFromString(dataStr) {
|
|
1223
|
+
let numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr), alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr), byteSegs, kanjiSegs;
|
|
1224
|
+
return Utils.isKanjiModeEnabled() ? (byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr), kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr)) : (byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr), kanjiSegs = []), numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs).sort(function(s1, s2) {
|
|
1225
|
+
return s1.index - s2.index;
|
|
1226
|
+
}).map(function(obj) {
|
|
1227
|
+
return {
|
|
1228
|
+
data: obj.data,
|
|
1229
|
+
mode: obj.mode,
|
|
1230
|
+
length: obj.length
|
|
1231
|
+
};
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
function getSegmentBitsLength(length, mode) {
|
|
1235
|
+
switch (mode) {
|
|
1236
|
+
case Mode.NUMERIC:
|
|
1237
|
+
return NumericData.getBitsLength(length);
|
|
1238
|
+
case Mode.ALPHANUMERIC:
|
|
1239
|
+
return AlphanumericData.getBitsLength(length);
|
|
1240
|
+
case Mode.KANJI:
|
|
1241
|
+
return KanjiData.getBitsLength(length);
|
|
1242
|
+
case Mode.BYTE:
|
|
1243
|
+
return ByteData.getBitsLength(length);
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
function mergeSegments(segs) {
|
|
1247
|
+
return segs.reduce(function(acc, curr) {
|
|
1248
|
+
let prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null;
|
|
1249
|
+
return prevSeg && prevSeg.mode === curr.mode ? (acc[acc.length - 1].data += curr.data, acc) : (acc.push(curr), acc);
|
|
1250
|
+
}, []);
|
|
1251
|
+
}
|
|
1252
|
+
function buildNodes(segs) {
|
|
1253
|
+
let nodes = [];
|
|
1254
|
+
for (let i = 0; i < segs.length; i++) {
|
|
1255
|
+
let seg = segs[i];
|
|
1256
|
+
switch (seg.mode) {
|
|
1257
|
+
case Mode.NUMERIC:
|
|
1258
|
+
nodes.push([
|
|
1259
|
+
seg,
|
|
1260
|
+
{ data: seg.data, mode: Mode.ALPHANUMERIC, length: seg.length },
|
|
1261
|
+
{ data: seg.data, mode: Mode.BYTE, length: seg.length }
|
|
1262
|
+
]);
|
|
1263
|
+
break;
|
|
1264
|
+
case Mode.ALPHANUMERIC:
|
|
1265
|
+
nodes.push([
|
|
1266
|
+
seg,
|
|
1267
|
+
{ data: seg.data, mode: Mode.BYTE, length: seg.length }
|
|
1268
|
+
]);
|
|
1269
|
+
break;
|
|
1270
|
+
case Mode.KANJI:
|
|
1271
|
+
nodes.push([
|
|
1272
|
+
seg,
|
|
1273
|
+
{ data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
|
|
1274
|
+
]);
|
|
1275
|
+
break;
|
|
1276
|
+
case Mode.BYTE:
|
|
1277
|
+
nodes.push([
|
|
1278
|
+
{ data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
|
|
1279
|
+
]);
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
return nodes;
|
|
1283
|
+
}
|
|
1284
|
+
function buildGraph(nodes, version) {
|
|
1285
|
+
let table = {}, graph = { start: {} }, prevNodeIds = ["start"];
|
|
1286
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
1287
|
+
let nodeGroup = nodes[i], currentNodeIds = [];
|
|
1288
|
+
for (let j = 0; j < nodeGroup.length; j++) {
|
|
1289
|
+
let node = nodeGroup[j], key = "" + i + j;
|
|
1290
|
+
currentNodeIds.push(key), table[key] = { node, lastCount: 0 }, graph[key] = {};
|
|
1291
|
+
for (let n = 0; n < prevNodeIds.length; n++) {
|
|
1292
|
+
let prevNodeId = prevNodeIds[n];
|
|
1293
|
+
table[prevNodeId] && table[prevNodeId].node.mode === node.mode ? (graph[prevNodeId][key] = getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) - getSegmentBitsLength(table[prevNodeId].lastCount, node.mode), table[prevNodeId].lastCount += node.length) : (table[prevNodeId] && (table[prevNodeId].lastCount = node.length), graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) + 4 + Mode.getCharCountIndicator(node.mode, version));
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
prevNodeIds = currentNodeIds;
|
|
1297
|
+
}
|
|
1298
|
+
for (let n = 0; n < prevNodeIds.length; n++)
|
|
1299
|
+
graph[prevNodeIds[n]].end = 0;
|
|
1300
|
+
return { map: graph, table };
|
|
1301
|
+
}
|
|
1302
|
+
function buildSingleSegment(data, modesHint) {
|
|
1303
|
+
let mode, bestMode = Mode.getBestModeForData(data);
|
|
1304
|
+
if (mode = Mode.from(modesHint, bestMode), mode !== Mode.BYTE && mode.bit < bestMode.bit)
|
|
1305
|
+
throw new Error('"' + data + '" cannot be encoded with mode ' + Mode.toString(mode) + `.
|
|
1306
|
+
Suggested mode is: ` + Mode.toString(bestMode));
|
|
1307
|
+
switch (mode === Mode.KANJI && !Utils.isKanjiModeEnabled() && (mode = Mode.BYTE), mode) {
|
|
1308
|
+
case Mode.NUMERIC:
|
|
1309
|
+
return new NumericData(data);
|
|
1310
|
+
case Mode.ALPHANUMERIC:
|
|
1311
|
+
return new AlphanumericData(data);
|
|
1312
|
+
case Mode.KANJI:
|
|
1313
|
+
return new KanjiData(data);
|
|
1314
|
+
case Mode.BYTE:
|
|
1315
|
+
return new ByteData(data);
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
exports.fromArray = function(array) {
|
|
1319
|
+
return array.reduce(function(acc, seg) {
|
|
1320
|
+
return typeof seg == "string" ? acc.push(buildSingleSegment(seg, null)) : seg.data && acc.push(buildSingleSegment(seg.data, seg.mode)), acc;
|
|
1321
|
+
}, []);
|
|
1322
|
+
};
|
|
1323
|
+
exports.fromString = function(data, version) {
|
|
1324
|
+
let segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled()), nodes = buildNodes(segs), graph = buildGraph(nodes, version), path = dijkstra.find_path(graph.map, "start", "end"), optimizedSegs = [];
|
|
1325
|
+
for (let i = 1; i < path.length - 1; i++)
|
|
1326
|
+
optimizedSegs.push(graph.table[path[i]].node);
|
|
1327
|
+
return exports.fromArray(mergeSegments(optimizedSegs));
|
|
1328
|
+
};
|
|
1329
|
+
exports.rawSplit = function(data) {
|
|
1330
|
+
return exports.fromArray(
|
|
1331
|
+
getSegmentsFromString(data, Utils.isKanjiModeEnabled())
|
|
1332
|
+
);
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
});
|
|
1336
|
+
|
|
1337
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js
|
|
1338
|
+
var require_qrcode = __commonJS({
|
|
1339
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js"(exports) {
|
|
1340
|
+
var Utils = require_utils(), ECLevel = require_error_correction_level(), BitBuffer = require_bit_buffer(), BitMatrix = require_bit_matrix(), AlignmentPattern = require_alignment_pattern(), FinderPattern = require_finder_pattern(), MaskPattern = require_mask_pattern(), ECCode = require_error_correction_code(), ReedSolomonEncoder = require_reed_solomon_encoder(), Version = require_version(), FormatInfo = require_format_info(), Mode = require_mode(), Segments = require_segments();
|
|
1341
|
+
function setupFinderPattern(matrix, version) {
|
|
1342
|
+
let size = matrix.size, pos = FinderPattern.getPositions(version);
|
|
1343
|
+
for (let i = 0; i < pos.length; i++) {
|
|
1344
|
+
let row = pos[i][0], col = pos[i][1];
|
|
1345
|
+
for (let r = -1; r <= 7; r++)
|
|
1346
|
+
if (!(row + r <= -1 || size <= row + r))
|
|
1347
|
+
for (let c = -1; c <= 7; c++)
|
|
1348
|
+
col + c <= -1 || size <= col + c || (r >= 0 && r <= 6 && (c === 0 || c === 6) || c >= 0 && c <= 6 && (r === 0 || r === 6) || r >= 2 && r <= 4 && c >= 2 && c <= 4 ? matrix.set(row + r, col + c, !0, !0) : matrix.set(row + r, col + c, !1, !0));
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
function setupTimingPattern(matrix) {
|
|
1352
|
+
let size = matrix.size;
|
|
1353
|
+
for (let r = 8; r < size - 8; r++) {
|
|
1354
|
+
let value = r % 2 === 0;
|
|
1355
|
+
matrix.set(r, 6, value, !0), matrix.set(6, r, value, !0);
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
function setupAlignmentPattern(matrix, version) {
|
|
1359
|
+
let pos = AlignmentPattern.getPositions(version);
|
|
1360
|
+
for (let i = 0; i < pos.length; i++) {
|
|
1361
|
+
let row = pos[i][0], col = pos[i][1];
|
|
1362
|
+
for (let r = -2; r <= 2; r++)
|
|
1363
|
+
for (let c = -2; c <= 2; c++)
|
|
1364
|
+
r === -2 || r === 2 || c === -2 || c === 2 || r === 0 && c === 0 ? matrix.set(row + r, col + c, !0, !0) : matrix.set(row + r, col + c, !1, !0);
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
function setupVersionInfo(matrix, version) {
|
|
1368
|
+
let size = matrix.size, bits = Version.getEncodedBits(version), row, col, mod;
|
|
1369
|
+
for (let i = 0; i < 18; i++)
|
|
1370
|
+
row = Math.floor(i / 3), col = i % 3 + size - 8 - 3, mod = (bits >> i & 1) === 1, matrix.set(row, col, mod, !0), matrix.set(col, row, mod, !0);
|
|
1371
|
+
}
|
|
1372
|
+
function setupFormatInfo(matrix, errorCorrectionLevel, maskPattern) {
|
|
1373
|
+
let size = matrix.size, bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern), i, mod;
|
|
1374
|
+
for (i = 0; i < 15; i++)
|
|
1375
|
+
mod = (bits >> i & 1) === 1, i < 6 ? matrix.set(i, 8, mod, !0) : i < 8 ? matrix.set(i + 1, 8, mod, !0) : matrix.set(size - 15 + i, 8, mod, !0), i < 8 ? matrix.set(8, size - i - 1, mod, !0) : i < 9 ? matrix.set(8, 15 - i - 1 + 1, mod, !0) : matrix.set(8, 15 - i - 1, mod, !0);
|
|
1376
|
+
matrix.set(size - 8, 8, 1, !0);
|
|
1377
|
+
}
|
|
1378
|
+
function setupData(matrix, data) {
|
|
1379
|
+
let size = matrix.size, inc = -1, row = size - 1, bitIndex = 7, byteIndex = 0;
|
|
1380
|
+
for (let col = size - 1; col > 0; col -= 2)
|
|
1381
|
+
for (col === 6 && col--; ; ) {
|
|
1382
|
+
for (let c = 0; c < 2; c++)
|
|
1383
|
+
if (!matrix.isReserved(row, col - c)) {
|
|
1384
|
+
let dark = !1;
|
|
1385
|
+
byteIndex < data.length && (dark = (data[byteIndex] >>> bitIndex & 1) === 1), matrix.set(row, col - c, dark), bitIndex--, bitIndex === -1 && (byteIndex++, bitIndex = 7);
|
|
1386
|
+
}
|
|
1387
|
+
if (row += inc, row < 0 || size <= row) {
|
|
1388
|
+
row -= inc, inc = -inc;
|
|
1389
|
+
break;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
function createData(version, errorCorrectionLevel, segments) {
|
|
1394
|
+
let buffer = new BitBuffer();
|
|
1395
|
+
segments.forEach(function(data) {
|
|
1396
|
+
buffer.put(data.mode.bit, 4), buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version)), data.write(buffer);
|
|
1397
|
+
});
|
|
1398
|
+
let totalCodewords = Utils.getSymbolTotalCodewords(version), ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel), dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
|
|
1399
|
+
for (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits && buffer.put(0, 4); buffer.getLengthInBits() % 8 !== 0; )
|
|
1400
|
+
buffer.putBit(0);
|
|
1401
|
+
let remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8;
|
|
1402
|
+
for (let i = 0; i < remainingByte; i++)
|
|
1403
|
+
buffer.put(i % 2 ? 17 : 236, 8);
|
|
1404
|
+
return createCodewords(buffer, version, errorCorrectionLevel);
|
|
1405
|
+
}
|
|
1406
|
+
function createCodewords(bitBuffer, version, errorCorrectionLevel) {
|
|
1407
|
+
let totalCodewords = Utils.getSymbolTotalCodewords(version), ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel), dataTotalCodewords = totalCodewords - ecTotalCodewords, ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel), blocksInGroup2 = totalCodewords % ecTotalBlocks, blocksInGroup1 = ecTotalBlocks - blocksInGroup2, totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks), dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks), dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1, ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1, rs = new ReedSolomonEncoder(ecCount), offset = 0, dcData = new Array(ecTotalBlocks), ecData = new Array(ecTotalBlocks), maxDataSize = 0, buffer = new Uint8Array(bitBuffer.buffer);
|
|
1408
|
+
for (let b = 0; b < ecTotalBlocks; b++) {
|
|
1409
|
+
let dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2;
|
|
1410
|
+
dcData[b] = buffer.slice(offset, offset + dataSize), ecData[b] = rs.encode(dcData[b]), offset += dataSize, maxDataSize = Math.max(maxDataSize, dataSize);
|
|
1411
|
+
}
|
|
1412
|
+
let data = new Uint8Array(totalCodewords), index = 0, i, r;
|
|
1413
|
+
for (i = 0; i < maxDataSize; i++)
|
|
1414
|
+
for (r = 0; r < ecTotalBlocks; r++)
|
|
1415
|
+
i < dcData[r].length && (data[index++] = dcData[r][i]);
|
|
1416
|
+
for (i = 0; i < ecCount; i++)
|
|
1417
|
+
for (r = 0; r < ecTotalBlocks; r++)
|
|
1418
|
+
data[index++] = ecData[r][i];
|
|
1419
|
+
return data;
|
|
1420
|
+
}
|
|
1421
|
+
function createSymbol(data, version, errorCorrectionLevel, maskPattern) {
|
|
1422
|
+
let segments;
|
|
1423
|
+
if (Array.isArray(data))
|
|
1424
|
+
segments = Segments.fromArray(data);
|
|
1425
|
+
else if (typeof data == "string") {
|
|
1426
|
+
let estimatedVersion = version;
|
|
1427
|
+
if (!estimatedVersion) {
|
|
1428
|
+
let rawSegments = Segments.rawSplit(data);
|
|
1429
|
+
estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel);
|
|
1430
|
+
}
|
|
1431
|
+
segments = Segments.fromString(data, estimatedVersion || 40);
|
|
1432
|
+
} else
|
|
1433
|
+
throw new Error("Invalid data");
|
|
1434
|
+
let bestVersion = Version.getBestVersionForData(segments, errorCorrectionLevel);
|
|
1435
|
+
if (!bestVersion)
|
|
1436
|
+
throw new Error("The amount of data is too big to be stored in a QR Code");
|
|
1437
|
+
if (!version)
|
|
1438
|
+
version = bestVersion;
|
|
1439
|
+
else if (version < bestVersion)
|
|
1440
|
+
throw new Error(
|
|
1441
|
+
`
|
|
1442
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
1443
|
+
Minimum version required to store current data is: ` + bestVersion + `.
|
|
1444
|
+
`
|
|
1445
|
+
);
|
|
1446
|
+
let dataBits = createData(version, errorCorrectionLevel, segments), moduleCount = Utils.getSymbolSize(version), modules = new BitMatrix(moduleCount);
|
|
1447
|
+
return setupFinderPattern(modules, version), setupTimingPattern(modules), setupAlignmentPattern(modules, version), setupFormatInfo(modules, errorCorrectionLevel, 0), version >= 7 && setupVersionInfo(modules, version), setupData(modules, dataBits), isNaN(maskPattern) && (maskPattern = MaskPattern.getBestMask(
|
|
1448
|
+
modules,
|
|
1449
|
+
setupFormatInfo.bind(null, modules, errorCorrectionLevel)
|
|
1450
|
+
)), MaskPattern.applyMask(maskPattern, modules), setupFormatInfo(modules, errorCorrectionLevel, maskPattern), {
|
|
1451
|
+
modules,
|
|
1452
|
+
version,
|
|
1453
|
+
errorCorrectionLevel,
|
|
1454
|
+
maskPattern,
|
|
1455
|
+
segments
|
|
1456
|
+
};
|
|
1457
|
+
}
|
|
1458
|
+
exports.create = function(data, options) {
|
|
1459
|
+
if (typeof data > "u" || data === "")
|
|
1460
|
+
throw new Error("No input text");
|
|
1461
|
+
let errorCorrectionLevel = ECLevel.M, version, mask;
|
|
1462
|
+
return typeof options < "u" && (errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M), version = Version.from(options.version), mask = MaskPattern.from(options.maskPattern), options.toSJISFunc && Utils.setToSJISFunction(options.toSJISFunc)), createSymbol(data, version, errorCorrectionLevel, mask);
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
});
|
|
1466
|
+
|
|
1467
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js
|
|
1468
|
+
var require_utils2 = __commonJS({
|
|
1469
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js"(exports) {
|
|
1470
|
+
function hex2rgba(hex) {
|
|
1471
|
+
if (typeof hex == "number" && (hex = hex.toString()), typeof hex != "string")
|
|
1472
|
+
throw new Error("Color should be defined as hex string");
|
|
1473
|
+
let hexCode = hex.slice().replace("#", "").split("");
|
|
1474
|
+
if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8)
|
|
1475
|
+
throw new Error("Invalid hex color: " + hex);
|
|
1476
|
+
(hexCode.length === 3 || hexCode.length === 4) && (hexCode = Array.prototype.concat.apply([], hexCode.map(function(c) {
|
|
1477
|
+
return [c, c];
|
|
1478
|
+
}))), hexCode.length === 6 && hexCode.push("F", "F");
|
|
1479
|
+
let hexValue = parseInt(hexCode.join(""), 16);
|
|
1480
|
+
return {
|
|
1481
|
+
r: hexValue >> 24 & 255,
|
|
1482
|
+
g: hexValue >> 16 & 255,
|
|
1483
|
+
b: hexValue >> 8 & 255,
|
|
1484
|
+
a: hexValue & 255,
|
|
1485
|
+
hex: "#" + hexCode.slice(0, 6).join("")
|
|
1486
|
+
};
|
|
1487
|
+
}
|
|
1488
|
+
exports.getOptions = function(options) {
|
|
1489
|
+
options || (options = {}), options.color || (options.color = {});
|
|
1490
|
+
let margin = typeof options.margin > "u" || options.margin === null || options.margin < 0 ? 4 : options.margin, width = options.width && options.width >= 21 ? options.width : void 0, scale = options.scale || 4;
|
|
1491
|
+
return {
|
|
1492
|
+
width,
|
|
1493
|
+
scale: width ? 4 : scale,
|
|
1494
|
+
margin,
|
|
1495
|
+
color: {
|
|
1496
|
+
dark: hex2rgba(options.color.dark || "#000000ff"),
|
|
1497
|
+
light: hex2rgba(options.color.light || "#ffffffff")
|
|
1498
|
+
},
|
|
1499
|
+
type: options.type,
|
|
1500
|
+
rendererOpts: options.rendererOpts || {}
|
|
1501
|
+
};
|
|
1502
|
+
};
|
|
1503
|
+
exports.getScale = function(qrSize, opts) {
|
|
1504
|
+
return opts.width && opts.width >= qrSize + opts.margin * 2 ? opts.width / (qrSize + opts.margin * 2) : opts.scale;
|
|
1505
|
+
};
|
|
1506
|
+
exports.getImageWidth = function(qrSize, opts) {
|
|
1507
|
+
let scale = exports.getScale(qrSize, opts);
|
|
1508
|
+
return Math.floor((qrSize + opts.margin * 2) * scale);
|
|
1509
|
+
};
|
|
1510
|
+
exports.qrToImageData = function(imgData, qr, opts) {
|
|
1511
|
+
let size = qr.modules.size, data = qr.modules.data, scale = exports.getScale(size, opts), symbolSize = Math.floor((size + opts.margin * 2) * scale), scaledMargin = opts.margin * scale, palette = [opts.color.light, opts.color.dark];
|
|
1512
|
+
for (let i = 0; i < symbolSize; i++)
|
|
1513
|
+
for (let j = 0; j < symbolSize; j++) {
|
|
1514
|
+
let posDst = (i * symbolSize + j) * 4, pxColor = opts.color.light;
|
|
1515
|
+
if (i >= scaledMargin && j >= scaledMargin && i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) {
|
|
1516
|
+
let iSrc = Math.floor((i - scaledMargin) / scale), jSrc = Math.floor((j - scaledMargin) / scale);
|
|
1517
|
+
pxColor = palette[data[iSrc * size + jSrc] ? 1 : 0];
|
|
1518
|
+
}
|
|
1519
|
+
imgData[posDst++] = pxColor.r, imgData[posDst++] = pxColor.g, imgData[posDst++] = pxColor.b, imgData[posDst] = pxColor.a;
|
|
1520
|
+
}
|
|
1521
|
+
};
|
|
1522
|
+
}
|
|
1523
|
+
});
|
|
1524
|
+
|
|
1525
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js
|
|
1526
|
+
var require_canvas = __commonJS({
|
|
1527
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js"(exports) {
|
|
1528
|
+
var Utils = require_utils2();
|
|
1529
|
+
function clearCanvas(ctx, canvas, size) {
|
|
1530
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height), canvas.style || (canvas.style = {}), canvas.height = size, canvas.width = size, canvas.style.height = size + "px", canvas.style.width = size + "px";
|
|
1531
|
+
}
|
|
1532
|
+
function getCanvasElement() {
|
|
1533
|
+
try {
|
|
1534
|
+
return document.createElement("canvas");
|
|
1535
|
+
} catch {
|
|
1536
|
+
throw new Error("You need to specify a canvas element");
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
exports.render = function(qrData, canvas, options) {
|
|
1540
|
+
let opts = options, canvasEl = canvas;
|
|
1541
|
+
typeof opts > "u" && (!canvas || !canvas.getContext) && (opts = canvas, canvas = void 0), canvas || (canvasEl = getCanvasElement()), opts = Utils.getOptions(opts);
|
|
1542
|
+
let size = Utils.getImageWidth(qrData.modules.size, opts), ctx = canvasEl.getContext("2d"), image = ctx.createImageData(size, size);
|
|
1543
|
+
return Utils.qrToImageData(image.data, qrData, opts), clearCanvas(ctx, canvasEl, size), ctx.putImageData(image, 0, 0), canvasEl;
|
|
1544
|
+
};
|
|
1545
|
+
exports.renderToDataURL = function(qrData, canvas, options) {
|
|
1546
|
+
let opts = options;
|
|
1547
|
+
typeof opts > "u" && (!canvas || !canvas.getContext) && (opts = canvas, canvas = void 0), opts || (opts = {});
|
|
1548
|
+
let canvasEl = exports.render(qrData, canvas, opts), type = opts.type || "image/png", rendererOpts = opts.rendererOpts || {};
|
|
1549
|
+
return canvasEl.toDataURL(type, rendererOpts.quality);
|
|
1550
|
+
};
|
|
1551
|
+
}
|
|
1552
|
+
});
|
|
1553
|
+
|
|
1554
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js
|
|
1555
|
+
var require_svg_tag = __commonJS({
|
|
1556
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js"(exports) {
|
|
1557
|
+
var Utils = require_utils2();
|
|
1558
|
+
function getColorAttrib(color, attrib) {
|
|
1559
|
+
let alpha = color.a / 255, str = attrib + '="' + color.hex + '"';
|
|
1560
|
+
return alpha < 1 ? str + " " + attrib + '-opacity="' + alpha.toFixed(2).slice(1) + '"' : str;
|
|
1561
|
+
}
|
|
1562
|
+
function svgCmd(cmd, x, y) {
|
|
1563
|
+
let str = cmd + x;
|
|
1564
|
+
return typeof y < "u" && (str += " " + y), str;
|
|
1565
|
+
}
|
|
1566
|
+
function qrToPath(data, size, margin) {
|
|
1567
|
+
let path = "", moveBy = 0, newRow = !1, lineLength = 0;
|
|
1568
|
+
for (let i = 0; i < data.length; i++) {
|
|
1569
|
+
let col = Math.floor(i % size), row = Math.floor(i / size);
|
|
1570
|
+
!col && !newRow && (newRow = !0), data[i] ? (lineLength++, i > 0 && col > 0 && data[i - 1] || (path += newRow ? svgCmd("M", col + margin, 0.5 + row + margin) : svgCmd("m", moveBy, 0), moveBy = 0, newRow = !1), col + 1 < size && data[i + 1] || (path += svgCmd("h", lineLength), lineLength = 0)) : moveBy++;
|
|
1571
|
+
}
|
|
1572
|
+
return path;
|
|
1573
|
+
}
|
|
1574
|
+
exports.render = function(qrData, options, cb) {
|
|
1575
|
+
let opts = Utils.getOptions(options), size = qrData.modules.size, data = qrData.modules.data, qrcodesize = size + opts.margin * 2, bg = opts.color.light.a ? "<path " + getColorAttrib(opts.color.light, "fill") + ' d="M0 0h' + qrcodesize + "v" + qrcodesize + 'H0z"/>' : "", path = "<path " + getColorAttrib(opts.color.dark, "stroke") + ' d="' + qrToPath(data, size, opts.margin) + '"/>', viewBox = 'viewBox="0 0 ' + qrcodesize + " " + qrcodesize + '"', svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + (opts.width ? 'width="' + opts.width + '" height="' + opts.width + '" ' : "") + viewBox + ' shape-rendering="crispEdges">' + bg + path + `</svg>
|
|
1576
|
+
`;
|
|
1577
|
+
return typeof cb == "function" && cb(null, svgTag), svgTag;
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
});
|
|
1581
|
+
|
|
1582
|
+
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js
|
|
1583
|
+
var require_browser = __commonJS({
|
|
1584
|
+
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js"(exports) {
|
|
1585
|
+
var canPromise = require_can_promise(), QRCode2 = require_qrcode(), CanvasRenderer = require_canvas(), SvgRenderer = require_svg_tag();
|
|
1586
|
+
function renderCanvas(renderFunc, canvas, text, opts, cb) {
|
|
1587
|
+
let args = [].slice.call(arguments, 1), argsNum = args.length, isLastArgCb = typeof args[argsNum - 1] == "function";
|
|
1588
|
+
if (!isLastArgCb && !canPromise())
|
|
1589
|
+
throw new Error("Callback required as last argument");
|
|
1590
|
+
if (isLastArgCb) {
|
|
1591
|
+
if (argsNum < 2)
|
|
1592
|
+
throw new Error("Too few arguments provided");
|
|
1593
|
+
argsNum === 2 ? (cb = text, text = canvas, canvas = opts = void 0) : argsNum === 3 && (canvas.getContext && typeof cb > "u" ? (cb = opts, opts = void 0) : (cb = opts, opts = text, text = canvas, canvas = void 0));
|
|
1594
|
+
} else {
|
|
1595
|
+
if (argsNum < 1)
|
|
1596
|
+
throw new Error("Too few arguments provided");
|
|
1597
|
+
return argsNum === 1 ? (text = canvas, canvas = opts = void 0) : argsNum === 2 && !canvas.getContext && (opts = text, text = canvas, canvas = void 0), new Promise(function(resolve, reject) {
|
|
1598
|
+
try {
|
|
1599
|
+
let data = QRCode2.create(text, opts);
|
|
1600
|
+
resolve(renderFunc(data, canvas, opts));
|
|
1601
|
+
} catch (e) {
|
|
1602
|
+
reject(e);
|
|
1603
|
+
}
|
|
1604
|
+
});
|
|
1605
|
+
}
|
|
1606
|
+
try {
|
|
1607
|
+
let data = QRCode2.create(text, opts);
|
|
1608
|
+
cb(null, renderFunc(data, canvas, opts));
|
|
1609
|
+
} catch (e) {
|
|
1610
|
+
cb(e);
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
exports.create = QRCode2.create;
|
|
1614
|
+
exports.toCanvas = renderCanvas.bind(null, CanvasRenderer.render);
|
|
1615
|
+
exports.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL);
|
|
1616
|
+
exports.toString = renderCanvas.bind(null, function(data, _, opts) {
|
|
1617
|
+
return SvgRenderer.render(data, opts);
|
|
1618
|
+
});
|
|
1619
|
+
}
|
|
1620
|
+
});
|
|
1621
|
+
|
|
1622
|
+
// src/client.ts
|
|
1623
|
+
var import_qrcode = __toESM(require_browser(), 1), clientModuleId = "dsh-remote", localeNamespace = "dsh-remote", en = {
|
|
1624
|
+
pluginTitle: "DeepSeek Remote",
|
|
1625
|
+
pluginDescription: "Connect once. Available anytime.",
|
|
1626
|
+
expandSettings: "Show settings: {name}",
|
|
1627
|
+
collapseSettings: "Hide settings: {name}",
|
|
1628
|
+
unsaved: "Unsaved",
|
|
1629
|
+
associated: "Authorized",
|
|
1630
|
+
authorizationComplete: "Authorization complete",
|
|
1631
|
+
loadingSettings: "Loading DeepSeek Remote settings\u2026",
|
|
1632
|
+
mode: "Mode",
|
|
1633
|
+
pluginMode: "Plugin mode",
|
|
1634
|
+
host: "Host",
|
|
1635
|
+
client: "Client",
|
|
1636
|
+
authorization: "Authorization",
|
|
1637
|
+
account: "Account",
|
|
1638
|
+
hostRegistrationCode: "One-time device authorization code",
|
|
1639
|
+
ownedDeviceAuthorization: "Owned device",
|
|
1640
|
+
authorizedOn: "{role} is authorized on {serverUrl}.",
|
|
1641
|
+
readOnly: "This DSH profile does not provide writable user settings.",
|
|
1642
|
+
discard: "Discard",
|
|
1643
|
+
save: "Save",
|
|
1644
|
+
saving: "Saving\u2026",
|
|
1645
|
+
signOut: "Sign out",
|
|
1646
|
+
signingOut: "Signing out\u2026",
|
|
1647
|
+
serverUrl: "Server URL",
|
|
1648
|
+
serverUrlHint: "HTTPS origin used for account authorization and encrypted relay.",
|
|
1649
|
+
serverSaved: "Server address saved. Restart DSH to apply it.",
|
|
1650
|
+
authorizeFromRemote: "Sign in from the Remote entry in the sidebar, then return here to manage this device.",
|
|
1651
|
+
authorizationMethod: "Authorization method",
|
|
1652
|
+
accountPassword: "Account password",
|
|
1653
|
+
registrationCode: "Device authorization code",
|
|
1654
|
+
registrationCodeHint: "Generate it after signing in on the Server website. Use it once to connect this device.",
|
|
1655
|
+
accountHint: "The account must belong to the selected Server.",
|
|
1656
|
+
password: "Password",
|
|
1657
|
+
passwordHint: "Used only for this HTTPS authorization request and never saved.",
|
|
1658
|
+
modeSavedNeedsAuthorization: "Mode saved. Authorize {role} before connecting. Existing registrations were kept.",
|
|
1659
|
+
modeSavedReused: "Mode saved. Existing registration reused. Restart Harness to apply.",
|
|
1660
|
+
modeSavedOwnedRole: "Mode saved. This owned device was authorized automatically. Restart Harness to apply.",
|
|
1661
|
+
enterRegistrationCode: "Enter the device authorization code.",
|
|
1662
|
+
enterAccountPassword: "Enter the Server account and password.",
|
|
1663
|
+
associationSaved: "Associated. Restart Harness to apply.",
|
|
1664
|
+
signedOut: "Signed out. Restart Harness to disconnect this mode.",
|
|
1665
|
+
remoteRequestFailed: "Remote mode request failed.",
|
|
1666
|
+
switchTarget: "Switch Local / Remote Harness target",
|
|
1667
|
+
harnessTarget: "Harness target",
|
|
1668
|
+
close: "Close",
|
|
1669
|
+
local: "Local",
|
|
1670
|
+
remoteTarget: "Remote \xB7 {name}",
|
|
1671
|
+
thisMachineLocal: "This machine (Local)",
|
|
1672
|
+
noRemoteHosts: "No authorized remote Host for this account.",
|
|
1673
|
+
online: "Online",
|
|
1674
|
+
offline: "Offline",
|
|
1675
|
+
thisMachineHost: "This machine as Remote Host",
|
|
1676
|
+
connected: "Connected",
|
|
1677
|
+
connectedAs: "Connected as {account}",
|
|
1678
|
+
connection: "Connection",
|
|
1679
|
+
checkingConnection: "Checking connection\u2026",
|
|
1680
|
+
connecting: "Connecting",
|
|
1681
|
+
reconnecting: "Reconnecting",
|
|
1682
|
+
lastActive: "Last active: {time}",
|
|
1683
|
+
neverConnected: "No successful connection yet.",
|
|
1684
|
+
reconnect: "Reconnect",
|
|
1685
|
+
reconnectingAction: "Reconnecting\u2026",
|
|
1686
|
+
reconnectStarted: "Reconnect requested.",
|
|
1687
|
+
connectionAuthorizationExpired: "Authorization expired. Sign out and authorize this Host again.",
|
|
1688
|
+
connectionDeviceRevoked: "This Host was revoked on the Server. Sign out and authorize it again.",
|
|
1689
|
+
connectionOwnershipRequired: "The Server no longer recognizes this Host as an owned device.",
|
|
1690
|
+
connectionRateLimited: "The Server is receiving too many requests. Automatic retry will continue.",
|
|
1691
|
+
connectionVersionMismatch: "The Plugin and Server protocol versions are incompatible.",
|
|
1692
|
+
connectionInvalidResponse: "The Server returned an invalid control message.",
|
|
1693
|
+
connectionReachability: "Cannot reach the Server. Check the network and Server address.",
|
|
1694
|
+
connectionUnexpected: "The connection stopped unexpectedly. Automatic retry will continue.",
|
|
1695
|
+
hostSignInHint: "Sign in to authorize this Host on the selected Server.",
|
|
1696
|
+
checkingHost: "Checking Host registration\u2026",
|
|
1697
|
+
hostUnavailable: "Host unavailable: {error}",
|
|
1698
|
+
serverAccountEmail: "Server account email",
|
|
1699
|
+
serverAccountPassword: "Server account password",
|
|
1700
|
+
signInRegisterHost: "Sign in and register Host",
|
|
1701
|
+
signingIn: "Signing in\u2026",
|
|
1702
|
+
useRegistrationCode: "Use connection code",
|
|
1703
|
+
registering: "Registering\u2026",
|
|
1704
|
+
remoteEntry: "Remote",
|
|
1705
|
+
remoteTitle: "Open a remote workspace",
|
|
1706
|
+
remoteDescription: "Choose one of your Hosts, then select a working directory. The Harness interface stays on this device.",
|
|
1707
|
+
chooseHost: "Host",
|
|
1708
|
+
chooseDirectory: "Working directory",
|
|
1709
|
+
selectHostHint: "Select an online Host to browse its directories.",
|
|
1710
|
+
emptyDirectory: "This directory has no visible subdirectories.",
|
|
1711
|
+
openWorkspace: "Open workspace",
|
|
1712
|
+
openingWorkspace: "Opening\u2026",
|
|
1713
|
+
loadingDirectory: "Loading directories\u2026",
|
|
1714
|
+
backToHosts: "Choose another Host",
|
|
1715
|
+
currentDirectory: "Selected directory",
|
|
1716
|
+
directoryTruncated: "Only part of this directory could be shown.",
|
|
1717
|
+
pluginVersion: "Plugin {version}",
|
|
1718
|
+
harnessVersion: "Harness {version}",
|
|
1719
|
+
existingWorkspaces: "Existing workspaces",
|
|
1720
|
+
remotePathPlaceholder: "/home/user/project",
|
|
1721
|
+
remotePathHint: "Enter an absolute directory path on the selected Host.",
|
|
1722
|
+
noRemoteWorkspaces: "No remote workspaces yet. Use + to add one.",
|
|
1723
|
+
activeRemote: "{name}",
|
|
1724
|
+
exitRemote: "Exit",
|
|
1725
|
+
addRemoteWorkspace: "Add remote workspace",
|
|
1726
|
+
remoteModeLabel: "Remote mode \xB7 {name}",
|
|
1727
|
+
remoteNetworkP2p: "P2P",
|
|
1728
|
+
remoteNetworkTurn: "TURN",
|
|
1729
|
+
remoteNetworkRelay: "Relay",
|
|
1730
|
+
remoteNetworkLan: "LAN",
|
|
1731
|
+
remoteNetworkOffline: "Disconnected",
|
|
1732
|
+
remoteLinkEncrypted: "End-to-end encrypted",
|
|
1733
|
+
connectionRouteTitle: "Connection route",
|
|
1734
|
+
connectionRouteFrom: "From",
|
|
1735
|
+
connectionRouteVia: "Via",
|
|
1736
|
+
connectionRouteTo: "To",
|
|
1737
|
+
connectionRouteCurrentDevice: "This device",
|
|
1738
|
+
connectionRouteLan: "Local network",
|
|
1739
|
+
connectionRouteP2p: "Direct internet path",
|
|
1740
|
+
connectionRouteTurn: "TURN relay service",
|
|
1741
|
+
connectionRouteRelay: "Remote Server",
|
|
1742
|
+
connectionRouteHost: "Work computer running Harness",
|
|
1743
|
+
connectionRouteEncrypted: "Application data remains end-to-end encrypted along this route.",
|
|
1744
|
+
openLocalWorkspaces: "Open local workspaces",
|
|
1745
|
+
clientSignInHint: "Sign in to this Server to list your remote Hosts.",
|
|
1746
|
+
signInClient: "DeepSeek Harness Remote",
|
|
1747
|
+
signInClientDescription: "Connect once. Available anytime.",
|
|
1748
|
+
startSignIn: "Start sign-in",
|
|
1749
|
+
allowControlCurrentDevice: "Allow control of this device",
|
|
1750
|
+
exitRemoteAccount: "Sign out",
|
|
1751
|
+
scanWithZhihu: "Scan to sign in",
|
|
1752
|
+
scanLoginHint: "Authorize on your phone. This window will continue automatically.",
|
|
1753
|
+
currentServiceAddress: "Current service address:",
|
|
1754
|
+
accountPasswordLogin: "Account and password",
|
|
1755
|
+
qrLoginExpired: "This QR code expired. Refresh it to continue.",
|
|
1756
|
+
refreshQrCode: "Refresh QR code"
|
|
1757
|
+
}, zh = {
|
|
1758
|
+
pluginTitle: "DeepSeek \u8FDC\u7A0B\u8FDE\u63A5",
|
|
1759
|
+
pluginDescription: "\u4E00\u6B21\u8FDE\u63A5\uFF0C\u968F\u65F6\u53EF\u7528\u3002",
|
|
1760
|
+
expandSettings: "\u5C55\u5F00\u8BBE\u7F6E\uFF1A{name}",
|
|
1761
|
+
collapseSettings: "\u6536\u8D77\u8BBE\u7F6E\uFF1A{name}",
|
|
1762
|
+
unsaved: "\u672A\u4FDD\u5B58",
|
|
1763
|
+
associated: "\u5DF2\u6388\u6743",
|
|
1764
|
+
authorizationComplete: "\u5DF2\u5B8C\u6210\u6388\u6743",
|
|
1765
|
+
loadingSettings: "\u6B63\u5728\u52A0\u8F7D DeepSeek \u8FDC\u7A0B\u8FDE\u63A5\u8BBE\u7F6E\u2026",
|
|
1766
|
+
mode: "\u6A21\u5F0F",
|
|
1767
|
+
pluginMode: "\u63D2\u4EF6\u6A21\u5F0F",
|
|
1768
|
+
host: "\u4E3B\u673A",
|
|
1769
|
+
client: "Client",
|
|
1770
|
+
authorization: "\u6388\u6743",
|
|
1771
|
+
account: "\u8D26\u53F7",
|
|
1772
|
+
hostRegistrationCode: "\u4E00\u6B21\u6027\u8BBE\u5907\u6388\u6743\u7801",
|
|
1773
|
+
ownedDeviceAuthorization: "\u81EA\u6709\u8BBE\u5907",
|
|
1774
|
+
authorizedOn: "{role}\u5DF2\u7ECF\u5728 {serverUrl} \u5B8C\u6210\u6388\u6743\u3002",
|
|
1775
|
+
readOnly: "\u6B64 DSH profile \u4E0D\u63D0\u4F9B\u53EF\u5199\u7684\u7528\u6237\u8BBE\u7F6E\u3002",
|
|
1776
|
+
discard: "\u653E\u5F03\u4FEE\u6539",
|
|
1777
|
+
save: "\u4FDD\u5B58",
|
|
1778
|
+
saving: "\u4FDD\u5B58\u4E2D\u2026",
|
|
1779
|
+
signOut: "\u9000\u51FA\u6388\u6743",
|
|
1780
|
+
signingOut: "\u6B63\u5728\u9000\u51FA\u2026",
|
|
1781
|
+
serverUrl: "Server \u5730\u5740",
|
|
1782
|
+
serverUrlHint: "\u7528\u4E8E\u8D26\u53F7\u6388\u6743\u548C\u52A0\u5BC6\u4E2D\u7EE7\u7684 HTTPS \u5730\u5740\u3002",
|
|
1783
|
+
serverSaved: "Server \u5730\u5740\u5DF2\u4FDD\u5B58\uFF0C\u91CD\u542F DSH \u540E\u751F\u6548\u3002",
|
|
1784
|
+
authorizeFromRemote: "\u8BF7\u4ECE\u4FA7\u680F Remote \u5165\u53E3\u767B\u5F55\uFF0C\u767B\u5F55\u540E\u53EF\u5728\u8FD9\u91CC\u7BA1\u7406\u5F53\u524D\u8BBE\u5907\u3002",
|
|
1785
|
+
authorizationMethod: "\u6388\u6743\u65B9\u5F0F",
|
|
1786
|
+
accountPassword: "\u8D26\u53F7\u5BC6\u7801",
|
|
1787
|
+
registrationCode: "\u8BBE\u5907\u6388\u6743\u7801",
|
|
1788
|
+
registrationCodeHint: "\u767B\u5F55 Server \u7F51\u9875\u540E\u751F\u6210\uFF0C\u7528\u4E00\u6B21\u5373\u53EF\u8FDE\u63A5\u8FD9\u53F0\u8BBE\u5907\u3002",
|
|
1789
|
+
accountHint: "\u8D26\u53F7\u5FC5\u987B\u5C5E\u4E8E\u6240\u9009 Server\u3002",
|
|
1790
|
+
password: "\u5BC6\u7801",
|
|
1791
|
+
passwordHint: "\u4EC5\u7528\u4E8E\u672C\u6B21 HTTPS \u6388\u6743\u8BF7\u6C42\uFF0C\u4E0D\u4F1A\u4FDD\u5B58\u3002",
|
|
1792
|
+
modeSavedNeedsAuthorization: "\u6A21\u5F0F\u5DF2\u4FDD\u5B58\u3002\u8FDE\u63A5\u524D\u8BF7\u5148\u6388\u6743 {role}\uFF1B\u5DF2\u6709\u6CE8\u518C\u4FE1\u606F\u5DF2\u4FDD\u7559\u3002",
|
|
1793
|
+
modeSavedReused: "\u6A21\u5F0F\u5DF2\u4FDD\u5B58\u5E76\u590D\u7528\u5DF2\u6709\u6CE8\u518C\u4FE1\u606F\u3002\u91CD\u542F Harness \u540E\u751F\u6548\u3002",
|
|
1794
|
+
modeSavedOwnedRole: "\u6A21\u5F0F\u5DF2\u4FDD\u5B58\uFF0C\u5E76\u5DF2\u81EA\u52A8\u6388\u6743\u6B64\u81EA\u6709\u8BBE\u5907\u3002\u91CD\u542F Harness \u540E\u751F\u6548\u3002",
|
|
1795
|
+
enterRegistrationCode: "\u8BF7\u8F93\u5165\u8BBE\u5907\u6388\u6743\u7801\u3002",
|
|
1796
|
+
enterAccountPassword: "\u8BF7\u8F93\u5165 Server \u8D26\u53F7\u548C\u5BC6\u7801\u3002",
|
|
1797
|
+
associationSaved: "\u5173\u8054\u6210\u529F\u3002\u91CD\u542F Harness \u540E\u751F\u6548\u3002",
|
|
1798
|
+
signedOut: "\u5DF2\u9000\u51FA\u6388\u6743\u3002\u91CD\u542F Harness \u540E\u5C06\u65AD\u5F00\u6B64\u6A21\u5F0F\u3002",
|
|
1799
|
+
remoteRequestFailed: "\u8FDC\u7A0B\u6A21\u5F0F\u8BF7\u6C42\u5931\u8D25\u3002",
|
|
1800
|
+
switchTarget: "\u5207\u6362\u672C\u5730\u6216\u8FDC\u7A0B Harness",
|
|
1801
|
+
harnessTarget: "Harness \u76EE\u6807",
|
|
1802
|
+
close: "\u5173\u95ED",
|
|
1803
|
+
local: "\u672C\u5730",
|
|
1804
|
+
remoteTarget: "\u8FDC\u7A0B \xB7 {name}",
|
|
1805
|
+
thisMachineLocal: "\u6B64\u8BBE\u5907\uFF08\u672C\u5730\uFF09",
|
|
1806
|
+
noRemoteHosts: "\u6B64\u8D26\u53F7\u6CA1\u6709\u5DF2\u6388\u6743\u7684\u8FDC\u7A0B Host\u3002",
|
|
1807
|
+
online: "\u5728\u7EBF",
|
|
1808
|
+
offline: "\u79BB\u7EBF",
|
|
1809
|
+
thisMachineHost: "\u5C06\u6B64\u8BBE\u5907\u4F5C\u4E3A\u8FDC\u7A0B Host",
|
|
1810
|
+
connected: "\u5DF2\u8FDE\u63A5",
|
|
1811
|
+
connectedAs: "\u5DF2\u4F7F\u7528 {account} \u8FDE\u63A5",
|
|
1812
|
+
connection: "\u8FDE\u63A5\u72B6\u6001",
|
|
1813
|
+
checkingConnection: "\u6B63\u5728\u68C0\u67E5\u8FDE\u63A5\u2026",
|
|
1814
|
+
connecting: "\u6B63\u5728\u8FDE\u63A5",
|
|
1815
|
+
reconnecting: "\u6B63\u5728\u91CD\u8FDE",
|
|
1816
|
+
lastActive: "\u6700\u540E\u6D3B\u8DC3\uFF1A{time}",
|
|
1817
|
+
neverConnected: "\u5C1A\u672A\u6210\u529F\u8FDE\u63A5\u8FC7\u3002",
|
|
1818
|
+
reconnect: "\u624B\u52A8\u91CD\u8FDE",
|
|
1819
|
+
reconnectingAction: "\u6B63\u5728\u91CD\u8FDE\u2026",
|
|
1820
|
+
reconnectStarted: "\u5DF2\u53D1\u8D77\u91CD\u8FDE\u3002",
|
|
1821
|
+
connectionAuthorizationExpired: "\u6388\u6743\u5DF2\u5931\u6548\uFF0C\u8BF7\u9000\u51FA\u6388\u6743\u540E\u91CD\u65B0\u8FDE\u63A5\u6B64 Host\u3002",
|
|
1822
|
+
connectionDeviceRevoked: "\u6B64 Host \u5DF2\u5728 Server \u4E0A\u88AB\u64A4\u9500\uFF0C\u8BF7\u9000\u51FA\u6388\u6743\u540E\u91CD\u65B0\u8FDE\u63A5\u3002",
|
|
1823
|
+
connectionOwnershipRequired: "Server \u5DF2\u4E0D\u518D\u5C06\u6B64 Host \u8BC6\u522B\u4E3A\u5F53\u524D\u8D26\u53F7\u7684\u8BBE\u5907\u3002",
|
|
1824
|
+
connectionRateLimited: "Server \u8BF7\u6C42\u8FC7\u591A\uFF0C\u63D2\u4EF6\u5C06\u7EE7\u7EED\u81EA\u52A8\u91CD\u8BD5\u3002",
|
|
1825
|
+
connectionVersionMismatch: "Plugin \u4E0E Server \u7684\u534F\u8BAE\u7248\u672C\u4E0D\u517C\u5BB9\u3002",
|
|
1826
|
+
connectionInvalidResponse: "Server \u8FD4\u56DE\u4E86\u65E0\u6548\u7684\u63A7\u5236\u6D88\u606F\u3002",
|
|
1827
|
+
connectionReachability: "\u65E0\u6CD5\u8FDE\u63A5 Server\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u548C Server \u5730\u5740\u3002",
|
|
1828
|
+
connectionUnexpected: "\u8FDE\u63A5\u610F\u5916\u4E2D\u65AD\uFF0C\u63D2\u4EF6\u5C06\u7EE7\u7EED\u81EA\u52A8\u91CD\u8BD5\u3002",
|
|
1829
|
+
hostSignInHint: "\u767B\u5F55\u540E\u5728\u6240\u9009 Server \u4E0A\u6388\u6743\u6B64 Host\u3002",
|
|
1830
|
+
checkingHost: "\u6B63\u5728\u68C0\u67E5 Host \u6CE8\u518C\u72B6\u6001\u2026",
|
|
1831
|
+
hostUnavailable: "Host \u4E0D\u53EF\u7528\uFF1A{error}",
|
|
1832
|
+
serverAccountEmail: "Server \u8D26\u53F7\u90AE\u7BB1",
|
|
1833
|
+
serverAccountPassword: "Server \u8D26\u53F7\u5BC6\u7801",
|
|
1834
|
+
signInRegisterHost: "\u767B\u5F55\u5E76\u6CE8\u518C Host",
|
|
1835
|
+
signingIn: "\u6B63\u5728\u767B\u5F55\u2026",
|
|
1836
|
+
useRegistrationCode: "\u4F7F\u7528\u8FDE\u63A5\u7801",
|
|
1837
|
+
registering: "\u6B63\u5728\u6CE8\u518C\u2026",
|
|
1838
|
+
remoteEntry: "Remote",
|
|
1839
|
+
remoteTitle: "\u6253\u5F00\u8FDC\u7AEF\u5DE5\u4F5C\u533A",
|
|
1840
|
+
remoteDescription: "\u9009\u62E9\u60F3\u8981\u8FDE\u63A5\u4E3B\u673A\u548C\u5DE5\u4F5C\u76EE\u5F55\u3002",
|
|
1841
|
+
chooseHost: "\u4E3B\u673A",
|
|
1842
|
+
chooseDirectory: "\u5DE5\u4F5C\u76EE\u5F55",
|
|
1843
|
+
selectHostHint: "\u9009\u62E9\u4E00\u53F0\u5728\u7EBF\u4E3B\u673A\u4EE5\u6D4F\u89C8\u5176\u76EE\u5F55\u3002",
|
|
1844
|
+
emptyDirectory: "\u8FD9\u4E2A\u76EE\u5F55\u4E0B\u6CA1\u6709\u53EF\u89C1\u7684\u5B50\u76EE\u5F55\u3002",
|
|
1845
|
+
openWorkspace: "\u6253\u5F00\u5DE5\u4F5C\u533A",
|
|
1846
|
+
openingWorkspace: "\u6B63\u5728\u6253\u5F00\u2026",
|
|
1847
|
+
loadingDirectory: "\u6B63\u5728\u52A0\u8F7D\u76EE\u5F55\u2026",
|
|
1848
|
+
backToHosts: "\u9009\u62E9\u5176\u4ED6\u4E3B\u673A",
|
|
1849
|
+
currentDirectory: "\u5DF2\u9009\u76EE\u5F55",
|
|
1850
|
+
directoryTruncated: "\u76EE\u5F55\u5185\u5BB9\u8F83\u591A\uFF0C\u76EE\u524D\u53EA\u663E\u793A\u4E86\u4E00\u90E8\u5206\u3002",
|
|
1851
|
+
pluginVersion: "\u63D2\u4EF6 {version}",
|
|
1852
|
+
harnessVersion: "Harness {version}",
|
|
1853
|
+
existingWorkspaces: "\u5DF2\u6709\u5DE5\u4F5C\u533A",
|
|
1854
|
+
remotePathPlaceholder: "/home/user/project",
|
|
1855
|
+
remotePathHint: "\u8F93\u5165\u6240\u9009\u4E3B\u673A\u4E0A\u7684\u7EDD\u5BF9\u76EE\u5F55\u8DEF\u5F84\u3002",
|
|
1856
|
+
noRemoteWorkspaces: "\u8FD9\u53F0\u4E3B\u673A\u8FD8\u6CA1\u6709\u5DE5\u4F5C\u533A\uFF0C\u70B9\u51FB + \u6DFB\u52A0\u3002",
|
|
1857
|
+
activeRemote: "{name}",
|
|
1858
|
+
exitRemote: "\u9000\u51FA",
|
|
1859
|
+
addRemoteWorkspace: "\u6DFB\u52A0\u8FDC\u7A0B\u5DE5\u4F5C\u533A",
|
|
1860
|
+
remoteModeLabel: "\u8FDC\u7A0B\u6A21\u5F0F \xB7 {name}",
|
|
1861
|
+
remoteNetworkP2p: "P2P",
|
|
1862
|
+
remoteNetworkTurn: "TURN",
|
|
1863
|
+
remoteNetworkRelay: "\u4E2D\u7EE7",
|
|
1864
|
+
remoteNetworkLan: "\u5C40\u57DF\u7F51",
|
|
1865
|
+
remoteNetworkOffline: "\u5DF2\u65AD\u5F00",
|
|
1866
|
+
remoteLinkEncrypted: "\u7AEF\u5230\u7AEF\u52A0\u5BC6",
|
|
1867
|
+
connectionRouteTitle: "\u8FDE\u63A5\u7EBF\u8DEF",
|
|
1868
|
+
connectionRouteFrom: "\u8D77\u70B9",
|
|
1869
|
+
connectionRouteVia: "\u7ECF\u8FC7",
|
|
1870
|
+
connectionRouteTo: "\u7EC8\u70B9",
|
|
1871
|
+
connectionRouteCurrentDevice: "\u5F53\u524D\u8BBE\u5907",
|
|
1872
|
+
connectionRouteLan: "\u540C\u4E00\u5C40\u57DF\u7F51",
|
|
1873
|
+
connectionRouteP2p: "\u4E92\u8054\u7F51\u76F4\u8FDE",
|
|
1874
|
+
connectionRouteTurn: "TURN \u4E2D\u7EE7\u670D\u52A1",
|
|
1875
|
+
connectionRouteRelay: "Remote Server",
|
|
1876
|
+
connectionRouteHost: "\u8FD0\u884C Harness \u7684\u5DE5\u4F5C\u7535\u8111",
|
|
1877
|
+
connectionRouteEncrypted: "\u7EBF\u8DEF\u4E0A\u7684\u4E1A\u52A1\u6570\u636E\u4FDD\u6301\u7AEF\u5230\u7AEF\u52A0\u5BC6\u3002",
|
|
1878
|
+
openLocalWorkspaces: "\u6253\u5F00\u672C\u5730\u5DE5\u4F5C\u533A",
|
|
1879
|
+
clientSignInHint: "\u767B\u5F55 Server \u540E\u5373\u53EF\u67E5\u770B\u81EA\u5DF1\u7684\u8FDC\u7AEF\u4E3B\u673A\u3002",
|
|
1880
|
+
signInClient: "DeepSeek Harness Remote",
|
|
1881
|
+
signInClientDescription: "\u4E00\u6B21\u8FDE\u63A5\uFF0C\u968F\u65F6\u53EF\u7528\u3002",
|
|
1882
|
+
startSignIn: "\u5F00\u59CB\u767B\u5F55",
|
|
1883
|
+
allowControlCurrentDevice: "\u5141\u8BB8\u63A7\u5236\u5F53\u524D\u8BBE\u5907",
|
|
1884
|
+
exitRemoteAccount: "\u9000\u51FA",
|
|
1885
|
+
scanWithZhihu: "\u626B\u7801\u767B\u5F55",
|
|
1886
|
+
scanLoginHint: "\u8BF7\u5728\u624B\u673A\u4E0A\u5B8C\u6210\u6388\u6743\uFF0C\u6B64\u7A97\u53E3\u4F1A\u81EA\u52A8\u7EE7\u7EED\u3002",
|
|
1887
|
+
currentServiceAddress: "\u5F53\u524D\u670D\u52A1\u5730\u5740\uFF1A",
|
|
1888
|
+
accountPasswordLogin: "\u8D26\u53F7\u5BC6\u7801",
|
|
1889
|
+
qrLoginExpired: "\u4E8C\u7EF4\u7801\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u5237\u65B0\u540E\u91CD\u8BD5\u3002",
|
|
1890
|
+
refreshQrCode: "\u5237\u65B0\u4E8C\u7EF4\u7801"
|
|
1891
|
+
};
|
|
1892
|
+
function formatLocalTime(value) {
|
|
1893
|
+
let date = new Date(value);
|
|
1894
|
+
return Number.isNaN(date.getTime()) ? "\u2014" : date.toLocaleString();
|
|
1895
|
+
}
|
|
1896
|
+
function connectionErrorMessage(code, t) {
|
|
1897
|
+
return t(code === "ACCOUNT_AUTH_REQUIRED" || code === "AUTH_INVALID" || code === "TOKEN_EXPIRED" ? "connectionAuthorizationExpired" : code === "DEVICE_REVOKED" ? "connectionDeviceRevoked" : code === "DEVICE_OWNERSHIP_REQUIRED" ? "connectionOwnershipRequired" : code === "RATE_LIMITED" ? "connectionRateLimited" : code === "UNSUPPORTED_VERSION" ? "connectionVersionMismatch" : code === "INVALID_MESSAGE" ? "connectionInvalidResponse" : code === "CONNECTION_FAILED" || code === "SERVER_NOT_CONFIGURED" ? "connectionReachability" : "connectionUnexpected");
|
|
1898
|
+
}
|
|
1899
|
+
function connectionStatusLabel(status, t) {
|
|
1900
|
+
return status === void 0 ? t("checkingConnection") : status.online ? t("online") : status.reconnecting ? t(status.lastActiveAt === void 0 && status.error === void 0 ? "connecting" : "reconnecting") : t("offline");
|
|
1901
|
+
}
|
|
1902
|
+
function connectionStatusClass(status) {
|
|
1903
|
+
return status?.online ? " isOnline" : status?.reconnecting ? " isReconnecting" : status === void 0 ? "" : " isOffline";
|
|
1904
|
+
}
|
|
1905
|
+
window.__ModuleLoader__.load({
|
|
1906
|
+
id: clientModuleId,
|
|
1907
|
+
factory: (require2) => {
|
|
1908
|
+
let module = { exports: {} }, React = require2("react"), inject = ["connection", "slots", "locale"];
|
|
1909
|
+
function RemotePluginOptions(props) {
|
|
1910
|
+
let { t } = props, [open, setOpen] = React.useState(!1), [serverUrl, setServerUrl] = React.useState(""), role = "host", [registrationCode, setRegistrationCode] = React.useState(""), [associations, setAssociations] = React.useState({}), [loaded, setLoaded] = React.useState(!1), [writable, setWritable] = React.useState(!1), [busy, setBusy] = React.useState(!1), [reconnectBusy, setReconnectBusy] = React.useState(!1), [hostStatus, setHostStatus] = React.useState(void 0), [notice, setNotice] = React.useState(void 0), [error, setError] = React.useState(void 0), [settingsView, setSettingsView] = React.useState(void 0), persistedServerUrl = settingsView?.config.serverUrl ?? "https://dsh.r2049.cn", association = associations.client ?? associations.host, serverDirty = settingsView !== void 0 && serverUrl !== persistedServerUrl, draftDirty = serverDirty, applyView = (view) => {
|
|
1911
|
+
setSettingsView(view), setServerUrl(view.config.serverUrl ?? "https://dsh.r2049.cn"), setAssociations(view.associations ?? (view.association === void 0 ? {} : { host: view.association })), setWritable(view.writable), setLoaded(!0);
|
|
1912
|
+
}, load = async () => {
|
|
1913
|
+
let [view, status] = await Promise.all([
|
|
1914
|
+
props.control("settings.get"),
|
|
1915
|
+
props.control("status").catch(() => {
|
|
1916
|
+
})
|
|
1917
|
+
]);
|
|
1918
|
+
applyView(view), setHostStatus(status?.host);
|
|
1919
|
+
}, refreshHostStatus = async () => {
|
|
1920
|
+
setHostStatus((await props.control("status")).host);
|
|
1921
|
+
};
|
|
1922
|
+
React.useEffect(() => {
|
|
1923
|
+
load().catch((reason) => setError(messageOf(reason)));
|
|
1924
|
+
}, []), React.useEffect(() => {
|
|
1925
|
+
if (association === void 0) return;
|
|
1926
|
+
refreshHostStatus().catch(() => {
|
|
1927
|
+
});
|
|
1928
|
+
let timer = window.setInterval(() => {
|
|
1929
|
+
refreshHostStatus().catch(() => {
|
|
1930
|
+
});
|
|
1931
|
+
}, 3e4);
|
|
1932
|
+
return () => window.clearInterval(timer);
|
|
1933
|
+
}, [association !== void 0]);
|
|
1934
|
+
let save = async (event) => {
|
|
1935
|
+
if (event?.preventDefault(), !(!writable || !serverDirty)) {
|
|
1936
|
+
setBusy(!0), setNotice(void 0), setError(void 0);
|
|
1937
|
+
try {
|
|
1938
|
+
let view = await props.control("settings.server.set", {
|
|
1939
|
+
serverUrl
|
|
1940
|
+
});
|
|
1941
|
+
applyView(view), setNotice({ key: "serverSaved" });
|
|
1942
|
+
} catch (reason) {
|
|
1943
|
+
setError(messageOf(reason));
|
|
1944
|
+
} finally {
|
|
1945
|
+
setBusy(!1);
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
}, logout = async () => {
|
|
1949
|
+
setBusy(!0), setError(void 0), setNotice(void 0);
|
|
1950
|
+
try {
|
|
1951
|
+
let view = await props.control("settings.logout");
|
|
1952
|
+
applyView(view), setRegistrationCode(""), setNotice({ key: "signedOut" });
|
|
1953
|
+
} catch (reason) {
|
|
1954
|
+
setError(messageOf(reason));
|
|
1955
|
+
} finally {
|
|
1956
|
+
setBusy(!1);
|
|
1957
|
+
}
|
|
1958
|
+
}, reconnectHost = async () => {
|
|
1959
|
+
setReconnectBusy(!0), setError(void 0), setNotice(void 0);
|
|
1960
|
+
try {
|
|
1961
|
+
let status = await props.control("host.reconnect");
|
|
1962
|
+
setHostStatus(status.host), setNotice({ key: "reconnectStarted" });
|
|
1963
|
+
} catch (reason) {
|
|
1964
|
+
setError(messageOf(reason));
|
|
1965
|
+
} finally {
|
|
1966
|
+
setReconnectBusy(!1);
|
|
1967
|
+
}
|
|
1968
|
+
}, setCurrentDeviceControl = async (enabled) => {
|
|
1969
|
+
setBusy(!0), setError(void 0), setNotice(void 0);
|
|
1970
|
+
try {
|
|
1971
|
+
let status = await props.control("host.authorization.set", { enabled });
|
|
1972
|
+
setHostStatus(status.host);
|
|
1973
|
+
} catch (reason) {
|
|
1974
|
+
setError(messageOf(reason));
|
|
1975
|
+
} finally {
|
|
1976
|
+
setBusy(!1);
|
|
1977
|
+
}
|
|
1978
|
+
}, discard = () => {
|
|
1979
|
+
settingsView !== void 0 && applyView(settingsView), setRegistrationCode(""), setNotice(void 0), setError(void 0);
|
|
1980
|
+
};
|
|
1981
|
+
return React.createElement(
|
|
1982
|
+
"li",
|
|
1983
|
+
{ className: `dshRemotePluginCard${open ? " isOpen" : ""}` },
|
|
1984
|
+
React.createElement(
|
|
1985
|
+
"div",
|
|
1986
|
+
{ className: "dshRemotePluginCardHeader" },
|
|
1987
|
+
React.createElement(
|
|
1988
|
+
"button",
|
|
1989
|
+
{
|
|
1990
|
+
type: "button",
|
|
1991
|
+
className: "dshRemotePluginCardToggle",
|
|
1992
|
+
"aria-expanded": open,
|
|
1993
|
+
"aria-label": t(open ? "collapseSettings" : "expandSettings", { name: t("pluginTitle") }),
|
|
1994
|
+
onClick: () => setOpen((current) => !current)
|
|
1995
|
+
},
|
|
1996
|
+
React.createElement(
|
|
1997
|
+
"span",
|
|
1998
|
+
{ className: "dshRemotePluginCardHeading" },
|
|
1999
|
+
React.createElement("strong", null, t("pluginTitle")),
|
|
2000
|
+
React.createElement("span", null, t("pluginDescription"))
|
|
2001
|
+
),
|
|
2002
|
+
draftDirty ? React.createElement("span", { className: "dshRemotePluginCardStatus" }, t("unsaved")) : association === void 0 ? null : React.createElement("span", {
|
|
2003
|
+
className: `dshRemotePluginCardStatus${connectionStatusClass(hostStatus)}`
|
|
2004
|
+
}, hostStatus === void 0 ? t("associated") : connectionStatusLabel(hostStatus, t)),
|
|
2005
|
+
React.createElement("span", { className: "dshRemotePluginCardChevron", "aria-hidden": !0 }, "\u2304")
|
|
2006
|
+
)
|
|
2007
|
+
),
|
|
2008
|
+
open ? React.createElement(
|
|
2009
|
+
"div",
|
|
2010
|
+
{ className: "dshRemotePluginCardBody" },
|
|
2011
|
+
loaded ? association !== void 0 ? React.createElement(
|
|
2012
|
+
"div",
|
|
2013
|
+
{ className: "dshRemoteSettings" },
|
|
2014
|
+
React.createElement(
|
|
2015
|
+
"div",
|
|
2016
|
+
{ className: "dshRemoteSettingsTop" },
|
|
2017
|
+
React.createElement(
|
|
2018
|
+
"div",
|
|
2019
|
+
{ className: "dshRemoteAssociation" },
|
|
2020
|
+
React.createElement("span", null, t(association.account === void 0 ? "authorization" : "account")),
|
|
2021
|
+
React.createElement("strong", null, association.account ?? t("authorizationComplete")),
|
|
2022
|
+
React.createElement("p", null, association.account === void 0 ? serverUrl : t("authorizedOn", { role: "Remote", serverUrl }))
|
|
2023
|
+
)
|
|
2024
|
+
),
|
|
2025
|
+
React.createElement(
|
|
2026
|
+
"div",
|
|
2027
|
+
{ className: "dshRemoteField" },
|
|
2028
|
+
React.createElement("label", { htmlFor: "dsh-remote-server-url-authorized" }, t("serverUrl")),
|
|
2029
|
+
React.createElement("input", {
|
|
2030
|
+
id: "dsh-remote-server-url-authorized",
|
|
2031
|
+
type: "url",
|
|
2032
|
+
value: serverUrl,
|
|
2033
|
+
disabled: !0,
|
|
2034
|
+
required: !0,
|
|
2035
|
+
placeholder: "https://dsh.r2049.cn",
|
|
2036
|
+
onChange: (event) => {
|
|
2037
|
+
setServerUrl(event.target.value), setNotice(void 0);
|
|
2038
|
+
}
|
|
2039
|
+
}),
|
|
2040
|
+
React.createElement("p", null, t("serverUrlHint"))
|
|
2041
|
+
),
|
|
2042
|
+
React.createElement(
|
|
2043
|
+
"div",
|
|
2044
|
+
{ className: "dshRemoteAuthorizationSetting" },
|
|
2045
|
+
React.createElement(
|
|
2046
|
+
"div",
|
|
2047
|
+
null,
|
|
2048
|
+
React.createElement("strong", null, t("allowControlCurrentDevice")),
|
|
2049
|
+
React.createElement("p", null, t("thisMachineHost"))
|
|
2050
|
+
),
|
|
2051
|
+
React.createElement("input", {
|
|
2052
|
+
type: "checkbox",
|
|
2053
|
+
role: "switch",
|
|
2054
|
+
disabled: busy,
|
|
2055
|
+
"aria-label": t("allowControlCurrentDevice"),
|
|
2056
|
+
checked: hostStatus?.authorized === !0,
|
|
2057
|
+
onChange: (event) => void setCurrentDeviceControl(event.target.checked)
|
|
2058
|
+
})
|
|
2059
|
+
),
|
|
2060
|
+
React.createElement(
|
|
2061
|
+
"div",
|
|
2062
|
+
{ className: "dshRemoteConnection", "aria-live": "polite" },
|
|
2063
|
+
React.createElement(
|
|
2064
|
+
"div",
|
|
2065
|
+
{ className: "dshRemoteConnectionSummary" },
|
|
2066
|
+
React.createElement("span", null, t("connection")),
|
|
2067
|
+
React.createElement(
|
|
2068
|
+
"strong",
|
|
2069
|
+
null,
|
|
2070
|
+
React.createElement("span", {
|
|
2071
|
+
className: `dshRemoteConnectionDot${connectionStatusClass(hostStatus)}`,
|
|
2072
|
+
"aria-hidden": !0
|
|
2073
|
+
}),
|
|
2074
|
+
connectionStatusLabel(hostStatus, t)
|
|
2075
|
+
),
|
|
2076
|
+
React.createElement("p", null, hostStatus === void 0 ? t("checkingConnection") : hostStatus.lastActiveAt === void 0 ? t("neverConnected") : t("lastActive", { time: formatLocalTime(hostStatus.lastActiveAt) }))
|
|
2077
|
+
),
|
|
2078
|
+
React.createElement("button", {
|
|
2079
|
+
type: "button",
|
|
2080
|
+
className: "dshRemoteReconnect",
|
|
2081
|
+
disabled: reconnectBusy || hostStatus?.configured === !1,
|
|
2082
|
+
onClick: () => void reconnectHost()
|
|
2083
|
+
}, t(reconnectBusy ? "reconnectingAction" : "reconnect"))
|
|
2084
|
+
),
|
|
2085
|
+
hostStatus?.error === void 0 || hostStatus.online ? null : React.createElement("p", { className: "dshRemoteConnectionIssue", role: "status" }, connectionErrorMessage(hostStatus.error, t)),
|
|
2086
|
+
writable ? null : React.createElement("p", { className: "dshRemoteError" }, t("readOnly")),
|
|
2087
|
+
React.createElement(
|
|
2088
|
+
"div",
|
|
2089
|
+
{ className: "dshRemoteSettingsFooter" },
|
|
2090
|
+
error !== void 0 ? React.createElement("p", { className: "dshRemoteError", role: "alert" }, error) : notice === void 0 ? null : React.createElement("p", { className: "dshRemoteNotice", role: "status" }, t(notice.key, notice.params)),
|
|
2091
|
+
draftDirty ? React.createElement(
|
|
2092
|
+
React.Fragment,
|
|
2093
|
+
null,
|
|
2094
|
+
React.createElement("button", { type: "button", className: "dshRemoteDiscard", disabled: busy, onClick: discard }, t("discard")),
|
|
2095
|
+
React.createElement("button", { type: "button", className: "dshRemoteSave", disabled: busy || !writable, onClick: () => void save() }, t(busy ? "saving" : "save"))
|
|
2096
|
+
) : React.createElement("button", {
|
|
2097
|
+
type: "button",
|
|
2098
|
+
className: "dshRemoteDiscard",
|
|
2099
|
+
disabled: busy || !writable,
|
|
2100
|
+
onClick: () => void logout()
|
|
2101
|
+
}, t(busy ? "signingOut" : "signOut"))
|
|
2102
|
+
)
|
|
2103
|
+
) : React.createElement(
|
|
2104
|
+
"form",
|
|
2105
|
+
{ className: "dshRemoteSettings", noValidate: !0, onSubmit: (event) => void save(event) },
|
|
2106
|
+
React.createElement(
|
|
2107
|
+
"div",
|
|
2108
|
+
{ className: "dshRemoteField" },
|
|
2109
|
+
React.createElement("label", { htmlFor: "dsh-remote-server-url" }, t("serverUrl")),
|
|
2110
|
+
React.createElement("input", {
|
|
2111
|
+
id: "dsh-remote-server-url",
|
|
2112
|
+
type: "url",
|
|
2113
|
+
value: serverUrl,
|
|
2114
|
+
disabled: busy || !writable,
|
|
2115
|
+
required: !0,
|
|
2116
|
+
placeholder: "https://dsh.r2049.cn",
|
|
2117
|
+
onChange: (event) => {
|
|
2118
|
+
setServerUrl(event.target.value), setNotice(void 0);
|
|
2119
|
+
}
|
|
2120
|
+
}),
|
|
2121
|
+
React.createElement("p", null, t("serverUrlHint"))
|
|
2122
|
+
),
|
|
2123
|
+
React.createElement("p", { className: "dshRemoteSettingsState" }, t("authorizeFromRemote")),
|
|
2124
|
+
writable ? null : React.createElement("p", { className: "dshRemoteError" }, t("readOnly")),
|
|
2125
|
+
React.createElement(
|
|
2126
|
+
"div",
|
|
2127
|
+
{ className: "dshRemoteSettingsFooter" },
|
|
2128
|
+
error !== void 0 ? React.createElement("p", { className: "dshRemoteError", role: "alert" }, error) : notice === void 0 ? null : React.createElement("p", { className: "dshRemoteNotice", role: "status" }, t(notice.key, notice.params)),
|
|
2129
|
+
React.createElement("button", { type: "button", className: "dshRemoteDiscard", disabled: busy || !draftDirty, onClick: discard }, t("discard")),
|
|
2130
|
+
React.createElement("button", { type: "submit", className: "dshRemoteSave", disabled: busy || !writable || !serverDirty }, t(busy ? "saving" : "save"))
|
|
2131
|
+
)
|
|
2132
|
+
) : React.createElement("p", { className: "dshRemoteSettingsState" }, error ?? t("loadingSettings"))
|
|
2133
|
+
) : null
|
|
2134
|
+
);
|
|
2135
|
+
}
|
|
2136
|
+
function RemoteWorkspaceAction(props) {
|
|
2137
|
+
let { t } = props, [open, setOpen] = React.useState(!1), [status, setStatus] = React.useState(void 0), [devices, setDevices] = React.useState([]), [selectedHost, setSelectedHost] = React.useState(void 0), [workspaces, setWorkspaces] = React.useState([]), [directory, setDirectory] = React.useState(void 0), [path, setPath] = React.useState(""), [addingWorkspace, setAddingWorkspace] = React.useState(!1), [busy, setBusy] = React.useState(!1), [needsAuthorization, setNeedsAuthorization] = React.useState(!1), [email, setEmail] = React.useState(""), [password, setPassword] = React.useState(""), [loginMethod, setLoginMethod] = React.useState("qr"), [qrSession, setQrSession] = React.useState(void 0), [qrImage, setQrImage] = React.useState(void 0), [qrExpired, setQrExpired] = React.useState(!1), [notice, setNotice] = React.useState(void 0), [error, setError] = React.useState(void 0);
|
|
2138
|
+
React.useEffect(() => {
|
|
2139
|
+
if (!open) return;
|
|
2140
|
+
let closeOnEscape = (event) => {
|
|
2141
|
+
event.key === "Escape" && setOpen(!1);
|
|
2142
|
+
};
|
|
2143
|
+
return window.addEventListener("keydown", closeOnEscape), () => window.removeEventListener("keydown", closeOnEscape);
|
|
2144
|
+
}, [open]), React.useEffect(() => {
|
|
2145
|
+
props.control("status").then(setStatus).catch(() => {
|
|
2146
|
+
});
|
|
2147
|
+
}, []), React.useEffect(() => {
|
|
2148
|
+
let remoteActive = status?.mode === "remote";
|
|
2149
|
+
return document.documentElement.classList.toggle("dshRemoteTargetActive", remoteActive), () => {
|
|
2150
|
+
remoteActive && document.documentElement.classList.remove("dshRemoteTargetActive");
|
|
2151
|
+
};
|
|
2152
|
+
}, [status?.mode]);
|
|
2153
|
+
let startQrLogin = async () => {
|
|
2154
|
+
setBusy(!0), setError(void 0), setQrExpired(!1);
|
|
2155
|
+
try {
|
|
2156
|
+
let session = await props.control("client.account.qr.start"), image = await import_qrcode.default.toDataURL(session.scanUrl, {
|
|
2157
|
+
width: 184,
|
|
2158
|
+
margin: 1,
|
|
2159
|
+
errorCorrectionLevel: "L"
|
|
2160
|
+
});
|
|
2161
|
+
setQrSession(session), setQrImage(image);
|
|
2162
|
+
} catch (reason) {
|
|
2163
|
+
setError(messageOf(reason));
|
|
2164
|
+
} finally {
|
|
2165
|
+
setBusy(!1);
|
|
2166
|
+
}
|
|
2167
|
+
};
|
|
2168
|
+
React.useEffect(() => {
|
|
2169
|
+
!open || !needsAuthorization || loginMethod !== "qr" || qrSession !== void 0 || qrExpired || startQrLogin();
|
|
2170
|
+
}, [open, needsAuthorization, loginMethod, qrSession, qrExpired]), React.useEffect(() => {
|
|
2171
|
+
if (!open || loginMethod !== "qr" || qrSession === void 0) return;
|
|
2172
|
+
let active = !0, poll = () => {
|
|
2173
|
+
props.control("client.account.qr.poll", { qrId: qrSession.qrId }).then(async (result) => {
|
|
2174
|
+
active && (result.status === "complete" ? (setDevices(await props.control("devices")), setStatus(await props.control("status")), setNeedsAuthorization(!1), setQrSession(void 0), setQrImage(void 0)) : result.status === "expired" && (setQrExpired(!0), setQrSession(void 0), setQrImage(void 0)));
|
|
2175
|
+
}).catch((reason) => {
|
|
2176
|
+
active && setError(messageOf(reason));
|
|
2177
|
+
});
|
|
2178
|
+
};
|
|
2179
|
+
poll();
|
|
2180
|
+
let timer = window.setInterval(poll, 1500);
|
|
2181
|
+
return () => {
|
|
2182
|
+
active = !1, window.clearInterval(timer);
|
|
2183
|
+
};
|
|
2184
|
+
}, [open, loginMethod, qrSession]);
|
|
2185
|
+
let selectHost = async (host) => {
|
|
2186
|
+
setBusy(!0), setError(void 0);
|
|
2187
|
+
try {
|
|
2188
|
+
setWorkspaces(await props.control("workspaces.list", { targetDeviceId: host.deviceId })), setSelectedHost(host), setPath(""), setAddingWorkspace(!1), setDirectory(void 0);
|
|
2189
|
+
} catch (reason) {
|
|
2190
|
+
setError(messageOf(reason));
|
|
2191
|
+
} finally {
|
|
2192
|
+
setBusy(!1);
|
|
2193
|
+
}
|
|
2194
|
+
}, browseDirectory = async (nextPath) => {
|
|
2195
|
+
if (selectedHost !== void 0) {
|
|
2196
|
+
setBusy(!0), setError(void 0);
|
|
2197
|
+
try {
|
|
2198
|
+
let listing = await props.control("directory.list", {
|
|
2199
|
+
targetDeviceId: selectedHost.deviceId,
|
|
2200
|
+
...nextPath === void 0 ? {} : { path: nextPath }
|
|
2201
|
+
});
|
|
2202
|
+
setDirectory(listing), setPath(listing.path);
|
|
2203
|
+
} catch (reason) {
|
|
2204
|
+
setError(messageOf(reason));
|
|
2205
|
+
} finally {
|
|
2206
|
+
setBusy(!1);
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
}, show = async () => {
|
|
2210
|
+
setOpen(!0), setBusy(!0), setNotice(void 0), setError(void 0);
|
|
2211
|
+
try {
|
|
2212
|
+
let nextStatus = await props.control("status");
|
|
2213
|
+
if (setStatus(nextStatus), nextStatus.available)
|
|
2214
|
+
try {
|
|
2215
|
+
setDevices(await props.control("devices")), setNeedsAuthorization(!1);
|
|
2216
|
+
} catch {
|
|
2217
|
+
setNeedsAuthorization(!0);
|
|
2218
|
+
}
|
|
2219
|
+
} catch (reason) {
|
|
2220
|
+
setError(messageOf(reason));
|
|
2221
|
+
} finally {
|
|
2222
|
+
setBusy(!1);
|
|
2223
|
+
}
|
|
2224
|
+
}, signInClient = async () => {
|
|
2225
|
+
if (!(email.trim() === "" || password === "")) {
|
|
2226
|
+
setBusy(!0), setError(void 0);
|
|
2227
|
+
try {
|
|
2228
|
+
await props.control("client.account.login", { email: email.trim(), password }), setDevices(await props.control("devices")), setStatus(await props.control("status")), setNeedsAuthorization(!1), setPassword("");
|
|
2229
|
+
} catch (reason) {
|
|
2230
|
+
setError(messageOf(reason));
|
|
2231
|
+
} finally {
|
|
2232
|
+
setBusy(!1);
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
}, openLocalWorkspaces = async () => {
|
|
2236
|
+
setBusy(!0), setError(void 0);
|
|
2237
|
+
try {
|
|
2238
|
+
await props.control("mode.set", { mode: "local" }), window.location.reload();
|
|
2239
|
+
} catch (reason) {
|
|
2240
|
+
setError(messageOf(reason)), setBusy(!1);
|
|
2241
|
+
}
|
|
2242
|
+
}, setCurrentDeviceControl = async (enabled) => {
|
|
2243
|
+
setBusy(!0), setError(void 0);
|
|
2244
|
+
try {
|
|
2245
|
+
setStatus(await props.control("host.authorization.set", { enabled }));
|
|
2246
|
+
} catch (reason) {
|
|
2247
|
+
setError(messageOf(reason));
|
|
2248
|
+
} finally {
|
|
2249
|
+
setBusy(!1);
|
|
2250
|
+
}
|
|
2251
|
+
}, logoutRemote = async () => {
|
|
2252
|
+
setBusy(!0), setError(void 0);
|
|
2253
|
+
try {
|
|
2254
|
+
await props.control("settings.logout"), setDevices([]), setNeedsAuthorization(!0), setQrSession(void 0), setQrImage(void 0), setQrExpired(!1), setStatus(await props.control("status"));
|
|
2255
|
+
} catch (reason) {
|
|
2256
|
+
setError(messageOf(reason));
|
|
2257
|
+
} finally {
|
|
2258
|
+
setBusy(!1);
|
|
2259
|
+
}
|
|
2260
|
+
}, openWorkspace = async () => {
|
|
2261
|
+
if (!(selectedHost === void 0 || path.trim() === "")) {
|
|
2262
|
+
setBusy(!0), setError(void 0);
|
|
2263
|
+
try {
|
|
2264
|
+
await props.control("workspace.open", {
|
|
2265
|
+
targetDeviceId: selectedHost.deviceId,
|
|
2266
|
+
path: path.trim()
|
|
2267
|
+
}), window.location.reload();
|
|
2268
|
+
} catch (reason) {
|
|
2269
|
+
setError(messageOf(reason)), setBusy(!1);
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
}, remoteLabel = status?.mode === "remote" ? t("activeRemote", { name: status.target?.name ?? t("host") }) : t("remoteEntry");
|
|
2273
|
+
return React.createElement(
|
|
2274
|
+
React.Fragment,
|
|
2275
|
+
null,
|
|
2276
|
+
React.createElement(
|
|
2277
|
+
"div",
|
|
2278
|
+
{ className: `dshRemoteSidebarEntry${status?.mode === "remote" ? " isActive" : ""}${props.wide ? " isWide" : " isRail"}` },
|
|
2279
|
+
React.createElement(status?.mode === "remote" ? "div" : "button", {
|
|
2280
|
+
...status?.mode === "remote" ? {} : { type: "button", onClick: () => void show() },
|
|
2281
|
+
className: "dshRemoteModeButton",
|
|
2282
|
+
title: remoteLabel,
|
|
2283
|
+
"aria-label": remoteLabel
|
|
2284
|
+
}, React.createElement(
|
|
2285
|
+
"svg",
|
|
2286
|
+
{
|
|
2287
|
+
className: "dshRemoteComputerIcon",
|
|
2288
|
+
viewBox: "0 0 24 24",
|
|
2289
|
+
fill: "none",
|
|
2290
|
+
stroke: "currentColor",
|
|
2291
|
+
strokeWidth: 1.7,
|
|
2292
|
+
strokeLinecap: "round",
|
|
2293
|
+
strokeLinejoin: "round",
|
|
2294
|
+
"aria-hidden": !0
|
|
2295
|
+
},
|
|
2296
|
+
React.createElement("rect", { x: 3, y: 4, width: 18, height: 13, rx: 2 }),
|
|
2297
|
+
React.createElement("path", { d: "M8 21h8M12 17v4" })
|
|
2298
|
+
), props.wide ? React.createElement("span", { className: "dshRemoteSidebarLabel" }, remoteLabel) : null),
|
|
2299
|
+
status?.mode === "remote" && props.wide ? React.createElement("button", {
|
|
2300
|
+
type: "button",
|
|
2301
|
+
className: "dshRemoteExitLink",
|
|
2302
|
+
disabled: busy,
|
|
2303
|
+
onClick: () => void openLocalWorkspaces()
|
|
2304
|
+
}, t("exitRemote")) : null
|
|
2305
|
+
),
|
|
2306
|
+
open ? React.createElement("div", {
|
|
2307
|
+
className: "dshRemoteBackdrop",
|
|
2308
|
+
role: "presentation",
|
|
2309
|
+
onMouseDown: (event) => {
|
|
2310
|
+
event.target === event.currentTarget && setOpen(!1);
|
|
2311
|
+
}
|
|
2312
|
+
}, React.createElement(
|
|
2313
|
+
"section",
|
|
2314
|
+
{ className: "dshRemotePage", role: "dialog", "aria-modal": !0, "aria-label": t("remoteTitle") },
|
|
2315
|
+
React.createElement(
|
|
2316
|
+
"header",
|
|
2317
|
+
{ className: "dshRemotePageHeader" },
|
|
2318
|
+
React.createElement(
|
|
2319
|
+
"div",
|
|
2320
|
+
{ className: "dshRemotePageIntro" },
|
|
2321
|
+
React.createElement("strong", null, t("remoteTitle")),
|
|
2322
|
+
React.createElement("p", null, t("remoteDescription"))
|
|
2323
|
+
),
|
|
2324
|
+
React.createElement("button", { type: "button", onClick: () => setOpen(!1), "aria-label": t("close") }, "\xD7")
|
|
2325
|
+
),
|
|
2326
|
+
React.createElement(
|
|
2327
|
+
"main",
|
|
2328
|
+
{ className: "dshRemotePageBody" },
|
|
2329
|
+
status?.mode === "remote" ? React.createElement("button", {
|
|
2330
|
+
type: "button",
|
|
2331
|
+
className: "dshRemoteLocalLink",
|
|
2332
|
+
disabled: busy,
|
|
2333
|
+
onClick: () => void openLocalWorkspaces()
|
|
2334
|
+
}, t("openLocalWorkspaces")) : null,
|
|
2335
|
+
React.createElement(
|
|
2336
|
+
React.Fragment,
|
|
2337
|
+
null,
|
|
2338
|
+
needsAuthorization ? React.createElement(
|
|
2339
|
+
"section",
|
|
2340
|
+
{ className: "dshRemoteEnable" },
|
|
2341
|
+
React.createElement(
|
|
2342
|
+
"div",
|
|
2343
|
+
{ className: "dshRemoteLoginHeading" },
|
|
2344
|
+
React.createElement("strong", { className: "dshRemoteLoginTitle" }, t("signInClient")),
|
|
2345
|
+
React.createElement("span", null, t("signInClientDescription"))
|
|
2346
|
+
),
|
|
2347
|
+
React.createElement(
|
|
2348
|
+
"div",
|
|
2349
|
+
{ className: "dshRemoteLoginTabs", role: "tablist" },
|
|
2350
|
+
React.createElement("button", {
|
|
2351
|
+
type: "button",
|
|
2352
|
+
role: "tab",
|
|
2353
|
+
id: "dsh-remote-qr-tab",
|
|
2354
|
+
"aria-selected": loginMethod === "qr",
|
|
2355
|
+
"aria-controls": "dsh-remote-qr-panel",
|
|
2356
|
+
className: loginMethod === "qr" ? "isActive" : "",
|
|
2357
|
+
disabled: busy,
|
|
2358
|
+
onClick: () => {
|
|
2359
|
+
setLoginMethod("qr"), setError(void 0);
|
|
2360
|
+
}
|
|
2361
|
+
}, t("scanWithZhihu")),
|
|
2362
|
+
React.createElement("button", {
|
|
2363
|
+
type: "button",
|
|
2364
|
+
role: "tab",
|
|
2365
|
+
id: "dsh-remote-password-tab",
|
|
2366
|
+
"aria-selected": loginMethod === "password",
|
|
2367
|
+
"aria-controls": "dsh-remote-password-panel",
|
|
2368
|
+
className: loginMethod === "password" ? "isActive" : "",
|
|
2369
|
+
disabled: busy,
|
|
2370
|
+
onClick: () => {
|
|
2371
|
+
setLoginMethod("password"), setError(void 0);
|
|
2372
|
+
}
|
|
2373
|
+
}, t("accountPasswordLogin"))
|
|
2374
|
+
),
|
|
2375
|
+
loginMethod === "qr" ? React.createElement(
|
|
2376
|
+
"div",
|
|
2377
|
+
{
|
|
2378
|
+
className: "dshRemoteQrLogin",
|
|
2379
|
+
role: "tabpanel",
|
|
2380
|
+
id: "dsh-remote-qr-panel",
|
|
2381
|
+
"aria-labelledby": "dsh-remote-qr-tab"
|
|
2382
|
+
},
|
|
2383
|
+
qrImage === void 0 ? React.createElement(
|
|
2384
|
+
"div",
|
|
2385
|
+
{ className: "dshRemoteQrPlaceholder", "aria-busy": busy },
|
|
2386
|
+
qrExpired ? React.createElement("p", null, t("qrLoginExpired")) : React.createElement("span", null, t("checkingConnection"))
|
|
2387
|
+
) : React.createElement("img", { src: qrImage, width: 184, height: 184, alt: t("scanWithZhihu") }),
|
|
2388
|
+
React.createElement("strong", null, t("scanWithZhihu")),
|
|
2389
|
+
React.createElement("p", null, t("scanLoginHint")),
|
|
2390
|
+
status?.serverUrl === void 0 ? null : React.createElement(
|
|
2391
|
+
"p",
|
|
2392
|
+
{ className: "dshRemoteServiceAddress" },
|
|
2393
|
+
t("currentServiceAddress"),
|
|
2394
|
+
" ",
|
|
2395
|
+
React.createElement("a", {
|
|
2396
|
+
href: status.serverUrl,
|
|
2397
|
+
target: "_blank",
|
|
2398
|
+
rel: "noreferrer"
|
|
2399
|
+
}, status.serverUrl)
|
|
2400
|
+
),
|
|
2401
|
+
qrExpired ? React.createElement("button", {
|
|
2402
|
+
type: "button",
|
|
2403
|
+
disabled: busy,
|
|
2404
|
+
onClick: () => setQrExpired(!1)
|
|
2405
|
+
}, t("refreshQrCode")) : null
|
|
2406
|
+
) : React.createElement(
|
|
2407
|
+
"div",
|
|
2408
|
+
{
|
|
2409
|
+
className: "dshRemoteClientLogin",
|
|
2410
|
+
role: "tabpanel",
|
|
2411
|
+
id: "dsh-remote-password-panel",
|
|
2412
|
+
"aria-labelledby": "dsh-remote-password-tab"
|
|
2413
|
+
},
|
|
2414
|
+
React.createElement("input", {
|
|
2415
|
+
type: "email",
|
|
2416
|
+
value: email,
|
|
2417
|
+
disabled: busy,
|
|
2418
|
+
autoComplete: "username",
|
|
2419
|
+
placeholder: t("account"),
|
|
2420
|
+
"aria-label": t("account"),
|
|
2421
|
+
onChange: (event) => setEmail(event.target.value)
|
|
2422
|
+
}),
|
|
2423
|
+
React.createElement("input", {
|
|
2424
|
+
type: "password",
|
|
2425
|
+
value: password,
|
|
2426
|
+
disabled: busy,
|
|
2427
|
+
autoComplete: "current-password",
|
|
2428
|
+
placeholder: t("password"),
|
|
2429
|
+
"aria-label": t("password"),
|
|
2430
|
+
onChange: (event) => setPassword(event.target.value)
|
|
2431
|
+
}),
|
|
2432
|
+
React.createElement("button", { type: "button", disabled: busy || email.trim() === "" || password === "", onClick: () => void signInClient() }, t(busy ? "signingIn" : "startSignIn"))
|
|
2433
|
+
)
|
|
2434
|
+
) : null,
|
|
2435
|
+
needsAuthorization ? null : React.createElement(
|
|
2436
|
+
React.Fragment,
|
|
2437
|
+
null,
|
|
2438
|
+
React.createElement(
|
|
2439
|
+
"section",
|
|
2440
|
+
{ className: "dshRemoteHosts", "aria-label": t("chooseHost") },
|
|
2441
|
+
React.createElement(
|
|
2442
|
+
"div",
|
|
2443
|
+
{ className: "dshRemoteSectionHeading" },
|
|
2444
|
+
React.createElement("strong", null, t("chooseHost")),
|
|
2445
|
+
React.createElement(
|
|
2446
|
+
"div",
|
|
2447
|
+
{ className: "dshRemoteSectionActions" },
|
|
2448
|
+
status?.hostAuthorizationAvailable ? React.createElement(
|
|
2449
|
+
"div",
|
|
2450
|
+
{ className: "dshRemoteHostControlToggle" },
|
|
2451
|
+
React.createElement("span", null, t("allowControlCurrentDevice")),
|
|
2452
|
+
React.createElement("input", {
|
|
2453
|
+
type: "checkbox",
|
|
2454
|
+
role: "switch",
|
|
2455
|
+
disabled: busy,
|
|
2456
|
+
"aria-label": t("allowControlCurrentDevice"),
|
|
2457
|
+
checked: status.host?.authorized === !0,
|
|
2458
|
+
onChange: (event) => void setCurrentDeviceControl(event.target.checked)
|
|
2459
|
+
})
|
|
2460
|
+
) : null,
|
|
2461
|
+
selectedHost === void 0 ? null : React.createElement("button", {
|
|
2462
|
+
type: "button",
|
|
2463
|
+
onClick: () => {
|
|
2464
|
+
setSelectedHost(void 0), setWorkspaces([]), setDirectory(void 0), setPath(""), setAddingWorkspace(!1), setError(void 0);
|
|
2465
|
+
}
|
|
2466
|
+
}, t("backToHosts")),
|
|
2467
|
+
React.createElement("button", {
|
|
2468
|
+
type: "button",
|
|
2469
|
+
className: "dshRemoteAccountExit",
|
|
2470
|
+
disabled: busy,
|
|
2471
|
+
onClick: () => void logoutRemote()
|
|
2472
|
+
}, t("exitRemoteAccount"))
|
|
2473
|
+
)
|
|
2474
|
+
),
|
|
2475
|
+
selectedHost === void 0 ? React.createElement("div", { className: "dshRemoteHostList" }, devices.length === 0 ? React.createElement("p", null, t(busy ? "checkingConnection" : "noRemoteHosts")) : devices.map((device) => React.createElement(
|
|
2476
|
+
"button",
|
|
2477
|
+
{
|
|
2478
|
+
type: "button",
|
|
2479
|
+
key: device.deviceId,
|
|
2480
|
+
disabled: busy || !device.online,
|
|
2481
|
+
onClick: () => void selectHost(device)
|
|
2482
|
+
},
|
|
2483
|
+
React.createElement(
|
|
2484
|
+
"span",
|
|
2485
|
+
null,
|
|
2486
|
+
React.createElement("strong", null, device.name),
|
|
2487
|
+
React.createElement("small", null, [
|
|
2488
|
+
formatPlatform(device.platform),
|
|
2489
|
+
device.harnessVersion === void 0 ? void 0 : t("harnessVersion", { version: device.harnessVersion }),
|
|
2490
|
+
device.clientVersion === void 0 ? void 0 : t("pluginVersion", { version: device.clientVersion })
|
|
2491
|
+
].filter(Boolean).join(" \xB7 "))
|
|
2492
|
+
),
|
|
2493
|
+
React.createElement("small", null, t(device.online ? "online" : "offline"))
|
|
2494
|
+
))) : React.createElement(
|
|
2495
|
+
"div",
|
|
2496
|
+
{ className: "dshRemoteSelectedHost" },
|
|
2497
|
+
React.createElement("span", null, selectedHost.name),
|
|
2498
|
+
React.createElement("small", null, [formatPlatform(selectedHost.platform), t("online")].join(" \xB7 "))
|
|
2499
|
+
)
|
|
2500
|
+
),
|
|
2501
|
+
selectedHost === void 0 ? React.createElement("p", { className: "dshRemoteHint" }, t("selectHostHint")) : React.createElement(
|
|
2502
|
+
"section",
|
|
2503
|
+
{ className: "dshRemoteBrowser", "aria-label": t("chooseDirectory") },
|
|
2504
|
+
React.createElement(
|
|
2505
|
+
"div",
|
|
2506
|
+
{ className: "dshRemoteSectionHeading" },
|
|
2507
|
+
React.createElement("strong", null, t("existingWorkspaces")),
|
|
2508
|
+
React.createElement("button", {
|
|
2509
|
+
type: "button",
|
|
2510
|
+
className: "dshRemoteAddWorkspace",
|
|
2511
|
+
title: t("addRemoteWorkspace"),
|
|
2512
|
+
"aria-label": t("addRemoteWorkspace"),
|
|
2513
|
+
"aria-expanded": addingWorkspace,
|
|
2514
|
+
onClick: () => {
|
|
2515
|
+
if (addingWorkspace) {
|
|
2516
|
+
setAddingWorkspace(!1), setDirectory(void 0), setPath("");
|
|
2517
|
+
return;
|
|
2518
|
+
}
|
|
2519
|
+
setAddingWorkspace(!0), browseDirectory();
|
|
2520
|
+
}
|
|
2521
|
+
}, "+")
|
|
2522
|
+
),
|
|
2523
|
+
React.createElement("div", { className: "dshRemoteDirectoryList" }, workspaces.length === 0 ? React.createElement("p", null, t("noRemoteWorkspaces")) : workspaces.map((workspace) => React.createElement(
|
|
2524
|
+
"button",
|
|
2525
|
+
{
|
|
2526
|
+
type: "button",
|
|
2527
|
+
key: workspace.workspaceId,
|
|
2528
|
+
disabled: busy,
|
|
2529
|
+
className: !addingWorkspace && path === workspace.path ? "isSelected" : "",
|
|
2530
|
+
"aria-pressed": !addingWorkspace && path === workspace.path,
|
|
2531
|
+
onClick: () => {
|
|
2532
|
+
setAddingWorkspace(!1), setPath(workspace.path);
|
|
2533
|
+
}
|
|
2534
|
+
},
|
|
2535
|
+
React.createElement("span", { "aria-hidden": !0 }, "\u25B1"),
|
|
2536
|
+
React.createElement("span", null, workspace.title),
|
|
2537
|
+
React.createElement("small", null, workspace.path)
|
|
2538
|
+
))),
|
|
2539
|
+
addingWorkspace ? React.createElement(
|
|
2540
|
+
"div",
|
|
2541
|
+
{ className: "dshRemoteFolderBrowser" },
|
|
2542
|
+
directory === void 0 ? React.createElement("p", null, t("loadingDirectory")) : React.createElement(
|
|
2543
|
+
React.Fragment,
|
|
2544
|
+
null,
|
|
2545
|
+
React.createElement(
|
|
2546
|
+
"nav",
|
|
2547
|
+
{ className: "dshRemoteCrumbs", "aria-label": t("currentDirectory") },
|
|
2548
|
+
directory.crumbs.map((crumb) => React.createElement("button", {
|
|
2549
|
+
type: "button",
|
|
2550
|
+
key: crumb.path,
|
|
2551
|
+
disabled: busy || crumb.path === directory.path,
|
|
2552
|
+
onClick: () => void browseDirectory(crumb.path)
|
|
2553
|
+
}, crumb.path === directory.home ? "\u2302" : crumb.name))
|
|
2554
|
+
),
|
|
2555
|
+
React.createElement("div", { className: "dshRemoteFolderList" }, directory.entries.filter((entry) => !entry.hidden).length === 0 ? React.createElement("p", null, t("emptyDirectory")) : directory.entries.filter((entry) => !entry.hidden).map((entry) => React.createElement("button", {
|
|
2556
|
+
type: "button",
|
|
2557
|
+
key: entry.path,
|
|
2558
|
+
disabled: busy,
|
|
2559
|
+
onClick: () => void browseDirectory(entry.path)
|
|
2560
|
+
}, React.createElement("span", { "aria-hidden": !0 }, "\u25B1"), React.createElement("span", null, entry.name)))),
|
|
2561
|
+
directory.truncated ? React.createElement("small", null, t("directoryTruncated")) : null
|
|
2562
|
+
)
|
|
2563
|
+
) : null,
|
|
2564
|
+
React.createElement(
|
|
2565
|
+
"footer",
|
|
2566
|
+
{ className: "dshRemoteOpenBar" },
|
|
2567
|
+
React.createElement("div", null, React.createElement("span", null, t("currentDirectory")), React.createElement("strong", null, path || "\u2014")),
|
|
2568
|
+
React.createElement("button", { type: "button", disabled: busy || path.trim() === "", onClick: () => void openWorkspace() }, t(busy ? "openingWorkspace" : "openWorkspace"))
|
|
2569
|
+
)
|
|
2570
|
+
)
|
|
2571
|
+
)
|
|
2572
|
+
),
|
|
2573
|
+
notice === void 0 ? null : React.createElement("p", { className: "dshRemoteNotice", role: "status" }, notice),
|
|
2574
|
+
error === void 0 ? null : React.createElement("p", { className: "dshRemoteError", role: "alert" }, error)
|
|
2575
|
+
)
|
|
2576
|
+
)) : null
|
|
2577
|
+
);
|
|
2578
|
+
}
|
|
2579
|
+
function RemoteModeAction(props) {
|
|
2580
|
+
let { t } = props, [open, setOpen] = React.useState(!1), [status, setStatus] = React.useState(void 0), [devices, setDevices] = React.useState([]), [hostRegistrationCode, setHostRegistrationCode] = React.useState(""), [email, setEmail] = React.useState(""), [password, setPassword] = React.useState(""), [busy, setBusy] = React.useState(!1), [error, setError] = React.useState(void 0), [supported, setSupported] = React.useState(!0), refresh = async () => {
|
|
2581
|
+
let [nextStatus, nextDevices] = await Promise.all([
|
|
2582
|
+
props.control("status"),
|
|
2583
|
+
props.control("devices").catch(() => [])
|
|
2584
|
+
]);
|
|
2585
|
+
setStatus(nextStatus), setDevices(nextDevices);
|
|
2586
|
+
}, refreshStatus = async () => {
|
|
2587
|
+
setStatus(await props.control("status"));
|
|
2588
|
+
};
|
|
2589
|
+
React.useEffect(() => {
|
|
2590
|
+
refresh().catch((reason) => {
|
|
2591
|
+
setError(messageOf(reason)), setSupported(!1);
|
|
2592
|
+
});
|
|
2593
|
+
}, []), React.useEffect(() => {
|
|
2594
|
+
if (!open) return;
|
|
2595
|
+
refreshStatus();
|
|
2596
|
+
let timer = window.setInterval(() => {
|
|
2597
|
+
refreshStatus();
|
|
2598
|
+
}, 1500);
|
|
2599
|
+
return () => window.clearInterval(timer);
|
|
2600
|
+
}, [open]);
|
|
2601
|
+
let switchMode = async (mode, targetDeviceId) => {
|
|
2602
|
+
setBusy(!0), setError(void 0);
|
|
2603
|
+
try {
|
|
2604
|
+
await props.control("mode.set", { mode, ...targetDeviceId === void 0 ? {} : { targetDeviceId } }), window.location.reload();
|
|
2605
|
+
} catch (reason) {
|
|
2606
|
+
setError(messageOf(reason)), setBusy(!1);
|
|
2607
|
+
}
|
|
2608
|
+
}, loginHost = async () => {
|
|
2609
|
+
if (!(email.trim() === "" || password === "")) {
|
|
2610
|
+
setBusy(!0), setError(void 0);
|
|
2611
|
+
try {
|
|
2612
|
+
await props.control("host.account.login", { email: email.trim(), password }), await refreshStatus();
|
|
2613
|
+
} catch (reason) {
|
|
2614
|
+
setError(messageOf(reason));
|
|
2615
|
+
} finally {
|
|
2616
|
+
setPassword(""), setBusy(!1);
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
}, registerHostWithCode = async () => {
|
|
2620
|
+
if (hostRegistrationCode.trim() !== "") {
|
|
2621
|
+
setBusy(!0), setError(void 0);
|
|
2622
|
+
try {
|
|
2623
|
+
await props.control("host.registration-code.submit", { code: hostRegistrationCode.trim() }), setHostRegistrationCode(""), await refreshStatus();
|
|
2624
|
+
} catch (reason) {
|
|
2625
|
+
setError(messageOf(reason));
|
|
2626
|
+
} finally {
|
|
2627
|
+
setBusy(!1);
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
}, label = status?.mode === "remote" ? t("remoteTarget", { name: status.target?.name ?? t("host") }) : t("local");
|
|
2631
|
+
return supported ? React.createElement(
|
|
2632
|
+
React.Fragment,
|
|
2633
|
+
null,
|
|
2634
|
+
React.createElement("button", {
|
|
2635
|
+
type: "button",
|
|
2636
|
+
className: "dshRemoteModeButton",
|
|
2637
|
+
title: t("switchTarget"),
|
|
2638
|
+
"aria-label": t("switchTarget"),
|
|
2639
|
+
onClick: () => setOpen(!0)
|
|
2640
|
+
}, React.createElement("span", { "aria-hidden": !0 }, "\u25CE"), props.wide ? React.createElement("span", null, label) : null),
|
|
2641
|
+
open ? React.createElement(
|
|
2642
|
+
"div",
|
|
2643
|
+
{ className: "dshRemoteBackdrop", role: "presentation" },
|
|
2644
|
+
React.createElement(
|
|
2645
|
+
"section",
|
|
2646
|
+
{
|
|
2647
|
+
className: "dshRemoteDialog",
|
|
2648
|
+
role: "dialog",
|
|
2649
|
+
"aria-modal": !0,
|
|
2650
|
+
"aria-label": t("harnessTarget")
|
|
2651
|
+
},
|
|
2652
|
+
React.createElement(
|
|
2653
|
+
"div",
|
|
2654
|
+
{ className: "dshRemoteHeader" },
|
|
2655
|
+
React.createElement("strong", null, t("harnessTarget")),
|
|
2656
|
+
React.createElement("button", { type: "button", onClick: () => setOpen(!1), "aria-label": t("close") }, "\xD7")
|
|
2657
|
+
),
|
|
2658
|
+
React.createElement("button", {
|
|
2659
|
+
type: "button",
|
|
2660
|
+
disabled: busy || status?.mode === "local",
|
|
2661
|
+
onClick: () => void switchMode("local")
|
|
2662
|
+
}, t("thisMachineLocal")),
|
|
2663
|
+
React.createElement("div", { className: "dshRemoteDevices" }, devices.length === 0 ? React.createElement("p", null, t("noRemoteHosts")) : devices.map((device) => React.createElement("button", {
|
|
2664
|
+
type: "button",
|
|
2665
|
+
key: device.deviceId,
|
|
2666
|
+
disabled: busy || !device.online || status?.target?.deviceId === device.deviceId,
|
|
2667
|
+
onClick: () => void switchMode("remote", device.deviceId)
|
|
2668
|
+
}, `${device.name} \xB7 ${t(device.online ? "online" : "offline")}`))),
|
|
2669
|
+
status?.hostAuthorizationAvailable && status.host !== void 0 ? React.createElement(
|
|
2670
|
+
"div",
|
|
2671
|
+
{ className: "dshRemoteHostAccount" },
|
|
2672
|
+
React.createElement("strong", null, t("thisMachineHost")),
|
|
2673
|
+
React.createElement("p", null, status.host.online ? status.host.account === void 0 ? t("connected") : t("connectedAs", { account: status.host.account }) : status.host.accountRequired ? t("hostSignInHint") : status.host.error === void 0 ? t("checkingHost") : t("hostUnavailable", { error: connectionErrorMessage(status.host.error, t) })),
|
|
2674
|
+
status.host.accountRequired ? React.createElement(
|
|
2675
|
+
"div",
|
|
2676
|
+
{ className: "dshRemoteLogin" },
|
|
2677
|
+
React.createElement("input", {
|
|
2678
|
+
type: "email",
|
|
2679
|
+
value: email,
|
|
2680
|
+
disabled: busy,
|
|
2681
|
+
autoComplete: "username",
|
|
2682
|
+
placeholder: t("serverAccountEmail"),
|
|
2683
|
+
"aria-label": t("serverAccountEmail"),
|
|
2684
|
+
onChange: (event) => setEmail(event.target.value)
|
|
2685
|
+
}),
|
|
2686
|
+
React.createElement("input", {
|
|
2687
|
+
type: "password",
|
|
2688
|
+
value: password,
|
|
2689
|
+
disabled: busy,
|
|
2690
|
+
autoComplete: "current-password",
|
|
2691
|
+
placeholder: t("password"),
|
|
2692
|
+
"aria-label": t("serverAccountPassword"),
|
|
2693
|
+
onChange: (event) => setPassword(event.target.value)
|
|
2694
|
+
}),
|
|
2695
|
+
React.createElement("button", {
|
|
2696
|
+
type: "button",
|
|
2697
|
+
disabled: busy || email.trim() === "" || password === "",
|
|
2698
|
+
onClick: () => void loginHost()
|
|
2699
|
+
}, t(busy ? "signingIn" : "signInRegisterHost")),
|
|
2700
|
+
React.createElement("input", {
|
|
2701
|
+
value: hostRegistrationCode,
|
|
2702
|
+
disabled: busy,
|
|
2703
|
+
autoComplete: "one-time-code",
|
|
2704
|
+
placeholder: t("hostRegistrationCode"),
|
|
2705
|
+
"aria-label": t("hostRegistrationCode"),
|
|
2706
|
+
onChange: (event) => setHostRegistrationCode(event.target.value)
|
|
2707
|
+
}),
|
|
2708
|
+
React.createElement("button", {
|
|
2709
|
+
type: "button",
|
|
2710
|
+
disabled: busy || hostRegistrationCode.trim() === "",
|
|
2711
|
+
onClick: () => void registerHostWithCode()
|
|
2712
|
+
}, t(busy ? "registering" : "useRegistrationCode"))
|
|
2713
|
+
) : null
|
|
2714
|
+
) : null,
|
|
2715
|
+
error === void 0 ? null : React.createElement("p", { className: "dshRemoteError", role: "alert" }, error)
|
|
2716
|
+
)
|
|
2717
|
+
) : null
|
|
2718
|
+
) : null;
|
|
2719
|
+
}
|
|
2720
|
+
function RemoteSessionHeaderAction(props) {
|
|
2721
|
+
let { t } = props, [status, setStatus] = React.useState(void 0), [busy, setBusy] = React.useState(!1), [routeOpen, setRouteOpen] = React.useState(!1);
|
|
2722
|
+
if (React.useEffect(() => {
|
|
2723
|
+
let active = !0, refresh = () => {
|
|
2724
|
+
props.control("status").then((next) => {
|
|
2725
|
+
active && setStatus(next);
|
|
2726
|
+
}).catch(() => {
|
|
2727
|
+
});
|
|
2728
|
+
};
|
|
2729
|
+
refresh();
|
|
2730
|
+
let timer = window.setInterval(refresh, 1500);
|
|
2731
|
+
return () => {
|
|
2732
|
+
active = !1, window.clearInterval(timer);
|
|
2733
|
+
};
|
|
2734
|
+
}, []), React.useEffect(() => {
|
|
2735
|
+
if (status?.mode === "remote")
|
|
2736
|
+
return hideLocalSessionActions();
|
|
2737
|
+
}, [status?.mode]), status?.mode !== "remote") return null;
|
|
2738
|
+
let exit = async () => {
|
|
2739
|
+
setBusy(!0);
|
|
2740
|
+
try {
|
|
2741
|
+
await props.control("mode.set", { mode: "local" }), window.location.reload();
|
|
2742
|
+
} finally {
|
|
2743
|
+
setBusy(!1);
|
|
2744
|
+
}
|
|
2745
|
+
}, transport = status.transport ?? "Disconnected", networkLabel = t(transport === "P2P" ? "remoteNetworkP2p" : transport === "TURN" ? "remoteNetworkTurn" : transport === "Relay" ? "remoteNetworkRelay" : transport === "LAN" ? "remoteNetworkLan" : "remoteNetworkOffline"), networkOnline = status.connected === !0 && transport !== "Disconnected", routeVia = t(transport === "P2P" ? "connectionRouteP2p" : transport === "TURN" ? "connectionRouteTurn" : transport === "Relay" ? "connectionRouteRelay" : "connectionRouteLan");
|
|
2746
|
+
return React.createElement(
|
|
2747
|
+
"div",
|
|
2748
|
+
{ className: "dshRemoteSessionHeader", role: "status" },
|
|
2749
|
+
React.createElement("svg", {
|
|
2750
|
+
viewBox: "0 0 24 24",
|
|
2751
|
+
fill: "none",
|
|
2752
|
+
stroke: "currentColor",
|
|
2753
|
+
strokeWidth: 1.7,
|
|
2754
|
+
strokeLinecap: "round",
|
|
2755
|
+
strokeLinejoin: "round",
|
|
2756
|
+
"aria-hidden": !0
|
|
2757
|
+
}, React.createElement("rect", { x: 3, y: 4, width: 18, height: 13, rx: 2 }), React.createElement("path", { d: "M8 21h8M12 17v4" })),
|
|
2758
|
+
React.createElement("span", { className: "dshRemoteSessionTarget" }, t("remoteModeLabel", { name: status.target?.name ?? t("host") })),
|
|
2759
|
+
React.createElement("button", {
|
|
2760
|
+
type: "button",
|
|
2761
|
+
className: `dshRemoteNetwork${networkOnline ? " isOnline" : " isOffline"}`,
|
|
2762
|
+
title: networkLabel,
|
|
2763
|
+
disabled: !networkOnline,
|
|
2764
|
+
"aria-haspopup": "dialog",
|
|
2765
|
+
"aria-expanded": routeOpen,
|
|
2766
|
+
onClick: () => setRouteOpen((value) => !value)
|
|
2767
|
+
}, React.createElement("i", { "aria-hidden": !0 }), networkLabel),
|
|
2768
|
+
networkOnline ? React.createElement("span", { className: "dshRemoteEncrypted" }, t("remoteLinkEncrypted")) : null,
|
|
2769
|
+
React.createElement("button", { type: "button", className: "dshRemoteHeaderExitLink", disabled: busy, onClick: () => void exit() }, t("exitRemote")),
|
|
2770
|
+
routeOpen ? React.createElement("div", {
|
|
2771
|
+
className: "dshRemoteRouteBackdrop",
|
|
2772
|
+
role: "presentation",
|
|
2773
|
+
onMouseDown: (event) => {
|
|
2774
|
+
event.target === event.currentTarget && setRouteOpen(!1);
|
|
2775
|
+
}
|
|
2776
|
+
}, React.createElement(
|
|
2777
|
+
"section",
|
|
2778
|
+
{
|
|
2779
|
+
className: "dshRemoteRoutePanel",
|
|
2780
|
+
role: "dialog",
|
|
2781
|
+
"aria-modal": !0,
|
|
2782
|
+
"aria-label": t("connectionRouteTitle")
|
|
2783
|
+
},
|
|
2784
|
+
React.createElement(
|
|
2785
|
+
"header",
|
|
2786
|
+
null,
|
|
2787
|
+
React.createElement("strong", null, t("connectionRouteTitle")),
|
|
2788
|
+
React.createElement("button", { type: "button", "aria-label": t("close"), onClick: () => setRouteOpen(!1) }, "\xD7")
|
|
2789
|
+
),
|
|
2790
|
+
React.createElement(
|
|
2791
|
+
"ol",
|
|
2792
|
+
null,
|
|
2793
|
+
React.createElement("li", null, React.createElement("small", null, t("connectionRouteFrom")), React.createElement("strong", null, t("connectionRouteCurrentDevice"))),
|
|
2794
|
+
React.createElement("li", null, React.createElement("small", null, t("connectionRouteVia")), React.createElement("strong", null, routeVia)),
|
|
2795
|
+
React.createElement("li", null, React.createElement("small", null, t("connectionRouteTo")), React.createElement("strong", null, status.target?.name ?? t("host")), React.createElement("span", null, t("connectionRouteHost")))
|
|
2796
|
+
),
|
|
2797
|
+
React.createElement("p", null, t("connectionRouteEncrypted"))
|
|
2798
|
+
)) : null
|
|
2799
|
+
);
|
|
2800
|
+
}
|
|
2801
|
+
function hideLocalSessionActions() {
|
|
2802
|
+
let selector = 'button,a,[role="button"]', hiddenAttribute = "data-dsh-remote-hidden-action", localAction = /(?:open|打开).{0,12}vs\s*code|vs\s*code.{0,12}(?:open|打开)|session\s*logs?|download.{0,12}session\s*logs?|会话日志|下载.{0,8}日志/i, inspect = (root) => {
|
|
2803
|
+
let candidates = root instanceof Element && root.matches(selector) ? [root, ...Array.from(root.querySelectorAll(selector))] : Array.from(root.querySelectorAll(selector));
|
|
2804
|
+
for (let candidate of candidates) {
|
|
2805
|
+
if (candidate.closest(".dshRemoteSessionHeader") !== null) continue;
|
|
2806
|
+
let label = [
|
|
2807
|
+
candidate.getAttribute("aria-label"),
|
|
2808
|
+
candidate.getAttribute("title"),
|
|
2809
|
+
candidate.getAttribute("data-tooltip"),
|
|
2810
|
+
candidate.textContent
|
|
2811
|
+
].filter(Boolean).join(" ");
|
|
2812
|
+
localAction.test(label) && candidate.setAttribute(hiddenAttribute, "");
|
|
2813
|
+
}
|
|
2814
|
+
};
|
|
2815
|
+
inspect(document.body);
|
|
2816
|
+
let observer = new MutationObserver((records) => {
|
|
2817
|
+
for (let record of records) {
|
|
2818
|
+
record.type === "attributes" && inspect(record.target);
|
|
2819
|
+
for (let node of Array.from(record.addedNodes))
|
|
2820
|
+
node instanceof Element && inspect(node);
|
|
2821
|
+
}
|
|
2822
|
+
});
|
|
2823
|
+
return observer.observe(document.body, {
|
|
2824
|
+
subtree: !0,
|
|
2825
|
+
childList: !0,
|
|
2826
|
+
attributes: !0,
|
|
2827
|
+
attributeFilter: ["aria-label", "title", "data-tooltip"]
|
|
2828
|
+
}), () => {
|
|
2829
|
+
observer.disconnect(), document.querySelectorAll(`[${hiddenAttribute}]`).forEach((element) => element.removeAttribute(hiddenAttribute));
|
|
2830
|
+
};
|
|
2831
|
+
}
|
|
2832
|
+
function installStyle() {
|
|
2833
|
+
let style = document.createElement("style");
|
|
2834
|
+
return style.dataset.pluginCss = "dsh-remote", style.textContent = [
|
|
2835
|
+
'html.dshRemoteTargetActive button[aria-label="\u6DFB\u52A0\u5DE5\u4F5C\u533A"],html.dshRemoteTargetActive button[aria-label="Add workspace"]{display:none!important}',
|
|
2836
|
+
"[data-dsh-remote-hidden-action]{display:none!important}",
|
|
2837
|
+
".dshRemoteModeButton{min-height:36px;border:0;background:transparent;color:var(--dsw-alias-label-primary);display:flex;align-items:center;gap:8px;padding:0 10px;border-radius:8px}.dshRemoteModeButton:is(button){cursor:pointer}",
|
|
2838
|
+
".dshRemoteModeButton:is(button):hover{background:var(--dsw-alias-interactive-bg-hover)}",
|
|
2839
|
+
".dshRemoteSidebarEntry{box-sizing:border-box;position:relative;min-width:0;display:block;overflow:hidden}.dshRemoteSidebarEntry .dshRemoteModeButton{box-sizing:border-box;width:100%;min-width:0}.dshRemoteSidebarEntry.isWide{width:calc(100% + 8px);height:34px;margin:4px -4px}.dshRemoteSidebarEntry.isWide .dshRemoteModeButton{height:34px;min-height:34px;padding:6px 48px 6px 10px;border-radius:12px}.dshRemoteSidebarEntry.isRail{width:36px;height:54px}.dshRemoteSidebarEntry.isRail .dshRemoteModeButton{width:36px;height:36px;min-height:36px;justify-content:center;gap:0;margin:8px 0 10px;padding:0;border-radius:50%}.dshRemoteSidebarEntry.isActive .dshRemoteModeButton{color:var(--dsw-alias-label-secondary);background:transparent}.dshRemoteSidebarLabel{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dshRemoteExitLink{position:absolute;top:50%;right:10px;transform:translateY(-50%);white-space:nowrap;border:0;background:transparent;color:var(--dsw-alias-label-secondary);padding:0;font:inherit;font-size:12px;line-height:20px;cursor:pointer}.dshRemoteExitLink:hover{color:var(--dsw-alias-label-primary);text-decoration:underline}.dshRemoteExitLink:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px;border-radius:2px}.dshRemoteExitLink:disabled{opacity:.45;cursor:default;text-decoration:none}",
|
|
2840
|
+
".dshRemoteComputerIcon{box-sizing:border-box;width:18px;height:18px;flex:0 0 18px;color:var(--dsw-alias-label-secondary)}",
|
|
2841
|
+
'.dshRemoteSessionHeader{position:fixed;z-index:25;top:12px;left:50%;transform:translateX(-50%);max-width:calc(100vw - 360px);height:28px;display:inline-flex;align-items:center;gap:7px;color:var(--dsw-alias-label-secondary);font-size:12px;white-space:nowrap}.dshRemoteSessionHeader>svg{width:15px;height:15px;flex:0 0 auto}.dshRemoteSessionTarget{min-width:0;max-width:260px;overflow:hidden;text-overflow:ellipsis}.dshRemoteNetwork{flex:0 0 auto;border:0;background:transparent;color:inherit;font:inherit;padding:3px 2px;display:inline-flex;align-items:center;gap:5px;cursor:pointer}.dshRemoteNetwork:hover:not(:disabled){color:var(--dsw-alias-label-primary);text-decoration:underline}.dshRemoteNetwork:disabled{cursor:default}.dshRemoteNetwork>i{width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-label-tertiary)}.dshRemoteNetwork.isOnline>i{background:var(--dsw-alias-state-success-primary)}.dshRemoteNetwork.isOffline{color:var(--dsw-alias-state-error-primary)}.dshRemoteNetwork.isOffline>i{background:currentColor}.dshRemoteEncrypted{flex:0 0 auto;color:var(--dsw-alias-label-tertiary)}.dshRemoteHeaderExitLink{flex:0 0 auto;border:0;background:transparent;color:var(--dsw-alias-label-secondary);padding:3px 2px;font:inherit;text-decoration:none;cursor:pointer}.dshRemoteHeaderExitLink:hover{text-decoration:underline;color:var(--dsw-alias-label-primary)}.dshRemoteHeaderExitLink:disabled{opacity:.45;cursor:default;text-decoration:none}.dshRemoteRouteBackdrop{position:fixed;inset:0;z-index:26}.dshRemoteRoutePanel{position:absolute;top:48px;right:28px;width:min(460px,calc(100vw - 32px));color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);border-radius:12px;box-shadow:var(--dsw-shadow-lv2);padding:16px;white-space:normal}.dshRemoteRoutePanel>header{display:flex;align-items:center;justify-content:space-between}.dshRemoteRoutePanel>header strong{font-size:14px}.dshRemoteRoutePanel>header button{width:28px;height:28px;border:0;border-radius:7px;background:transparent;color:inherit;font-size:20px;cursor:pointer}.dshRemoteRoutePanel>header button:hover{background:var(--dsw-alias-interactive-bg-hover)}.dshRemoteRoutePanel ol{display:flex;align-items:stretch;margin:16px 0;padding:0;list-style:none}.dshRemoteRoutePanel li{position:relative;min-width:0;flex:1;display:flex;flex-direction:column;gap:4px;padding-right:20px}.dshRemoteRoutePanel li:not(:last-child)::after{content:"\u2192";position:absolute;right:7px;top:21px;color:var(--dsw-alias-label-tertiary)}.dshRemoteRoutePanel li small{color:var(--dsw-alias-label-tertiary)}.dshRemoteRoutePanel li strong,.dshRemoteRoutePanel li span{overflow:hidden;text-overflow:ellipsis}.dshRemoteRoutePanel li strong{font-size:13px}.dshRemoteRoutePanel li span{color:var(--dsw-alias-label-secondary);font-size:11px}.dshRemoteRoutePanel>p{margin:14px 0 0;padding-top:12px;border-top:1px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1.5}@media(max-width:620px){.dshRemoteSessionHeader{top:8px;max-width:calc(100vw - 112px)}.dshRemoteSessionHeader>svg{display:none}.dshRemoteSessionTarget{max-width:130px}.dshRemoteEncrypted{display:none}.dshRemoteRoutePanel{top:42px;right:12px}.dshRemoteRoutePanel ol{flex-direction:column;gap:18px}.dshRemoteRoutePanel li:not(:last-child)::after{content:"\u2193";top:auto;right:auto;bottom:-16px;left:3px}}',
|
|
2842
|
+
".dshRemoteSessionHeader{left:auto;right:148px;transform:none;max-width:calc(100vw - 420px)}@media(max-width:760px){.dshRemoteSessionHeader{left:auto;right:104px;transform:none;max-width:calc(100vw - 124px)}}",
|
|
2843
|
+
".dshRemoteModeButton:focus-visible,.dshRemotePage button:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}",
|
|
2844
|
+
".dshRemotePage{width:min(720px,100%);max-height:min(760px,calc(100vh - 40px));display:flex;flex-direction:column;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);border-radius:14px;overflow:hidden;animation:dshRemotePageIn .18s cubic-bezier(.25,1,.5,1)}",
|
|
2845
|
+
".dshRemotePageHeader{min-height:72px;display:flex;align-items:center;justify-content:space-between;gap:24px;padding:14px 24px;border-bottom:1px solid var(--dsw-alias-border-l2)}.dshRemotePageIntro{min-width:0;flex:1}.dshRemotePageHeader strong{display:block;font-size:18px;line-height:1.4}.dshRemotePageHeader p{min-width:0;max-width:70ch;margin:3px 0 0;color:var(--dsw-alias-label-secondary);font-size:13px;line-height:1.5}.dshRemotePageHeader>button{width:40px;height:40px;flex:0 0 auto;border:0;border-radius:8px;background:transparent;color:inherit;font-size:24px;cursor:pointer}.dshRemotePageHeader>button:hover{background:var(--dsw-alias-interactive-bg-hover)}",
|
|
2846
|
+
".dshRemotePageBody{padding:24px;overflow:auto;display:flex;flex-direction:column;gap:24px}.dshRemotePageBody button{font:inherit;color:inherit}",
|
|
2847
|
+
".dshRemoteSectionHeading{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:10px}.dshRemoteSectionHeading>strong{font-size:14px}.dshRemoteSectionActions{display:flex;align-items:center;gap:14px}.dshRemoteSectionActions>button{border:0;background:transparent;color:var(--dsw-alias-label-secondary);cursor:pointer;padding:5px 0;font-size:12px}.dshRemoteSectionActions>button:hover:not(:disabled){color:var(--dsw-alias-label-primary);text-decoration:underline}",
|
|
2848
|
+
".dshRemoteSectionHeading>.dshRemoteAddWorkspace{width:30px;height:30px;display:inline-flex;align-items:center;justify-content:center;padding:0;border-radius:50%;font-size:20px;line-height:1}.dshRemoteSectionHeading>.dshRemoteAddWorkspace:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}",
|
|
2849
|
+
".dshRemoteHostList{display:flex;flex-direction:column;border-top:1px solid var(--dsw-alias-border-l2)}.dshRemoteHostList>button{min-height:58px;display:flex;align-items:center;justify-content:space-between;gap:16px;text-align:left;border:0;border-bottom:1px solid var(--dsw-alias-border-l2);background:transparent;padding:10px 4px;cursor:pointer}.dshRemoteHostList>button:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.dshRemoteHostList>button:disabled{opacity:.5;cursor:default}.dshRemoteHostList>button>span{min-width:0;display:flex;flex-direction:column;gap:3px}.dshRemoteHostList>button strong{font-size:14px;font-weight:500}.dshRemoteHostList small,.dshRemoteSelectedHost small{color:var(--dsw-alias-label-secondary);font-size:12px}",
|
|
2850
|
+
".dshRemoteSelectedHost{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 14px;border-radius:10px;background:var(--dsw-alias-bg-layer-2)}",
|
|
2851
|
+
'.dshRemoteBrowser{display:flex;flex-direction:column}.dshRemoteCrumbs{display:flex;align-items:center;gap:4px;overflow:auto;padding:2px 0 10px}.dshRemoteCrumbs>button{flex:0 0 auto;border:0;background:transparent;color:var(--dsw-alias-label-secondary);padding:5px 7px;border-radius:6px;cursor:pointer}.dshRemoteCrumbs>button:not(:last-child)::after{content:" /";color:var(--dsw-alias-label-tertiary)}.dshRemoteCrumbs>button:disabled{color:var(--dsw-alias-label-primary);font-weight:600}',
|
|
2852
|
+
".dshRemoteDirectoryList{min-height:72px;display:flex;flex-direction:column;border-top:1px solid var(--dsw-alias-border-l2)}.dshRemoteDirectoryList>button{min-height:52px;display:grid;grid-template-columns:auto 1fr;column-gap:10px;text-align:left;border:0;border-bottom:1px solid var(--dsw-alias-border-l2);background:transparent;padding:8px 4px;cursor:pointer}.dshRemoteDirectoryList>button:hover,.dshRemoteDirectoryList>button.isSelected{background:var(--dsw-alias-interactive-bg-hover)}.dshRemoteDirectoryList>button.isSelected{color:var(--dsw-alias-label-primary)}.dshRemoteDirectoryList>button>span:first-child{grid-row:1/3}.dshRemoteDirectoryList>button>small{grid-column:2;color:var(--dsw-alias-label-secondary);overflow:hidden;text-overflow:ellipsis}.dshRemoteDirectoryList>p,.dshRemoteHint{margin:12px 0;color:var(--dsw-alias-label-secondary);font-size:13px}",
|
|
2853
|
+
".dshRemoteFolderBrowser{margin-top:14px}.dshRemoteFolderBrowser>p,.dshRemoteFolderList>p{margin:12px 0;color:var(--dsw-alias-label-secondary);font-size:13px}.dshRemoteFolderList{max-height:260px;overflow:auto;border-block:1px solid var(--dsw-alias-border-l2)}.dshRemoteFolderList>button{width:100%;min-height:42px;display:flex;align-items:center;gap:9px;border:0;border-bottom:1px solid var(--dsw-alias-border-l2);background:transparent;padding:7px 6px;text-align:left;cursor:pointer}.dshRemoteFolderList>button:hover{background:var(--dsw-alias-interactive-bg-hover)}.dshRemoteFolderBrowser>small{display:block;margin-top:8px;color:var(--dsw-alias-state-warn-label)}",
|
|
2854
|
+
".dshRemotePathField{display:flex;flex-direction:column;gap:6px;margin-top:20px}.dshRemotePathField>span{font-size:13px;font-weight:600}.dshRemotePathField>input{min-height:40px;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;background:var(--dsw-alias-bg-layer-3);color:inherit;padding:0 12px;font:inherit}.dshRemotePathField>small{color:var(--dsw-alias-label-secondary)}",
|
|
2855
|
+
".dshRemoteOpenBar{position:sticky;bottom:-96px;display:flex;align-items:center;justify-content:space-between;gap:20px;margin-top:20px;padding:14px 0;background:var(--dsw-alias-bg-layer-1);border-top:1px solid var(--dsw-alias-border-l2)}.dshRemoteOpenBar>div{min-width:0;display:flex;flex-direction:column;gap:3px}.dshRemoteOpenBar span{color:var(--dsw-alias-label-secondary);font-size:12px}.dshRemoteOpenBar strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px}.dshRemoteOpenBar>button,.dshRemoteEnable>button{min-height:40px;flex:0 0 auto;border:0;border-radius:8px;background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-1);padding:8px 16px;cursor:pointer}.dshRemoteOpenBar>button:disabled,.dshRemoteEnable>button:disabled{opacity:.5;cursor:default}",
|
|
2856
|
+
".dshRemoteEnable{max-width:600px;display:flex;flex-direction:column;align-items:flex-start;gap:10px}.dshRemoteEnable p{margin:0;color:var(--dsw-alias-label-secondary);line-height:1.5}",
|
|
2857
|
+
'.dshRemoteLoginTabs{width:min(440px,100%);display:flex;border-bottom:1px solid var(--dsw-alias-border-l2)}.dshRemoteLoginTabs>button{position:relative;min-height:38px;border:0;background:transparent;color:var(--dsw-alias-label-secondary);padding:6px 14px;font:inherit;font-size:13px;cursor:pointer}.dshRemoteLoginTabs>button:hover:not(:disabled){color:var(--dsw-alias-label-primary)}.dshRemoteLoginTabs>button.isActive{color:var(--dsw-alias-label-primary);font-weight:600}.dshRemoteLoginTabs>button.isActive::after{content:"";position:absolute;right:12px;bottom:-1px;left:12px;height:2px;border-radius:2px 2px 0 0;background:var(--dsw-alias-brand-primary)}.dshRemoteLoginTabs>button:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px;border-radius:6px}',
|
|
2858
|
+
".dshRemoteClientLogin{width:min(440px,100%);display:flex;flex-direction:column;gap:8px}.dshRemoteClientLogin input{min-height:40px;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;background:var(--dsw-alias-bg-layer-3);color:inherit;padding:0 12px;font:inherit}.dshRemoteClientLogin button{align-self:flex-start;min-height:40px;border:0;border-radius:8px;background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-1);padding:8px 16px;cursor:pointer}",
|
|
2859
|
+
".dshRemoteQrLogin{width:min(440px,100%);display:flex;flex-direction:column;align-items:center;gap:8px;padding:6px 0 2px;text-align:center}.dshRemoteQrLogin img,.dshRemoteQrPlaceholder{box-sizing:border-box;width:200px;height:200px;border:1px solid var(--dsw-alias-border-l2);border-radius:12px;background:#fff;padding:8px}.dshRemoteQrPlaceholder{display:flex;align-items:center;justify-content:center;color:var(--dsw-alias-label-secondary)}.dshRemoteQrLogin>strong{font-size:14px}.dshRemoteQrLogin>p{max-width:48ch;margin:0;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1.5}.dshRemoteQrLogin>.dshRemoteServiceAddress{margin-top:2px;color:var(--dsw-alias-label-tertiary)}.dshRemoteServiceAddress>a{color:var(--dsw-alias-label-secondary);text-decoration:none}.dshRemoteServiceAddress>a:hover{color:var(--dsw-alias-label-primary);text-decoration:underline}.dshRemoteQrLogin>button,.dshRemoteClientLogin>.dshRemoteLoginSwitch{min-height:32px;border:0;background:transparent;color:var(--dsw-alias-label-secondary);padding:4px 8px;font:inherit;font-size:12px;cursor:pointer}.dshRemoteQrLogin>button:hover,.dshRemoteClientLogin>.dshRemoteLoginSwitch:hover{color:var(--dsw-alias-label-primary);text-decoration:underline}.dshRemoteClientLogin>.dshRemoteLoginSwitch{align-self:flex-start;background:transparent;color:var(--dsw-alias-label-secondary);padding-left:0}",
|
|
2860
|
+
".dshRemoteEnable{box-sizing:border-box;width:100%;min-height:388px}.dshRemoteLoginHeading{max-width:100%;display:flex;align-items:baseline;gap:10px;overflow:hidden;white-space:nowrap}.dshRemoteLoginTitle{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dshRemoteLoginHeading>span{flex:0 0 auto;color:var(--dsw-alias-label-secondary);font-size:13px;font-weight:400}.dshRemoteLoginTabs{width:100%}.dshRemoteLoginTabs>button{flex:1}.dshRemoteLoginTabs>button.isActive::after{right:0;left:0;border-radius:0}.dshRemoteClientLogin,.dshRemoteQrLogin{box-sizing:border-box;width:min(440px,100%);height:300px;min-height:300px;align-self:center}.dshRemoteClientLogin{align-items:stretch;padding-top:16px}.dshRemoteClientLogin>button{align-self:stretch;width:100%}.dshRemoteQrLogin{padding-top:12px}",
|
|
2861
|
+
'.dshRemoteHostControlToggle{display:flex;align-items:center;gap:8px;color:var(--dsw-alias-label-secondary);font-size:12px;white-space:nowrap;cursor:default}.dshRemoteHostControlToggle>input{appearance:none;position:relative;width:38px;height:22px;flex:0 0 auto;margin:0;border:1px solid var(--dsw-alias-label-secondary);border-radius:999px;background:var(--dsw-alias-bg-layer-3);cursor:pointer;box-shadow:inset 0 0 0 1px var(--dsw-alias-border-l2);transition:background .16s ease-out,border-color .16s ease-out,box-shadow .16s ease-out}.dshRemoteHostControlToggle>input::after{content:"";position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:50%;background:var(--dsw-alias-label-secondary);transition:transform .16s ease-out,background .16s ease-out}.dshRemoteHostControlToggle>input:checked{border-color:var(--dsw-alias-state-success-primary);background:var(--dsw-alias-state-success-primary);box-shadow:none}.dshRemoteHostControlToggle>input:checked::after{transform:translateX(16px);background:var(--dsw-alias-bg-layer-1)}.dshRemoteHostControlToggle>input:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}.dshRemoteHostControlToggle>input:disabled{opacity:.5;cursor:default}@media(prefers-reduced-motion:reduce){.dshRemoteHostControlToggle>input,.dshRemoteHostControlToggle>input::after{transition:none}}',
|
|
2862
|
+
".dshRemoteAccountExit{flex:0 0 auto}.dshRemoteAccountExit:disabled{opacity:.5;cursor:default;text-decoration:none}",
|
|
2863
|
+
".dshRemoteLocalLink{align-self:flex-start;border:0;background:transparent;color:var(--dsw-alias-label-secondary);padding:4px 0;cursor:pointer}.dshRemoteLocalLink:hover{color:var(--dsw-alias-label-primary)}",
|
|
2864
|
+
"@keyframes dshRemotePageIn{from{opacity:0;transform:translateY(6px) scale(.99)}to{opacity:1;transform:none}}@media(prefers-reduced-motion:reduce){.dshRemotePage{animation:none}}@media(max-width:620px){.dshRemoteBackdrop{padding:12px}.dshRemotePage{max-height:calc(100vh - 24px)}.dshRemotePageHeader{padding:12px 16px}.dshRemoteSectionHeading{align-items:flex-start;flex-direction:column;gap:8px}.dshRemoteSectionActions{width:100%;justify-content:space-between}.dshRemotePageBody{padding:20px 16px}.dshRemoteOpenBar{align-items:flex-end}.dshRemoteOpenBar>button{min-height:48px}}",
|
|
2865
|
+
".dshRemoteBackdrop{position:fixed;inset:0;z-index:1000;background:var(--dsw-alias-bg-mask-3);display:grid;place-items:center;padding:20px}",
|
|
2866
|
+
".dshRemoteDialog{width:min(460px,100%);max-height:80vh;overflow:auto;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l2);border-radius:14px;padding:18px;display:grid;gap:12px;box-shadow:var(--dsw-shadow-lv2)}",
|
|
2867
|
+
".dshRemoteDialog button,.dshRemoteDialog input{font:inherit;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:9px 10px;background:transparent;color:inherit}",
|
|
2868
|
+
".dshRemoteDialog button:not(:disabled){cursor:pointer}.dshRemoteDialog button:disabled{opacity:.5}",
|
|
2869
|
+
".dshRemoteHeader{display:flex;align-items:center;justify-content:space-between}.dshRemoteHeader button{border:0;font-size:22px;padding:0 6px}",
|
|
2870
|
+
".dshRemoteDevices{display:grid;gap:8px}.dshRemoteDevices p{margin:4px 0;color:var(--dsw-alias-label-secondary)}",
|
|
2871
|
+
".dshRemoteError{margin:0;color:var(--dsw-alias-state-error-primary)}",
|
|
2872
|
+
".dshRemoteHostAccount{display:grid;gap:8px;border-top:1px solid var(--dsw-alias-border-l3);padding-top:12px}.dshRemoteHostAccount p{margin:0;color:var(--dsw-alias-label-secondary);font-size:13px}",
|
|
2873
|
+
".dshRemoteLogin{display:grid;grid-template-columns:1fr 1fr;gap:8px}.dshRemoteLogin button{grid-column:1/-1}",
|
|
2874
|
+
".dshRemotePluginCard{list-style:none;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:12px;transition:border-color .16s,background .16s}",
|
|
2875
|
+
".dshRemotePluginCard:hover{border-color:var(--dsw-alias-label-dimmed)}.dshRemotePluginCard.isOpen{background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-label-dimmed)}",
|
|
2876
|
+
".dshRemotePluginCardHeader{display:flex;align-items:center}.dshRemotePluginCardToggle{appearance:none;width:100%;min-width:0;font:inherit;color:inherit;text-align:left;cursor:pointer;background:transparent;border:0;border-radius:12px;display:flex;align-items:center;gap:12px;padding:14px 16px}.dshRemotePluginCardToggle:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px}",
|
|
2877
|
+
".dshRemotePluginCardHeading{display:flex;flex-direction:column;gap:4px;min-width:0;flex:1}.dshRemotePluginCardHeading>strong{color:var(--dsw-alias-label-primary);font-size:15px;font-weight:600;line-height:1.4}.dshRemotePluginCardHeading>span{color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:1.5}.dshRemotePluginCardStatus{white-space:nowrap;background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-secondary);border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px}.dshRemotePluginCardStatus.isOnline{color:var(--dsw-alias-state-success-primary)}.dshRemotePluginCardStatus.isReconnecting{color:var(--dsw-alias-state-warn-label)}.dshRemotePluginCardStatus.isOffline{color:var(--dsw-alias-state-error-primary)}.dshRemotePluginCardChevron{color:var(--dsw-alias-label-tertiary);font-size:18px;line-height:14px;transition:transform .16s}.dshRemotePluginCard.isOpen .dshRemotePluginCardChevron{transform:rotate(180deg)}",
|
|
2878
|
+
".dshRemotePluginCardBody{border-top:1px solid var(--dsw-alias-border-l2);margin:0 16px;padding-bottom:8px}.dshRemoteSettings{display:flex;flex-direction:column;max-width:720px}.dshRemoteSettingsTop{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;padding:12px 0}.dshRemoteSettingsState{margin:0;color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:1.5}",
|
|
2879
|
+
".dshRemoteField{display:flex;flex-direction:column;gap:6px;padding:12px 0}.dshRemoteField+.dshRemoteField{border-top:1px solid var(--dsw-alias-border-l2)}.dshRemoteField label{color:var(--dsw-alias-label-primary);font-size:13px;font-weight:500;line-height:1.5}.dshRemoteField input{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);height:34px;font:inherit;color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 12px;font-size:13px;line-height:1.5}.dshRemoteField input:focus-visible{border-color:var(--dsw-alias-brand-primary);outline:none}.dshRemoteField input:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}.dshRemoteField p{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:1.5}",
|
|
2880
|
+
'.dshRemoteAuthorizationSetting{border-top:1px solid var(--dsw-alias-border-l2);display:flex;align-items:center;justify-content:space-between;gap:20px;padding:12px 0}.dshRemoteAuthorizationSetting>div{min-width:0}.dshRemoteAuthorizationSetting strong{font-size:13px;font-weight:500}.dshRemoteAuthorizationSetting p{margin:3px 0 0;color:var(--dsw-alias-label-tertiary);font-size:12px}.dshRemoteAuthorizationSetting>input{appearance:none;position:relative;width:38px;height:22px;flex:0 0 auto;margin:0;border:1px solid var(--dsw-alias-label-secondary);border-radius:999px;background:var(--dsw-alias-bg-layer-3);cursor:pointer;box-shadow:inset 0 0 0 1px var(--dsw-alias-border-l2);transition:background .16s ease-out,border-color .16s ease-out,box-shadow .16s ease-out}.dshRemoteAuthorizationSetting>input::after{content:"";position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:50%;background:var(--dsw-alias-label-secondary);transition:transform .16s ease-out,background .16s ease-out}.dshRemoteAuthorizationSetting>input:checked{border-color:var(--dsw-alias-state-success-primary);background:var(--dsw-alias-state-success-primary);box-shadow:none}.dshRemoteAuthorizationSetting>input:checked::after{transform:translateX(16px);background:var(--dsw-alias-bg-layer-1)}.dshRemoteAuthorizationSetting>input:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}.dshRemoteAuthorizationSetting>input:disabled{opacity:.5;cursor:default}@media(prefers-reduced-motion:reduce){.dshRemoteAuthorizationSetting>input,.dshRemoteAuthorizationSetting>input::after{transition:none}}',
|
|
2881
|
+
".dshRemoteAssociation{min-width:0;flex:1;display:flex;flex-direction:column;gap:4px}.dshRemoteAssociation>span{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:1.5}.dshRemoteAssociation strong{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:500;line-height:1.5}.dshRemoteAssociation p{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:1.5}",
|
|
2882
|
+
".dshRemoteConnection{border-top:1px solid var(--dsw-alias-border-l2);display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 0}.dshRemoteConnectionSummary{min-width:0;display:flex;flex-direction:column;gap:4px}.dshRemoteConnectionSummary>span{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:1.5}.dshRemoteConnectionSummary strong{display:flex;align-items:center;gap:7px;color:var(--dsw-alias-label-primary);font-size:14px;font-weight:500;line-height:1.5}.dshRemoteConnectionSummary p,.dshRemoteConnectionIssue{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:1.5}.dshRemoteConnectionDot{width:8px;height:8px;flex:0 0 auto;border-radius:999px;background:var(--dsw-alias-label-tertiary)}.dshRemoteConnectionDot.isOnline{background:var(--dsw-alias-state-success-primary)}.dshRemoteConnectionDot.isReconnecting{background:var(--dsw-alias-state-warn-primary)}.dshRemoteConnectionDot.isOffline{background:var(--dsw-alias-state-error-primary)}.dshRemoteConnectionIssue{color:var(--dsw-alias-state-error-primary);padding:0 0 12px}.dshRemoteReconnect{appearance:none;flex:0 0 auto;font:inherit;cursor:pointer;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary);min-height:34px;padding:5px 14px;font-size:13px;line-height:1.5}.dshRemoteReconnect:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed);background:var(--dsw-alias-interactive-bg-hover)}.dshRemoteReconnect:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}.dshRemoteReconnect:disabled{opacity:.4;cursor:default}",
|
|
2883
|
+
".dshRemoteSettingsFooter{border-top:1px solid var(--dsw-alias-border-l2);display:flex;justify-content:flex-end;align-items:center;gap:8px;padding:12px 0 4px}.dshRemoteSettingsFooter .dshRemoteError,.dshRemoteNotice{min-width:0;flex:1;margin:0;font-size:12px;line-height:1.5}.dshRemoteNotice{color:var(--dsw-alias-label-tertiary)}.dshRemoteDiscard,.dshRemoteSave{appearance:none;font:inherit;cursor:pointer;border:1px solid transparent;border-radius:8px;padding:5px 14px;font-size:13px;line-height:1.5}.dshRemoteDiscard{border-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);background:transparent}.dshRemoteDiscard:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed)}.dshRemoteSave{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}.dshRemoteDiscard:disabled,.dshRemoteSave:disabled{opacity:.4;cursor:default}.dshRemoteDiscard:focus-visible,.dshRemoteSave:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}",
|
|
2884
|
+
"@media(max-width:620px){.dshRemotePluginCardStatus{display:none}.dshRemoteSettingsTop{gap:10px}.dshRemoteConnection{align-items:flex-start}.dshRemoteReconnect{min-height:40px}}"
|
|
2885
|
+
].join(""), document.head.append(style), () => style.remove();
|
|
2886
|
+
}
|
|
2887
|
+
function apply(ctx) {
|
|
2888
|
+
let t = ctx.locale.bind(localeNamespace), control = async (endpoint, payload = {}) => {
|
|
2889
|
+
let result;
|
|
2890
|
+
for (let attempt = 0; ; attempt += 1)
|
|
2891
|
+
try {
|
|
2892
|
+
result = await ctx.connection.rpc.call("/remote", endpoint, payload);
|
|
2893
|
+
break;
|
|
2894
|
+
} catch (reason) {
|
|
2895
|
+
if (attempt >= 19 || !isPendingControlRoute(reason)) throw reason;
|
|
2896
|
+
await delay(100);
|
|
2897
|
+
}
|
|
2898
|
+
if (!result.ok) throw new Error(result.error?.message ?? t("remoteRequestFailed"));
|
|
2899
|
+
return result.value;
|
|
2900
|
+
};
|
|
2901
|
+
ctx.effect(() => ctx.locale.register(localeNamespace, { zh, en }), "dsh-remote: dictionaries"), ctx.effect(installStyle, "dsh-remote: client styles"), ctx.slots.inject("shell.overlay", () => ctx.slots.register({
|
|
2902
|
+
name: "shell.overlay",
|
|
2903
|
+
id: "dsh-remote-global-context",
|
|
2904
|
+
order: 20,
|
|
2905
|
+
locale: localeNamespace,
|
|
2906
|
+
inject: () => ({ control })
|
|
2907
|
+
}, RemoteSessionHeaderAction)), ctx.slots.inject("sidebar.footer.action", () => ctx.slots.register({
|
|
2908
|
+
name: "sidebar.footer.action",
|
|
2909
|
+
id: "dsh-remote-workspace",
|
|
2910
|
+
order: -20,
|
|
2911
|
+
locale: localeNamespace,
|
|
2912
|
+
inject: () => ({ control })
|
|
2913
|
+
}, RemoteWorkspaceAction)), ctx.slots.inject("settings.plugin.item", () => ctx.slots.register({
|
|
2914
|
+
name: "settings.plugin.item",
|
|
2915
|
+
key: "dsh-remote",
|
|
2916
|
+
id: "dsh-remote",
|
|
2917
|
+
order: 30,
|
|
2918
|
+
locale: localeNamespace,
|
|
2919
|
+
inject: () => ({ control })
|
|
2920
|
+
}, RemotePluginOptions));
|
|
2921
|
+
}
|
|
2922
|
+
function isPendingControlRoute(reason) {
|
|
2923
|
+
return reason instanceof Error && /transport failure for \/remote\/[^:]+: HTTP 405$/.test(reason.message);
|
|
2924
|
+
}
|
|
2925
|
+
function delay(ms) {
|
|
2926
|
+
return new Promise((resolve) => window.setTimeout(resolve, ms));
|
|
2927
|
+
}
|
|
2928
|
+
function messageOf(reason) {
|
|
2929
|
+
return reason instanceof Error ? reason.message : String(reason);
|
|
2930
|
+
}
|
|
2931
|
+
function formatPlatform(value) {
|
|
2932
|
+
let normalized = value.toLowerCase();
|
|
2933
|
+
return normalized === "darwin" || normalized === "macos" ? "macOS" : normalized === "win32" || normalized === "windows" ? "Windows" : normalized === "linux" ? "Linux" : value;
|
|
2934
|
+
}
|
|
2935
|
+
return module.exports.apply = apply, module.exports.inject = inject, module.exports;
|
|
2936
|
+
}
|
|
2937
|
+
});
|
|
2938
|
+
})();
|