dsh-dock 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +136 -0
- package/client.js +2522 -115
- package/features/games/view.jsx +1 -1
- package/features/mobile-relay/gateway.js +217 -81
- package/features/mobile-relay/host.js +305 -230
- package/features/mobile-relay/view.jsx +107 -140
- package/index.js +20 -1
- package/package.json +2 -1
- package/src/client.jsx +4 -3
- package/src/host-core.js +7 -1
package/client.js
CHANGED
|
@@ -11,6 +11,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
11
11
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
12
|
var __getProtoOf = Object.getPrototypeOf;
|
|
13
13
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
15
|
+
try {
|
|
16
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
17
|
+
} catch (e) {
|
|
18
|
+
throw mod = 0, e;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
14
21
|
var __export = (target, all) => {
|
|
15
22
|
for (var name in all)
|
|
16
23
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -33,6 +40,2084 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
40
|
));
|
|
34
41
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
42
|
|
|
43
|
+
// node_modules/qrcode/lib/can-promise.js
|
|
44
|
+
var require_can_promise = __commonJS({
|
|
45
|
+
"node_modules/qrcode/lib/can-promise.js"(exports, module2) {
|
|
46
|
+
module2.exports = function() {
|
|
47
|
+
return typeof Promise === "function" && Promise.prototype && Promise.prototype.then;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// node_modules/qrcode/lib/core/utils.js
|
|
53
|
+
var require_utils = __commonJS({
|
|
54
|
+
"node_modules/qrcode/lib/core/utils.js"(exports) {
|
|
55
|
+
var toSJISFunction;
|
|
56
|
+
var CODEWORDS_COUNT = [
|
|
57
|
+
0,
|
|
58
|
+
// Not used
|
|
59
|
+
26,
|
|
60
|
+
44,
|
|
61
|
+
70,
|
|
62
|
+
100,
|
|
63
|
+
134,
|
|
64
|
+
172,
|
|
65
|
+
196,
|
|
66
|
+
242,
|
|
67
|
+
292,
|
|
68
|
+
346,
|
|
69
|
+
404,
|
|
70
|
+
466,
|
|
71
|
+
532,
|
|
72
|
+
581,
|
|
73
|
+
655,
|
|
74
|
+
733,
|
|
75
|
+
815,
|
|
76
|
+
901,
|
|
77
|
+
991,
|
|
78
|
+
1085,
|
|
79
|
+
1156,
|
|
80
|
+
1258,
|
|
81
|
+
1364,
|
|
82
|
+
1474,
|
|
83
|
+
1588,
|
|
84
|
+
1706,
|
|
85
|
+
1828,
|
|
86
|
+
1921,
|
|
87
|
+
2051,
|
|
88
|
+
2185,
|
|
89
|
+
2323,
|
|
90
|
+
2465,
|
|
91
|
+
2611,
|
|
92
|
+
2761,
|
|
93
|
+
2876,
|
|
94
|
+
3034,
|
|
95
|
+
3196,
|
|
96
|
+
3362,
|
|
97
|
+
3532,
|
|
98
|
+
3706
|
|
99
|
+
];
|
|
100
|
+
exports.getSymbolSize = function getSymbolSize(version) {
|
|
101
|
+
if (!version) throw new Error('"version" cannot be null or undefined');
|
|
102
|
+
if (version < 1 || version > 40) throw new Error('"version" should be in range from 1 to 40');
|
|
103
|
+
return version * 4 + 17;
|
|
104
|
+
};
|
|
105
|
+
exports.getSymbolTotalCodewords = function getSymbolTotalCodewords(version) {
|
|
106
|
+
return CODEWORDS_COUNT[version];
|
|
107
|
+
};
|
|
108
|
+
exports.getBCHDigit = function(data) {
|
|
109
|
+
let digit = 0;
|
|
110
|
+
while (data !== 0) {
|
|
111
|
+
digit++;
|
|
112
|
+
data >>>= 1;
|
|
113
|
+
}
|
|
114
|
+
return digit;
|
|
115
|
+
};
|
|
116
|
+
exports.setToSJISFunction = function setToSJISFunction(f) {
|
|
117
|
+
if (typeof f !== "function") {
|
|
118
|
+
throw new Error('"toSJISFunc" is not a valid function.');
|
|
119
|
+
}
|
|
120
|
+
toSJISFunction = f;
|
|
121
|
+
};
|
|
122
|
+
exports.isKanjiModeEnabled = function() {
|
|
123
|
+
return typeof toSJISFunction !== "undefined";
|
|
124
|
+
};
|
|
125
|
+
exports.toSJIS = function toSJIS(kanji) {
|
|
126
|
+
return toSJISFunction(kanji);
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// node_modules/qrcode/lib/core/error-correction-level.js
|
|
132
|
+
var require_error_correction_level = __commonJS({
|
|
133
|
+
"node_modules/qrcode/lib/core/error-correction-level.js"(exports) {
|
|
134
|
+
exports.L = { bit: 1 };
|
|
135
|
+
exports.M = { bit: 0 };
|
|
136
|
+
exports.Q = { bit: 3 };
|
|
137
|
+
exports.H = { bit: 2 };
|
|
138
|
+
function fromString(string) {
|
|
139
|
+
if (typeof string !== "string") {
|
|
140
|
+
throw new Error("Param is not a string");
|
|
141
|
+
}
|
|
142
|
+
const lcStr = string.toLowerCase();
|
|
143
|
+
switch (lcStr) {
|
|
144
|
+
case "l":
|
|
145
|
+
case "low":
|
|
146
|
+
return exports.L;
|
|
147
|
+
case "m":
|
|
148
|
+
case "medium":
|
|
149
|
+
return exports.M;
|
|
150
|
+
case "q":
|
|
151
|
+
case "quartile":
|
|
152
|
+
return exports.Q;
|
|
153
|
+
case "h":
|
|
154
|
+
case "high":
|
|
155
|
+
return exports.H;
|
|
156
|
+
default:
|
|
157
|
+
throw new Error("Unknown EC Level: " + string);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
exports.isValid = function isValid(level) {
|
|
161
|
+
return level && typeof level.bit !== "undefined" && level.bit >= 0 && level.bit < 4;
|
|
162
|
+
};
|
|
163
|
+
exports.from = function from(value, defaultValue) {
|
|
164
|
+
if (exports.isValid(value)) {
|
|
165
|
+
return value;
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
return fromString(value);
|
|
169
|
+
} catch (e) {
|
|
170
|
+
return defaultValue;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// node_modules/qrcode/lib/core/bit-buffer.js
|
|
177
|
+
var require_bit_buffer = __commonJS({
|
|
178
|
+
"node_modules/qrcode/lib/core/bit-buffer.js"(exports, module2) {
|
|
179
|
+
function BitBuffer() {
|
|
180
|
+
this.buffer = [];
|
|
181
|
+
this.length = 0;
|
|
182
|
+
}
|
|
183
|
+
BitBuffer.prototype = {
|
|
184
|
+
get: function(index) {
|
|
185
|
+
const bufIndex = Math.floor(index / 8);
|
|
186
|
+
return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) === 1;
|
|
187
|
+
},
|
|
188
|
+
put: function(num, length) {
|
|
189
|
+
for (let i = 0; i < length; i++) {
|
|
190
|
+
this.putBit((num >>> length - i - 1 & 1) === 1);
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
getLengthInBits: function() {
|
|
194
|
+
return this.length;
|
|
195
|
+
},
|
|
196
|
+
putBit: function(bit) {
|
|
197
|
+
const bufIndex = Math.floor(this.length / 8);
|
|
198
|
+
if (this.buffer.length <= bufIndex) {
|
|
199
|
+
this.buffer.push(0);
|
|
200
|
+
}
|
|
201
|
+
if (bit) {
|
|
202
|
+
this.buffer[bufIndex] |= 128 >>> this.length % 8;
|
|
203
|
+
}
|
|
204
|
+
this.length++;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
module2.exports = BitBuffer;
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// node_modules/qrcode/lib/core/bit-matrix.js
|
|
212
|
+
var require_bit_matrix = __commonJS({
|
|
213
|
+
"node_modules/qrcode/lib/core/bit-matrix.js"(exports, module2) {
|
|
214
|
+
function BitMatrix(size) {
|
|
215
|
+
if (!size || size < 1) {
|
|
216
|
+
throw new Error("BitMatrix size must be defined and greater than 0");
|
|
217
|
+
}
|
|
218
|
+
this.size = size;
|
|
219
|
+
this.data = new Uint8Array(size * size);
|
|
220
|
+
this.reservedBit = new Uint8Array(size * size);
|
|
221
|
+
}
|
|
222
|
+
BitMatrix.prototype.set = function(row, col, value, reserved) {
|
|
223
|
+
const index = row * this.size + col;
|
|
224
|
+
this.data[index] = value;
|
|
225
|
+
if (reserved) this.reservedBit[index] = true;
|
|
226
|
+
};
|
|
227
|
+
BitMatrix.prototype.get = function(row, col) {
|
|
228
|
+
return this.data[row * this.size + col];
|
|
229
|
+
};
|
|
230
|
+
BitMatrix.prototype.xor = function(row, col, value) {
|
|
231
|
+
this.data[row * this.size + col] ^= value;
|
|
232
|
+
};
|
|
233
|
+
BitMatrix.prototype.isReserved = function(row, col) {
|
|
234
|
+
return this.reservedBit[row * this.size + col];
|
|
235
|
+
};
|
|
236
|
+
module2.exports = BitMatrix;
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// node_modules/qrcode/lib/core/alignment-pattern.js
|
|
241
|
+
var require_alignment_pattern = __commonJS({
|
|
242
|
+
"node_modules/qrcode/lib/core/alignment-pattern.js"(exports) {
|
|
243
|
+
var getSymbolSize = require_utils().getSymbolSize;
|
|
244
|
+
exports.getRowColCoords = function getRowColCoords(version) {
|
|
245
|
+
if (version === 1) return [];
|
|
246
|
+
const posCount = Math.floor(version / 7) + 2;
|
|
247
|
+
const size = getSymbolSize(version);
|
|
248
|
+
const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2;
|
|
249
|
+
const positions = [size - 7];
|
|
250
|
+
for (let i = 1; i < posCount - 1; i++) {
|
|
251
|
+
positions[i] = positions[i - 1] - intervals;
|
|
252
|
+
}
|
|
253
|
+
positions.push(6);
|
|
254
|
+
return positions.reverse();
|
|
255
|
+
};
|
|
256
|
+
exports.getPositions = function getPositions(version) {
|
|
257
|
+
const coords = [];
|
|
258
|
+
const pos = exports.getRowColCoords(version);
|
|
259
|
+
const posLength = pos.length;
|
|
260
|
+
for (let i = 0; i < posLength; i++) {
|
|
261
|
+
for (let j = 0; j < posLength; j++) {
|
|
262
|
+
if (i === 0 && j === 0 || // top-left
|
|
263
|
+
i === 0 && j === posLength - 1 || // bottom-left
|
|
264
|
+
i === posLength - 1 && j === 0) {
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
coords.push([pos[i], pos[j]]);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return coords;
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
// node_modules/qrcode/lib/core/finder-pattern.js
|
|
276
|
+
var require_finder_pattern = __commonJS({
|
|
277
|
+
"node_modules/qrcode/lib/core/finder-pattern.js"(exports) {
|
|
278
|
+
var getSymbolSize = require_utils().getSymbolSize;
|
|
279
|
+
var FINDER_PATTERN_SIZE = 7;
|
|
280
|
+
exports.getPositions = function getPositions(version) {
|
|
281
|
+
const size = getSymbolSize(version);
|
|
282
|
+
return [
|
|
283
|
+
// top-left
|
|
284
|
+
[0, 0],
|
|
285
|
+
// top-right
|
|
286
|
+
[size - FINDER_PATTERN_SIZE, 0],
|
|
287
|
+
// bottom-left
|
|
288
|
+
[0, size - FINDER_PATTERN_SIZE]
|
|
289
|
+
];
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// node_modules/qrcode/lib/core/mask-pattern.js
|
|
295
|
+
var require_mask_pattern = __commonJS({
|
|
296
|
+
"node_modules/qrcode/lib/core/mask-pattern.js"(exports) {
|
|
297
|
+
exports.Patterns = {
|
|
298
|
+
PATTERN000: 0,
|
|
299
|
+
PATTERN001: 1,
|
|
300
|
+
PATTERN010: 2,
|
|
301
|
+
PATTERN011: 3,
|
|
302
|
+
PATTERN100: 4,
|
|
303
|
+
PATTERN101: 5,
|
|
304
|
+
PATTERN110: 6,
|
|
305
|
+
PATTERN111: 7
|
|
306
|
+
};
|
|
307
|
+
var PenaltyScores = {
|
|
308
|
+
N1: 3,
|
|
309
|
+
N2: 3,
|
|
310
|
+
N3: 40,
|
|
311
|
+
N4: 10
|
|
312
|
+
};
|
|
313
|
+
exports.isValid = function isValid(mask) {
|
|
314
|
+
return mask != null && mask !== "" && !isNaN(mask) && mask >= 0 && mask <= 7;
|
|
315
|
+
};
|
|
316
|
+
exports.from = function from(value) {
|
|
317
|
+
return exports.isValid(value) ? parseInt(value, 10) : void 0;
|
|
318
|
+
};
|
|
319
|
+
exports.getPenaltyN1 = function getPenaltyN1(data) {
|
|
320
|
+
const size = data.size;
|
|
321
|
+
let points = 0;
|
|
322
|
+
let sameCountCol = 0;
|
|
323
|
+
let sameCountRow = 0;
|
|
324
|
+
let lastCol = null;
|
|
325
|
+
let lastRow = null;
|
|
326
|
+
for (let row = 0; row < size; row++) {
|
|
327
|
+
sameCountCol = sameCountRow = 0;
|
|
328
|
+
lastCol = lastRow = null;
|
|
329
|
+
for (let col = 0; col < size; col++) {
|
|
330
|
+
let module3 = data.get(row, col);
|
|
331
|
+
if (module3 === lastCol) {
|
|
332
|
+
sameCountCol++;
|
|
333
|
+
} else {
|
|
334
|
+
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
|
|
335
|
+
lastCol = module3;
|
|
336
|
+
sameCountCol = 1;
|
|
337
|
+
}
|
|
338
|
+
module3 = data.get(col, row);
|
|
339
|
+
if (module3 === lastRow) {
|
|
340
|
+
sameCountRow++;
|
|
341
|
+
} else {
|
|
342
|
+
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
|
|
343
|
+
lastRow = module3;
|
|
344
|
+
sameCountRow = 1;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
|
|
348
|
+
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
|
|
349
|
+
}
|
|
350
|
+
return points;
|
|
351
|
+
};
|
|
352
|
+
exports.getPenaltyN2 = function getPenaltyN2(data) {
|
|
353
|
+
const size = data.size;
|
|
354
|
+
let points = 0;
|
|
355
|
+
for (let row = 0; row < size - 1; row++) {
|
|
356
|
+
for (let col = 0; col < size - 1; col++) {
|
|
357
|
+
const last = data.get(row, col) + data.get(row, col + 1) + data.get(row + 1, col) + data.get(row + 1, col + 1);
|
|
358
|
+
if (last === 4 || last === 0) points++;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return points * PenaltyScores.N2;
|
|
362
|
+
};
|
|
363
|
+
exports.getPenaltyN3 = function getPenaltyN3(data) {
|
|
364
|
+
const size = data.size;
|
|
365
|
+
let points = 0;
|
|
366
|
+
let bitsCol = 0;
|
|
367
|
+
let bitsRow = 0;
|
|
368
|
+
for (let row = 0; row < size; row++) {
|
|
369
|
+
bitsCol = bitsRow = 0;
|
|
370
|
+
for (let col = 0; col < size; col++) {
|
|
371
|
+
bitsCol = bitsCol << 1 & 2047 | data.get(row, col);
|
|
372
|
+
if (col >= 10 && (bitsCol === 1488 || bitsCol === 93)) points++;
|
|
373
|
+
bitsRow = bitsRow << 1 & 2047 | data.get(col, row);
|
|
374
|
+
if (col >= 10 && (bitsRow === 1488 || bitsRow === 93)) points++;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
return points * PenaltyScores.N3;
|
|
378
|
+
};
|
|
379
|
+
exports.getPenaltyN4 = function getPenaltyN4(data) {
|
|
380
|
+
let darkCount = 0;
|
|
381
|
+
const modulesCount = data.data.length;
|
|
382
|
+
for (let i = 0; i < modulesCount; i++) darkCount += data.data[i];
|
|
383
|
+
const k = Math.abs(Math.ceil(darkCount * 100 / modulesCount / 5) - 10);
|
|
384
|
+
return k * PenaltyScores.N4;
|
|
385
|
+
};
|
|
386
|
+
function getMaskAt(maskPattern, i, j) {
|
|
387
|
+
switch (maskPattern) {
|
|
388
|
+
case exports.Patterns.PATTERN000:
|
|
389
|
+
return (i + j) % 2 === 0;
|
|
390
|
+
case exports.Patterns.PATTERN001:
|
|
391
|
+
return i % 2 === 0;
|
|
392
|
+
case exports.Patterns.PATTERN010:
|
|
393
|
+
return j % 3 === 0;
|
|
394
|
+
case exports.Patterns.PATTERN011:
|
|
395
|
+
return (i + j) % 3 === 0;
|
|
396
|
+
case exports.Patterns.PATTERN100:
|
|
397
|
+
return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0;
|
|
398
|
+
case exports.Patterns.PATTERN101:
|
|
399
|
+
return i * j % 2 + i * j % 3 === 0;
|
|
400
|
+
case exports.Patterns.PATTERN110:
|
|
401
|
+
return (i * j % 2 + i * j % 3) % 2 === 0;
|
|
402
|
+
case exports.Patterns.PATTERN111:
|
|
403
|
+
return (i * j % 3 + (i + j) % 2) % 2 === 0;
|
|
404
|
+
default:
|
|
405
|
+
throw new Error("bad maskPattern:" + maskPattern);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
exports.applyMask = function applyMask(pattern, data) {
|
|
409
|
+
const size = data.size;
|
|
410
|
+
for (let col = 0; col < size; col++) {
|
|
411
|
+
for (let row = 0; row < size; row++) {
|
|
412
|
+
if (data.isReserved(row, col)) continue;
|
|
413
|
+
data.xor(row, col, getMaskAt(pattern, row, col));
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
exports.getBestMask = function getBestMask(data, setupFormatFunc) {
|
|
418
|
+
const numPatterns = Object.keys(exports.Patterns).length;
|
|
419
|
+
let bestPattern = 0;
|
|
420
|
+
let lowerPenalty = Infinity;
|
|
421
|
+
for (let p = 0; p < numPatterns; p++) {
|
|
422
|
+
setupFormatFunc(p);
|
|
423
|
+
exports.applyMask(p, data);
|
|
424
|
+
const penalty = exports.getPenaltyN1(data) + exports.getPenaltyN2(data) + exports.getPenaltyN3(data) + exports.getPenaltyN4(data);
|
|
425
|
+
exports.applyMask(p, data);
|
|
426
|
+
if (penalty < lowerPenalty) {
|
|
427
|
+
lowerPenalty = penalty;
|
|
428
|
+
bestPattern = p;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return bestPattern;
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
// node_modules/qrcode/lib/core/error-correction-code.js
|
|
437
|
+
var require_error_correction_code = __commonJS({
|
|
438
|
+
"node_modules/qrcode/lib/core/error-correction-code.js"(exports) {
|
|
439
|
+
var ECLevel = require_error_correction_level();
|
|
440
|
+
var EC_BLOCKS_TABLE = [
|
|
441
|
+
// L M Q H
|
|
442
|
+
1,
|
|
443
|
+
1,
|
|
444
|
+
1,
|
|
445
|
+
1,
|
|
446
|
+
1,
|
|
447
|
+
1,
|
|
448
|
+
1,
|
|
449
|
+
1,
|
|
450
|
+
1,
|
|
451
|
+
1,
|
|
452
|
+
2,
|
|
453
|
+
2,
|
|
454
|
+
1,
|
|
455
|
+
2,
|
|
456
|
+
2,
|
|
457
|
+
4,
|
|
458
|
+
1,
|
|
459
|
+
2,
|
|
460
|
+
4,
|
|
461
|
+
4,
|
|
462
|
+
2,
|
|
463
|
+
4,
|
|
464
|
+
4,
|
|
465
|
+
4,
|
|
466
|
+
2,
|
|
467
|
+
4,
|
|
468
|
+
6,
|
|
469
|
+
5,
|
|
470
|
+
2,
|
|
471
|
+
4,
|
|
472
|
+
6,
|
|
473
|
+
6,
|
|
474
|
+
2,
|
|
475
|
+
5,
|
|
476
|
+
8,
|
|
477
|
+
8,
|
|
478
|
+
4,
|
|
479
|
+
5,
|
|
480
|
+
8,
|
|
481
|
+
8,
|
|
482
|
+
4,
|
|
483
|
+
5,
|
|
484
|
+
8,
|
|
485
|
+
11,
|
|
486
|
+
4,
|
|
487
|
+
8,
|
|
488
|
+
10,
|
|
489
|
+
11,
|
|
490
|
+
4,
|
|
491
|
+
9,
|
|
492
|
+
12,
|
|
493
|
+
16,
|
|
494
|
+
4,
|
|
495
|
+
9,
|
|
496
|
+
16,
|
|
497
|
+
16,
|
|
498
|
+
6,
|
|
499
|
+
10,
|
|
500
|
+
12,
|
|
501
|
+
18,
|
|
502
|
+
6,
|
|
503
|
+
10,
|
|
504
|
+
17,
|
|
505
|
+
16,
|
|
506
|
+
6,
|
|
507
|
+
11,
|
|
508
|
+
16,
|
|
509
|
+
19,
|
|
510
|
+
6,
|
|
511
|
+
13,
|
|
512
|
+
18,
|
|
513
|
+
21,
|
|
514
|
+
7,
|
|
515
|
+
14,
|
|
516
|
+
21,
|
|
517
|
+
25,
|
|
518
|
+
8,
|
|
519
|
+
16,
|
|
520
|
+
20,
|
|
521
|
+
25,
|
|
522
|
+
8,
|
|
523
|
+
17,
|
|
524
|
+
23,
|
|
525
|
+
25,
|
|
526
|
+
9,
|
|
527
|
+
17,
|
|
528
|
+
23,
|
|
529
|
+
34,
|
|
530
|
+
9,
|
|
531
|
+
18,
|
|
532
|
+
25,
|
|
533
|
+
30,
|
|
534
|
+
10,
|
|
535
|
+
20,
|
|
536
|
+
27,
|
|
537
|
+
32,
|
|
538
|
+
12,
|
|
539
|
+
21,
|
|
540
|
+
29,
|
|
541
|
+
35,
|
|
542
|
+
12,
|
|
543
|
+
23,
|
|
544
|
+
34,
|
|
545
|
+
37,
|
|
546
|
+
12,
|
|
547
|
+
25,
|
|
548
|
+
34,
|
|
549
|
+
40,
|
|
550
|
+
13,
|
|
551
|
+
26,
|
|
552
|
+
35,
|
|
553
|
+
42,
|
|
554
|
+
14,
|
|
555
|
+
28,
|
|
556
|
+
38,
|
|
557
|
+
45,
|
|
558
|
+
15,
|
|
559
|
+
29,
|
|
560
|
+
40,
|
|
561
|
+
48,
|
|
562
|
+
16,
|
|
563
|
+
31,
|
|
564
|
+
43,
|
|
565
|
+
51,
|
|
566
|
+
17,
|
|
567
|
+
33,
|
|
568
|
+
45,
|
|
569
|
+
54,
|
|
570
|
+
18,
|
|
571
|
+
35,
|
|
572
|
+
48,
|
|
573
|
+
57,
|
|
574
|
+
19,
|
|
575
|
+
37,
|
|
576
|
+
51,
|
|
577
|
+
60,
|
|
578
|
+
19,
|
|
579
|
+
38,
|
|
580
|
+
53,
|
|
581
|
+
63,
|
|
582
|
+
20,
|
|
583
|
+
40,
|
|
584
|
+
56,
|
|
585
|
+
66,
|
|
586
|
+
21,
|
|
587
|
+
43,
|
|
588
|
+
59,
|
|
589
|
+
70,
|
|
590
|
+
22,
|
|
591
|
+
45,
|
|
592
|
+
62,
|
|
593
|
+
74,
|
|
594
|
+
24,
|
|
595
|
+
47,
|
|
596
|
+
65,
|
|
597
|
+
77,
|
|
598
|
+
25,
|
|
599
|
+
49,
|
|
600
|
+
68,
|
|
601
|
+
81
|
|
602
|
+
];
|
|
603
|
+
var EC_CODEWORDS_TABLE = [
|
|
604
|
+
// L M Q H
|
|
605
|
+
7,
|
|
606
|
+
10,
|
|
607
|
+
13,
|
|
608
|
+
17,
|
|
609
|
+
10,
|
|
610
|
+
16,
|
|
611
|
+
22,
|
|
612
|
+
28,
|
|
613
|
+
15,
|
|
614
|
+
26,
|
|
615
|
+
36,
|
|
616
|
+
44,
|
|
617
|
+
20,
|
|
618
|
+
36,
|
|
619
|
+
52,
|
|
620
|
+
64,
|
|
621
|
+
26,
|
|
622
|
+
48,
|
|
623
|
+
72,
|
|
624
|
+
88,
|
|
625
|
+
36,
|
|
626
|
+
64,
|
|
627
|
+
96,
|
|
628
|
+
112,
|
|
629
|
+
40,
|
|
630
|
+
72,
|
|
631
|
+
108,
|
|
632
|
+
130,
|
|
633
|
+
48,
|
|
634
|
+
88,
|
|
635
|
+
132,
|
|
636
|
+
156,
|
|
637
|
+
60,
|
|
638
|
+
110,
|
|
639
|
+
160,
|
|
640
|
+
192,
|
|
641
|
+
72,
|
|
642
|
+
130,
|
|
643
|
+
192,
|
|
644
|
+
224,
|
|
645
|
+
80,
|
|
646
|
+
150,
|
|
647
|
+
224,
|
|
648
|
+
264,
|
|
649
|
+
96,
|
|
650
|
+
176,
|
|
651
|
+
260,
|
|
652
|
+
308,
|
|
653
|
+
104,
|
|
654
|
+
198,
|
|
655
|
+
288,
|
|
656
|
+
352,
|
|
657
|
+
120,
|
|
658
|
+
216,
|
|
659
|
+
320,
|
|
660
|
+
384,
|
|
661
|
+
132,
|
|
662
|
+
240,
|
|
663
|
+
360,
|
|
664
|
+
432,
|
|
665
|
+
144,
|
|
666
|
+
280,
|
|
667
|
+
408,
|
|
668
|
+
480,
|
|
669
|
+
168,
|
|
670
|
+
308,
|
|
671
|
+
448,
|
|
672
|
+
532,
|
|
673
|
+
180,
|
|
674
|
+
338,
|
|
675
|
+
504,
|
|
676
|
+
588,
|
|
677
|
+
196,
|
|
678
|
+
364,
|
|
679
|
+
546,
|
|
680
|
+
650,
|
|
681
|
+
224,
|
|
682
|
+
416,
|
|
683
|
+
600,
|
|
684
|
+
700,
|
|
685
|
+
224,
|
|
686
|
+
442,
|
|
687
|
+
644,
|
|
688
|
+
750,
|
|
689
|
+
252,
|
|
690
|
+
476,
|
|
691
|
+
690,
|
|
692
|
+
816,
|
|
693
|
+
270,
|
|
694
|
+
504,
|
|
695
|
+
750,
|
|
696
|
+
900,
|
|
697
|
+
300,
|
|
698
|
+
560,
|
|
699
|
+
810,
|
|
700
|
+
960,
|
|
701
|
+
312,
|
|
702
|
+
588,
|
|
703
|
+
870,
|
|
704
|
+
1050,
|
|
705
|
+
336,
|
|
706
|
+
644,
|
|
707
|
+
952,
|
|
708
|
+
1110,
|
|
709
|
+
360,
|
|
710
|
+
700,
|
|
711
|
+
1020,
|
|
712
|
+
1200,
|
|
713
|
+
390,
|
|
714
|
+
728,
|
|
715
|
+
1050,
|
|
716
|
+
1260,
|
|
717
|
+
420,
|
|
718
|
+
784,
|
|
719
|
+
1140,
|
|
720
|
+
1350,
|
|
721
|
+
450,
|
|
722
|
+
812,
|
|
723
|
+
1200,
|
|
724
|
+
1440,
|
|
725
|
+
480,
|
|
726
|
+
868,
|
|
727
|
+
1290,
|
|
728
|
+
1530,
|
|
729
|
+
510,
|
|
730
|
+
924,
|
|
731
|
+
1350,
|
|
732
|
+
1620,
|
|
733
|
+
540,
|
|
734
|
+
980,
|
|
735
|
+
1440,
|
|
736
|
+
1710,
|
|
737
|
+
570,
|
|
738
|
+
1036,
|
|
739
|
+
1530,
|
|
740
|
+
1800,
|
|
741
|
+
570,
|
|
742
|
+
1064,
|
|
743
|
+
1590,
|
|
744
|
+
1890,
|
|
745
|
+
600,
|
|
746
|
+
1120,
|
|
747
|
+
1680,
|
|
748
|
+
1980,
|
|
749
|
+
630,
|
|
750
|
+
1204,
|
|
751
|
+
1770,
|
|
752
|
+
2100,
|
|
753
|
+
660,
|
|
754
|
+
1260,
|
|
755
|
+
1860,
|
|
756
|
+
2220,
|
|
757
|
+
720,
|
|
758
|
+
1316,
|
|
759
|
+
1950,
|
|
760
|
+
2310,
|
|
761
|
+
750,
|
|
762
|
+
1372,
|
|
763
|
+
2040,
|
|
764
|
+
2430
|
|
765
|
+
];
|
|
766
|
+
exports.getBlocksCount = function getBlocksCount(version, errorCorrectionLevel) {
|
|
767
|
+
switch (errorCorrectionLevel) {
|
|
768
|
+
case ECLevel.L:
|
|
769
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 0];
|
|
770
|
+
case ECLevel.M:
|
|
771
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 1];
|
|
772
|
+
case ECLevel.Q:
|
|
773
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 2];
|
|
774
|
+
case ECLevel.H:
|
|
775
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 3];
|
|
776
|
+
default:
|
|
777
|
+
return void 0;
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
exports.getTotalCodewordsCount = function getTotalCodewordsCount(version, errorCorrectionLevel) {
|
|
781
|
+
switch (errorCorrectionLevel) {
|
|
782
|
+
case ECLevel.L:
|
|
783
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0];
|
|
784
|
+
case ECLevel.M:
|
|
785
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1];
|
|
786
|
+
case ECLevel.Q:
|
|
787
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2];
|
|
788
|
+
case ECLevel.H:
|
|
789
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3];
|
|
790
|
+
default:
|
|
791
|
+
return void 0;
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
|
|
797
|
+
// node_modules/qrcode/lib/core/galois-field.js
|
|
798
|
+
var require_galois_field = __commonJS({
|
|
799
|
+
"node_modules/qrcode/lib/core/galois-field.js"(exports) {
|
|
800
|
+
var EXP_TABLE = new Uint8Array(512);
|
|
801
|
+
var LOG_TABLE = new Uint8Array(256);
|
|
802
|
+
(function initTables() {
|
|
803
|
+
let x = 1;
|
|
804
|
+
for (let i = 0; i < 255; i++) {
|
|
805
|
+
EXP_TABLE[i] = x;
|
|
806
|
+
LOG_TABLE[x] = i;
|
|
807
|
+
x <<= 1;
|
|
808
|
+
if (x & 256) {
|
|
809
|
+
x ^= 285;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
for (let i = 255; i < 512; i++) {
|
|
813
|
+
EXP_TABLE[i] = EXP_TABLE[i - 255];
|
|
814
|
+
}
|
|
815
|
+
})();
|
|
816
|
+
exports.log = function log(n) {
|
|
817
|
+
if (n < 1) throw new Error("log(" + n + ")");
|
|
818
|
+
return LOG_TABLE[n];
|
|
819
|
+
};
|
|
820
|
+
exports.exp = function exp(n) {
|
|
821
|
+
return EXP_TABLE[n];
|
|
822
|
+
};
|
|
823
|
+
exports.mul = function mul(x, y) {
|
|
824
|
+
if (x === 0 || y === 0) return 0;
|
|
825
|
+
return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]];
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
});
|
|
829
|
+
|
|
830
|
+
// node_modules/qrcode/lib/core/polynomial.js
|
|
831
|
+
var require_polynomial = __commonJS({
|
|
832
|
+
"node_modules/qrcode/lib/core/polynomial.js"(exports) {
|
|
833
|
+
var GF = require_galois_field();
|
|
834
|
+
exports.mul = function mul(p1, p2) {
|
|
835
|
+
const coeff = new Uint8Array(p1.length + p2.length - 1);
|
|
836
|
+
for (let i = 0; i < p1.length; i++) {
|
|
837
|
+
for (let j = 0; j < p2.length; j++) {
|
|
838
|
+
coeff[i + j] ^= GF.mul(p1[i], p2[j]);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
return coeff;
|
|
842
|
+
};
|
|
843
|
+
exports.mod = function mod(divident, divisor) {
|
|
844
|
+
let result = new Uint8Array(divident);
|
|
845
|
+
while (result.length - divisor.length >= 0) {
|
|
846
|
+
const coeff = result[0];
|
|
847
|
+
for (let i = 0; i < divisor.length; i++) {
|
|
848
|
+
result[i] ^= GF.mul(divisor[i], coeff);
|
|
849
|
+
}
|
|
850
|
+
let offset = 0;
|
|
851
|
+
while (offset < result.length && result[offset] === 0) offset++;
|
|
852
|
+
result = result.slice(offset);
|
|
853
|
+
}
|
|
854
|
+
return result;
|
|
855
|
+
};
|
|
856
|
+
exports.generateECPolynomial = function generateECPolynomial(degree) {
|
|
857
|
+
let poly = new Uint8Array([1]);
|
|
858
|
+
for (let i = 0; i < degree; i++) {
|
|
859
|
+
poly = exports.mul(poly, new Uint8Array([1, GF.exp(i)]));
|
|
860
|
+
}
|
|
861
|
+
return poly;
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
});
|
|
865
|
+
|
|
866
|
+
// node_modules/qrcode/lib/core/reed-solomon-encoder.js
|
|
867
|
+
var require_reed_solomon_encoder = __commonJS({
|
|
868
|
+
"node_modules/qrcode/lib/core/reed-solomon-encoder.js"(exports, module2) {
|
|
869
|
+
var Polynomial = require_polynomial();
|
|
870
|
+
function ReedSolomonEncoder(degree) {
|
|
871
|
+
this.genPoly = void 0;
|
|
872
|
+
this.degree = degree;
|
|
873
|
+
if (this.degree) this.initialize(this.degree);
|
|
874
|
+
}
|
|
875
|
+
ReedSolomonEncoder.prototype.initialize = function initialize(degree) {
|
|
876
|
+
this.degree = degree;
|
|
877
|
+
this.genPoly = Polynomial.generateECPolynomial(this.degree);
|
|
878
|
+
};
|
|
879
|
+
ReedSolomonEncoder.prototype.encode = function encode(data) {
|
|
880
|
+
if (!this.genPoly) {
|
|
881
|
+
throw new Error("Encoder not initialized");
|
|
882
|
+
}
|
|
883
|
+
const paddedData = new Uint8Array(data.length + this.degree);
|
|
884
|
+
paddedData.set(data);
|
|
885
|
+
const remainder = Polynomial.mod(paddedData, this.genPoly);
|
|
886
|
+
const start = this.degree - remainder.length;
|
|
887
|
+
if (start > 0) {
|
|
888
|
+
const buff = new Uint8Array(this.degree);
|
|
889
|
+
buff.set(remainder, start);
|
|
890
|
+
return buff;
|
|
891
|
+
}
|
|
892
|
+
return remainder;
|
|
893
|
+
};
|
|
894
|
+
module2.exports = ReedSolomonEncoder;
|
|
895
|
+
}
|
|
896
|
+
});
|
|
897
|
+
|
|
898
|
+
// node_modules/qrcode/lib/core/version-check.js
|
|
899
|
+
var require_version_check = __commonJS({
|
|
900
|
+
"node_modules/qrcode/lib/core/version-check.js"(exports) {
|
|
901
|
+
exports.isValid = function isValid(version) {
|
|
902
|
+
return !isNaN(version) && version >= 1 && version <= 40;
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
});
|
|
906
|
+
|
|
907
|
+
// node_modules/qrcode/lib/core/regex.js
|
|
908
|
+
var require_regex = __commonJS({
|
|
909
|
+
"node_modules/qrcode/lib/core/regex.js"(exports) {
|
|
910
|
+
var numeric = "[0-9]+";
|
|
911
|
+
var alphanumeric = "[A-Z $%*+\\-./:]+";
|
|
912
|
+
var kanji = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";
|
|
913
|
+
kanji = kanji.replace(/u/g, "\\u");
|
|
914
|
+
var byte = "(?:(?![A-Z0-9 $%*+\\-./:]|" + kanji + ")(?:.|[\r\n]))+";
|
|
915
|
+
exports.KANJI = new RegExp(kanji, "g");
|
|
916
|
+
exports.BYTE_KANJI = new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g");
|
|
917
|
+
exports.BYTE = new RegExp(byte, "g");
|
|
918
|
+
exports.NUMERIC = new RegExp(numeric, "g");
|
|
919
|
+
exports.ALPHANUMERIC = new RegExp(alphanumeric, "g");
|
|
920
|
+
var TEST_KANJI = new RegExp("^" + kanji + "$");
|
|
921
|
+
var TEST_NUMERIC = new RegExp("^" + numeric + "$");
|
|
922
|
+
var TEST_ALPHANUMERIC = new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
|
|
923
|
+
exports.testKanji = function testKanji(str) {
|
|
924
|
+
return TEST_KANJI.test(str);
|
|
925
|
+
};
|
|
926
|
+
exports.testNumeric = function testNumeric(str) {
|
|
927
|
+
return TEST_NUMERIC.test(str);
|
|
928
|
+
};
|
|
929
|
+
exports.testAlphanumeric = function testAlphanumeric(str) {
|
|
930
|
+
return TEST_ALPHANUMERIC.test(str);
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
});
|
|
934
|
+
|
|
935
|
+
// node_modules/qrcode/lib/core/mode.js
|
|
936
|
+
var require_mode = __commonJS({
|
|
937
|
+
"node_modules/qrcode/lib/core/mode.js"(exports) {
|
|
938
|
+
var VersionCheck = require_version_check();
|
|
939
|
+
var Regex = require_regex();
|
|
940
|
+
exports.NUMERIC = {
|
|
941
|
+
id: "Numeric",
|
|
942
|
+
bit: 1 << 0,
|
|
943
|
+
ccBits: [10, 12, 14]
|
|
944
|
+
};
|
|
945
|
+
exports.ALPHANUMERIC = {
|
|
946
|
+
id: "Alphanumeric",
|
|
947
|
+
bit: 1 << 1,
|
|
948
|
+
ccBits: [9, 11, 13]
|
|
949
|
+
};
|
|
950
|
+
exports.BYTE = {
|
|
951
|
+
id: "Byte",
|
|
952
|
+
bit: 1 << 2,
|
|
953
|
+
ccBits: [8, 16, 16]
|
|
954
|
+
};
|
|
955
|
+
exports.KANJI = {
|
|
956
|
+
id: "Kanji",
|
|
957
|
+
bit: 1 << 3,
|
|
958
|
+
ccBits: [8, 10, 12]
|
|
959
|
+
};
|
|
960
|
+
exports.MIXED = {
|
|
961
|
+
bit: -1
|
|
962
|
+
};
|
|
963
|
+
exports.getCharCountIndicator = function getCharCountIndicator(mode, version) {
|
|
964
|
+
if (!mode.ccBits) throw new Error("Invalid mode: " + mode);
|
|
965
|
+
if (!VersionCheck.isValid(version)) {
|
|
966
|
+
throw new Error("Invalid version: " + version);
|
|
967
|
+
}
|
|
968
|
+
if (version >= 1 && version < 10) return mode.ccBits[0];
|
|
969
|
+
else if (version < 27) return mode.ccBits[1];
|
|
970
|
+
return mode.ccBits[2];
|
|
971
|
+
};
|
|
972
|
+
exports.getBestModeForData = function getBestModeForData(dataStr) {
|
|
973
|
+
if (Regex.testNumeric(dataStr)) return exports.NUMERIC;
|
|
974
|
+
else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC;
|
|
975
|
+
else if (Regex.testKanji(dataStr)) return exports.KANJI;
|
|
976
|
+
else return exports.BYTE;
|
|
977
|
+
};
|
|
978
|
+
exports.toString = function toString(mode) {
|
|
979
|
+
if (mode && mode.id) return mode.id;
|
|
980
|
+
throw new Error("Invalid mode");
|
|
981
|
+
};
|
|
982
|
+
exports.isValid = function isValid(mode) {
|
|
983
|
+
return mode && mode.bit && mode.ccBits;
|
|
984
|
+
};
|
|
985
|
+
function fromString(string) {
|
|
986
|
+
if (typeof string !== "string") {
|
|
987
|
+
throw new Error("Param is not a string");
|
|
988
|
+
}
|
|
989
|
+
const lcStr = string.toLowerCase();
|
|
990
|
+
switch (lcStr) {
|
|
991
|
+
case "numeric":
|
|
992
|
+
return exports.NUMERIC;
|
|
993
|
+
case "alphanumeric":
|
|
994
|
+
return exports.ALPHANUMERIC;
|
|
995
|
+
case "kanji":
|
|
996
|
+
return exports.KANJI;
|
|
997
|
+
case "byte":
|
|
998
|
+
return exports.BYTE;
|
|
999
|
+
default:
|
|
1000
|
+
throw new Error("Unknown mode: " + string);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
exports.from = function from(value, defaultValue) {
|
|
1004
|
+
if (exports.isValid(value)) {
|
|
1005
|
+
return value;
|
|
1006
|
+
}
|
|
1007
|
+
try {
|
|
1008
|
+
return fromString(value);
|
|
1009
|
+
} catch (e) {
|
|
1010
|
+
return defaultValue;
|
|
1011
|
+
}
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
});
|
|
1015
|
+
|
|
1016
|
+
// node_modules/qrcode/lib/core/version.js
|
|
1017
|
+
var require_version = __commonJS({
|
|
1018
|
+
"node_modules/qrcode/lib/core/version.js"(exports) {
|
|
1019
|
+
var Utils = require_utils();
|
|
1020
|
+
var ECCode = require_error_correction_code();
|
|
1021
|
+
var ECLevel = require_error_correction_level();
|
|
1022
|
+
var Mode = require_mode();
|
|
1023
|
+
var VersionCheck = require_version_check();
|
|
1024
|
+
var G18 = 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0;
|
|
1025
|
+
var G18_BCH = Utils.getBCHDigit(G18);
|
|
1026
|
+
function getBestVersionForDataLength(mode, length, errorCorrectionLevel) {
|
|
1027
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
|
|
1028
|
+
if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) {
|
|
1029
|
+
return currentVersion;
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
return void 0;
|
|
1033
|
+
}
|
|
1034
|
+
function getReservedBitsCount(mode, version) {
|
|
1035
|
+
return Mode.getCharCountIndicator(mode, version) + 4;
|
|
1036
|
+
}
|
|
1037
|
+
function getTotalBitsFromDataArray(segments, version) {
|
|
1038
|
+
let totalBits = 0;
|
|
1039
|
+
segments.forEach(function(data) {
|
|
1040
|
+
const reservedBits = getReservedBitsCount(data.mode, version);
|
|
1041
|
+
totalBits += reservedBits + data.getBitsLength();
|
|
1042
|
+
});
|
|
1043
|
+
return totalBits;
|
|
1044
|
+
}
|
|
1045
|
+
function getBestVersionForMixedData(segments, errorCorrectionLevel) {
|
|
1046
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
|
|
1047
|
+
const length = getTotalBitsFromDataArray(segments, currentVersion);
|
|
1048
|
+
if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) {
|
|
1049
|
+
return currentVersion;
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
return void 0;
|
|
1053
|
+
}
|
|
1054
|
+
exports.from = function from(value, defaultValue) {
|
|
1055
|
+
if (VersionCheck.isValid(value)) {
|
|
1056
|
+
return parseInt(value, 10);
|
|
1057
|
+
}
|
|
1058
|
+
return defaultValue;
|
|
1059
|
+
};
|
|
1060
|
+
exports.getCapacity = function getCapacity(version, errorCorrectionLevel, mode) {
|
|
1061
|
+
if (!VersionCheck.isValid(version)) {
|
|
1062
|
+
throw new Error("Invalid QR Code version");
|
|
1063
|
+
}
|
|
1064
|
+
if (typeof mode === "undefined") mode = Mode.BYTE;
|
|
1065
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version);
|
|
1066
|
+
const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
|
|
1067
|
+
const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
|
|
1068
|
+
if (mode === Mode.MIXED) return dataTotalCodewordsBits;
|
|
1069
|
+
const usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version);
|
|
1070
|
+
switch (mode) {
|
|
1071
|
+
case Mode.NUMERIC:
|
|
1072
|
+
return Math.floor(usableBits / 10 * 3);
|
|
1073
|
+
case Mode.ALPHANUMERIC:
|
|
1074
|
+
return Math.floor(usableBits / 11 * 2);
|
|
1075
|
+
case Mode.KANJI:
|
|
1076
|
+
return Math.floor(usableBits / 13);
|
|
1077
|
+
case Mode.BYTE:
|
|
1078
|
+
default:
|
|
1079
|
+
return Math.floor(usableBits / 8);
|
|
1080
|
+
}
|
|
1081
|
+
};
|
|
1082
|
+
exports.getBestVersionForData = function getBestVersionForData(data, errorCorrectionLevel) {
|
|
1083
|
+
let seg;
|
|
1084
|
+
const ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M);
|
|
1085
|
+
if (Array.isArray(data)) {
|
|
1086
|
+
if (data.length > 1) {
|
|
1087
|
+
return getBestVersionForMixedData(data, ecl);
|
|
1088
|
+
}
|
|
1089
|
+
if (data.length === 0) {
|
|
1090
|
+
return 1;
|
|
1091
|
+
}
|
|
1092
|
+
seg = data[0];
|
|
1093
|
+
} else {
|
|
1094
|
+
seg = data;
|
|
1095
|
+
}
|
|
1096
|
+
return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl);
|
|
1097
|
+
};
|
|
1098
|
+
exports.getEncodedBits = function getEncodedBits(version) {
|
|
1099
|
+
if (!VersionCheck.isValid(version) || version < 7) {
|
|
1100
|
+
throw new Error("Invalid QR Code version");
|
|
1101
|
+
}
|
|
1102
|
+
let d = version << 12;
|
|
1103
|
+
while (Utils.getBCHDigit(d) - G18_BCH >= 0) {
|
|
1104
|
+
d ^= G18 << Utils.getBCHDigit(d) - G18_BCH;
|
|
1105
|
+
}
|
|
1106
|
+
return version << 12 | d;
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
});
|
|
1110
|
+
|
|
1111
|
+
// node_modules/qrcode/lib/core/format-info.js
|
|
1112
|
+
var require_format_info = __commonJS({
|
|
1113
|
+
"node_modules/qrcode/lib/core/format-info.js"(exports) {
|
|
1114
|
+
var Utils = require_utils();
|
|
1115
|
+
var G15 = 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0;
|
|
1116
|
+
var G15_MASK = 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1;
|
|
1117
|
+
var G15_BCH = Utils.getBCHDigit(G15);
|
|
1118
|
+
exports.getEncodedBits = function getEncodedBits(errorCorrectionLevel, mask) {
|
|
1119
|
+
const data = errorCorrectionLevel.bit << 3 | mask;
|
|
1120
|
+
let d = data << 10;
|
|
1121
|
+
while (Utils.getBCHDigit(d) - G15_BCH >= 0) {
|
|
1122
|
+
d ^= G15 << Utils.getBCHDigit(d) - G15_BCH;
|
|
1123
|
+
}
|
|
1124
|
+
return (data << 10 | d) ^ G15_MASK;
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1127
|
+
});
|
|
1128
|
+
|
|
1129
|
+
// node_modules/qrcode/lib/core/numeric-data.js
|
|
1130
|
+
var require_numeric_data = __commonJS({
|
|
1131
|
+
"node_modules/qrcode/lib/core/numeric-data.js"(exports, module2) {
|
|
1132
|
+
var Mode = require_mode();
|
|
1133
|
+
function NumericData(data) {
|
|
1134
|
+
this.mode = Mode.NUMERIC;
|
|
1135
|
+
this.data = data.toString();
|
|
1136
|
+
}
|
|
1137
|
+
NumericData.getBitsLength = function getBitsLength(length) {
|
|
1138
|
+
return 10 * Math.floor(length / 3) + (length % 3 ? length % 3 * 3 + 1 : 0);
|
|
1139
|
+
};
|
|
1140
|
+
NumericData.prototype.getLength = function getLength() {
|
|
1141
|
+
return this.data.length;
|
|
1142
|
+
};
|
|
1143
|
+
NumericData.prototype.getBitsLength = function getBitsLength() {
|
|
1144
|
+
return NumericData.getBitsLength(this.data.length);
|
|
1145
|
+
};
|
|
1146
|
+
NumericData.prototype.write = function write(bitBuffer) {
|
|
1147
|
+
let i, group, value;
|
|
1148
|
+
for (i = 0; i + 3 <= this.data.length; i += 3) {
|
|
1149
|
+
group = this.data.substr(i, 3);
|
|
1150
|
+
value = parseInt(group, 10);
|
|
1151
|
+
bitBuffer.put(value, 10);
|
|
1152
|
+
}
|
|
1153
|
+
const remainingNum = this.data.length - i;
|
|
1154
|
+
if (remainingNum > 0) {
|
|
1155
|
+
group = this.data.substr(i);
|
|
1156
|
+
value = parseInt(group, 10);
|
|
1157
|
+
bitBuffer.put(value, remainingNum * 3 + 1);
|
|
1158
|
+
}
|
|
1159
|
+
};
|
|
1160
|
+
module2.exports = NumericData;
|
|
1161
|
+
}
|
|
1162
|
+
});
|
|
1163
|
+
|
|
1164
|
+
// node_modules/qrcode/lib/core/alphanumeric-data.js
|
|
1165
|
+
var require_alphanumeric_data = __commonJS({
|
|
1166
|
+
"node_modules/qrcode/lib/core/alphanumeric-data.js"(exports, module2) {
|
|
1167
|
+
var Mode = require_mode();
|
|
1168
|
+
var ALPHA_NUM_CHARS = [
|
|
1169
|
+
"0",
|
|
1170
|
+
"1",
|
|
1171
|
+
"2",
|
|
1172
|
+
"3",
|
|
1173
|
+
"4",
|
|
1174
|
+
"5",
|
|
1175
|
+
"6",
|
|
1176
|
+
"7",
|
|
1177
|
+
"8",
|
|
1178
|
+
"9",
|
|
1179
|
+
"A",
|
|
1180
|
+
"B",
|
|
1181
|
+
"C",
|
|
1182
|
+
"D",
|
|
1183
|
+
"E",
|
|
1184
|
+
"F",
|
|
1185
|
+
"G",
|
|
1186
|
+
"H",
|
|
1187
|
+
"I",
|
|
1188
|
+
"J",
|
|
1189
|
+
"K",
|
|
1190
|
+
"L",
|
|
1191
|
+
"M",
|
|
1192
|
+
"N",
|
|
1193
|
+
"O",
|
|
1194
|
+
"P",
|
|
1195
|
+
"Q",
|
|
1196
|
+
"R",
|
|
1197
|
+
"S",
|
|
1198
|
+
"T",
|
|
1199
|
+
"U",
|
|
1200
|
+
"V",
|
|
1201
|
+
"W",
|
|
1202
|
+
"X",
|
|
1203
|
+
"Y",
|
|
1204
|
+
"Z",
|
|
1205
|
+
" ",
|
|
1206
|
+
"$",
|
|
1207
|
+
"%",
|
|
1208
|
+
"*",
|
|
1209
|
+
"+",
|
|
1210
|
+
"-",
|
|
1211
|
+
".",
|
|
1212
|
+
"/",
|
|
1213
|
+
":"
|
|
1214
|
+
];
|
|
1215
|
+
function AlphanumericData(data) {
|
|
1216
|
+
this.mode = Mode.ALPHANUMERIC;
|
|
1217
|
+
this.data = data;
|
|
1218
|
+
}
|
|
1219
|
+
AlphanumericData.getBitsLength = function getBitsLength(length) {
|
|
1220
|
+
return 11 * Math.floor(length / 2) + 6 * (length % 2);
|
|
1221
|
+
};
|
|
1222
|
+
AlphanumericData.prototype.getLength = function getLength() {
|
|
1223
|
+
return this.data.length;
|
|
1224
|
+
};
|
|
1225
|
+
AlphanumericData.prototype.getBitsLength = function getBitsLength() {
|
|
1226
|
+
return AlphanumericData.getBitsLength(this.data.length);
|
|
1227
|
+
};
|
|
1228
|
+
AlphanumericData.prototype.write = function write(bitBuffer) {
|
|
1229
|
+
let i;
|
|
1230
|
+
for (i = 0; i + 2 <= this.data.length; i += 2) {
|
|
1231
|
+
let value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45;
|
|
1232
|
+
value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1]);
|
|
1233
|
+
bitBuffer.put(value, 11);
|
|
1234
|
+
}
|
|
1235
|
+
if (this.data.length % 2) {
|
|
1236
|
+
bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6);
|
|
1237
|
+
}
|
|
1238
|
+
};
|
|
1239
|
+
module2.exports = AlphanumericData;
|
|
1240
|
+
}
|
|
1241
|
+
});
|
|
1242
|
+
|
|
1243
|
+
// node_modules/qrcode/lib/core/byte-data.js
|
|
1244
|
+
var require_byte_data = __commonJS({
|
|
1245
|
+
"node_modules/qrcode/lib/core/byte-data.js"(exports, module2) {
|
|
1246
|
+
var Mode = require_mode();
|
|
1247
|
+
function ByteData(data) {
|
|
1248
|
+
this.mode = Mode.BYTE;
|
|
1249
|
+
if (typeof data === "string") {
|
|
1250
|
+
this.data = new TextEncoder().encode(data);
|
|
1251
|
+
} else {
|
|
1252
|
+
this.data = new Uint8Array(data);
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
ByteData.getBitsLength = function getBitsLength(length) {
|
|
1256
|
+
return length * 8;
|
|
1257
|
+
};
|
|
1258
|
+
ByteData.prototype.getLength = function getLength() {
|
|
1259
|
+
return this.data.length;
|
|
1260
|
+
};
|
|
1261
|
+
ByteData.prototype.getBitsLength = function getBitsLength() {
|
|
1262
|
+
return ByteData.getBitsLength(this.data.length);
|
|
1263
|
+
};
|
|
1264
|
+
ByteData.prototype.write = function(bitBuffer) {
|
|
1265
|
+
for (let i = 0, l = this.data.length; i < l; i++) {
|
|
1266
|
+
bitBuffer.put(this.data[i], 8);
|
|
1267
|
+
}
|
|
1268
|
+
};
|
|
1269
|
+
module2.exports = ByteData;
|
|
1270
|
+
}
|
|
1271
|
+
});
|
|
1272
|
+
|
|
1273
|
+
// node_modules/qrcode/lib/core/kanji-data.js
|
|
1274
|
+
var require_kanji_data = __commonJS({
|
|
1275
|
+
"node_modules/qrcode/lib/core/kanji-data.js"(exports, module2) {
|
|
1276
|
+
var Mode = require_mode();
|
|
1277
|
+
var Utils = require_utils();
|
|
1278
|
+
function KanjiData(data) {
|
|
1279
|
+
this.mode = Mode.KANJI;
|
|
1280
|
+
this.data = data;
|
|
1281
|
+
}
|
|
1282
|
+
KanjiData.getBitsLength = function getBitsLength(length) {
|
|
1283
|
+
return length * 13;
|
|
1284
|
+
};
|
|
1285
|
+
KanjiData.prototype.getLength = function getLength() {
|
|
1286
|
+
return this.data.length;
|
|
1287
|
+
};
|
|
1288
|
+
KanjiData.prototype.getBitsLength = function getBitsLength() {
|
|
1289
|
+
return KanjiData.getBitsLength(this.data.length);
|
|
1290
|
+
};
|
|
1291
|
+
KanjiData.prototype.write = function(bitBuffer) {
|
|
1292
|
+
let i;
|
|
1293
|
+
for (i = 0; i < this.data.length; i++) {
|
|
1294
|
+
let value = Utils.toSJIS(this.data[i]);
|
|
1295
|
+
if (value >= 33088 && value <= 40956) {
|
|
1296
|
+
value -= 33088;
|
|
1297
|
+
} else if (value >= 57408 && value <= 60351) {
|
|
1298
|
+
value -= 49472;
|
|
1299
|
+
} else {
|
|
1300
|
+
throw new Error(
|
|
1301
|
+
"Invalid SJIS character: " + this.data[i] + "\nMake sure your charset is UTF-8"
|
|
1302
|
+
);
|
|
1303
|
+
}
|
|
1304
|
+
value = (value >>> 8 & 255) * 192 + (value & 255);
|
|
1305
|
+
bitBuffer.put(value, 13);
|
|
1306
|
+
}
|
|
1307
|
+
};
|
|
1308
|
+
module2.exports = KanjiData;
|
|
1309
|
+
}
|
|
1310
|
+
});
|
|
1311
|
+
|
|
1312
|
+
// node_modules/dijkstrajs/dijkstra.js
|
|
1313
|
+
var require_dijkstra = __commonJS({
|
|
1314
|
+
"node_modules/dijkstrajs/dijkstra.js"(exports, module2) {
|
|
1315
|
+
"use strict";
|
|
1316
|
+
var dijkstra = {
|
|
1317
|
+
single_source_shortest_paths: function(graph, s, d) {
|
|
1318
|
+
var predecessors = {};
|
|
1319
|
+
var costs = {};
|
|
1320
|
+
costs[s] = 0;
|
|
1321
|
+
var open = dijkstra.PriorityQueue.make();
|
|
1322
|
+
open.push(s, 0);
|
|
1323
|
+
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;
|
|
1324
|
+
while (!open.empty()) {
|
|
1325
|
+
closest = open.pop();
|
|
1326
|
+
u = closest.value;
|
|
1327
|
+
cost_of_s_to_u = closest.cost;
|
|
1328
|
+
adjacent_nodes = graph[u] || {};
|
|
1329
|
+
for (v in adjacent_nodes) {
|
|
1330
|
+
if (adjacent_nodes.hasOwnProperty(v)) {
|
|
1331
|
+
cost_of_e = adjacent_nodes[v];
|
|
1332
|
+
cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
|
|
1333
|
+
cost_of_s_to_v = costs[v];
|
|
1334
|
+
first_visit = typeof costs[v] === "undefined";
|
|
1335
|
+
if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
|
|
1336
|
+
costs[v] = cost_of_s_to_u_plus_cost_of_e;
|
|
1337
|
+
open.push(v, cost_of_s_to_u_plus_cost_of_e);
|
|
1338
|
+
predecessors[v] = u;
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
if (typeof d !== "undefined" && typeof costs[d] === "undefined") {
|
|
1344
|
+
var msg = ["Could not find a path from ", s, " to ", d, "."].join("");
|
|
1345
|
+
throw new Error(msg);
|
|
1346
|
+
}
|
|
1347
|
+
return predecessors;
|
|
1348
|
+
},
|
|
1349
|
+
extract_shortest_path_from_predecessor_list: function(predecessors, d) {
|
|
1350
|
+
var nodes = [];
|
|
1351
|
+
var u = d;
|
|
1352
|
+
var predecessor;
|
|
1353
|
+
while (u) {
|
|
1354
|
+
nodes.push(u);
|
|
1355
|
+
predecessor = predecessors[u];
|
|
1356
|
+
u = predecessors[u];
|
|
1357
|
+
}
|
|
1358
|
+
nodes.reverse();
|
|
1359
|
+
return nodes;
|
|
1360
|
+
},
|
|
1361
|
+
find_path: function(graph, s, d) {
|
|
1362
|
+
var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
|
|
1363
|
+
return dijkstra.extract_shortest_path_from_predecessor_list(
|
|
1364
|
+
predecessors,
|
|
1365
|
+
d
|
|
1366
|
+
);
|
|
1367
|
+
},
|
|
1368
|
+
/**
|
|
1369
|
+
* A very naive priority queue implementation.
|
|
1370
|
+
*/
|
|
1371
|
+
PriorityQueue: {
|
|
1372
|
+
make: function(opts) {
|
|
1373
|
+
var T = dijkstra.PriorityQueue, t = {}, key;
|
|
1374
|
+
opts = opts || {};
|
|
1375
|
+
for (key in T) {
|
|
1376
|
+
if (T.hasOwnProperty(key)) {
|
|
1377
|
+
t[key] = T[key];
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
t.queue = [];
|
|
1381
|
+
t.sorter = opts.sorter || T.default_sorter;
|
|
1382
|
+
return t;
|
|
1383
|
+
},
|
|
1384
|
+
default_sorter: function(a, b) {
|
|
1385
|
+
return a.cost - b.cost;
|
|
1386
|
+
},
|
|
1387
|
+
/**
|
|
1388
|
+
* Add a new item to the queue and ensure the highest priority element
|
|
1389
|
+
* is at the front of the queue.
|
|
1390
|
+
*/
|
|
1391
|
+
push: function(value, cost) {
|
|
1392
|
+
var item = { value, cost };
|
|
1393
|
+
this.queue.push(item);
|
|
1394
|
+
this.queue.sort(this.sorter);
|
|
1395
|
+
},
|
|
1396
|
+
/**
|
|
1397
|
+
* Return the highest priority element in the queue.
|
|
1398
|
+
*/
|
|
1399
|
+
pop: function() {
|
|
1400
|
+
return this.queue.shift();
|
|
1401
|
+
},
|
|
1402
|
+
empty: function() {
|
|
1403
|
+
return this.queue.length === 0;
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
};
|
|
1407
|
+
if (typeof module2 !== "undefined") {
|
|
1408
|
+
module2.exports = dijkstra;
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
});
|
|
1412
|
+
|
|
1413
|
+
// node_modules/qrcode/lib/core/segments.js
|
|
1414
|
+
var require_segments = __commonJS({
|
|
1415
|
+
"node_modules/qrcode/lib/core/segments.js"(exports) {
|
|
1416
|
+
var Mode = require_mode();
|
|
1417
|
+
var NumericData = require_numeric_data();
|
|
1418
|
+
var AlphanumericData = require_alphanumeric_data();
|
|
1419
|
+
var ByteData = require_byte_data();
|
|
1420
|
+
var KanjiData = require_kanji_data();
|
|
1421
|
+
var Regex = require_regex();
|
|
1422
|
+
var Utils = require_utils();
|
|
1423
|
+
var dijkstra = require_dijkstra();
|
|
1424
|
+
function getStringByteLength(str) {
|
|
1425
|
+
return unescape(encodeURIComponent(str)).length;
|
|
1426
|
+
}
|
|
1427
|
+
function getSegments(regex, mode, str) {
|
|
1428
|
+
const segments = [];
|
|
1429
|
+
let result;
|
|
1430
|
+
while ((result = regex.exec(str)) !== null) {
|
|
1431
|
+
segments.push({
|
|
1432
|
+
data: result[0],
|
|
1433
|
+
index: result.index,
|
|
1434
|
+
mode,
|
|
1435
|
+
length: result[0].length
|
|
1436
|
+
});
|
|
1437
|
+
}
|
|
1438
|
+
return segments;
|
|
1439
|
+
}
|
|
1440
|
+
function getSegmentsFromString(dataStr) {
|
|
1441
|
+
const numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr);
|
|
1442
|
+
const alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr);
|
|
1443
|
+
let byteSegs;
|
|
1444
|
+
let kanjiSegs;
|
|
1445
|
+
if (Utils.isKanjiModeEnabled()) {
|
|
1446
|
+
byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr);
|
|
1447
|
+
kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr);
|
|
1448
|
+
} else {
|
|
1449
|
+
byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr);
|
|
1450
|
+
kanjiSegs = [];
|
|
1451
|
+
}
|
|
1452
|
+
const segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs);
|
|
1453
|
+
return segs.sort(function(s1, s2) {
|
|
1454
|
+
return s1.index - s2.index;
|
|
1455
|
+
}).map(function(obj) {
|
|
1456
|
+
return {
|
|
1457
|
+
data: obj.data,
|
|
1458
|
+
mode: obj.mode,
|
|
1459
|
+
length: obj.length
|
|
1460
|
+
};
|
|
1461
|
+
});
|
|
1462
|
+
}
|
|
1463
|
+
function getSegmentBitsLength(length, mode) {
|
|
1464
|
+
switch (mode) {
|
|
1465
|
+
case Mode.NUMERIC:
|
|
1466
|
+
return NumericData.getBitsLength(length);
|
|
1467
|
+
case Mode.ALPHANUMERIC:
|
|
1468
|
+
return AlphanumericData.getBitsLength(length);
|
|
1469
|
+
case Mode.KANJI:
|
|
1470
|
+
return KanjiData.getBitsLength(length);
|
|
1471
|
+
case Mode.BYTE:
|
|
1472
|
+
return ByteData.getBitsLength(length);
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
function mergeSegments(segs) {
|
|
1476
|
+
return segs.reduce(function(acc, curr) {
|
|
1477
|
+
const prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null;
|
|
1478
|
+
if (prevSeg && prevSeg.mode === curr.mode) {
|
|
1479
|
+
acc[acc.length - 1].data += curr.data;
|
|
1480
|
+
return acc;
|
|
1481
|
+
}
|
|
1482
|
+
acc.push(curr);
|
|
1483
|
+
return acc;
|
|
1484
|
+
}, []);
|
|
1485
|
+
}
|
|
1486
|
+
function buildNodes(segs) {
|
|
1487
|
+
const nodes = [];
|
|
1488
|
+
for (let i = 0; i < segs.length; i++) {
|
|
1489
|
+
const seg = segs[i];
|
|
1490
|
+
switch (seg.mode) {
|
|
1491
|
+
case Mode.NUMERIC:
|
|
1492
|
+
nodes.push([
|
|
1493
|
+
seg,
|
|
1494
|
+
{ data: seg.data, mode: Mode.ALPHANUMERIC, length: seg.length },
|
|
1495
|
+
{ data: seg.data, mode: Mode.BYTE, length: seg.length }
|
|
1496
|
+
]);
|
|
1497
|
+
break;
|
|
1498
|
+
case Mode.ALPHANUMERIC:
|
|
1499
|
+
nodes.push([
|
|
1500
|
+
seg,
|
|
1501
|
+
{ data: seg.data, mode: Mode.BYTE, length: seg.length }
|
|
1502
|
+
]);
|
|
1503
|
+
break;
|
|
1504
|
+
case Mode.KANJI:
|
|
1505
|
+
nodes.push([
|
|
1506
|
+
seg,
|
|
1507
|
+
{ data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
|
|
1508
|
+
]);
|
|
1509
|
+
break;
|
|
1510
|
+
case Mode.BYTE:
|
|
1511
|
+
nodes.push([
|
|
1512
|
+
{ data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
|
|
1513
|
+
]);
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
return nodes;
|
|
1517
|
+
}
|
|
1518
|
+
function buildGraph(nodes, version) {
|
|
1519
|
+
const table = {};
|
|
1520
|
+
const graph = { start: {} };
|
|
1521
|
+
let prevNodeIds = ["start"];
|
|
1522
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
1523
|
+
const nodeGroup = nodes[i];
|
|
1524
|
+
const currentNodeIds = [];
|
|
1525
|
+
for (let j = 0; j < nodeGroup.length; j++) {
|
|
1526
|
+
const node = nodeGroup[j];
|
|
1527
|
+
const key = "" + i + j;
|
|
1528
|
+
currentNodeIds.push(key);
|
|
1529
|
+
table[key] = { node, lastCount: 0 };
|
|
1530
|
+
graph[key] = {};
|
|
1531
|
+
for (let n = 0; n < prevNodeIds.length; n++) {
|
|
1532
|
+
const prevNodeId = prevNodeIds[n];
|
|
1533
|
+
if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
|
|
1534
|
+
graph[prevNodeId][key] = getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) - getSegmentBitsLength(table[prevNodeId].lastCount, node.mode);
|
|
1535
|
+
table[prevNodeId].lastCount += node.length;
|
|
1536
|
+
} else {
|
|
1537
|
+
if (table[prevNodeId]) table[prevNodeId].lastCount = node.length;
|
|
1538
|
+
graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) + 4 + Mode.getCharCountIndicator(node.mode, version);
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
prevNodeIds = currentNodeIds;
|
|
1543
|
+
}
|
|
1544
|
+
for (let n = 0; n < prevNodeIds.length; n++) {
|
|
1545
|
+
graph[prevNodeIds[n]].end = 0;
|
|
1546
|
+
}
|
|
1547
|
+
return { map: graph, table };
|
|
1548
|
+
}
|
|
1549
|
+
function buildSingleSegment(data, modesHint) {
|
|
1550
|
+
let mode;
|
|
1551
|
+
const bestMode = Mode.getBestModeForData(data);
|
|
1552
|
+
mode = Mode.from(modesHint, bestMode);
|
|
1553
|
+
if (mode !== Mode.BYTE && mode.bit < bestMode.bit) {
|
|
1554
|
+
throw new Error('"' + data + '" cannot be encoded with mode ' + Mode.toString(mode) + ".\n Suggested mode is: " + Mode.toString(bestMode));
|
|
1555
|
+
}
|
|
1556
|
+
if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) {
|
|
1557
|
+
mode = Mode.BYTE;
|
|
1558
|
+
}
|
|
1559
|
+
switch (mode) {
|
|
1560
|
+
case Mode.NUMERIC:
|
|
1561
|
+
return new NumericData(data);
|
|
1562
|
+
case Mode.ALPHANUMERIC:
|
|
1563
|
+
return new AlphanumericData(data);
|
|
1564
|
+
case Mode.KANJI:
|
|
1565
|
+
return new KanjiData(data);
|
|
1566
|
+
case Mode.BYTE:
|
|
1567
|
+
return new ByteData(data);
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
exports.fromArray = function fromArray(array) {
|
|
1571
|
+
return array.reduce(function(acc, seg) {
|
|
1572
|
+
if (typeof seg === "string") {
|
|
1573
|
+
acc.push(buildSingleSegment(seg, null));
|
|
1574
|
+
} else if (seg.data) {
|
|
1575
|
+
acc.push(buildSingleSegment(seg.data, seg.mode));
|
|
1576
|
+
}
|
|
1577
|
+
return acc;
|
|
1578
|
+
}, []);
|
|
1579
|
+
};
|
|
1580
|
+
exports.fromString = function fromString(data, version) {
|
|
1581
|
+
const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled());
|
|
1582
|
+
const nodes = buildNodes(segs);
|
|
1583
|
+
const graph = buildGraph(nodes, version);
|
|
1584
|
+
const path = dijkstra.find_path(graph.map, "start", "end");
|
|
1585
|
+
const optimizedSegs = [];
|
|
1586
|
+
for (let i = 1; i < path.length - 1; i++) {
|
|
1587
|
+
optimizedSegs.push(graph.table[path[i]].node);
|
|
1588
|
+
}
|
|
1589
|
+
return exports.fromArray(mergeSegments(optimizedSegs));
|
|
1590
|
+
};
|
|
1591
|
+
exports.rawSplit = function rawSplit(data) {
|
|
1592
|
+
return exports.fromArray(
|
|
1593
|
+
getSegmentsFromString(data, Utils.isKanjiModeEnabled())
|
|
1594
|
+
);
|
|
1595
|
+
};
|
|
1596
|
+
}
|
|
1597
|
+
});
|
|
1598
|
+
|
|
1599
|
+
// node_modules/qrcode/lib/core/qrcode.js
|
|
1600
|
+
var require_qrcode = __commonJS({
|
|
1601
|
+
"node_modules/qrcode/lib/core/qrcode.js"(exports) {
|
|
1602
|
+
var Utils = require_utils();
|
|
1603
|
+
var ECLevel = require_error_correction_level();
|
|
1604
|
+
var BitBuffer = require_bit_buffer();
|
|
1605
|
+
var BitMatrix = require_bit_matrix();
|
|
1606
|
+
var AlignmentPattern = require_alignment_pattern();
|
|
1607
|
+
var FinderPattern = require_finder_pattern();
|
|
1608
|
+
var MaskPattern = require_mask_pattern();
|
|
1609
|
+
var ECCode = require_error_correction_code();
|
|
1610
|
+
var ReedSolomonEncoder = require_reed_solomon_encoder();
|
|
1611
|
+
var Version = require_version();
|
|
1612
|
+
var FormatInfo = require_format_info();
|
|
1613
|
+
var Mode = require_mode();
|
|
1614
|
+
var Segments = require_segments();
|
|
1615
|
+
function setupFinderPattern(matrix, version) {
|
|
1616
|
+
const size = matrix.size;
|
|
1617
|
+
const pos = FinderPattern.getPositions(version);
|
|
1618
|
+
for (let i = 0; i < pos.length; i++) {
|
|
1619
|
+
const row = pos[i][0];
|
|
1620
|
+
const col = pos[i][1];
|
|
1621
|
+
for (let r = -1; r <= 7; r++) {
|
|
1622
|
+
if (row + r <= -1 || size <= row + r) continue;
|
|
1623
|
+
for (let c = -1; c <= 7; c++) {
|
|
1624
|
+
if (col + c <= -1 || size <= col + c) continue;
|
|
1625
|
+
if (r >= 0 && r <= 6 && (c === 0 || c === 6) || c >= 0 && c <= 6 && (r === 0 || r === 6) || r >= 2 && r <= 4 && c >= 2 && c <= 4) {
|
|
1626
|
+
matrix.set(row + r, col + c, true, true);
|
|
1627
|
+
} else {
|
|
1628
|
+
matrix.set(row + r, col + c, false, true);
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
function setupTimingPattern(matrix) {
|
|
1635
|
+
const size = matrix.size;
|
|
1636
|
+
for (let r = 8; r < size - 8; r++) {
|
|
1637
|
+
const value = r % 2 === 0;
|
|
1638
|
+
matrix.set(r, 6, value, true);
|
|
1639
|
+
matrix.set(6, r, value, true);
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
function setupAlignmentPattern(matrix, version) {
|
|
1643
|
+
const pos = AlignmentPattern.getPositions(version);
|
|
1644
|
+
for (let i = 0; i < pos.length; i++) {
|
|
1645
|
+
const row = pos[i][0];
|
|
1646
|
+
const col = pos[i][1];
|
|
1647
|
+
for (let r = -2; r <= 2; r++) {
|
|
1648
|
+
for (let c = -2; c <= 2; c++) {
|
|
1649
|
+
if (r === -2 || r === 2 || c === -2 || c === 2 || r === 0 && c === 0) {
|
|
1650
|
+
matrix.set(row + r, col + c, true, true);
|
|
1651
|
+
} else {
|
|
1652
|
+
matrix.set(row + r, col + c, false, true);
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
function setupVersionInfo(matrix, version) {
|
|
1659
|
+
const size = matrix.size;
|
|
1660
|
+
const bits = Version.getEncodedBits(version);
|
|
1661
|
+
let row, col, mod;
|
|
1662
|
+
for (let i = 0; i < 18; i++) {
|
|
1663
|
+
row = Math.floor(i / 3);
|
|
1664
|
+
col = i % 3 + size - 8 - 3;
|
|
1665
|
+
mod = (bits >> i & 1) === 1;
|
|
1666
|
+
matrix.set(row, col, mod, true);
|
|
1667
|
+
matrix.set(col, row, mod, true);
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
function setupFormatInfo(matrix, errorCorrectionLevel, maskPattern) {
|
|
1671
|
+
const size = matrix.size;
|
|
1672
|
+
const bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern);
|
|
1673
|
+
let i, mod;
|
|
1674
|
+
for (i = 0; i < 15; i++) {
|
|
1675
|
+
mod = (bits >> i & 1) === 1;
|
|
1676
|
+
if (i < 6) {
|
|
1677
|
+
matrix.set(i, 8, mod, true);
|
|
1678
|
+
} else if (i < 8) {
|
|
1679
|
+
matrix.set(i + 1, 8, mod, true);
|
|
1680
|
+
} else {
|
|
1681
|
+
matrix.set(size - 15 + i, 8, mod, true);
|
|
1682
|
+
}
|
|
1683
|
+
if (i < 8) {
|
|
1684
|
+
matrix.set(8, size - i - 1, mod, true);
|
|
1685
|
+
} else if (i < 9) {
|
|
1686
|
+
matrix.set(8, 15 - i - 1 + 1, mod, true);
|
|
1687
|
+
} else {
|
|
1688
|
+
matrix.set(8, 15 - i - 1, mod, true);
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
matrix.set(size - 8, 8, 1, true);
|
|
1692
|
+
}
|
|
1693
|
+
function setupData(matrix, data) {
|
|
1694
|
+
const size = matrix.size;
|
|
1695
|
+
let inc = -1;
|
|
1696
|
+
let row = size - 1;
|
|
1697
|
+
let bitIndex = 7;
|
|
1698
|
+
let byteIndex = 0;
|
|
1699
|
+
for (let col = size - 1; col > 0; col -= 2) {
|
|
1700
|
+
if (col === 6) col--;
|
|
1701
|
+
while (true) {
|
|
1702
|
+
for (let c = 0; c < 2; c++) {
|
|
1703
|
+
if (!matrix.isReserved(row, col - c)) {
|
|
1704
|
+
let dark = false;
|
|
1705
|
+
if (byteIndex < data.length) {
|
|
1706
|
+
dark = (data[byteIndex] >>> bitIndex & 1) === 1;
|
|
1707
|
+
}
|
|
1708
|
+
matrix.set(row, col - c, dark);
|
|
1709
|
+
bitIndex--;
|
|
1710
|
+
if (bitIndex === -1) {
|
|
1711
|
+
byteIndex++;
|
|
1712
|
+
bitIndex = 7;
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
row += inc;
|
|
1717
|
+
if (row < 0 || size <= row) {
|
|
1718
|
+
row -= inc;
|
|
1719
|
+
inc = -inc;
|
|
1720
|
+
break;
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
function createData(version, errorCorrectionLevel, segments) {
|
|
1726
|
+
const buffer = new BitBuffer();
|
|
1727
|
+
segments.forEach(function(data) {
|
|
1728
|
+
buffer.put(data.mode.bit, 4);
|
|
1729
|
+
buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version));
|
|
1730
|
+
data.write(buffer);
|
|
1731
|
+
});
|
|
1732
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version);
|
|
1733
|
+
const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
|
|
1734
|
+
const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
|
|
1735
|
+
if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) {
|
|
1736
|
+
buffer.put(0, 4);
|
|
1737
|
+
}
|
|
1738
|
+
while (buffer.getLengthInBits() % 8 !== 0) {
|
|
1739
|
+
buffer.putBit(0);
|
|
1740
|
+
}
|
|
1741
|
+
const remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8;
|
|
1742
|
+
for (let i = 0; i < remainingByte; i++) {
|
|
1743
|
+
buffer.put(i % 2 ? 17 : 236, 8);
|
|
1744
|
+
}
|
|
1745
|
+
return createCodewords(buffer, version, errorCorrectionLevel);
|
|
1746
|
+
}
|
|
1747
|
+
function createCodewords(bitBuffer, version, errorCorrectionLevel) {
|
|
1748
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version);
|
|
1749
|
+
const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
|
|
1750
|
+
const dataTotalCodewords = totalCodewords - ecTotalCodewords;
|
|
1751
|
+
const ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel);
|
|
1752
|
+
const blocksInGroup2 = totalCodewords % ecTotalBlocks;
|
|
1753
|
+
const blocksInGroup1 = ecTotalBlocks - blocksInGroup2;
|
|
1754
|
+
const totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks);
|
|
1755
|
+
const dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks);
|
|
1756
|
+
const dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1;
|
|
1757
|
+
const ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1;
|
|
1758
|
+
const rs = new ReedSolomonEncoder(ecCount);
|
|
1759
|
+
let offset = 0;
|
|
1760
|
+
const dcData = new Array(ecTotalBlocks);
|
|
1761
|
+
const ecData = new Array(ecTotalBlocks);
|
|
1762
|
+
let maxDataSize = 0;
|
|
1763
|
+
const buffer = new Uint8Array(bitBuffer.buffer);
|
|
1764
|
+
for (let b = 0; b < ecTotalBlocks; b++) {
|
|
1765
|
+
const dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2;
|
|
1766
|
+
dcData[b] = buffer.slice(offset, offset + dataSize);
|
|
1767
|
+
ecData[b] = rs.encode(dcData[b]);
|
|
1768
|
+
offset += dataSize;
|
|
1769
|
+
maxDataSize = Math.max(maxDataSize, dataSize);
|
|
1770
|
+
}
|
|
1771
|
+
const data = new Uint8Array(totalCodewords);
|
|
1772
|
+
let index = 0;
|
|
1773
|
+
let i, r;
|
|
1774
|
+
for (i = 0; i < maxDataSize; i++) {
|
|
1775
|
+
for (r = 0; r < ecTotalBlocks; r++) {
|
|
1776
|
+
if (i < dcData[r].length) {
|
|
1777
|
+
data[index++] = dcData[r][i];
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
for (i = 0; i < ecCount; i++) {
|
|
1782
|
+
for (r = 0; r < ecTotalBlocks; r++) {
|
|
1783
|
+
data[index++] = ecData[r][i];
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
return data;
|
|
1787
|
+
}
|
|
1788
|
+
function createSymbol(data, version, errorCorrectionLevel, maskPattern) {
|
|
1789
|
+
let segments;
|
|
1790
|
+
if (Array.isArray(data)) {
|
|
1791
|
+
segments = Segments.fromArray(data);
|
|
1792
|
+
} else if (typeof data === "string") {
|
|
1793
|
+
let estimatedVersion = version;
|
|
1794
|
+
if (!estimatedVersion) {
|
|
1795
|
+
const rawSegments = Segments.rawSplit(data);
|
|
1796
|
+
estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel);
|
|
1797
|
+
}
|
|
1798
|
+
segments = Segments.fromString(data, estimatedVersion || 40);
|
|
1799
|
+
} else {
|
|
1800
|
+
throw new Error("Invalid data");
|
|
1801
|
+
}
|
|
1802
|
+
const bestVersion = Version.getBestVersionForData(segments, errorCorrectionLevel);
|
|
1803
|
+
if (!bestVersion) {
|
|
1804
|
+
throw new Error("The amount of data is too big to be stored in a QR Code");
|
|
1805
|
+
}
|
|
1806
|
+
if (!version) {
|
|
1807
|
+
version = bestVersion;
|
|
1808
|
+
} else if (version < bestVersion) {
|
|
1809
|
+
throw new Error(
|
|
1810
|
+
"\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: " + bestVersion + ".\n"
|
|
1811
|
+
);
|
|
1812
|
+
}
|
|
1813
|
+
const dataBits = createData(version, errorCorrectionLevel, segments);
|
|
1814
|
+
const moduleCount = Utils.getSymbolSize(version);
|
|
1815
|
+
const modules = new BitMatrix(moduleCount);
|
|
1816
|
+
setupFinderPattern(modules, version);
|
|
1817
|
+
setupTimingPattern(modules);
|
|
1818
|
+
setupAlignmentPattern(modules, version);
|
|
1819
|
+
setupFormatInfo(modules, errorCorrectionLevel, 0);
|
|
1820
|
+
if (version >= 7) {
|
|
1821
|
+
setupVersionInfo(modules, version);
|
|
1822
|
+
}
|
|
1823
|
+
setupData(modules, dataBits);
|
|
1824
|
+
if (isNaN(maskPattern)) {
|
|
1825
|
+
maskPattern = MaskPattern.getBestMask(
|
|
1826
|
+
modules,
|
|
1827
|
+
setupFormatInfo.bind(null, modules, errorCorrectionLevel)
|
|
1828
|
+
);
|
|
1829
|
+
}
|
|
1830
|
+
MaskPattern.applyMask(maskPattern, modules);
|
|
1831
|
+
setupFormatInfo(modules, errorCorrectionLevel, maskPattern);
|
|
1832
|
+
return {
|
|
1833
|
+
modules,
|
|
1834
|
+
version,
|
|
1835
|
+
errorCorrectionLevel,
|
|
1836
|
+
maskPattern,
|
|
1837
|
+
segments
|
|
1838
|
+
};
|
|
1839
|
+
}
|
|
1840
|
+
exports.create = function create(data, options) {
|
|
1841
|
+
if (typeof data === "undefined" || data === "") {
|
|
1842
|
+
throw new Error("No input text");
|
|
1843
|
+
}
|
|
1844
|
+
let errorCorrectionLevel = ECLevel.M;
|
|
1845
|
+
let version;
|
|
1846
|
+
let mask;
|
|
1847
|
+
if (typeof options !== "undefined") {
|
|
1848
|
+
errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M);
|
|
1849
|
+
version = Version.from(options.version);
|
|
1850
|
+
mask = MaskPattern.from(options.maskPattern);
|
|
1851
|
+
if (options.toSJISFunc) {
|
|
1852
|
+
Utils.setToSJISFunction(options.toSJISFunc);
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
return createSymbol(data, version, errorCorrectionLevel, mask);
|
|
1856
|
+
};
|
|
1857
|
+
}
|
|
1858
|
+
});
|
|
1859
|
+
|
|
1860
|
+
// node_modules/qrcode/lib/renderer/utils.js
|
|
1861
|
+
var require_utils2 = __commonJS({
|
|
1862
|
+
"node_modules/qrcode/lib/renderer/utils.js"(exports) {
|
|
1863
|
+
function hex2rgba(hex) {
|
|
1864
|
+
if (typeof hex === "number") {
|
|
1865
|
+
hex = hex.toString();
|
|
1866
|
+
}
|
|
1867
|
+
if (typeof hex !== "string") {
|
|
1868
|
+
throw new Error("Color should be defined as hex string");
|
|
1869
|
+
}
|
|
1870
|
+
let hexCode = hex.slice().replace("#", "").split("");
|
|
1871
|
+
if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) {
|
|
1872
|
+
throw new Error("Invalid hex color: " + hex);
|
|
1873
|
+
}
|
|
1874
|
+
if (hexCode.length === 3 || hexCode.length === 4) {
|
|
1875
|
+
hexCode = Array.prototype.concat.apply([], hexCode.map(function(c) {
|
|
1876
|
+
return [c, c];
|
|
1877
|
+
}));
|
|
1878
|
+
}
|
|
1879
|
+
if (hexCode.length === 6) hexCode.push("F", "F");
|
|
1880
|
+
const hexValue = parseInt(hexCode.join(""), 16);
|
|
1881
|
+
return {
|
|
1882
|
+
r: hexValue >> 24 & 255,
|
|
1883
|
+
g: hexValue >> 16 & 255,
|
|
1884
|
+
b: hexValue >> 8 & 255,
|
|
1885
|
+
a: hexValue & 255,
|
|
1886
|
+
hex: "#" + hexCode.slice(0, 6).join("")
|
|
1887
|
+
};
|
|
1888
|
+
}
|
|
1889
|
+
exports.getOptions = function getOptions(options) {
|
|
1890
|
+
if (!options) options = {};
|
|
1891
|
+
if (!options.color) options.color = {};
|
|
1892
|
+
const margin = typeof options.margin === "undefined" || options.margin === null || options.margin < 0 ? 4 : options.margin;
|
|
1893
|
+
const width = options.width && options.width >= 21 ? options.width : void 0;
|
|
1894
|
+
const scale = options.scale || 4;
|
|
1895
|
+
return {
|
|
1896
|
+
width,
|
|
1897
|
+
scale: width ? 4 : scale,
|
|
1898
|
+
margin,
|
|
1899
|
+
color: {
|
|
1900
|
+
dark: hex2rgba(options.color.dark || "#000000ff"),
|
|
1901
|
+
light: hex2rgba(options.color.light || "#ffffffff")
|
|
1902
|
+
},
|
|
1903
|
+
type: options.type,
|
|
1904
|
+
rendererOpts: options.rendererOpts || {}
|
|
1905
|
+
};
|
|
1906
|
+
};
|
|
1907
|
+
exports.getScale = function getScale(qrSize, opts) {
|
|
1908
|
+
return opts.width && opts.width >= qrSize + opts.margin * 2 ? opts.width / (qrSize + opts.margin * 2) : opts.scale;
|
|
1909
|
+
};
|
|
1910
|
+
exports.getImageWidth = function getImageWidth(qrSize, opts) {
|
|
1911
|
+
const scale = exports.getScale(qrSize, opts);
|
|
1912
|
+
return Math.floor((qrSize + opts.margin * 2) * scale);
|
|
1913
|
+
};
|
|
1914
|
+
exports.qrToImageData = function qrToImageData(imgData, qr, opts) {
|
|
1915
|
+
const size = qr.modules.size;
|
|
1916
|
+
const data = qr.modules.data;
|
|
1917
|
+
const scale = exports.getScale(size, opts);
|
|
1918
|
+
const symbolSize = Math.floor((size + opts.margin * 2) * scale);
|
|
1919
|
+
const scaledMargin = opts.margin * scale;
|
|
1920
|
+
const palette = [opts.color.light, opts.color.dark];
|
|
1921
|
+
for (let i = 0; i < symbolSize; i++) {
|
|
1922
|
+
for (let j = 0; j < symbolSize; j++) {
|
|
1923
|
+
let posDst = (i * symbolSize + j) * 4;
|
|
1924
|
+
let pxColor = opts.color.light;
|
|
1925
|
+
if (i >= scaledMargin && j >= scaledMargin && i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) {
|
|
1926
|
+
const iSrc = Math.floor((i - scaledMargin) / scale);
|
|
1927
|
+
const jSrc = Math.floor((j - scaledMargin) / scale);
|
|
1928
|
+
pxColor = palette[data[iSrc * size + jSrc] ? 1 : 0];
|
|
1929
|
+
}
|
|
1930
|
+
imgData[posDst++] = pxColor.r;
|
|
1931
|
+
imgData[posDst++] = pxColor.g;
|
|
1932
|
+
imgData[posDst++] = pxColor.b;
|
|
1933
|
+
imgData[posDst] = pxColor.a;
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
};
|
|
1937
|
+
}
|
|
1938
|
+
});
|
|
1939
|
+
|
|
1940
|
+
// node_modules/qrcode/lib/renderer/canvas.js
|
|
1941
|
+
var require_canvas = __commonJS({
|
|
1942
|
+
"node_modules/qrcode/lib/renderer/canvas.js"(exports) {
|
|
1943
|
+
var Utils = require_utils2();
|
|
1944
|
+
function clearCanvas(ctx, canvas, size) {
|
|
1945
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
1946
|
+
if (!canvas.style) canvas.style = {};
|
|
1947
|
+
canvas.height = size;
|
|
1948
|
+
canvas.width = size;
|
|
1949
|
+
canvas.style.height = size + "px";
|
|
1950
|
+
canvas.style.width = size + "px";
|
|
1951
|
+
}
|
|
1952
|
+
function getCanvasElement() {
|
|
1953
|
+
try {
|
|
1954
|
+
return document.createElement("canvas");
|
|
1955
|
+
} catch (e) {
|
|
1956
|
+
throw new Error("You need to specify a canvas element");
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
exports.render = function render(qrData, canvas, options) {
|
|
1960
|
+
let opts = options;
|
|
1961
|
+
let canvasEl = canvas;
|
|
1962
|
+
if (typeof opts === "undefined" && (!canvas || !canvas.getContext)) {
|
|
1963
|
+
opts = canvas;
|
|
1964
|
+
canvas = void 0;
|
|
1965
|
+
}
|
|
1966
|
+
if (!canvas) {
|
|
1967
|
+
canvasEl = getCanvasElement();
|
|
1968
|
+
}
|
|
1969
|
+
opts = Utils.getOptions(opts);
|
|
1970
|
+
const size = Utils.getImageWidth(qrData.modules.size, opts);
|
|
1971
|
+
const ctx = canvasEl.getContext("2d");
|
|
1972
|
+
const image = ctx.createImageData(size, size);
|
|
1973
|
+
Utils.qrToImageData(image.data, qrData, opts);
|
|
1974
|
+
clearCanvas(ctx, canvasEl, size);
|
|
1975
|
+
ctx.putImageData(image, 0, 0);
|
|
1976
|
+
return canvasEl;
|
|
1977
|
+
};
|
|
1978
|
+
exports.renderToDataURL = function renderToDataURL(qrData, canvas, options) {
|
|
1979
|
+
let opts = options;
|
|
1980
|
+
if (typeof opts === "undefined" && (!canvas || !canvas.getContext)) {
|
|
1981
|
+
opts = canvas;
|
|
1982
|
+
canvas = void 0;
|
|
1983
|
+
}
|
|
1984
|
+
if (!opts) opts = {};
|
|
1985
|
+
const canvasEl = exports.render(qrData, canvas, opts);
|
|
1986
|
+
const type = opts.type || "image/png";
|
|
1987
|
+
const rendererOpts = opts.rendererOpts || {};
|
|
1988
|
+
return canvasEl.toDataURL(type, rendererOpts.quality);
|
|
1989
|
+
};
|
|
1990
|
+
}
|
|
1991
|
+
});
|
|
1992
|
+
|
|
1993
|
+
// node_modules/qrcode/lib/renderer/svg-tag.js
|
|
1994
|
+
var require_svg_tag = __commonJS({
|
|
1995
|
+
"node_modules/qrcode/lib/renderer/svg-tag.js"(exports) {
|
|
1996
|
+
var Utils = require_utils2();
|
|
1997
|
+
function getColorAttrib(color, attrib) {
|
|
1998
|
+
const alpha = color.a / 255;
|
|
1999
|
+
const str = attrib + '="' + color.hex + '"';
|
|
2000
|
+
return alpha < 1 ? str + " " + attrib + '-opacity="' + alpha.toFixed(2).slice(1) + '"' : str;
|
|
2001
|
+
}
|
|
2002
|
+
function svgCmd(cmd, x, y) {
|
|
2003
|
+
let str = cmd + x;
|
|
2004
|
+
if (typeof y !== "undefined") str += " " + y;
|
|
2005
|
+
return str;
|
|
2006
|
+
}
|
|
2007
|
+
function qrToPath(data, size, margin) {
|
|
2008
|
+
let path = "";
|
|
2009
|
+
let moveBy = 0;
|
|
2010
|
+
let newRow = false;
|
|
2011
|
+
let lineLength = 0;
|
|
2012
|
+
for (let i = 0; i < data.length; i++) {
|
|
2013
|
+
const col = Math.floor(i % size);
|
|
2014
|
+
const row = Math.floor(i / size);
|
|
2015
|
+
if (!col && !newRow) newRow = true;
|
|
2016
|
+
if (data[i]) {
|
|
2017
|
+
lineLength++;
|
|
2018
|
+
if (!(i > 0 && col > 0 && data[i - 1])) {
|
|
2019
|
+
path += newRow ? svgCmd("M", col + margin, 0.5 + row + margin) : svgCmd("m", moveBy, 0);
|
|
2020
|
+
moveBy = 0;
|
|
2021
|
+
newRow = false;
|
|
2022
|
+
}
|
|
2023
|
+
if (!(col + 1 < size && data[i + 1])) {
|
|
2024
|
+
path += svgCmd("h", lineLength);
|
|
2025
|
+
lineLength = 0;
|
|
2026
|
+
}
|
|
2027
|
+
} else {
|
|
2028
|
+
moveBy++;
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
return path;
|
|
2032
|
+
}
|
|
2033
|
+
exports.render = function render(qrData, options, cb) {
|
|
2034
|
+
const opts = Utils.getOptions(options);
|
|
2035
|
+
const size = qrData.modules.size;
|
|
2036
|
+
const data = qrData.modules.data;
|
|
2037
|
+
const qrcodesize = size + opts.margin * 2;
|
|
2038
|
+
const bg = !opts.color.light.a ? "" : "<path " + getColorAttrib(opts.color.light, "fill") + ' d="M0 0h' + qrcodesize + "v" + qrcodesize + 'H0z"/>';
|
|
2039
|
+
const path = "<path " + getColorAttrib(opts.color.dark, "stroke") + ' d="' + qrToPath(data, size, opts.margin) + '"/>';
|
|
2040
|
+
const viewBox = 'viewBox="0 0 ' + qrcodesize + " " + qrcodesize + '"';
|
|
2041
|
+
const width = !opts.width ? "" : 'width="' + opts.width + '" height="' + opts.width + '" ';
|
|
2042
|
+
const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path + "</svg>\n";
|
|
2043
|
+
if (typeof cb === "function") {
|
|
2044
|
+
cb(null, svgTag);
|
|
2045
|
+
}
|
|
2046
|
+
return svgTag;
|
|
2047
|
+
};
|
|
2048
|
+
}
|
|
2049
|
+
});
|
|
2050
|
+
|
|
2051
|
+
// node_modules/qrcode/lib/browser.js
|
|
2052
|
+
var require_browser = __commonJS({
|
|
2053
|
+
"node_modules/qrcode/lib/browser.js"(exports) {
|
|
2054
|
+
var canPromise = require_can_promise();
|
|
2055
|
+
var QRCode2 = require_qrcode();
|
|
2056
|
+
var CanvasRenderer = require_canvas();
|
|
2057
|
+
var SvgRenderer = require_svg_tag();
|
|
2058
|
+
function renderCanvas(renderFunc, canvas, text, opts, cb) {
|
|
2059
|
+
const args = [].slice.call(arguments, 1);
|
|
2060
|
+
const argsNum = args.length;
|
|
2061
|
+
const isLastArgCb = typeof args[argsNum - 1] === "function";
|
|
2062
|
+
if (!isLastArgCb && !canPromise()) {
|
|
2063
|
+
throw new Error("Callback required as last argument");
|
|
2064
|
+
}
|
|
2065
|
+
if (isLastArgCb) {
|
|
2066
|
+
if (argsNum < 2) {
|
|
2067
|
+
throw new Error("Too few arguments provided");
|
|
2068
|
+
}
|
|
2069
|
+
if (argsNum === 2) {
|
|
2070
|
+
cb = text;
|
|
2071
|
+
text = canvas;
|
|
2072
|
+
canvas = opts = void 0;
|
|
2073
|
+
} else if (argsNum === 3) {
|
|
2074
|
+
if (canvas.getContext && typeof cb === "undefined") {
|
|
2075
|
+
cb = opts;
|
|
2076
|
+
opts = void 0;
|
|
2077
|
+
} else {
|
|
2078
|
+
cb = opts;
|
|
2079
|
+
opts = text;
|
|
2080
|
+
text = canvas;
|
|
2081
|
+
canvas = void 0;
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
} else {
|
|
2085
|
+
if (argsNum < 1) {
|
|
2086
|
+
throw new Error("Too few arguments provided");
|
|
2087
|
+
}
|
|
2088
|
+
if (argsNum === 1) {
|
|
2089
|
+
text = canvas;
|
|
2090
|
+
canvas = opts = void 0;
|
|
2091
|
+
} else if (argsNum === 2 && !canvas.getContext) {
|
|
2092
|
+
opts = text;
|
|
2093
|
+
text = canvas;
|
|
2094
|
+
canvas = void 0;
|
|
2095
|
+
}
|
|
2096
|
+
return new Promise(function(resolve, reject) {
|
|
2097
|
+
try {
|
|
2098
|
+
const data = QRCode2.create(text, opts);
|
|
2099
|
+
resolve(renderFunc(data, canvas, opts));
|
|
2100
|
+
} catch (e) {
|
|
2101
|
+
reject(e);
|
|
2102
|
+
}
|
|
2103
|
+
});
|
|
2104
|
+
}
|
|
2105
|
+
try {
|
|
2106
|
+
const data = QRCode2.create(text, opts);
|
|
2107
|
+
cb(null, renderFunc(data, canvas, opts));
|
|
2108
|
+
} catch (e) {
|
|
2109
|
+
cb(e);
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
exports.create = QRCode2.create;
|
|
2113
|
+
exports.toCanvas = renderCanvas.bind(null, CanvasRenderer.render);
|
|
2114
|
+
exports.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL);
|
|
2115
|
+
exports.toString = renderCanvas.bind(null, function(data, _, opts) {
|
|
2116
|
+
return SvgRenderer.render(data, opts);
|
|
2117
|
+
});
|
|
2118
|
+
}
|
|
2119
|
+
});
|
|
2120
|
+
|
|
36
2121
|
// src/client.jsx
|
|
37
2122
|
var client_exports = {};
|
|
38
2123
|
__export(client_exports, {
|
|
@@ -41,7 +2126,7 @@ __export(client_exports, {
|
|
|
41
2126
|
inject: () => inject
|
|
42
2127
|
});
|
|
43
2128
|
module.exports = __toCommonJS(client_exports);
|
|
44
|
-
var
|
|
2129
|
+
var import_react20 = __toESM(require("react"), 1);
|
|
45
2130
|
|
|
46
2131
|
// src/shared.js
|
|
47
2132
|
var import_react = __toESM(require("react"), 1);
|
|
@@ -7344,7 +9429,7 @@ var baseCss = `
|
|
|
7344
9429
|
.dgwin-picker{position:absolute;inset:0;z-index:4;display:flex;flex-direction:column;gap:10px;padding:13px;background:rgb(10 14 32 / .86);backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);overflow-y:auto;animation:dgentry-in .15s ease-out}.dgwin-picker-head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}.dgwin-picker-head>div{display:flex;flex-direction:column;gap:3px}.dgwin-picker-head b{font-size:14px}.dgwin-picker-head span{font-size:11px;color:#aab3e8}.dgwin-picker-close{cursor:pointer;border:none;background:transparent;color:#7d86c0;border-radius:8px;width:28px;height:28px;display:inline-flex;align-items:center;justify-content:center;font-size:14px;flex:none}.dgwin-picker-close:hover{background:rgb(255 255 255 / .08);color:#e7ecff}.dgwin-picker .dgcov-grid{flex-direction:column;--dsw-alias-label-primary:#e7ecff;--dsw-alias-label-secondary:#aab3e8;--dsw-alias-border-l1:rgb(255 255 255 / .12)}.dgwin-picker .dgcov{min-width:0;background:rgb(255 255 255 / .04)}
|
|
7345
9430
|
.dgwin-resize{position:absolute;right:0;bottom:0;width:18px;height:18px;cursor:nwse-resize;z-index:3;touch-action:none}.dgwin-resize::after{content:'';position:absolute;right:4px;bottom:4px;width:8px;height:8px;border-right:2px solid rgb(255 255 255 / .3);border-bottom:2px solid rgb(255 255 255 / .3);border-radius:0 0 3px 0}
|
|
7346
9431
|
@keyframes dgentry-in{from{opacity:0}}
|
|
7347
|
-
@media (max-width:680px){.dgame{gap:12px;font-size:14px}.dgame-hero{padding:15px}.dgame-hero h2{font-size:20px}.dgame-planet{width:58px;height:58px}.dgame-planet::after{left:-12px;top:25px;width:80px;height:20px}.dgame-game{padding:12px}.dgame-dash-grid{grid-template-rows:repeat(5,48px)}.dgame-controls{grid-template-columns:1fr 1fr}.dgame-controls span{grid-column:1 / -1;grid-row:2}.dgame-reactor{gap:8px}.dgcov-grid{flex-direction:column}.dgcov{min-width:0}.dgfab{width:32px}.dgwin-title span,.dgwin-task{display:none}.dgwin-bar{gap:7px;padding:8px 10px}.dgwin-btn{padding:6px 8px}.dgwin-body{padding:10px}}
|
|
9432
|
+
@media (max-width:680px){.dgame{gap:12px;font-size:14px}.dgame-hero{padding:15px}.dgame-hero h2{font-size:20px}.dgame-planet{width:58px;height:58px}.dgame-planet::after{left:-12px;top:25px;width:80px;height:20px}.dgame-game{padding:12px}.dgame-dash-grid{grid-template-rows:repeat(5,48px)}.dgame-controls{grid-template-columns:1fr 1fr}.dgame-controls span{grid-column:1 / -1;grid-row:2}.dgame-reactor{gap:8px}.dgcov-grid{flex-direction:column}.dgcov{min-width:0}.dgfab{width:32px;opacity:.72}.dgfab:hover{opacity:1}.dgwin-title span,.dgwin-task{display:none}.dgwin-bar{gap:7px;padding:8px 10px}.dgwin-btn{padding:6px 8px}.dgwin-body{padding:10px}}
|
|
7348
9433
|
@media (prefers-reduced-motion:reduce){.dgame *,.dgcov *,.dgfab,.dgwin,.dgwin-picker *{animation:none!important;transition:none!important}}
|
|
7349
9434
|
`;
|
|
7350
9435
|
var dgcovGroupCss = `
|
|
@@ -7373,9 +9458,331 @@ var feature7 = {
|
|
|
7373
9458
|
Overlay: GamesOverlay
|
|
7374
9459
|
};
|
|
7375
9460
|
|
|
9461
|
+
// features/mobile-relay/view.jsx
|
|
9462
|
+
var import_react19 = require("react");
|
|
9463
|
+
var import_qrcode = __toESM(require_browser(), 1);
|
|
9464
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
9465
|
+
function rpc(method, payload) {
|
|
9466
|
+
return fetch("/dsh-dock/mobile-relay/" + method, {
|
|
9467
|
+
method: "POST",
|
|
9468
|
+
headers: { "content-type": "application/json" },
|
|
9469
|
+
body: JSON.stringify(payload || {})
|
|
9470
|
+
}).then(async (res) => {
|
|
9471
|
+
const body = await res.json().catch(() => ({}));
|
|
9472
|
+
if (res.ok && body && body.ok) return body.data;
|
|
9473
|
+
if (res.status === 404 || res.status === 405) throw new Error("\u5BBF\u4E3B\u8FDB\u7A0B\u4ECD\u662F\u65E7\u7248\u672C\uFF0C\u8BF7\u91CD\u542F dsh web \u540E\u518D\u8BD5");
|
|
9474
|
+
throw new Error(body && body.error && body.error.message || "\u8BF7\u6C42\u5931\u8D25\uFF08" + res.status + "\uFF09");
|
|
9475
|
+
});
|
|
9476
|
+
}
|
|
9477
|
+
function copy(value) {
|
|
9478
|
+
if (navigator.clipboard && navigator.clipboard.writeText) return navigator.clipboard.writeText(value);
|
|
9479
|
+
return Promise.reject(new Error("\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u590D\u5236\uFF0C\u8BF7\u957F\u6309\u6216\u624B\u52A8\u590D\u5236"));
|
|
9480
|
+
}
|
|
9481
|
+
function RelayIcon({ name, size = 18 }) {
|
|
9482
|
+
const common = { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true };
|
|
9483
|
+
if (name === "link") return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("svg", { ...common, children: [
|
|
9484
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M10.5 13.5a4 4 0 0 0 5.66.01l2-2a4 4 0 0 0-5.66-5.66l-1.15 1.14" }),
|
|
9485
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M13.5 10.5a4 4 0 0 0-5.66-.01l-2 2a4 4 0 0 0 5.66 5.66l1.15-1.14" })
|
|
9486
|
+
] });
|
|
9487
|
+
if (name === "copy") return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("svg", { ...common, children: [
|
|
9488
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("rect", { x: "8", y: "8", width: "11", height: "12", rx: "1.5" }),
|
|
9489
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M16 8V5.5A1.5 1.5 0 0 0 14.5 4h-9A1.5 1.5 0 0 0 4 5.5v9A1.5 1.5 0 0 0 5.5 16H8" })
|
|
9490
|
+
] });
|
|
9491
|
+
if (name === "close") return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { ...common, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "m6 6 12 12M18 6 6 18" }) });
|
|
9492
|
+
if (name === "check") return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { ...common, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "m5 12 4.2 4.2L19 6.5" }) });
|
|
9493
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("svg", { ...common, children: [
|
|
9494
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", { cx: "12", cy: "12", r: "8" }),
|
|
9495
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M12 8v4l2.5 2" })
|
|
9496
|
+
] });
|
|
9497
|
+
}
|
|
9498
|
+
function useCompact() {
|
|
9499
|
+
const [compact, setCompact] = (0, import_react19.useState)(() => typeof window !== "undefined" && window.matchMedia("(max-width: 680px)").matches);
|
|
9500
|
+
(0, import_react19.useEffect)(() => {
|
|
9501
|
+
const media = window.matchMedia("(max-width: 680px)");
|
|
9502
|
+
const update = () => setCompact(media.matches);
|
|
9503
|
+
update();
|
|
9504
|
+
media.addEventListener("change", update);
|
|
9505
|
+
return () => media.removeEventListener("change", update);
|
|
9506
|
+
}, []);
|
|
9507
|
+
return compact;
|
|
9508
|
+
}
|
|
9509
|
+
function RemoteCard() {
|
|
9510
|
+
const compact = useCompact();
|
|
9511
|
+
const [lan, setLan] = (0, import_react19.useState)(null);
|
|
9512
|
+
const [username, setUsername] = (0, import_react19.useState)("");
|
|
9513
|
+
const [password, setPassword] = (0, import_react19.useState)("");
|
|
9514
|
+
const [newPassword, setNewPassword] = (0, import_react19.useState)("");
|
|
9515
|
+
const [port, setPort] = (0, import_react19.useState)("");
|
|
9516
|
+
const [address, setAddress] = (0, import_react19.useState)("");
|
|
9517
|
+
const [qr, setQr] = (0, import_react19.useState)("");
|
|
9518
|
+
const [busy, setBusy] = (0, import_react19.useState)("");
|
|
9519
|
+
const [message, setMessage] = (0, import_react19.useState)("");
|
|
9520
|
+
const [messageKind, setMessageKind] = (0, import_react19.useState)("error");
|
|
9521
|
+
const [changing, setChanging] = (0, import_react19.useState)(false);
|
|
9522
|
+
const [remote, setRemote] = (0, import_react19.useState)(false);
|
|
9523
|
+
const notify = (0, import_react19.useCallback)((text, kind) => {
|
|
9524
|
+
setMessage(text);
|
|
9525
|
+
setMessageKind(kind || "error");
|
|
9526
|
+
}, []);
|
|
9527
|
+
const refresh = (0, import_react19.useCallback)(async () => {
|
|
9528
|
+
try {
|
|
9529
|
+
const data = await rpc("lan");
|
|
9530
|
+
setLan(data);
|
|
9531
|
+
setAddress((prev) => prev || (data.addresses && data.addresses[0] ? data.addresses[0].address : ""));
|
|
9532
|
+
setUsername((prev) => prev || (data.username || ""));
|
|
9533
|
+
} catch (e) {
|
|
9534
|
+
notify(e && e.message ? e.message : String(e));
|
|
9535
|
+
}
|
|
9536
|
+
}, [notify]);
|
|
9537
|
+
(0, import_react19.useEffect)(() => {
|
|
9538
|
+
refresh();
|
|
9539
|
+
const timer = setInterval(refresh, 3e3);
|
|
9540
|
+
return () => clearInterval(timer);
|
|
9541
|
+
}, [refresh]);
|
|
9542
|
+
(0, import_react19.useEffect)(() => {
|
|
9543
|
+
fetch("/__dsh_auth/health", { method: "POST" }).then((r) => setRemote(Boolean(r.ok))).catch(() => setRemote(false));
|
|
9544
|
+
}, []);
|
|
9545
|
+
const active = Boolean(lan && lan.gatewayActive);
|
|
9546
|
+
const gatewayPort = lan && lan.gatewayPort ? lan.gatewayPort : 3081;
|
|
9547
|
+
const suggestedPort = lan && lan.mainPort ? lan.mainPort + 1 : gatewayPort;
|
|
9548
|
+
const lanLink = (0, import_react19.useMemo)(() => address && active ? "http://" + address + ":" + gatewayPort : "", [address, active, gatewayPort]);
|
|
9549
|
+
(0, import_react19.useEffect)(() => {
|
|
9550
|
+
let live = true;
|
|
9551
|
+
if (!lanLink) {
|
|
9552
|
+
setQr("");
|
|
9553
|
+
return () => {
|
|
9554
|
+
live = false;
|
|
9555
|
+
};
|
|
9556
|
+
}
|
|
9557
|
+
import_qrcode.default.toDataURL(lanLink, { errorCorrectionLevel: "M", margin: 2, width: 220, color: { dark: "#111827", light: "#ffffff" } }).then((value) => {
|
|
9558
|
+
if (live) setQr(value);
|
|
9559
|
+
}).catch(() => {
|
|
9560
|
+
});
|
|
9561
|
+
return () => {
|
|
9562
|
+
live = false;
|
|
9563
|
+
};
|
|
9564
|
+
}, [lanLink]);
|
|
9565
|
+
async function enable() {
|
|
9566
|
+
notify("");
|
|
9567
|
+
if (!lan.accountSet && (!username.trim() || password.length < 6)) {
|
|
9568
|
+
notify("\u9996\u6B21\u5F00\u542F\u8BF7\u8BBE\u7F6E\u8D26\u53F7\u548C\u81F3\u5C11 6 \u4F4D\u7684\u5BC6\u7801\u3002");
|
|
9569
|
+
return;
|
|
9570
|
+
}
|
|
9571
|
+
setBusy("start");
|
|
9572
|
+
try {
|
|
9573
|
+
const payload = {};
|
|
9574
|
+
if (username.trim() && newPassword) {
|
|
9575
|
+
payload.username = username.trim();
|
|
9576
|
+
payload.password = newPassword;
|
|
9577
|
+
} else if (!lan.accountSet) {
|
|
9578
|
+
payload.username = username.trim();
|
|
9579
|
+
payload.password = password;
|
|
9580
|
+
}
|
|
9581
|
+
const numericPort = Number(port);
|
|
9582
|
+
if (Number.isInteger(numericPort) && numericPort >= 1024 && numericPort <= 65535) payload.port = numericPort;
|
|
9583
|
+
const data = await rpc("lan/start", payload);
|
|
9584
|
+
setLan(data);
|
|
9585
|
+
setPassword("");
|
|
9586
|
+
setNewPassword("");
|
|
9587
|
+
setChanging(false);
|
|
9588
|
+
notify("\u8FDC\u7A0B\u8BBF\u95EE\u5DF2\u5F00\u542F\uFF1A\u8BBE\u5907\u8BBF\u95EE\u4E0B\u65B9\u5730\u5740\u5E76\u7528\u8D26\u53F7\u5BC6\u7801\u767B\u5F55\u3002" + (data.needsRestart ? "\uFF08\u5DE5\u4F5C\u533A\u76EE\u5F55\u7684\u6D4F\u89C8\u9009\u62E9\u9700\u91CD\u542F dsh web \u540E\u53EF\u7528\uFF09" : ""), "success");
|
|
9589
|
+
} catch (e) {
|
|
9590
|
+
notify(e && e.message ? e.message : String(e));
|
|
9591
|
+
} finally {
|
|
9592
|
+
setBusy("");
|
|
9593
|
+
}
|
|
9594
|
+
}
|
|
9595
|
+
async function disable() {
|
|
9596
|
+
notify("");
|
|
9597
|
+
setBusy("stop");
|
|
9598
|
+
try {
|
|
9599
|
+
const data = await rpc("lan/stop", {});
|
|
9600
|
+
setLan(data);
|
|
9601
|
+
notify("\u8FDC\u7A0B\u8BBF\u95EE\u5DF2\u5173\u95ED\uFF0C\u5DF2\u767B\u5F55\u8BBE\u5907\u5168\u90E8\u9000\u51FA\u3002" + (data.needsRestart ? "\u91CD\u542F dsh web \u540E\u6062\u590D\u5DE5\u4F5C\u533A\u539F\u751F\u9009\u62E9\u5668\u3002" : ""), "success");
|
|
9602
|
+
} catch (e) {
|
|
9603
|
+
notify(e && e.message ? e.message : String(e));
|
|
9604
|
+
} finally {
|
|
9605
|
+
setBusy("");
|
|
9606
|
+
}
|
|
9607
|
+
}
|
|
9608
|
+
async function saveAuth() {
|
|
9609
|
+
notify("");
|
|
9610
|
+
if (!username.trim() || newPassword.length < 6) {
|
|
9611
|
+
notify("\u8BF7\u586B\u5199\u8D26\u53F7\u548C\u81F3\u5C11 6 \u4F4D\u7684\u65B0\u5BC6\u7801\u3002");
|
|
9612
|
+
return;
|
|
9613
|
+
}
|
|
9614
|
+
setBusy("auth");
|
|
9615
|
+
try {
|
|
9616
|
+
const data = await rpc("auth/set", { username: username.trim(), password: newPassword });
|
|
9617
|
+
setLan(data);
|
|
9618
|
+
setPassword("");
|
|
9619
|
+
setNewPassword("");
|
|
9620
|
+
setChanging(false);
|
|
9621
|
+
notify("\u8D26\u53F7\u5BC6\u7801\u5DF2\u66F4\u65B0\uFF0C\u6240\u6709\u8BBE\u5907\u9700\u91CD\u65B0\u767B\u5F55\u3002", "success");
|
|
9622
|
+
} catch (e) {
|
|
9623
|
+
notify(e && e.message ? e.message : String(e));
|
|
9624
|
+
} finally {
|
|
9625
|
+
setBusy("");
|
|
9626
|
+
}
|
|
9627
|
+
}
|
|
9628
|
+
function copyLink() {
|
|
9629
|
+
copy(lanLink).then(() => notify("\u5730\u5740\u5DF2\u590D\u5236\u3002", "success")).catch((e) => notify(e.message));
|
|
9630
|
+
}
|
|
9631
|
+
function logout() {
|
|
9632
|
+
const info = typeof window !== "undefined" ? window.__DSH_REMOTE__ : null;
|
|
9633
|
+
if (info && info.logout) window.location.href = info.logout;
|
|
9634
|
+
}
|
|
9635
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("section", { className: "dmr " + (compact ? "dmr-compact" : ""), children: [
|
|
9636
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dmr-status-head", children: [
|
|
9637
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { children: [
|
|
9638
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "dmr-eyebrow", children: [
|
|
9639
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("i", {}),
|
|
9640
|
+
" \u8FDC\u7A0B\u8BBF\u95EE"
|
|
9641
|
+
] }),
|
|
9642
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h3", { children: active ? "\u5165\u53E3\u5DF2\u5F00\u542F" : "\u4ECE\u4EFB\u4F55\u8BBE\u5907\u8BBF\u95EE\u8FD9\u4E2A DSH" }),
|
|
9643
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: active ? "\u8BBE\u5907\u8BBF\u95EE\u4E0B\u65B9\u5730\u5740\uFF0C\u7528\u8D26\u53F7\u5BC6\u7801\u767B\u5F55\u5373\u53EF\u4F7F\u7528\u5B8C\u6574 DSH\uFF08\u4E0E\u672C\u673A\u540C\u4E00\u5B9E\u4F8B\uFF0C\u4EFB\u52A1\u8FDB\u5EA6\u5B9E\u65F6\u4E00\u81F4\uFF09\u3002" : "\u5F00\u542F\u540E\uFF0C\u5C40\u57DF\u7F51/\u865A\u62DF\u7F51\u8BBE\u5907\u8BBF\u95EE\u7F51\u5173\u5730\u5740\u5E76\u767B\u5F55\uFF0C\u5373\u53EF\u4F7F\u7528\u4E0E\u672C\u673A\u5B8C\u5168\u4E00\u81F4\u7684 DSH\u3002" })
|
|
9644
|
+
] }),
|
|
9645
|
+
remote && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", className: "dmr-secondary", onClick: logout, children: [
|
|
9646
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RelayIcon, { name: "close" }),
|
|
9647
|
+
"\u9000\u51FA\u767B\u5F55"
|
|
9648
|
+
] })
|
|
9649
|
+
] }),
|
|
9650
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("ol", { className: "dmr-steps", children: [
|
|
9651
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("li", { children: [
|
|
9652
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: "1" }),
|
|
9653
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { children: [
|
|
9654
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("strong", { children: "\u8BBE\u7F6E\u8D26\u53F7\u5BC6\u7801" }),
|
|
9655
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("small", { children: "\u8FDC\u7A0B\u767B\u5F55\u7684\u552F\u4E00\u51ED\u636E\uFF0C\u6539\u5BC6\u540E\u6240\u6709\u8BBE\u5907\u91CD\u65B0\u767B\u5F55\u3002" })
|
|
9656
|
+
] })
|
|
9657
|
+
] }),
|
|
9658
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("li", { children: [
|
|
9659
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: "2" }),
|
|
9660
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { children: [
|
|
9661
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("strong", { children: "\u5F00\u542F\u5165\u53E3" }),
|
|
9662
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("small", { children: "\u7F51\u5173\u76D1\u542C 0.0.0.0\uFF08\u9ED8\u8BA4\u4E3B\u7AEF\u53E3+1\uFF0C\u53EF\u6539\uFF09\uFF0C\u4E3B\u5B9E\u4F8B\u4FDD\u6301\u4EC5\u672C\u673A\u3002" })
|
|
9663
|
+
] })
|
|
9664
|
+
] }),
|
|
9665
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("li", { children: [
|
|
9666
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: "3" }),
|
|
9667
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { children: [
|
|
9668
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("strong", { children: "\u8BBE\u5907\u8BBF\u95EE" }),
|
|
9669
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("small", { children: "\u626B\u7801\u6216\u8F93\u5165\u5730\u5740\u767B\u5F55\uFF1B\u5F02\u5730\u7EC4\u7F51\uFF08Tailscale \u7B49\uFF09\u7528\u7EC4\u7F51 IP \u76F4\u8FDE\u3002" })
|
|
9670
|
+
] })
|
|
9671
|
+
] })
|
|
9672
|
+
] }),
|
|
9673
|
+
!active ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dmr-network-grid", children: [
|
|
9674
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "dmr-field", children: [
|
|
9675
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: "\u8D26\u53F7" }),
|
|
9676
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { value: username, onChange: (e) => setUsername(e.target.value), autoComplete: "username", placeholder: "\u767B\u5F55\u8D26\u53F7" })
|
|
9677
|
+
] }),
|
|
9678
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "dmr-field", children: [
|
|
9679
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: "\u5BC6\u7801" }),
|
|
9680
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { type: "password", value: password, onChange: (e) => setPassword(e.target.value), autoComplete: "new-password", placeholder: lan && lan.accountSet ? "\u5DF2\u8BBE\u7F6E\uFF0C\u7559\u7A7A\u6CBF\u7528" : "\u81F3\u5C11 6 \u4F4D" })
|
|
9681
|
+
] })
|
|
9682
|
+
] }) : null,
|
|
9683
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dmr-network-grid", children: [
|
|
9684
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "dmr-field", children: [
|
|
9685
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: "\u76D1\u542C\u7AEF\u53E3" }),
|
|
9686
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { value: port, onChange: (e) => setPort(e.target.value), inputMode: "numeric", type: "number", min: "1024", max: "65535", placeholder: "\u9ED8\u8BA4 " + suggestedPort, "aria-describedby": "dmr-lan-port-help" }),
|
|
9687
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("small", { id: "dmr-lan-port-help", children: [
|
|
9688
|
+
"\u7F51\u5173\u548C\u4E3B\u670D\u52A1\u662F\u540C\u4E00\u53F0\u673A\u5668\u4E0A\u7684\u4E24\u4E2A\u7AEF\u53E3\uFF0C\u4E0D\u80FD\u76F8\u540C\uFF1A\u4E3B\u5B9E\u4F8B ",
|
|
9689
|
+
lan && lan.mainPort ? lan.mainPort : "\u2026",
|
|
9690
|
+
" \u53EA\u7559\u7ED9\u672C\u673A\uFF0C\u5176\u4ED6\u8BBE\u5907\u8D70\u7F51\u5173\u7AEF\u53E3\u767B\u5F55\u3002\u7559\u7A7A\u5373\u7528 ",
|
|
9691
|
+
suggestedPort,
|
|
9692
|
+
"\uFF08\u4E3B\u7AEF\u53E3+1\uFF09\u3002"
|
|
9693
|
+
] })
|
|
9694
|
+
] }),
|
|
9695
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dmr-security", children: [
|
|
9696
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("strong", { children: "\u5B89\u5168\u8BF4\u660E" }),
|
|
9697
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: "\u4E3B\u5B9E\u4F8B\u4FDD\u6301\u4EC5\u76D1\u542C 127.0.0.1\uFF1A\u8FDC\u7A0B\u8BBE\u5907\u53EA\u80FD\u7ECF\u8FD9\u4E2A\u767B\u5F55\u7F51\u5173\u8FDB\u5165\uFF0C\u4E0D\u5B58\u5728\u514D\u767B\u5F55\u7684\u76F4\u8FDE\u8DEF\u5F84\u3002\u8D26\u53F7\u5BC6\u7801\u53EA\u53D1\u7ED9\u81EA\u5DF1\uFF1B\u6539\u5BC6\u540E\u6240\u6709\u8BBE\u5907\u9700\u91CD\u65B0\u767B\u5F55\u3002" })
|
|
9698
|
+
] })
|
|
9699
|
+
] }),
|
|
9700
|
+
active ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "dmr-share", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dmr-share-layout", children: [
|
|
9701
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dmr-qr-card", children: [
|
|
9702
|
+
qr ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("img", { src: qr, alt: "\u8FDC\u7A0B\u8BBF\u95EE\u5730\u5740\u4E8C\u7EF4\u7801", width: "220", height: "220" }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "dmr-qr-loading", children: "\u6B63\u5728\u751F\u6210\u4E8C\u7EF4\u7801\u2026" }),
|
|
9703
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("strong", { children: "\u626B\u7801\u6216\u8F93\u5165\u5730\u5740" }),
|
|
9704
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("small", { children: "\u6253\u5F00\u540E\u8F93\u5165\u8D26\u53F7\u5BC6\u7801\u767B\u5F55" })
|
|
9705
|
+
] }),
|
|
9706
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dmr-share-detail", children: [
|
|
9707
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { children: [
|
|
9708
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "dmr-eyebrow", children: [
|
|
9709
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("i", {}),
|
|
9710
|
+
" \u767B\u5F55\u7F51\u5173\u5DF2\u8FD0\u884C"
|
|
9711
|
+
] }),
|
|
9712
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h4", { children: lanLink })
|
|
9713
|
+
] }),
|
|
9714
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "dmr-link", title: lanLink, children: lanLink }),
|
|
9715
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dmr-share-actions", children: [
|
|
9716
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", className: "dmr-primary", onClick: copyLink, disabled: !lanLink, children: [
|
|
9717
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RelayIcon, { name: "copy" }),
|
|
9718
|
+
"\u590D\u5236\u5730\u5740"
|
|
9719
|
+
] }),
|
|
9720
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", className: "dmr-secondary dmr-danger", onClick: disable, disabled: busy === "stop", children: [
|
|
9721
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RelayIcon, { name: "close" }),
|
|
9722
|
+
busy === "stop" ? "\u6B63\u5728\u5173\u95ED\u2026" : "\u5173\u95ED\u8FDC\u7A0B\u8BBF\u95EE"
|
|
9723
|
+
] })
|
|
9724
|
+
] }),
|
|
9725
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("small", { children: "\u4E3B\u5B9E\u4F8B\u4FDD\u6301\u4EC5\u672C\u673A\uFF08\u7ED3\u6784\u4E0A\u4E0D\u5B58\u5728\u514D\u767B\u5F55\u76F4\u8FDE\uFF09\uFF1B\u8D26\u53F7\u5BC6\u7801\u53EA\u53D1\u7ED9\u81EA\u5DF1\u3002\u82E5\u5F00\u542F\u524D\u5DF2\u6709\u65E7\u670D\u52A1\u5668\u6A21\u5F0F\uFF080.0.0.0\uFF09\u914D\u7F6E\uFF0C\u4F1A\u4E00\u5E76\u79FB\u9664\u5E76\u63D0\u793A\u91CD\u542F\u3002" })
|
|
9726
|
+
] })
|
|
9727
|
+
] }) }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: "dmr-primary", onClick: enable, disabled: busy === "start", children: busy === "start" ? "\u6B63\u5728\u5F00\u542F\u2026" : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
9728
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RelayIcon, { name: "link" }),
|
|
9729
|
+
"\u5F00\u542F\u8FDC\u7A0B\u8BBF\u95EE"
|
|
9730
|
+
] }) }),
|
|
9731
|
+
active ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dmr-section", children: [
|
|
9732
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dmr-section-head", children: [
|
|
9733
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h4", { children: "\u4FEE\u6539\u8D26\u53F7\u5BC6\u7801" }),
|
|
9734
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: "dmr-text-button", onClick: () => setChanging((v) => !v), children: changing ? "\u6536\u8D77" : "\u4FEE\u6539" })
|
|
9735
|
+
] }),
|
|
9736
|
+
changing ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dmr-note", children: [
|
|
9737
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dmr-network-grid", children: [
|
|
9738
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "dmr-field", children: [
|
|
9739
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: "\u8D26\u53F7" }),
|
|
9740
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { value: username, onChange: (e) => setUsername(e.target.value), autoComplete: "username" })
|
|
9741
|
+
] }),
|
|
9742
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "dmr-field", children: [
|
|
9743
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: "\u65B0\u5BC6\u7801" }),
|
|
9744
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { type: "password", value: newPassword, onChange: (e) => setNewPassword(e.target.value), autoComplete: "new-password", placeholder: "\u81F3\u5C11 6 \u4F4D" })
|
|
9745
|
+
] })
|
|
9746
|
+
] }),
|
|
9747
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: "dmr-secondary", onClick: saveAuth, disabled: busy === "auth" || !username.trim() || newPassword.length < 6, children: busy === "auth" ? "\u4FDD\u5B58\u4E2D\u2026" : "\u4FDD\u5B58\uFF08\u6240\u6709\u8BBE\u5907\u91CD\u65B0\u767B\u5F55\uFF09" })
|
|
9748
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { className: "dmr-note", children: [
|
|
9749
|
+
"\u5F53\u524D\u8D26\u53F7\uFF1A",
|
|
9750
|
+
lan.username || "\u2014",
|
|
9751
|
+
"\u3002\u4FEE\u6539\u540E\u6240\u6709\u5DF2\u767B\u5F55\u8BBE\u5907\u5C06\u88AB\u5F3A\u5236\u9000\u51FA\u3002"
|
|
9752
|
+
] })
|
|
9753
|
+
] }) : null,
|
|
9754
|
+
message ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "dmr-message " + (messageKind === "success" ? "success" : "error"), role: "alert", children: message }) : null
|
|
9755
|
+
] });
|
|
9756
|
+
}
|
|
9757
|
+
function MobileRelayView() {
|
|
9758
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RemoteCard, {});
|
|
9759
|
+
}
|
|
9760
|
+
function MobileRelayHomeStat() {
|
|
9761
|
+
const [summary, setSummary] = (0, import_react19.useState)("\u672A\u5F00\u542F\uFF0C\u5F00\u542F\u540E\u53EF\u8FDC\u7A0B\u767B\u5F55");
|
|
9762
|
+
(0, import_react19.useEffect)(() => {
|
|
9763
|
+
rpc("lan").then((data) => {
|
|
9764
|
+
setSummary(data.gatewayActive ? "\u5165\u53E3\u8FD0\u884C\u4E2D \xB7 \u7AEF\u53E3 " + data.gatewayPort : data.accountSet ? "\u8D26\u53F7\u5DF2\u8BBE\u7F6E\uFF0C\u5165\u53E3\u672A\u5F00\u542F" : "\u672A\u5F00\u542F\uFF0C\u5F00\u542F\u540E\u53EF\u8FDC\u7A0B\u767B\u5F55");
|
|
9765
|
+
}).catch(() => {
|
|
9766
|
+
});
|
|
9767
|
+
}, []);
|
|
9768
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: summary });
|
|
9769
|
+
}
|
|
9770
|
+
var feature8 = {
|
|
9771
|
+
id: "mobile-relay",
|
|
9772
|
+
name: "\u8FDC\u7A0B\u8BBF\u95EE",
|
|
9773
|
+
order: 80,
|
|
9774
|
+
accent: "#38bdf8",
|
|
9775
|
+
description: "\u8D26\u53F7\u5BC6\u7801\u767B\u5F55\u7684\u8FDC\u7A0B\u5165\u53E3\uFF1A\u6240\u6709\u8BBE\u5907\u8BBF\u95EE\u540C\u4E00\u4E2A DSH\uFF0C\u4EFB\u52A1\u8FDB\u5EA6\u5B9E\u65F6\u4E00\u81F4",
|
|
9776
|
+
defaultEnabled: true,
|
|
9777
|
+
css: `
|
|
9778
|
+
.dmr{--dmr-accent:#38bdf8;--dmr-accent-soft:color-mix(in srgb,var(--dmr-accent) 13%,transparent);display:flex;flex-direction:column;gap:16px;max-width:720px;color:var(--dsw-alias-label-primary);font-size:13px;line-height:1.5}.dmr h3,.dmr h4,.dmr p{margin:0}.dmr h3{font-size:17px;line-height:1.25;letter-spacing:-.01em}.dmr h4{font-size:13px}.dmr-hero,.dmr-status-head{display:flex;align-items:flex-start;gap:12px}.dmr-hero>div,.dmr-status-head>div{min-width:0;display:flex;flex-direction:column;gap:4px}.dmr-hero p,.dmr-status-head p,.dmr-field small,.dmr-share small,.dmr-overview-card small,.dmr-task small,.dmr-note p{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1.55}.dmr-hero-icon{width:42px;height:42px;display:inline-flex;align-items:center;justify-content:center;flex:none;border-radius:14px;background:var(--dmr-accent-soft);color:var(--dmr-accent);border:1px solid color-mix(in srgb,var(--dmr-accent) 35%,var(--dsw-alias-border-l1))}.dmr-steps{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin:0;padding:0;list-style:none}.dmr-steps li{display:flex;gap:9px;padding:11px;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:12px}.dmr-steps li>span{width:21px;height:21px;display:inline-flex;align-items:center;justify-content:center;flex:none;border-radius:50%;font-size:11px;font-weight:700;color:var(--dmr-accent);background:var(--dmr-accent-soft)}.dmr-steps div{display:flex;flex-direction:column;gap:3px;min-width:0}.dmr-steps strong{font-size:12px}.dmr-steps small{font-size:11px;color:var(--dsw-alias-label-secondary);line-height:1.45}.dmr-field{display:flex;flex-direction:column;gap:6px;font-weight:600}.dmr-field input,.dmr-field select,.dmr-note textarea{box-sizing:border-box;width:100%;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);border-radius:10px;padding:10px 12px;min-height:44px;font:inherit;outline:none;transition:border-color .18s ease,box-shadow .18s ease}.dmr-field input:focus,.dmr-field select:focus,.dmr-note textarea:focus{border-color:var(--dmr-accent);box-shadow:0 0 0 3px var(--dmr-accent-soft)}.dmr-field small{font-weight:400}.dmr-network-grid{display:grid;grid-template-columns:minmax(0,1.4fr) minmax(150px,.6fr);gap:12px}.dmr-security{padding:12px 13px;border:1px solid color-mix(in srgb,#f59e0b 38%,var(--dsw-alias-border-l1));border-radius:12px;background:color-mix(in srgb,#f59e0b 8%,transparent)}.dmr-security strong{display:block;margin-bottom:4px;color:#f59e0b;font-size:12px}.dmr-security p{font-size:12px;color:var(--dsw-alias-label-secondary);line-height:1.55}.dmr-primary,.dmr-secondary,.dmr-text-button,.dmr-icon-button{font:inherit;touch-action:manipulation;cursor:pointer;transition:transform .15s ease,background .18s ease,border-color .18s ease,opacity .18s ease}.dmr-primary,.dmr-secondary{min-height:44px;display:inline-flex;align-items:center;justify-content:center;gap:8px;border-radius:10px;padding:9px 13px;font-weight:600}.dmr-primary{align-self:flex-start;border:1px solid var(--dmr-accent);background:var(--dmr-accent);color:#062238}.dmr-primary:hover{filter:brightness(1.05)}.dmr-secondary{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary)}.dmr-secondary:hover{border-color:var(--dmr-accent);background:var(--dmr-accent-soft)}.dmr-primary:active,.dmr-secondary:active,.dmr-icon-button:active{transform:scale(.98)}.dmr-primary:disabled,.dmr-secondary:disabled,.dmr-text-button:disabled,.dmr-icon-button:disabled{cursor:not-allowed;opacity:.5}.dmr-message{display:flex;align-items:flex-start;gap:7px;padding:10px 12px;border-radius:10px;font-size:12px}.dmr-message.success{color:var(--dsw-alias-state-success-primary);background:color-mix(in srgb,var(--dsw-alias-state-success-primary) 10%,transparent)}.dmr-message.error{color:var(--dsw-alias-state-error-primary);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent)}.dmr-status-head{justify-content:space-between}.dmr-eyebrow{display:inline-flex;align-items:center;gap:6px;font-size:11px;font-weight:600;color:var(--dmr-accent)}.dmr-eyebrow i{width:7px;height:7px;border-radius:50%;background:currentColor;box-shadow:0 0 0 4px var(--dmr-accent-soft)}.dmr-icon-button{display:inline-flex;align-items:center;justify-content:center;flex:none;width:44px;height:44px;border:1px solid var(--dsw-alias-border-l2);border-radius:10px;background:transparent;color:var(--dsw-alias-label-secondary)}.dmr-icon-button:hover{color:var(--dsw-alias-state-error-primary);border-color:currentColor}.dmr-share{display:flex;flex-direction:column;gap:9px;padding:13px;border:1px solid color-mix(in srgb,var(--dmr-accent) 32%,var(--dsw-alias-border-l1));border-radius:13px;background:var(--dmr-accent-soft)}.dmr-share-layout{display:grid;grid-template-columns:196px minmax(0,1fr);gap:16px;align-items:center}.dmr-qr-card{box-sizing:border-box;display:flex;flex-direction:column;align-items:center;gap:5px;padding:10px;border-radius:12px;background:#fff;color:#111827;text-align:center}.dmr-qr-card img{display:block;width:176px;height:176px;max-width:100%;object-fit:contain}.dmr-qr-card strong{font-size:12px}.dmr-qr-card small{color:#4b5563;font-size:10px}.dmr-qr-loading{display:grid;place-items:center;width:176px;height:176px;color:#64748b;font-size:12px}.dmr-share-detail{min-width:0;display:flex;flex-direction:column;gap:10px}.dmr-share-detail>div:first-child{display:flex;flex-direction:column;gap:4px}.dmr-link{padding:10px 11px;border-radius:8px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);font:12px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace;word-break:break-all;color:var(--dsw-alias-label-secondary)}.dmr-share-actions{display:flex;gap:8px;flex-wrap:wrap}.dmr-share-actions .dmr-primary{align-self:auto}.dmr-overview{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.dmr-overview-card{display:flex;flex-direction:column;gap:3px;padding:12px;border:1px solid var(--dsw-alias-border-l1);border-radius:12px;background:var(--dsw-alias-bg-layer-1)}.dmr-overview-card>span{font-size:11px;color:var(--dsw-alias-label-tertiary)}.dmr-overview-card strong{font-size:16px;letter-spacing:-.01em}.dmr-section{display:flex;flex-direction:column;gap:9px}.dmr-section-head{display:flex;align-items:center;justify-content:space-between;gap:10px}.dmr-section-head small{font-size:11px;color:var(--dsw-alias-label-tertiary)}.dmr-text-button{border:0;background:transparent;color:var(--dmr-accent);padding:8px;min-height:36px;font-weight:600}.dmr-task-list{display:flex;flex-direction:column;gap:8px}.dmr-task{display:flex;align-items:flex-start;gap:9px;padding:10px 11px;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}.dmr-task>div{display:flex;min-width:0;flex:1;flex-direction:column;gap:2px}.dmr-task strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dmr-phase{flex:none;border-radius:999px;padding:3px 8px;font-size:11px;background:var(--dmr-accent-soft);color:var(--dmr-accent)}.dmr-phase.write{color:var(--dsw-alias-state-success-primary)}.dmr-phase.code{color:#f59e0b}.dmr-phase.search{color:#14b8a6}.dmr-empty{padding:18px 12px;text-align:center;border:1px dashed var(--dsw-alias-border-l2);border-radius:10px;color:var(--dsw-alias-label-secondary);font-size:12px}.dmr-note{display:flex;flex-direction:column;gap:9px;padding-top:2px}.dmr-note blockquote{margin:0;padding:10px 12px;border-left:3px solid var(--dmr-accent);border-radius:0 9px 9px 0;background:var(--dmr-accent-soft);white-space:pre-wrap;font-size:12px}.dmr-note textarea{min-height:88px;resize:vertical;line-height:1.5}.dmr-note .dmr-secondary{align-self:flex-start}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@media (max-width:680px){.dmr{gap:14px;font-size:14px}.dmr h3{font-size:18px}.dmr-steps{grid-template-columns:1fr;gap:8px}.dmr-steps li{padding:10px}.dmr-steps small,.dmr-hero p,.dmr-status-head p,.dmr-field small,.dmr-share small,.dmr-overview-card small,.dmr-task small,.dmr-note p{font-size:12px}.dmr-network-grid{grid-template-columns:1fr;gap:10px}.dmr-field input,.dmr-field select{font-size:16px}.dmr-primary,.dmr-secondary{width:100%;font-size:14px}.dmr-share-layout{grid-template-columns:1fr;gap:12px}.dmr-qr-card{width:min(240px,100%);margin:0 auto}.dmr-qr-card img,.dmr-qr-loading{width:210px;height:210px}.dmr-share-actions{flex-direction:column}.dmr-share-actions .dmr-primary{width:100%}.dmr-overview{gap:8px}.dmr-overview-card{padding:11px}.dmr-status-head{gap:8px}.dmr-link{font-size:11px}.dmr-note textarea{font-size:16px;min-height:104px}.dmr-note .dmr-secondary{align-self:stretch}.dmr-compact .dmr-hero-icon{width:40px;height:40px;border-radius:13px}}@media (prefers-reduced-motion:reduce){.dmr-primary,.dmr-secondary,.dmr-text-button,.dmr-icon-button,.dmr-field input,.dmr-field select,.dmr-note textarea{transition:none}}.dmr-lan{flex:none;margin-top:6px;padding-top:16px;border-top:1px solid var(--dsw-alias-border-l1)}.dmr-lan-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}.dmr-lan-title{min-width:0;display:flex;flex-direction:column;gap:4px}.dmr-lan-title p{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1.55}.dmr-lan-badge{flex:none;display:inline-flex;align-items:center;gap:6px;border-radius:999px;padding:5px 10px;font-size:11px;font-weight:700;border:1px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-tertiary)}.dmr-lan-badge.on{border-color:color-mix(in srgb,var(--dmr-accent) 45%,transparent);background:var(--dmr-accent-soft);color:var(--dmr-accent)}.dmr-lan-active,.dmr-lan-idle{display:flex;flex-direction:column;gap:12px}.dmr-lan-active .dmr-share-detail small strong{color:var(--dsw-alias-state-error-primary)}.dmr-danger{border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 45%,var(--dsw-alias-border-l2));color:var(--dsw-alias-state-error-primary)}.dmr-danger:hover{border-color:var(--dsw-alias-state-error-primary);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent)}`,
|
|
9779
|
+
View: MobileRelayView,
|
|
9780
|
+
HomeStat: MobileRelayHomeStat
|
|
9781
|
+
};
|
|
9782
|
+
|
|
7376
9783
|
// src/client.jsx
|
|
7377
|
-
var DOCK_VERSION = "0.8.
|
|
7378
|
-
var BUILTIN_FEATURES = [feature, feature2, feature3, feature4, feature5, feature6, feature7];
|
|
9784
|
+
var DOCK_VERSION = "0.8.1";
|
|
9785
|
+
var BUILTIN_FEATURES = [feature, feature2, feature3, feature4, feature5, feature6, feature7, feature8];
|
|
7379
9786
|
var PLANNED_FEATURES = [];
|
|
7380
9787
|
var PLANNED_NOTES = {};
|
|
7381
9788
|
var externalDefs = [];
|
|
@@ -7447,7 +9854,7 @@ var SHELL_CSS = [
|
|
|
7447
9854
|
".docke2-btn.docke2-on{color:var(--dsw-alias-accent,#4d9fff);background:var(--dsw-alias-accent-soft,color-mix(in srgb,var(--dsw-alias-accent,#4d9fff) 12%,transparent));}",
|
|
7448
9855
|
".docke2-btn.docke2-rail{width:36px;height:36px;margin:8px 0 10px;padding:0;border-radius:50%;justify-content:center;gap:0;}",
|
|
7449
9856
|
".docke2-label{white-space:nowrap;overflow:hidden;}",
|
|
7450
|
-
".dockm-backdrop{position:fixed;inset:0;z-index:
|
|
9857
|
+
".dockm-backdrop{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--dsw-alias-bg-layer-1) 55%,transparent);backdrop-filter:blur(4px);pointer-events:auto;animation:dockm-fade .15s var(--ds-ease-in-out);}",
|
|
7451
9858
|
"@keyframes dockm-fade{from{opacity:0}to{opacity:1}}",
|
|
7452
9859
|
".dockm-dialog{box-sizing:border-box;position:relative;width:min(1080px,calc(100vw - 32px));height:min(700px,calc(100vh - 32px));display:flex;flex-direction:column;border-radius:16px;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);box-shadow:0 20px 64px rgb(0 0 0 / .32);overflow:hidden;animation:dockm-pop .18s var(--ds-ease-in-out);}",
|
|
7453
9860
|
"@keyframes dockm-pop{from{opacity:0;transform:translateY(10px) scale(.985)}to{opacity:1;transform:none}}",
|
|
@@ -7577,8 +9984,8 @@ function scheduleInitialCss() {
|
|
|
7577
9984
|
}
|
|
7578
9985
|
}
|
|
7579
9986
|
function useExternalVersion() {
|
|
7580
|
-
const [, bump] =
|
|
7581
|
-
|
|
9987
|
+
const [, bump] = import_react20.default.useReducer((n) => n + 1, 0);
|
|
9988
|
+
import_react20.default.useEffect(() => {
|
|
7582
9989
|
externalListeners.add(bump);
|
|
7583
9990
|
return () => {
|
|
7584
9991
|
externalListeners.delete(bump);
|
|
@@ -7588,44 +9995,44 @@ function useExternalVersion() {
|
|
|
7588
9995
|
var lastGeom = { x: null, y: null, w: null, h: null };
|
|
7589
9996
|
function DockIcon(props) {
|
|
7590
9997
|
const size = props && props.size || 16;
|
|
7591
|
-
return
|
|
9998
|
+
return import_react20.default.createElement(
|
|
7592
9999
|
"svg",
|
|
7593
10000
|
{ width: size, height: size, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: 1.3, "aria-hidden": true },
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
10001
|
+
import_react20.default.createElement("rect", { x: 2.5, y: 2.5, width: 4.4, height: 4.4, rx: 1.2 }),
|
|
10002
|
+
import_react20.default.createElement("rect", { x: 9, y: 2.5, width: 4.4, height: 4.4, rx: 1.2 }),
|
|
10003
|
+
import_react20.default.createElement("rect", { x: 2.5, y: 9, width: 4.4, height: 4.4, rx: 1.2 }),
|
|
10004
|
+
import_react20.default.createElement("rect", { x: 9, y: 9, width: 4.4, height: 4.4, rx: 1.2 })
|
|
7598
10005
|
);
|
|
7599
10006
|
}
|
|
7600
10007
|
function DockEntry(props) {
|
|
7601
10008
|
const wide = !!props.wide;
|
|
7602
|
-
const [open, setOpen] =
|
|
7603
|
-
|
|
7604
|
-
return
|
|
10009
|
+
const [open, setOpen] = import_react20.default.useState(panelNav.open);
|
|
10010
|
+
import_react20.default.useEffect(() => subscribePanel(() => setOpen(panelNav.open)), []);
|
|
10011
|
+
return import_react20.default.createElement("button", {
|
|
7605
10012
|
type: "button",
|
|
7606
10013
|
className: "docke2-btn" + (open ? " docke2-on" : "") + (wide ? "" : " docke2-rail"),
|
|
7607
10014
|
title: "\u529F\u80FD\u575E",
|
|
7608
10015
|
"aria-label": "\u529F\u80FD\u575E",
|
|
7609
10016
|
"aria-expanded": open,
|
|
7610
10017
|
onClick: () => setPanelOpen(!open)
|
|
7611
|
-
},
|
|
10018
|
+
}, import_react20.default.createElement(DockIcon, { size: wide ? 16 : 18 }), wide ? import_react20.default.createElement("span", { className: "docke2-label" }, "\u529F\u80FD\u575E") : null);
|
|
7612
10019
|
}
|
|
7613
10020
|
function DockModal() {
|
|
7614
|
-
const [nav, setNav] =
|
|
7615
|
-
|
|
10021
|
+
const [nav, setNav] = import_react20.default.useState({ open: panelNav.open, active: panelNav.active, params: panelNav.params });
|
|
10022
|
+
import_react20.default.useEffect(() => subscribePanel(() => setNav({ open: panelNav.open, active: panelNav.active, params: panelNav.params })), []);
|
|
7616
10023
|
const open = nav.open || typeof document === "undefined";
|
|
7617
10024
|
const active = nav.active;
|
|
7618
10025
|
const setActive = navigatePanel;
|
|
7619
10026
|
const navParams = nav.params;
|
|
7620
|
-
const [, force] =
|
|
10027
|
+
const [, force] = import_react20.default.useReducer((n) => n + 1, 0);
|
|
7621
10028
|
useExternalVersion();
|
|
7622
|
-
const [win, setWin] =
|
|
7623
|
-
const dlgRef =
|
|
7624
|
-
const contentRef =
|
|
7625
|
-
|
|
10029
|
+
const [win, setWin] = import_react20.default.useState(() => ({ mode: "normal", x: null, y: null, w: null, h: null }));
|
|
10030
|
+
const dlgRef = import_react20.default.useRef(null);
|
|
10031
|
+
const contentRef = import_react20.default.useRef(null);
|
|
10032
|
+
import_react20.default.useEffect(() => {
|
|
7626
10033
|
if (lastGeom.w) setWin({ mode: "normal", x: lastGeom.x, y: lastGeom.y, w: lastGeom.w, h: lastGeom.h });
|
|
7627
10034
|
}, []);
|
|
7628
|
-
|
|
10035
|
+
import_react20.default.useEffect(() => {
|
|
7629
10036
|
if (open && contentRef.current) contentRef.current.scrollTop = 0;
|
|
7630
10037
|
}, [active, open]);
|
|
7631
10038
|
function beginDrag(e, type) {
|
|
@@ -7663,13 +10070,13 @@ function DockModal() {
|
|
|
7663
10070
|
const mod = isHome ? null : MODULES.find((m) => m.id === active) || MODULES[0];
|
|
7664
10071
|
const st = mod ? stateOf(mod.id) : null;
|
|
7665
10072
|
const View = mod ? mod.View : null;
|
|
7666
|
-
const viewNode = mod && View ?
|
|
10073
|
+
const viewNode = mod && View ? import_react20.default.createElement(
|
|
7667
10074
|
"div",
|
|
7668
10075
|
{ className: "dockm-view" },
|
|
7669
|
-
|
|
7670
|
-
mod.external ? FeatureBoundary :
|
|
10076
|
+
import_react20.default.createElement(
|
|
10077
|
+
mod.external ? FeatureBoundary : import_react20.default.Fragment,
|
|
7671
10078
|
null,
|
|
7672
|
-
|
|
10079
|
+
import_react20.default.createElement(View, { ctx: ctxRef.current, feature: mod, params: navParams })
|
|
7673
10080
|
)
|
|
7674
10081
|
) : null;
|
|
7675
10082
|
const enabledCount = MODULES.filter((m) => {
|
|
@@ -7683,10 +10090,10 @@ function DockModal() {
|
|
|
7683
10090
|
width: win.w != null ? win.w : void 0,
|
|
7684
10091
|
height: win.mode === "min" ? "auto" : win.h != null ? win.h : void 0
|
|
7685
10092
|
} : null;
|
|
7686
|
-
return
|
|
10093
|
+
return import_react20.default.createElement(
|
|
7687
10094
|
"div",
|
|
7688
10095
|
{ className: "dockm-backdrop", onClick: () => setPanelOpen(false) },
|
|
7689
|
-
|
|
10096
|
+
import_react20.default.createElement(
|
|
7690
10097
|
"div",
|
|
7691
10098
|
{
|
|
7692
10099
|
className: "dockm-dialog" + (win.mode === "max" ? " dockm-max" : "") + (win.mode === "min" ? " dockm-min" : ""),
|
|
@@ -7694,41 +10101,41 @@ function DockModal() {
|
|
|
7694
10101
|
ref: dlgRef,
|
|
7695
10102
|
onClick: (e) => e.stopPropagation()
|
|
7696
10103
|
},
|
|
7697
|
-
|
|
10104
|
+
import_react20.default.createElement(
|
|
7698
10105
|
"div",
|
|
7699
10106
|
{
|
|
7700
10107
|
className: "dockm-head",
|
|
7701
10108
|
onPointerDown: (e) => beginDrag(e, "move"),
|
|
7702
10109
|
onDoubleClick: () => setWin((s) => Object.assign({}, s, { mode: s.mode === "max" ? "normal" : "max" }))
|
|
7703
10110
|
},
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
10111
|
+
import_react20.default.createElement(DockIcon, null),
|
|
10112
|
+
import_react20.default.createElement("span", { className: "dockm-title" }, "\u529F\u80FD\u575E"),
|
|
10113
|
+
import_react20.default.createElement("span", { className: "dockm-sub" }, "dsh-dock \xB7 \u4E5F\u53EF\u5728 \u8BBE\u7F6E \u2192 \u529F\u80FD\u575E \u6253\u5F00\u7BA1\u7406\u9875"),
|
|
10114
|
+
import_react20.default.createElement(
|
|
7708
10115
|
"span",
|
|
7709
10116
|
{ className: "dockm-ctrls" },
|
|
7710
|
-
|
|
10117
|
+
import_react20.default.createElement("button", {
|
|
7711
10118
|
type: "button",
|
|
7712
10119
|
className: "dockm-win",
|
|
7713
10120
|
title: win.mode === "min" ? "\u8FD8\u539F" : "\u6700\u5C0F\u5316",
|
|
7714
10121
|
onClick: () => setWin((s) => Object.assign({}, s, { mode: s.mode === "min" ? "normal" : "min" }))
|
|
7715
10122
|
}, "\u2581"),
|
|
7716
|
-
|
|
10123
|
+
import_react20.default.createElement("button", {
|
|
7717
10124
|
type: "button",
|
|
7718
10125
|
className: "dockm-win",
|
|
7719
10126
|
title: win.mode === "max" ? "\u8FD8\u539F" : "\u6700\u5927\u5316",
|
|
7720
10127
|
onClick: () => setWin((s) => Object.assign({}, s, { mode: s.mode === "max" ? "normal" : "max" }))
|
|
7721
10128
|
}, win.mode === "max" ? "\u2750" : "\u25A2"),
|
|
7722
|
-
|
|
10129
|
+
import_react20.default.createElement("button", { type: "button", className: "dockm-close", "aria-label": "\u5173\u95ED", title: "\u5173\u95ED", onClick: () => setPanelOpen(false) }, "\u2715")
|
|
7723
10130
|
)
|
|
7724
10131
|
),
|
|
7725
|
-
|
|
10132
|
+
import_react20.default.createElement(
|
|
7726
10133
|
"div",
|
|
7727
10134
|
{ className: "dockm-body" },
|
|
7728
|
-
|
|
10135
|
+
import_react20.default.createElement(
|
|
7729
10136
|
"nav",
|
|
7730
10137
|
{ className: "dockm-nav", "aria-label": "\u529F\u80FD\u6A21\u5757" },
|
|
7731
|
-
|
|
10138
|
+
import_react20.default.createElement(
|
|
7732
10139
|
"button",
|
|
7733
10140
|
{
|
|
7734
10141
|
type: "button",
|
|
@@ -7736,10 +10143,10 @@ function DockModal() {
|
|
|
7736
10143
|
className: "dockm-nav-item" + (isHome ? " on" : ""),
|
|
7737
10144
|
onClick: () => setActive("home")
|
|
7738
10145
|
},
|
|
7739
|
-
|
|
7740
|
-
|
|
10146
|
+
import_react20.default.createElement("span", { className: "dockm-navhome" }, import_react20.default.createElement(DockIcon, null)),
|
|
10147
|
+
import_react20.default.createElement("span", null, "\u9996\u9875")
|
|
7741
10148
|
),
|
|
7742
|
-
MODULES.map((m) =>
|
|
10149
|
+
MODULES.map((m) => import_react20.default.createElement(
|
|
7743
10150
|
"button",
|
|
7744
10151
|
{
|
|
7745
10152
|
type: "button",
|
|
@@ -7747,42 +10154,42 @@ function DockModal() {
|
|
|
7747
10154
|
className: "dockm-nav-item" + (m.id === active ? " on" : ""),
|
|
7748
10155
|
onClick: () => setActive(m.id)
|
|
7749
10156
|
},
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
m.planned ?
|
|
7753
|
-
m.external ?
|
|
10157
|
+
import_react20.default.createElement("span", { className: "dockm-dot", style: { background: m.accent } }),
|
|
10158
|
+
import_react20.default.createElement("span", null, m.name),
|
|
10159
|
+
m.planned ? import_react20.default.createElement("span", { className: "dockm-badge" }, "\u89C4\u5212\u4E2D") : null,
|
|
10160
|
+
m.external ? import_react20.default.createElement("span", { className: "dockm-badge" }, "\u5916\u90E8") : null
|
|
7754
10161
|
))
|
|
7755
10162
|
),
|
|
7756
|
-
|
|
10163
|
+
import_react20.default.createElement(
|
|
7757
10164
|
"div",
|
|
7758
10165
|
{ className: "dockm-content", ref: contentRef },
|
|
7759
|
-
|
|
10166
|
+
import_react20.default.createElement(
|
|
7760
10167
|
"div",
|
|
7761
10168
|
{ className: "dockm-content-head" },
|
|
7762
|
-
|
|
10169
|
+
import_react20.default.createElement(
|
|
7763
10170
|
"div",
|
|
7764
10171
|
{ className: "dockm-name" },
|
|
7765
|
-
isHome ?
|
|
10172
|
+
isHome ? import_react20.default.createElement("span", { className: "dockm-navhome" }, import_react20.default.createElement(DockIcon, null)) : import_react20.default.createElement("span", { className: "dockm-dot", style: { background: mod.accent } }),
|
|
7766
10173
|
isHome ? "\u9996\u9875" : mod.name,
|
|
7767
|
-
!isHome && mod.planned ?
|
|
7768
|
-
!isHome && mod.external ?
|
|
10174
|
+
!isHome && mod.planned ? import_react20.default.createElement("span", { className: "dockm-badge" }, "\u89C4\u5212\u4E2D") : null,
|
|
10175
|
+
!isHome && mod.external ? import_react20.default.createElement("span", { className: "dockm-badge" }, "\u5916\u90E8\u5305" + (mod.package ? " \xB7 " + mod.package : "")) : null
|
|
7769
10176
|
),
|
|
7770
|
-
|
|
10177
|
+
import_react20.default.createElement(
|
|
7771
10178
|
"div",
|
|
7772
10179
|
{ className: "dockm-desc" },
|
|
7773
10180
|
isHome ? "\u6240\u6709\u5B50\u529F\u80FD\u603B\u63FD\uFF1A\u8FD0\u884C\u72B6\u6001\u3001\u6982\u8981\u4E0E\u5FEB\u6377\u5F00\u5173\uFF0C\u70B9\u51FB\u5361\u7247\u8FDB\u5165\u5BF9\u5E94\u529F\u80FD\u9875\u3002" : mod.description
|
|
7774
10181
|
)
|
|
7775
10182
|
),
|
|
7776
|
-
isHome ?
|
|
7777
|
-
|
|
10183
|
+
isHome ? import_react20.default.createElement("div", { className: "dockm-view" }, import_react20.default.createElement(HomeView, { ctx: ctxRef.current, onOpen: setActive, onToggle: force })) : mod.planned ? import_react20.default.createElement("div", { className: "dockm-note" }, PLANNED_NOTES[mod.id] || "\u5F85\u63A5\u5165\uFF1A\u89C1 README \u8DEF\u7EBF\u56FE") : st && st.enabled && viewNode ? viewNode : st && st.error ? import_react20.default.createElement("div", { className: "dockm-note dockm-err" }, "\u529F\u80FD\u51FA\u9519\uFF1A" + st.error) : import_react20.default.createElement("div", { className: "dockm-note" }, "\u8BE5\u529F\u80FD\u5F53\u524D\u4E3A\u505C\u7528\u72B6\u6001\uFF08\u5F00\u5173\u5DF2\u6301\u4E45\u5316\uFF0C\u91CD\u542F\u540E\u4FDD\u6301\uFF09"),
|
|
10184
|
+
import_react20.default.createElement(
|
|
7778
10185
|
"div",
|
|
7779
10186
|
{ className: "dockm-foot" },
|
|
7780
|
-
|
|
7781
|
-
!isHome && mod && !mod.planned && st ?
|
|
10187
|
+
import_react20.default.createElement("span", null, isHome ? "\u529F\u80FD\u575E v" + DOCK_VERSION + " \xB7 \u5171 " + MODULES.length + " \u4E2A\u529F\u80FD\u6A21\u5757\uFF0C" + enabledCount + " \u4E2A\u5DF2\u542F\u7528" : "\u529F\u80FD\u575E v" + DOCK_VERSION + " \xB7 \u65B0\u529F\u80FD\u6309\u8DEF\u7EBF\u56FE\u8FFD\u52A0"),
|
|
10188
|
+
!isHome && mod && !mod.planned && st ? import_react20.default.createElement(
|
|
7782
10189
|
"span",
|
|
7783
10190
|
{ className: "dockm-foot-sw" },
|
|
7784
|
-
|
|
7785
|
-
|
|
10191
|
+
import_react20.default.createElement("span", { className: "dockm-foot-swlabel" + (st.enabled ? " on" : "") }, st.enabled ? "\u5DF2\u542F\u7528" : "\u5DF2\u505C\u7528"),
|
|
10192
|
+
import_react20.default.createElement("button", {
|
|
7786
10193
|
type: "button",
|
|
7787
10194
|
className: "dock-sw" + (st.enabled ? " on" : ""),
|
|
7788
10195
|
role: "switch",
|
|
@@ -7795,11 +10202,11 @@ function DockModal() {
|
|
|
7795
10202
|
}
|
|
7796
10203
|
})
|
|
7797
10204
|
) : null,
|
|
7798
|
-
!isHome && mod && typeof mod.Chip === "function" ?
|
|
10205
|
+
!isHome && mod && typeof mod.Chip === "function" ? import_react20.default.createElement(
|
|
7799
10206
|
"span",
|
|
7800
10207
|
{ className: "dockm-foot-sw" },
|
|
7801
|
-
|
|
7802
|
-
|
|
10208
|
+
import_react20.default.createElement("span", { className: "dockm-foot-swlabel" + (chipShown(mod.id) ? " on" : "") }, "\u4F1A\u8BDD\u9875\u5C0F\u63A7\u4EF6"),
|
|
10209
|
+
import_react20.default.createElement("button", {
|
|
7803
10210
|
type: "button",
|
|
7804
10211
|
className: "dock-sw" + (chipShown(mod.id) ? " on" : ""),
|
|
7805
10212
|
role: "switch",
|
|
@@ -7815,30 +10222,30 @@ function DockModal() {
|
|
|
7815
10222
|
)
|
|
7816
10223
|
)
|
|
7817
10224
|
),
|
|
7818
|
-
win.mode === "normal" ?
|
|
10225
|
+
win.mode === "normal" ? import_react20.default.createElement("div", { className: "dockm-resize", onPointerDown: (e) => beginDrag(e, "size") }) : null
|
|
7819
10226
|
)
|
|
7820
10227
|
);
|
|
7821
10228
|
}
|
|
7822
10229
|
function HomeView(props) {
|
|
7823
10230
|
const ctx = props && props.ctx;
|
|
7824
|
-
const [, force] =
|
|
10231
|
+
const [, force] = import_react20.default.useReducer((n) => n + 1, 0);
|
|
7825
10232
|
useExternalVersion();
|
|
7826
10233
|
const open = (id) => {
|
|
7827
10234
|
if (props && typeof props.onOpen === "function") props.onOpen(id);
|
|
7828
10235
|
};
|
|
7829
|
-
return
|
|
10236
|
+
return import_react20.default.createElement(
|
|
7830
10237
|
"div",
|
|
7831
10238
|
{ className: "dockh-grid" },
|
|
7832
10239
|
allModules().map((m) => {
|
|
7833
10240
|
const st = stateOf(m.id);
|
|
7834
10241
|
const enabled = !!(st && st.enabled);
|
|
7835
10242
|
const Stat = m.HomeStat;
|
|
7836
|
-
const statNode = m.planned ?
|
|
7837
|
-
m.external ? FeatureBoundary :
|
|
10243
|
+
const statNode = m.planned ? import_react20.default.createElement("span", null, PLANNED_NOTES[m.id] || "\u5F85\u63A5\u5165\uFF1A\u89C1 README \u8DEF\u7EBF\u56FE") : enabled && Stat ? import_react20.default.createElement(
|
|
10244
|
+
m.external ? FeatureBoundary : import_react20.default.Fragment,
|
|
7838
10245
|
null,
|
|
7839
|
-
|
|
7840
|
-
) :
|
|
7841
|
-
return
|
|
10246
|
+
import_react20.default.createElement(Stat, { ctx })
|
|
10247
|
+
) : import_react20.default.createElement("span", null, "\u5DF2\u505C\u7528\uFF0C\u542F\u7528\u540E\u5728\u6B64\u5C55\u793A\u8FD0\u884C\u6982\u8981");
|
|
10248
|
+
return import_react20.default.createElement(
|
|
7842
10249
|
"div",
|
|
7843
10250
|
{
|
|
7844
10251
|
key: m.id,
|
|
@@ -7853,21 +10260,21 @@ function HomeView(props) {
|
|
|
7853
10260
|
}
|
|
7854
10261
|
}
|
|
7855
10262
|
},
|
|
7856
|
-
|
|
10263
|
+
import_react20.default.createElement(
|
|
7857
10264
|
"div",
|
|
7858
10265
|
{ className: "dockh-head" },
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
m.external ?
|
|
10266
|
+
import_react20.default.createElement("span", { className: "dockm-dot", style: { background: m.accent } }),
|
|
10267
|
+
import_react20.default.createElement("span", { className: "dockh-name" }, m.name),
|
|
10268
|
+
m.external ? import_react20.default.createElement("span", { className: "dockh-badge", title: m.package || void 0 }, "\u5916\u90E8") : null,
|
|
7862
10269
|
// 状态标识:圆点 + 文字(纯展示,与开关视觉区分)
|
|
7863
|
-
|
|
10270
|
+
import_react20.default.createElement(
|
|
7864
10271
|
"span",
|
|
7865
10272
|
{ className: "dockh-status" + (m.planned ? " plan" : enabled ? "" : " off") },
|
|
7866
|
-
|
|
7867
|
-
|
|
10273
|
+
import_react20.default.createElement("span", { className: "dockh-sdot" }),
|
|
10274
|
+
import_react20.default.createElement("span", null, m.planned ? "\u89C4\u5212\u4E2D" : enabled ? "\u8FD0\u884C\u4E2D" : "\u5DF2\u505C\u7528")
|
|
7868
10275
|
),
|
|
7869
10276
|
// 启停开关(规划中的功能不显示)
|
|
7870
|
-
m.planned ? null :
|
|
10277
|
+
m.planned ? null : import_react20.default.createElement("button", {
|
|
7871
10278
|
type: "button",
|
|
7872
10279
|
className: "dock-sw" + (enabled ? " on" : ""),
|
|
7873
10280
|
role: "switch",
|
|
@@ -7882,12 +10289,12 @@ function HomeView(props) {
|
|
|
7882
10289
|
}
|
|
7883
10290
|
})
|
|
7884
10291
|
),
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
10292
|
+
import_react20.default.createElement("div", { className: "dockh-desc" }, m.description),
|
|
10293
|
+
import_react20.default.createElement("div", { className: "dockh-stat" }, statNode),
|
|
10294
|
+
import_react20.default.createElement(
|
|
7888
10295
|
"div",
|
|
7889
10296
|
{ className: "dockh-foot" },
|
|
7890
|
-
|
|
10297
|
+
import_react20.default.createElement("span", { className: "dockh-go" }, "\u67E5\u770B\u8BE6\u60C5 \u2192")
|
|
7891
10298
|
)
|
|
7892
10299
|
);
|
|
7893
10300
|
})
|
|
@@ -7895,16 +10302,16 @@ function HomeView(props) {
|
|
|
7895
10302
|
}
|
|
7896
10303
|
function DockPanel() {
|
|
7897
10304
|
const ctx = ctxRef.current;
|
|
7898
|
-
const [, force] =
|
|
10305
|
+
const [, force] = import_react20.default.useReducer((n) => n + 1, 0);
|
|
7899
10306
|
useExternalVersion();
|
|
7900
10307
|
const toggle = (id) => {
|
|
7901
10308
|
toggleFeature(id);
|
|
7902
10309
|
force();
|
|
7903
10310
|
};
|
|
7904
|
-
return
|
|
10311
|
+
return import_react20.default.createElement(
|
|
7905
10312
|
"div",
|
|
7906
10313
|
{ className: "dock-root" },
|
|
7907
|
-
|
|
10314
|
+
import_react20.default.createElement(
|
|
7908
10315
|
"div",
|
|
7909
10316
|
{ className: "dock-intro" },
|
|
7910
10317
|
"\u529F\u80FD\u575E\uFF08dsh-dock\uFF09\xB7 \u6240\u6709\u5C0F\u529F\u80FD\u96C6\u4E2D\u5728\u8FD9\u4E00\u4E2A\u9762\u677F\u91CC\u7BA1\u7406\u3002v0.4.0 \u8D77\u6BCF\u4E2A\u529F\u80FD\u662F\u72EC\u7ACB\u6A21\u5757\uFF08features/<id>/\uFF09\uFF0C",
|
|
@@ -7913,25 +10320,25 @@ function DockPanel() {
|
|
|
7913
10320
|
allModules().map((f) => {
|
|
7914
10321
|
const st = stateOf(f.id);
|
|
7915
10322
|
const View = f.View;
|
|
7916
|
-
const viewNode = !f.planned && st.enabled && View ?
|
|
10323
|
+
const viewNode = !f.planned && st.enabled && View ? import_react20.default.createElement(
|
|
7917
10324
|
"div",
|
|
7918
10325
|
{ className: "dock-body" },
|
|
7919
|
-
|
|
7920
|
-
f.external ? FeatureBoundary :
|
|
10326
|
+
import_react20.default.createElement(
|
|
10327
|
+
f.external ? FeatureBoundary : import_react20.default.Fragment,
|
|
7921
10328
|
null,
|
|
7922
|
-
|
|
10329
|
+
import_react20.default.createElement(View, { ctx, feature: f })
|
|
7923
10330
|
)
|
|
7924
10331
|
) : null;
|
|
7925
|
-
return
|
|
10332
|
+
return import_react20.default.createElement(
|
|
7926
10333
|
"div",
|
|
7927
10334
|
{ className: "dock-card", key: f.id },
|
|
7928
|
-
|
|
10335
|
+
import_react20.default.createElement(
|
|
7929
10336
|
"div",
|
|
7930
10337
|
{ className: "dock-card-head" },
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
|
|
7934
|
-
f.planned ?
|
|
10338
|
+
import_react20.default.createElement("span", { className: "dock-dot" + (st.error ? " err" : st.enabled ? " on" : "") }),
|
|
10339
|
+
import_react20.default.createElement("span", { className: "dock-name" }, f.name),
|
|
10340
|
+
import_react20.default.createElement("span", { className: "dock-desc" }, f.description + (f.external ? "\uFF08\u6765\u81EA\u5916\u90E8\u5305" + (f.package ? " " + f.package : "") + "\uFF09" : "")),
|
|
10341
|
+
f.planned ? import_react20.default.createElement("span", { className: "dock-badge" }, "\u89C4\u5212\u4E2D") : import_react20.default.createElement("button", {
|
|
7935
10342
|
type: "button",
|
|
7936
10343
|
className: "dock-sw" + (st.enabled ? " on" : ""),
|
|
7937
10344
|
role: "switch",
|
|
@@ -7940,11 +10347,11 @@ function DockPanel() {
|
|
|
7940
10347
|
title: st.enabled ? "\u505C\u7528\u300C" + f.name + "\u300D" : "\u542F\u7528\u300C" + f.name + "\u300D",
|
|
7941
10348
|
onClick: () => toggle(f.id)
|
|
7942
10349
|
}),
|
|
7943
|
-
!f.planned && typeof f.Chip === "function" ?
|
|
10350
|
+
!f.planned && typeof f.Chip === "function" ? import_react20.default.createElement(
|
|
7944
10351
|
"span",
|
|
7945
10352
|
{ className: "dockm-foot-sw" },
|
|
7946
|
-
|
|
7947
|
-
|
|
10353
|
+
import_react20.default.createElement("span", { className: "dockm-foot-swlabel" + (chipShown(f.id) ? " on" : "") }, "\u4F1A\u8BDD\u9875\u5C0F\u63A7\u4EF6"),
|
|
10354
|
+
import_react20.default.createElement("button", {
|
|
7948
10355
|
type: "button",
|
|
7949
10356
|
className: "dock-sw" + (chipShown(f.id) ? " on" : ""),
|
|
7950
10357
|
role: "switch",
|
|
@@ -7958,19 +10365,19 @@ function DockPanel() {
|
|
|
7958
10365
|
})
|
|
7959
10366
|
) : null
|
|
7960
10367
|
),
|
|
7961
|
-
f.planned ?
|
|
10368
|
+
f.planned ? import_react20.default.createElement("div", { className: "dock-body" }, PLANNED_NOTES[f.id] || "\u5F85\u63A5\u5165\uFF1A\u89C1 README \u8DEF\u7EBF\u56FE") : st.error ? import_react20.default.createElement("div", { className: "dock-body dockm-err" }, "\u529F\u80FD\u51FA\u9519\uFF1A" + st.error) : null,
|
|
7962
10369
|
viewNode
|
|
7963
10370
|
);
|
|
7964
10371
|
})
|
|
7965
10372
|
);
|
|
7966
10373
|
}
|
|
7967
10374
|
function DockChips(props) {
|
|
7968
|
-
const [, force] =
|
|
7969
|
-
|
|
10375
|
+
const [, force] = import_react20.default.useReducer((n) => n + 1, 0);
|
|
10376
|
+
import_react20.default.useEffect(() => subscribeFeatureState(() => force()), []);
|
|
7970
10377
|
const items = [];
|
|
7971
10378
|
for (const f of allModules()) {
|
|
7972
10379
|
if (f.planned || !stateOf(f.id).enabled || !chipShown(f.id) || typeof f.Chip !== "function") continue;
|
|
7973
|
-
items.push(
|
|
10380
|
+
items.push(import_react20.default.createElement(f.Chip, {
|
|
7974
10381
|
key: f.id,
|
|
7975
10382
|
ctx: props.ctx,
|
|
7976
10383
|
feature: f,
|
|
@@ -7980,23 +10387,23 @@ function DockChips(props) {
|
|
|
7980
10387
|
}));
|
|
7981
10388
|
}
|
|
7982
10389
|
if (items.length === 0) return null;
|
|
7983
|
-
return
|
|
10390
|
+
return import_react20.default.createElement("div", { className: "dockchip-row" }, items);
|
|
7984
10391
|
}
|
|
7985
10392
|
function FeatureOverlays() {
|
|
7986
|
-
const [, force] =
|
|
10393
|
+
const [, force] = import_react20.default.useReducer((n) => n + 1, 0);
|
|
7987
10394
|
useExternalVersion();
|
|
7988
|
-
|
|
10395
|
+
import_react20.default.useEffect(() => subscribeFeatureState(() => force()), []);
|
|
7989
10396
|
const items = [];
|
|
7990
10397
|
for (const f of allModules()) {
|
|
7991
10398
|
if (f.planned || !stateOf(f.id).enabled || typeof f.Overlay !== "function") continue;
|
|
7992
|
-
items.push(
|
|
10399
|
+
items.push(import_react20.default.createElement(
|
|
7993
10400
|
FeatureBoundary,
|
|
7994
10401
|
{ key: f.id },
|
|
7995
|
-
|
|
10402
|
+
import_react20.default.createElement(f.Overlay, { ctx: ctxRef.current, feature: f })
|
|
7996
10403
|
));
|
|
7997
10404
|
}
|
|
7998
10405
|
if (items.length === 0) return null;
|
|
7999
|
-
return
|
|
10406
|
+
return import_react20.default.createElement(import_react20.default.Fragment, null, items);
|
|
8000
10407
|
}
|
|
8001
10408
|
var ctxRef = { current: null };
|
|
8002
10409
|
function apply(ctx) {
|
|
@@ -8007,23 +10414,23 @@ function apply(ctx) {
|
|
|
8007
10414
|
if (slots === void 0) return;
|
|
8008
10415
|
slots.inject("sidebar.footer.action", () => slots.register(
|
|
8009
10416
|
{ name: "sidebar.footer.action", id: "dsh-dock", order: 1, label: "\u529F\u80FD\u575E" },
|
|
8010
|
-
(props) =>
|
|
10417
|
+
(props) => import_react20.default.createElement(DockEntry, props)
|
|
8011
10418
|
));
|
|
8012
10419
|
slots.inject("shell.overlay", () => slots.register(
|
|
8013
10420
|
{ name: "shell.overlay", id: "dsh-dock-panel", order: 21, label: "\u529F\u80FD\u575E\u9762\u677F" },
|
|
8014
|
-
() =>
|
|
10421
|
+
() => import_react20.default.createElement(DockModal, null)
|
|
8015
10422
|
));
|
|
8016
10423
|
slots.inject("shell.overlay", () => slots.register(
|
|
8017
10424
|
{ name: "shell.overlay", id: "dsh-dock-feature-overlays", order: 22, label: "\u529F\u80FD\u575E\u5168\u5C40\u6D6E\u5C42" },
|
|
8018
|
-
() =>
|
|
10425
|
+
() => import_react20.default.createElement(FeatureOverlays, null)
|
|
8019
10426
|
));
|
|
8020
10427
|
slots.inject("settings.section", () => slots.register(
|
|
8021
10428
|
{ name: "settings.section", id: "dsh-dock", order: 90, label: "\u529F\u80FD\u575E" },
|
|
8022
|
-
() =>
|
|
10429
|
+
() => import_react20.default.createElement(DockPanel, null)
|
|
8023
10430
|
));
|
|
8024
10431
|
slots.inject("conversation.input.left", () => slots.register(
|
|
8025
10432
|
{ name: "conversation.input.left", id: "dsh-dock-chips", order: 10, label: "\u529F\u80FD\u575E" },
|
|
8026
|
-
(zone) =>
|
|
10433
|
+
(zone) => import_react20.default.createElement(DockChips, Object.assign({}, zone, { ctx: ctxRef.current }))
|
|
8027
10434
|
));
|
|
8028
10435
|
}
|
|
8029
10436
|
var inject = ["timer"];
|