meshy-dsh 0.1.0 → 0.2.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 +21 -5
- package/README.zh.md +6 -2
- package/cordis.patch.yml +6 -3
- package/lib/client.js +3492 -0
- package/lib/client.viewer.js +4237 -0
- package/lib/index.js +133 -0
- package/package.json +16 -3
- package/skills/meshy-3d-generation/SKILL.md +5 -4
- package/skills/meshy-3d-generation/references/delivery.md +3 -1
- package/skills/meshy-3d-generation/references/setup.md +40 -14
- package/skills/meshy-3d-generation/references/troubleshooting.md +4 -4
- package/skills/meshy-3d-printing/SKILL.md +5 -4
- package/skills/meshy-3d-printing/references/delivery.md +3 -1
- package/skills/meshy-3d-printing/references/setup.md +40 -14
- package/skills/meshy-3d-printing/references/troubleshooting.md +4 -4
package/lib/client.js
ADDED
|
@@ -0,0 +1,3492 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({ id: "meshy-dsh", factory: (require) => {
|
|
2
|
+
|
|
3
|
+
var module = { exports: {} }; var exports = module.exports;
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
+
let react = require("react");
|
|
6
|
+
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
|
|
9
|
+
// node_modules/qrcode-generator/dist/qrcode.mjs
|
|
10
|
+
/**
|
|
11
|
+
* qrcode
|
|
12
|
+
* @param typeNumber 1 to 40
|
|
13
|
+
* @param errorCorrectionLevel 'L','M','Q','H'
|
|
14
|
+
*/
|
|
15
|
+
const qrcode = function(typeNumber, errorCorrectionLevel) {
|
|
16
|
+
const PAD0 = 236;
|
|
17
|
+
const PAD1 = 17;
|
|
18
|
+
let _typeNumber = typeNumber;
|
|
19
|
+
const _errorCorrectionLevel = QRErrorCorrectionLevel[errorCorrectionLevel];
|
|
20
|
+
let _modules = null;
|
|
21
|
+
let _moduleCount = 0;
|
|
22
|
+
let _dataCache = null;
|
|
23
|
+
const _dataList = [];
|
|
24
|
+
const _this = {};
|
|
25
|
+
const makeImpl = function(test, maskPattern) {
|
|
26
|
+
_moduleCount = _typeNumber * 4 + 17;
|
|
27
|
+
_modules = function(moduleCount) {
|
|
28
|
+
const modules = new Array(moduleCount);
|
|
29
|
+
for (let row = 0; row < moduleCount; row += 1) {
|
|
30
|
+
modules[row] = new Array(moduleCount);
|
|
31
|
+
for (let col = 0; col < moduleCount; col += 1) modules[row][col] = null;
|
|
32
|
+
}
|
|
33
|
+
return modules;
|
|
34
|
+
}(_moduleCount);
|
|
35
|
+
setupPositionProbePattern(0, 0);
|
|
36
|
+
setupPositionProbePattern(_moduleCount - 7, 0);
|
|
37
|
+
setupPositionProbePattern(0, _moduleCount - 7);
|
|
38
|
+
setupPositionAdjustPattern();
|
|
39
|
+
setupTimingPattern();
|
|
40
|
+
setupTypeInfo(test, maskPattern);
|
|
41
|
+
if (_typeNumber >= 7) setupTypeNumber(test);
|
|
42
|
+
if (_dataCache == null) _dataCache = createData(_typeNumber, _errorCorrectionLevel, _dataList);
|
|
43
|
+
mapData(_dataCache, maskPattern);
|
|
44
|
+
};
|
|
45
|
+
const setupPositionProbePattern = function(row, col) {
|
|
46
|
+
for (let r = -1; r <= 7; r += 1) {
|
|
47
|
+
if (row + r <= -1 || _moduleCount <= row + r) continue;
|
|
48
|
+
for (let c = -1; c <= 7; c += 1) {
|
|
49
|
+
if (col + c <= -1 || _moduleCount <= col + c) continue;
|
|
50
|
+
if (0 <= r && r <= 6 && (c == 0 || c == 6) || 0 <= c && c <= 6 && (r == 0 || r == 6) || 2 <= r && r <= 4 && 2 <= c && c <= 4) _modules[row + r][col + c] = true;
|
|
51
|
+
else _modules[row + r][col + c] = false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const getBestMaskPattern = function() {
|
|
56
|
+
let minLostPoint = 0;
|
|
57
|
+
let pattern = 0;
|
|
58
|
+
for (let i = 0; i < 8; i += 1) {
|
|
59
|
+
makeImpl(true, i);
|
|
60
|
+
const lostPoint = QRUtil.getLostPoint(_this);
|
|
61
|
+
if (i == 0 || minLostPoint > lostPoint) {
|
|
62
|
+
minLostPoint = lostPoint;
|
|
63
|
+
pattern = i;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return pattern;
|
|
67
|
+
};
|
|
68
|
+
const setupTimingPattern = function() {
|
|
69
|
+
for (let r = 8; r < _moduleCount - 8; r += 1) {
|
|
70
|
+
if (_modules[r][6] != null) continue;
|
|
71
|
+
_modules[r][6] = r % 2 == 0;
|
|
72
|
+
}
|
|
73
|
+
for (let c = 8; c < _moduleCount - 8; c += 1) {
|
|
74
|
+
if (_modules[6][c] != null) continue;
|
|
75
|
+
_modules[6][c] = c % 2 == 0;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const setupPositionAdjustPattern = function() {
|
|
79
|
+
const pos = QRUtil.getPatternPosition(_typeNumber);
|
|
80
|
+
for (let i = 0; i < pos.length; i += 1) for (let j = 0; j < pos.length; j += 1) {
|
|
81
|
+
const row = pos[i];
|
|
82
|
+
const col = pos[j];
|
|
83
|
+
if (_modules[row][col] != null) continue;
|
|
84
|
+
for (let r = -2; r <= 2; r += 1) for (let c = -2; c <= 2; c += 1) if (r == -2 || r == 2 || c == -2 || c == 2 || r == 0 && c == 0) _modules[row + r][col + c] = true;
|
|
85
|
+
else _modules[row + r][col + c] = false;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const setupTypeNumber = function(test) {
|
|
89
|
+
const bits = QRUtil.getBCHTypeNumber(_typeNumber);
|
|
90
|
+
for (let i = 0; i < 18; i += 1) {
|
|
91
|
+
const mod = !test && (bits >> i & 1) == 1;
|
|
92
|
+
_modules[Math.floor(i / 3)][i % 3 + _moduleCount - 8 - 3] = mod;
|
|
93
|
+
}
|
|
94
|
+
for (let i = 0; i < 18; i += 1) {
|
|
95
|
+
const mod = !test && (bits >> i & 1) == 1;
|
|
96
|
+
_modules[i % 3 + _moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const setupTypeInfo = function(test, maskPattern) {
|
|
100
|
+
const data = _errorCorrectionLevel << 3 | maskPattern;
|
|
101
|
+
const bits = QRUtil.getBCHTypeInfo(data);
|
|
102
|
+
for (let i = 0; i < 15; i += 1) {
|
|
103
|
+
const mod = !test && (bits >> i & 1) == 1;
|
|
104
|
+
if (i < 6) _modules[i][8] = mod;
|
|
105
|
+
else if (i < 8) _modules[i + 1][8] = mod;
|
|
106
|
+
else _modules[_moduleCount - 15 + i][8] = mod;
|
|
107
|
+
}
|
|
108
|
+
for (let i = 0; i < 15; i += 1) {
|
|
109
|
+
const mod = !test && (bits >> i & 1) == 1;
|
|
110
|
+
if (i < 8) _modules[8][_moduleCount - i - 1] = mod;
|
|
111
|
+
else if (i < 9) _modules[8][15 - i - 1 + 1] = mod;
|
|
112
|
+
else _modules[8][15 - i - 1] = mod;
|
|
113
|
+
}
|
|
114
|
+
_modules[_moduleCount - 8][8] = !test;
|
|
115
|
+
};
|
|
116
|
+
const mapData = function(data, maskPattern) {
|
|
117
|
+
let inc = -1;
|
|
118
|
+
let row = _moduleCount - 1;
|
|
119
|
+
let bitIndex = 7;
|
|
120
|
+
let byteIndex = 0;
|
|
121
|
+
const maskFunc = QRUtil.getMaskFunction(maskPattern);
|
|
122
|
+
for (let col = _moduleCount - 1; col > 0; col -= 2) {
|
|
123
|
+
if (col == 6) col -= 1;
|
|
124
|
+
while (true) {
|
|
125
|
+
for (let c = 0; c < 2; c += 1) if (_modules[row][col - c] == null) {
|
|
126
|
+
let dark = false;
|
|
127
|
+
if (byteIndex < data.length) dark = (data[byteIndex] >>> bitIndex & 1) == 1;
|
|
128
|
+
if (maskFunc(row, col - c)) dark = !dark;
|
|
129
|
+
_modules[row][col - c] = dark;
|
|
130
|
+
bitIndex -= 1;
|
|
131
|
+
if (bitIndex == -1) {
|
|
132
|
+
byteIndex += 1;
|
|
133
|
+
bitIndex = 7;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
row += inc;
|
|
137
|
+
if (row < 0 || _moduleCount <= row) {
|
|
138
|
+
row -= inc;
|
|
139
|
+
inc = -inc;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const createBytes = function(buffer, rsBlocks) {
|
|
146
|
+
let offset = 0;
|
|
147
|
+
let maxDcCount = 0;
|
|
148
|
+
let maxEcCount = 0;
|
|
149
|
+
const dcdata = new Array(rsBlocks.length);
|
|
150
|
+
const ecdata = new Array(rsBlocks.length);
|
|
151
|
+
for (let r = 0; r < rsBlocks.length; r += 1) {
|
|
152
|
+
const dcCount = rsBlocks[r].dataCount;
|
|
153
|
+
const ecCount = rsBlocks[r].totalCount - dcCount;
|
|
154
|
+
maxDcCount = Math.max(maxDcCount, dcCount);
|
|
155
|
+
maxEcCount = Math.max(maxEcCount, ecCount);
|
|
156
|
+
dcdata[r] = new Array(dcCount);
|
|
157
|
+
for (let i = 0; i < dcdata[r].length; i += 1) dcdata[r][i] = 255 & buffer.getBuffer()[i + offset];
|
|
158
|
+
offset += dcCount;
|
|
159
|
+
const rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
|
|
160
|
+
const modPoly = qrPolynomial(dcdata[r], rsPoly.getLength() - 1).mod(rsPoly);
|
|
161
|
+
ecdata[r] = new Array(rsPoly.getLength() - 1);
|
|
162
|
+
for (let i = 0; i < ecdata[r].length; i += 1) {
|
|
163
|
+
const modIndex = i + modPoly.getLength() - ecdata[r].length;
|
|
164
|
+
ecdata[r][i] = modIndex >= 0 ? modPoly.getAt(modIndex) : 0;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
let totalCodeCount = 0;
|
|
168
|
+
for (let i = 0; i < rsBlocks.length; i += 1) totalCodeCount += rsBlocks[i].totalCount;
|
|
169
|
+
const data = new Array(totalCodeCount);
|
|
170
|
+
let index = 0;
|
|
171
|
+
for (let i = 0; i < maxDcCount; i += 1) for (let r = 0; r < rsBlocks.length; r += 1) if (i < dcdata[r].length) {
|
|
172
|
+
data[index] = dcdata[r][i];
|
|
173
|
+
index += 1;
|
|
174
|
+
}
|
|
175
|
+
for (let i = 0; i < maxEcCount; i += 1) for (let r = 0; r < rsBlocks.length; r += 1) if (i < ecdata[r].length) {
|
|
176
|
+
data[index] = ecdata[r][i];
|
|
177
|
+
index += 1;
|
|
178
|
+
}
|
|
179
|
+
return data;
|
|
180
|
+
};
|
|
181
|
+
const createData = function(typeNumber, errorCorrectionLevel, dataList) {
|
|
182
|
+
const rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectionLevel);
|
|
183
|
+
const buffer = qrBitBuffer();
|
|
184
|
+
for (let i = 0; i < dataList.length; i += 1) {
|
|
185
|
+
const data = dataList[i];
|
|
186
|
+
buffer.put(data.getMode(), 4);
|
|
187
|
+
buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber));
|
|
188
|
+
data.write(buffer);
|
|
189
|
+
}
|
|
190
|
+
let totalDataCount = 0;
|
|
191
|
+
for (let i = 0; i < rsBlocks.length; i += 1) totalDataCount += rsBlocks[i].dataCount;
|
|
192
|
+
if (buffer.getLengthInBits() > totalDataCount * 8) throw "code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")";
|
|
193
|
+
if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) buffer.put(0, 4);
|
|
194
|
+
while (buffer.getLengthInBits() % 8 != 0) buffer.putBit(false);
|
|
195
|
+
while (true) {
|
|
196
|
+
if (buffer.getLengthInBits() >= totalDataCount * 8) break;
|
|
197
|
+
buffer.put(PAD0, 8);
|
|
198
|
+
if (buffer.getLengthInBits() >= totalDataCount * 8) break;
|
|
199
|
+
buffer.put(PAD1, 8);
|
|
200
|
+
}
|
|
201
|
+
return createBytes(buffer, rsBlocks);
|
|
202
|
+
};
|
|
203
|
+
_this.addData = function(data, mode) {
|
|
204
|
+
mode = mode || "Byte";
|
|
205
|
+
let newData = null;
|
|
206
|
+
switch (mode) {
|
|
207
|
+
case "Numeric":
|
|
208
|
+
newData = qrNumber(data);
|
|
209
|
+
break;
|
|
210
|
+
case "Alphanumeric":
|
|
211
|
+
newData = qrAlphaNum(data);
|
|
212
|
+
break;
|
|
213
|
+
case "Byte":
|
|
214
|
+
newData = qr8BitByte(data);
|
|
215
|
+
break;
|
|
216
|
+
case "Kanji":
|
|
217
|
+
newData = qrKanji(data);
|
|
218
|
+
break;
|
|
219
|
+
default: throw "mode:" + mode;
|
|
220
|
+
}
|
|
221
|
+
_dataList.push(newData);
|
|
222
|
+
_dataCache = null;
|
|
223
|
+
};
|
|
224
|
+
_this.isDark = function(row, col) {
|
|
225
|
+
if (row < 0 || _moduleCount <= row || col < 0 || _moduleCount <= col) throw row + "," + col;
|
|
226
|
+
return _modules[row][col];
|
|
227
|
+
};
|
|
228
|
+
_this.getModuleCount = function() {
|
|
229
|
+
return _moduleCount;
|
|
230
|
+
};
|
|
231
|
+
_this.make = function() {
|
|
232
|
+
if (_typeNumber < 1) {
|
|
233
|
+
let typeNumber = 1;
|
|
234
|
+
for (; typeNumber < 40; typeNumber++) {
|
|
235
|
+
const rsBlocks = QRRSBlock.getRSBlocks(typeNumber, _errorCorrectionLevel);
|
|
236
|
+
const buffer = qrBitBuffer();
|
|
237
|
+
for (let i = 0; i < _dataList.length; i++) {
|
|
238
|
+
const data = _dataList[i];
|
|
239
|
+
buffer.put(data.getMode(), 4);
|
|
240
|
+
buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber));
|
|
241
|
+
data.write(buffer);
|
|
242
|
+
}
|
|
243
|
+
let totalDataCount = 0;
|
|
244
|
+
for (let i = 0; i < rsBlocks.length; i++) totalDataCount += rsBlocks[i].dataCount;
|
|
245
|
+
if (buffer.getLengthInBits() <= totalDataCount * 8) break;
|
|
246
|
+
}
|
|
247
|
+
_typeNumber = typeNumber;
|
|
248
|
+
}
|
|
249
|
+
makeImpl(false, getBestMaskPattern());
|
|
250
|
+
};
|
|
251
|
+
_this.createTableTag = function(cellSize, margin) {
|
|
252
|
+
cellSize = cellSize || 2;
|
|
253
|
+
margin = typeof margin == "undefined" ? cellSize * 4 : margin;
|
|
254
|
+
let qrHtml = "";
|
|
255
|
+
qrHtml += "<table style=\"";
|
|
256
|
+
qrHtml += " border-width: 0px; border-style: none;";
|
|
257
|
+
qrHtml += " border-collapse: collapse;";
|
|
258
|
+
qrHtml += " padding: 0px; margin: " + margin + "px;";
|
|
259
|
+
qrHtml += "\">";
|
|
260
|
+
qrHtml += "<tbody>";
|
|
261
|
+
for (let r = 0; r < _this.getModuleCount(); r += 1) {
|
|
262
|
+
qrHtml += "<tr>";
|
|
263
|
+
for (let c = 0; c < _this.getModuleCount(); c += 1) {
|
|
264
|
+
qrHtml += "<td style=\"";
|
|
265
|
+
qrHtml += " border-width: 0px; border-style: none;";
|
|
266
|
+
qrHtml += " border-collapse: collapse;";
|
|
267
|
+
qrHtml += " padding: 0px; margin: 0px;";
|
|
268
|
+
qrHtml += " width: " + cellSize + "px;";
|
|
269
|
+
qrHtml += " height: " + cellSize + "px;";
|
|
270
|
+
qrHtml += " background-color: ";
|
|
271
|
+
qrHtml += _this.isDark(r, c) ? "#000000" : "#ffffff";
|
|
272
|
+
qrHtml += ";";
|
|
273
|
+
qrHtml += "\"/>";
|
|
274
|
+
}
|
|
275
|
+
qrHtml += "</tr>";
|
|
276
|
+
}
|
|
277
|
+
qrHtml += "</tbody>";
|
|
278
|
+
qrHtml += "</table>";
|
|
279
|
+
return qrHtml;
|
|
280
|
+
};
|
|
281
|
+
_this.createSvgTag = function(cellSize, margin, alt, title) {
|
|
282
|
+
let opts = {};
|
|
283
|
+
if (typeof arguments[0] == "object") {
|
|
284
|
+
opts = arguments[0];
|
|
285
|
+
cellSize = opts.cellSize;
|
|
286
|
+
margin = opts.margin;
|
|
287
|
+
alt = opts.alt;
|
|
288
|
+
title = opts.title;
|
|
289
|
+
}
|
|
290
|
+
cellSize = cellSize || 2;
|
|
291
|
+
margin = typeof margin == "undefined" ? cellSize * 4 : margin;
|
|
292
|
+
alt = typeof alt === "string" ? { text: alt } : alt || {};
|
|
293
|
+
alt.text = alt.text || null;
|
|
294
|
+
alt.id = alt.text ? alt.id || "qrcode-description" : null;
|
|
295
|
+
title = typeof title === "string" ? { text: title } : title || {};
|
|
296
|
+
title.text = title.text || null;
|
|
297
|
+
title.id = title.text ? title.id || "qrcode-title" : null;
|
|
298
|
+
const size = _this.getModuleCount() * cellSize + margin * 2;
|
|
299
|
+
let c, mc, r, mr, qrSvg = "", rect;
|
|
300
|
+
rect = "l" + cellSize + ",0 0," + cellSize + " -" + cellSize + ",0 0,-" + cellSize + "z ";
|
|
301
|
+
qrSvg += "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"";
|
|
302
|
+
qrSvg += !opts.scalable ? " width=\"" + size + "px\" height=\"" + size + "px\"" : "";
|
|
303
|
+
qrSvg += " viewBox=\"0 0 " + size + " " + size + "\" ";
|
|
304
|
+
qrSvg += " preserveAspectRatio=\"xMinYMin meet\"";
|
|
305
|
+
qrSvg += title.text || alt.text ? " role=\"img\" aria-labelledby=\"" + escapeXml([title.id, alt.id].join(" ").trim()) + "\"" : "";
|
|
306
|
+
qrSvg += ">";
|
|
307
|
+
qrSvg += title.text ? "<title id=\"" + escapeXml(title.id) + "\">" + escapeXml(title.text) + "</title>" : "";
|
|
308
|
+
qrSvg += alt.text ? "<description id=\"" + escapeXml(alt.id) + "\">" + escapeXml(alt.text) + "</description>" : "";
|
|
309
|
+
qrSvg += "<rect width=\"100%\" height=\"100%\" fill=\"white\" cx=\"0\" cy=\"0\"/>";
|
|
310
|
+
qrSvg += "<path d=\"";
|
|
311
|
+
for (r = 0; r < _this.getModuleCount(); r += 1) {
|
|
312
|
+
mr = r * cellSize + margin;
|
|
313
|
+
for (c = 0; c < _this.getModuleCount(); c += 1) if (_this.isDark(r, c)) {
|
|
314
|
+
mc = c * cellSize + margin;
|
|
315
|
+
qrSvg += "M" + mc + "," + mr + rect;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
qrSvg += "\" stroke=\"transparent\" fill=\"black\"/>";
|
|
319
|
+
qrSvg += "</svg>";
|
|
320
|
+
return qrSvg;
|
|
321
|
+
};
|
|
322
|
+
_this.createDataURL = function(cellSize, margin) {
|
|
323
|
+
cellSize = cellSize || 2;
|
|
324
|
+
margin = typeof margin == "undefined" ? cellSize * 4 : margin;
|
|
325
|
+
const size = _this.getModuleCount() * cellSize + margin * 2;
|
|
326
|
+
const min = margin;
|
|
327
|
+
const max = size - margin;
|
|
328
|
+
return createDataURL(size, size, function(x, y) {
|
|
329
|
+
if (min <= x && x < max && min <= y && y < max) {
|
|
330
|
+
const c = Math.floor((x - min) / cellSize);
|
|
331
|
+
const r = Math.floor((y - min) / cellSize);
|
|
332
|
+
return _this.isDark(r, c) ? 0 : 1;
|
|
333
|
+
} else return 1;
|
|
334
|
+
});
|
|
335
|
+
};
|
|
336
|
+
_this.createImgTag = function(cellSize, margin, alt) {
|
|
337
|
+
cellSize = cellSize || 2;
|
|
338
|
+
margin = typeof margin == "undefined" ? cellSize * 4 : margin;
|
|
339
|
+
const size = _this.getModuleCount() * cellSize + margin * 2;
|
|
340
|
+
let img = "";
|
|
341
|
+
img += "<img";
|
|
342
|
+
img += " src=\"";
|
|
343
|
+
img += _this.createDataURL(cellSize, margin);
|
|
344
|
+
img += "\"";
|
|
345
|
+
img += " width=\"";
|
|
346
|
+
img += size;
|
|
347
|
+
img += "\"";
|
|
348
|
+
img += " height=\"";
|
|
349
|
+
img += size;
|
|
350
|
+
img += "\"";
|
|
351
|
+
if (alt) {
|
|
352
|
+
img += " alt=\"";
|
|
353
|
+
img += escapeXml(alt);
|
|
354
|
+
img += "\"";
|
|
355
|
+
}
|
|
356
|
+
img += "/>";
|
|
357
|
+
return img;
|
|
358
|
+
};
|
|
359
|
+
const escapeXml = function(s) {
|
|
360
|
+
let escaped = "";
|
|
361
|
+
for (let i = 0; i < s.length; i += 1) {
|
|
362
|
+
const c = s.charAt(i);
|
|
363
|
+
switch (c) {
|
|
364
|
+
case "<":
|
|
365
|
+
escaped += "<";
|
|
366
|
+
break;
|
|
367
|
+
case ">":
|
|
368
|
+
escaped += ">";
|
|
369
|
+
break;
|
|
370
|
+
case "&":
|
|
371
|
+
escaped += "&";
|
|
372
|
+
break;
|
|
373
|
+
case "\"":
|
|
374
|
+
escaped += """;
|
|
375
|
+
break;
|
|
376
|
+
default: escaped += c;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return escaped;
|
|
380
|
+
};
|
|
381
|
+
const _createHalfASCII = function(margin) {
|
|
382
|
+
const cellSize = 1;
|
|
383
|
+
margin = typeof margin == "undefined" ? 2 : margin;
|
|
384
|
+
const size = _this.getModuleCount() * cellSize + margin * 2;
|
|
385
|
+
const min = margin;
|
|
386
|
+
const max = size - margin;
|
|
387
|
+
let y, x, r1, r2, p;
|
|
388
|
+
const blocks = {
|
|
389
|
+
"██": "█",
|
|
390
|
+
"█ ": "▀",
|
|
391
|
+
" █": "▄",
|
|
392
|
+
" ": " "
|
|
393
|
+
};
|
|
394
|
+
const blocksLastLineNoMargin = {
|
|
395
|
+
"██": "▀",
|
|
396
|
+
"█ ": "▀",
|
|
397
|
+
" █": " ",
|
|
398
|
+
" ": " "
|
|
399
|
+
};
|
|
400
|
+
let ascii = "";
|
|
401
|
+
for (y = 0; y < size; y += 2) {
|
|
402
|
+
r1 = Math.floor((y - min) / cellSize);
|
|
403
|
+
r2 = Math.floor((y + 1 - min) / cellSize);
|
|
404
|
+
for (x = 0; x < size; x += 1) {
|
|
405
|
+
p = "█";
|
|
406
|
+
if (min <= x && x < max && min <= y && y < max && _this.isDark(r1, Math.floor((x - min) / cellSize))) p = " ";
|
|
407
|
+
if (min <= x && x < max && min <= y + 1 && y + 1 < max && _this.isDark(r2, Math.floor((x - min) / cellSize))) p += " ";
|
|
408
|
+
else p += "█";
|
|
409
|
+
ascii += margin < 1 && y + 1 >= max ? blocksLastLineNoMargin[p] : blocks[p];
|
|
410
|
+
}
|
|
411
|
+
ascii += "\n";
|
|
412
|
+
}
|
|
413
|
+
if (size % 2 && margin > 0) return ascii.substring(0, ascii.length - size - 1) + Array(size + 1).join("▀");
|
|
414
|
+
return ascii.substring(0, ascii.length - 1);
|
|
415
|
+
};
|
|
416
|
+
_this.createASCII = function(cellSize, margin) {
|
|
417
|
+
cellSize = cellSize || 1;
|
|
418
|
+
if (cellSize < 2) return _createHalfASCII(margin);
|
|
419
|
+
cellSize -= 1;
|
|
420
|
+
margin = typeof margin == "undefined" ? cellSize * 2 : margin;
|
|
421
|
+
const size = _this.getModuleCount() * cellSize + margin * 2;
|
|
422
|
+
const min = margin;
|
|
423
|
+
const max = size - margin;
|
|
424
|
+
let y, x, r, p;
|
|
425
|
+
const white = Array(cellSize + 1).join("██");
|
|
426
|
+
const black = Array(cellSize + 1).join(" ");
|
|
427
|
+
let ascii = "";
|
|
428
|
+
let line = "";
|
|
429
|
+
for (y = 0; y < size; y += 1) {
|
|
430
|
+
r = Math.floor((y - min) / cellSize);
|
|
431
|
+
line = "";
|
|
432
|
+
for (x = 0; x < size; x += 1) {
|
|
433
|
+
p = 1;
|
|
434
|
+
if (min <= x && x < max && min <= y && y < max && _this.isDark(r, Math.floor((x - min) / cellSize))) p = 0;
|
|
435
|
+
line += p ? white : black;
|
|
436
|
+
}
|
|
437
|
+
for (r = 0; r < cellSize; r += 1) ascii += line + "\n";
|
|
438
|
+
}
|
|
439
|
+
return ascii.substring(0, ascii.length - 1);
|
|
440
|
+
};
|
|
441
|
+
_this.renderTo2dContext = function(context, cellSize) {
|
|
442
|
+
cellSize = cellSize || 2;
|
|
443
|
+
const length = _this.getModuleCount();
|
|
444
|
+
for (let row = 0; row < length; row++) for (let col = 0; col < length; col++) {
|
|
445
|
+
context.fillStyle = _this.isDark(row, col) ? "black" : "white";
|
|
446
|
+
context.fillRect(col * cellSize, row * cellSize, cellSize, cellSize);
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
return _this;
|
|
450
|
+
};
|
|
451
|
+
qrcode.stringToBytes = function(s) {
|
|
452
|
+
const bytes = [];
|
|
453
|
+
for (let i = 0; i < s.length; i += 1) {
|
|
454
|
+
const c = s.charCodeAt(i);
|
|
455
|
+
bytes.push(c & 255);
|
|
456
|
+
}
|
|
457
|
+
return bytes;
|
|
458
|
+
};
|
|
459
|
+
/**
|
|
460
|
+
* @param unicodeData base64 string of byte array.
|
|
461
|
+
* [16bit Unicode],[16bit Bytes], ...
|
|
462
|
+
* @param numChars
|
|
463
|
+
*/
|
|
464
|
+
qrcode.createStringToBytes = function(unicodeData, numChars) {
|
|
465
|
+
const unicodeMap = function() {
|
|
466
|
+
const bin = base64DecodeInputStream(unicodeData);
|
|
467
|
+
const read = function() {
|
|
468
|
+
const b = bin.read();
|
|
469
|
+
if (b == -1) throw "eof";
|
|
470
|
+
return b;
|
|
471
|
+
};
|
|
472
|
+
let count = 0;
|
|
473
|
+
const unicodeMap = {};
|
|
474
|
+
while (true) {
|
|
475
|
+
const b0 = bin.read();
|
|
476
|
+
if (b0 == -1) break;
|
|
477
|
+
const b1 = read();
|
|
478
|
+
const b2 = read();
|
|
479
|
+
const b3 = read();
|
|
480
|
+
const k = String.fromCharCode(b0 << 8 | b1);
|
|
481
|
+
unicodeMap[k] = b2 << 8 | b3;
|
|
482
|
+
count += 1;
|
|
483
|
+
}
|
|
484
|
+
if (count != numChars) throw count + " != " + numChars;
|
|
485
|
+
return unicodeMap;
|
|
486
|
+
}();
|
|
487
|
+
const unknownChar = "?".charCodeAt(0);
|
|
488
|
+
return function(s) {
|
|
489
|
+
const bytes = [];
|
|
490
|
+
for (let i = 0; i < s.length; i += 1) {
|
|
491
|
+
const c = s.charCodeAt(i);
|
|
492
|
+
if (c < 128) bytes.push(c);
|
|
493
|
+
else {
|
|
494
|
+
const b = unicodeMap[s.charAt(i)];
|
|
495
|
+
if (typeof b == "number") {
|
|
496
|
+
if ((b & 255) == b) bytes.push(b);
|
|
497
|
+
else {
|
|
498
|
+
bytes.push(b >>> 8);
|
|
499
|
+
bytes.push(b & 255);
|
|
500
|
+
}
|
|
501
|
+
} else bytes.push(unknownChar);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
return bytes;
|
|
505
|
+
};
|
|
506
|
+
};
|
|
507
|
+
const QRMode = {
|
|
508
|
+
MODE_NUMBER: 1,
|
|
509
|
+
MODE_ALPHA_NUM: 2,
|
|
510
|
+
MODE_8BIT_BYTE: 4,
|
|
511
|
+
MODE_KANJI: 8
|
|
512
|
+
};
|
|
513
|
+
const QRErrorCorrectionLevel = {
|
|
514
|
+
L: 1,
|
|
515
|
+
M: 0,
|
|
516
|
+
Q: 3,
|
|
517
|
+
H: 2
|
|
518
|
+
};
|
|
519
|
+
const QRMaskPattern = {
|
|
520
|
+
PATTERN000: 0,
|
|
521
|
+
PATTERN001: 1,
|
|
522
|
+
PATTERN010: 2,
|
|
523
|
+
PATTERN011: 3,
|
|
524
|
+
PATTERN100: 4,
|
|
525
|
+
PATTERN101: 5,
|
|
526
|
+
PATTERN110: 6,
|
|
527
|
+
PATTERN111: 7
|
|
528
|
+
};
|
|
529
|
+
const QRUtil = function() {
|
|
530
|
+
const PATTERN_POSITION_TABLE = [
|
|
531
|
+
[],
|
|
532
|
+
[6, 18],
|
|
533
|
+
[6, 22],
|
|
534
|
+
[6, 26],
|
|
535
|
+
[6, 30],
|
|
536
|
+
[6, 34],
|
|
537
|
+
[
|
|
538
|
+
6,
|
|
539
|
+
22,
|
|
540
|
+
38
|
|
541
|
+
],
|
|
542
|
+
[
|
|
543
|
+
6,
|
|
544
|
+
24,
|
|
545
|
+
42
|
|
546
|
+
],
|
|
547
|
+
[
|
|
548
|
+
6,
|
|
549
|
+
26,
|
|
550
|
+
46
|
|
551
|
+
],
|
|
552
|
+
[
|
|
553
|
+
6,
|
|
554
|
+
28,
|
|
555
|
+
50
|
|
556
|
+
],
|
|
557
|
+
[
|
|
558
|
+
6,
|
|
559
|
+
30,
|
|
560
|
+
54
|
|
561
|
+
],
|
|
562
|
+
[
|
|
563
|
+
6,
|
|
564
|
+
32,
|
|
565
|
+
58
|
|
566
|
+
],
|
|
567
|
+
[
|
|
568
|
+
6,
|
|
569
|
+
34,
|
|
570
|
+
62
|
|
571
|
+
],
|
|
572
|
+
[
|
|
573
|
+
6,
|
|
574
|
+
26,
|
|
575
|
+
46,
|
|
576
|
+
66
|
|
577
|
+
],
|
|
578
|
+
[
|
|
579
|
+
6,
|
|
580
|
+
26,
|
|
581
|
+
48,
|
|
582
|
+
70
|
|
583
|
+
],
|
|
584
|
+
[
|
|
585
|
+
6,
|
|
586
|
+
26,
|
|
587
|
+
50,
|
|
588
|
+
74
|
|
589
|
+
],
|
|
590
|
+
[
|
|
591
|
+
6,
|
|
592
|
+
30,
|
|
593
|
+
54,
|
|
594
|
+
78
|
|
595
|
+
],
|
|
596
|
+
[
|
|
597
|
+
6,
|
|
598
|
+
30,
|
|
599
|
+
56,
|
|
600
|
+
82
|
|
601
|
+
],
|
|
602
|
+
[
|
|
603
|
+
6,
|
|
604
|
+
30,
|
|
605
|
+
58,
|
|
606
|
+
86
|
|
607
|
+
],
|
|
608
|
+
[
|
|
609
|
+
6,
|
|
610
|
+
34,
|
|
611
|
+
62,
|
|
612
|
+
90
|
|
613
|
+
],
|
|
614
|
+
[
|
|
615
|
+
6,
|
|
616
|
+
28,
|
|
617
|
+
50,
|
|
618
|
+
72,
|
|
619
|
+
94
|
|
620
|
+
],
|
|
621
|
+
[
|
|
622
|
+
6,
|
|
623
|
+
26,
|
|
624
|
+
50,
|
|
625
|
+
74,
|
|
626
|
+
98
|
|
627
|
+
],
|
|
628
|
+
[
|
|
629
|
+
6,
|
|
630
|
+
30,
|
|
631
|
+
54,
|
|
632
|
+
78,
|
|
633
|
+
102
|
|
634
|
+
],
|
|
635
|
+
[
|
|
636
|
+
6,
|
|
637
|
+
28,
|
|
638
|
+
54,
|
|
639
|
+
80,
|
|
640
|
+
106
|
|
641
|
+
],
|
|
642
|
+
[
|
|
643
|
+
6,
|
|
644
|
+
32,
|
|
645
|
+
58,
|
|
646
|
+
84,
|
|
647
|
+
110
|
|
648
|
+
],
|
|
649
|
+
[
|
|
650
|
+
6,
|
|
651
|
+
30,
|
|
652
|
+
58,
|
|
653
|
+
86,
|
|
654
|
+
114
|
|
655
|
+
],
|
|
656
|
+
[
|
|
657
|
+
6,
|
|
658
|
+
34,
|
|
659
|
+
62,
|
|
660
|
+
90,
|
|
661
|
+
118
|
|
662
|
+
],
|
|
663
|
+
[
|
|
664
|
+
6,
|
|
665
|
+
26,
|
|
666
|
+
50,
|
|
667
|
+
74,
|
|
668
|
+
98,
|
|
669
|
+
122
|
|
670
|
+
],
|
|
671
|
+
[
|
|
672
|
+
6,
|
|
673
|
+
30,
|
|
674
|
+
54,
|
|
675
|
+
78,
|
|
676
|
+
102,
|
|
677
|
+
126
|
|
678
|
+
],
|
|
679
|
+
[
|
|
680
|
+
6,
|
|
681
|
+
26,
|
|
682
|
+
52,
|
|
683
|
+
78,
|
|
684
|
+
104,
|
|
685
|
+
130
|
|
686
|
+
],
|
|
687
|
+
[
|
|
688
|
+
6,
|
|
689
|
+
30,
|
|
690
|
+
56,
|
|
691
|
+
82,
|
|
692
|
+
108,
|
|
693
|
+
134
|
|
694
|
+
],
|
|
695
|
+
[
|
|
696
|
+
6,
|
|
697
|
+
34,
|
|
698
|
+
60,
|
|
699
|
+
86,
|
|
700
|
+
112,
|
|
701
|
+
138
|
|
702
|
+
],
|
|
703
|
+
[
|
|
704
|
+
6,
|
|
705
|
+
30,
|
|
706
|
+
58,
|
|
707
|
+
86,
|
|
708
|
+
114,
|
|
709
|
+
142
|
|
710
|
+
],
|
|
711
|
+
[
|
|
712
|
+
6,
|
|
713
|
+
34,
|
|
714
|
+
62,
|
|
715
|
+
90,
|
|
716
|
+
118,
|
|
717
|
+
146
|
|
718
|
+
],
|
|
719
|
+
[
|
|
720
|
+
6,
|
|
721
|
+
30,
|
|
722
|
+
54,
|
|
723
|
+
78,
|
|
724
|
+
102,
|
|
725
|
+
126,
|
|
726
|
+
150
|
|
727
|
+
],
|
|
728
|
+
[
|
|
729
|
+
6,
|
|
730
|
+
24,
|
|
731
|
+
50,
|
|
732
|
+
76,
|
|
733
|
+
102,
|
|
734
|
+
128,
|
|
735
|
+
154
|
|
736
|
+
],
|
|
737
|
+
[
|
|
738
|
+
6,
|
|
739
|
+
28,
|
|
740
|
+
54,
|
|
741
|
+
80,
|
|
742
|
+
106,
|
|
743
|
+
132,
|
|
744
|
+
158
|
|
745
|
+
],
|
|
746
|
+
[
|
|
747
|
+
6,
|
|
748
|
+
32,
|
|
749
|
+
58,
|
|
750
|
+
84,
|
|
751
|
+
110,
|
|
752
|
+
136,
|
|
753
|
+
162
|
|
754
|
+
],
|
|
755
|
+
[
|
|
756
|
+
6,
|
|
757
|
+
26,
|
|
758
|
+
54,
|
|
759
|
+
82,
|
|
760
|
+
110,
|
|
761
|
+
138,
|
|
762
|
+
166
|
|
763
|
+
],
|
|
764
|
+
[
|
|
765
|
+
6,
|
|
766
|
+
30,
|
|
767
|
+
58,
|
|
768
|
+
86,
|
|
769
|
+
114,
|
|
770
|
+
142,
|
|
771
|
+
170
|
|
772
|
+
]
|
|
773
|
+
];
|
|
774
|
+
const G15 = 1335;
|
|
775
|
+
const G18 = 7973;
|
|
776
|
+
const G15_MASK = 21522;
|
|
777
|
+
const _this = {};
|
|
778
|
+
const getBCHDigit = function(data) {
|
|
779
|
+
let digit = 0;
|
|
780
|
+
while (data != 0) {
|
|
781
|
+
digit += 1;
|
|
782
|
+
data >>>= 1;
|
|
783
|
+
}
|
|
784
|
+
return digit;
|
|
785
|
+
};
|
|
786
|
+
_this.getBCHTypeInfo = function(data) {
|
|
787
|
+
let d = data << 10;
|
|
788
|
+
while (getBCHDigit(d) - getBCHDigit(G15) >= 0) d ^= G15 << getBCHDigit(d) - getBCHDigit(G15);
|
|
789
|
+
return (data << 10 | d) ^ G15_MASK;
|
|
790
|
+
};
|
|
791
|
+
_this.getBCHTypeNumber = function(data) {
|
|
792
|
+
let d = data << 12;
|
|
793
|
+
while (getBCHDigit(d) - getBCHDigit(G18) >= 0) d ^= G18 << getBCHDigit(d) - getBCHDigit(G18);
|
|
794
|
+
return data << 12 | d;
|
|
795
|
+
};
|
|
796
|
+
_this.getPatternPosition = function(typeNumber) {
|
|
797
|
+
return PATTERN_POSITION_TABLE[typeNumber - 1];
|
|
798
|
+
};
|
|
799
|
+
_this.getMaskFunction = function(maskPattern) {
|
|
800
|
+
switch (maskPattern) {
|
|
801
|
+
case QRMaskPattern.PATTERN000: return function(i, j) {
|
|
802
|
+
return (i + j) % 2 == 0;
|
|
803
|
+
};
|
|
804
|
+
case QRMaskPattern.PATTERN001: return function(i, j) {
|
|
805
|
+
return i % 2 == 0;
|
|
806
|
+
};
|
|
807
|
+
case QRMaskPattern.PATTERN010: return function(i, j) {
|
|
808
|
+
return j % 3 == 0;
|
|
809
|
+
};
|
|
810
|
+
case QRMaskPattern.PATTERN011: return function(i, j) {
|
|
811
|
+
return (i + j) % 3 == 0;
|
|
812
|
+
};
|
|
813
|
+
case QRMaskPattern.PATTERN100: return function(i, j) {
|
|
814
|
+
return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0;
|
|
815
|
+
};
|
|
816
|
+
case QRMaskPattern.PATTERN101: return function(i, j) {
|
|
817
|
+
return i * j % 2 + i * j % 3 == 0;
|
|
818
|
+
};
|
|
819
|
+
case QRMaskPattern.PATTERN110: return function(i, j) {
|
|
820
|
+
return (i * j % 2 + i * j % 3) % 2 == 0;
|
|
821
|
+
};
|
|
822
|
+
case QRMaskPattern.PATTERN111: return function(i, j) {
|
|
823
|
+
return (i * j % 3 + (i + j) % 2) % 2 == 0;
|
|
824
|
+
};
|
|
825
|
+
default: throw "bad maskPattern:" + maskPattern;
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
_this.getErrorCorrectPolynomial = function(errorCorrectLength) {
|
|
829
|
+
let a = qrPolynomial([1], 0);
|
|
830
|
+
for (let i = 0; i < errorCorrectLength; i += 1) a = a.multiply(qrPolynomial([1, QRMath.gexp(i)], 0));
|
|
831
|
+
return a;
|
|
832
|
+
};
|
|
833
|
+
_this.getLengthInBits = function(mode, type) {
|
|
834
|
+
if (1 <= type && type < 10) switch (mode) {
|
|
835
|
+
case QRMode.MODE_NUMBER: return 10;
|
|
836
|
+
case QRMode.MODE_ALPHA_NUM: return 9;
|
|
837
|
+
case QRMode.MODE_8BIT_BYTE: return 8;
|
|
838
|
+
case QRMode.MODE_KANJI: return 8;
|
|
839
|
+
default: throw "mode:" + mode;
|
|
840
|
+
}
|
|
841
|
+
else if (type < 27) switch (mode) {
|
|
842
|
+
case QRMode.MODE_NUMBER: return 12;
|
|
843
|
+
case QRMode.MODE_ALPHA_NUM: return 11;
|
|
844
|
+
case QRMode.MODE_8BIT_BYTE: return 16;
|
|
845
|
+
case QRMode.MODE_KANJI: return 10;
|
|
846
|
+
default: throw "mode:" + mode;
|
|
847
|
+
}
|
|
848
|
+
else if (type < 41) switch (mode) {
|
|
849
|
+
case QRMode.MODE_NUMBER: return 14;
|
|
850
|
+
case QRMode.MODE_ALPHA_NUM: return 13;
|
|
851
|
+
case QRMode.MODE_8BIT_BYTE: return 16;
|
|
852
|
+
case QRMode.MODE_KANJI: return 12;
|
|
853
|
+
default: throw "mode:" + mode;
|
|
854
|
+
}
|
|
855
|
+
else throw "type:" + type;
|
|
856
|
+
};
|
|
857
|
+
_this.getLostPoint = function(qrcode) {
|
|
858
|
+
const moduleCount = qrcode.getModuleCount();
|
|
859
|
+
let lostPoint = 0;
|
|
860
|
+
for (let row = 0; row < moduleCount; row += 1) for (let col = 0; col < moduleCount; col += 1) {
|
|
861
|
+
let sameCount = 0;
|
|
862
|
+
const dark = qrcode.isDark(row, col);
|
|
863
|
+
for (let r = -1; r <= 1; r += 1) {
|
|
864
|
+
if (row + r < 0 || moduleCount <= row + r) continue;
|
|
865
|
+
for (let c = -1; c <= 1; c += 1) {
|
|
866
|
+
if (col + c < 0 || moduleCount <= col + c) continue;
|
|
867
|
+
if (r == 0 && c == 0) continue;
|
|
868
|
+
if (dark == qrcode.isDark(row + r, col + c)) sameCount += 1;
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
if (sameCount > 5) lostPoint += 3 + sameCount - 5;
|
|
872
|
+
}
|
|
873
|
+
for (let row = 0; row < moduleCount - 1; row += 1) for (let col = 0; col < moduleCount - 1; col += 1) {
|
|
874
|
+
let count = 0;
|
|
875
|
+
if (qrcode.isDark(row, col)) count += 1;
|
|
876
|
+
if (qrcode.isDark(row + 1, col)) count += 1;
|
|
877
|
+
if (qrcode.isDark(row, col + 1)) count += 1;
|
|
878
|
+
if (qrcode.isDark(row + 1, col + 1)) count += 1;
|
|
879
|
+
if (count == 0 || count == 4) lostPoint += 3;
|
|
880
|
+
}
|
|
881
|
+
for (let row = 0; row < moduleCount; row += 1) for (let col = 0; col < moduleCount - 6; col += 1) if (qrcode.isDark(row, col) && !qrcode.isDark(row, col + 1) && qrcode.isDark(row, col + 2) && qrcode.isDark(row, col + 3) && qrcode.isDark(row, col + 4) && !qrcode.isDark(row, col + 5) && qrcode.isDark(row, col + 6)) lostPoint += 40;
|
|
882
|
+
for (let col = 0; col < moduleCount; col += 1) for (let row = 0; row < moduleCount - 6; row += 1) if (qrcode.isDark(row, col) && !qrcode.isDark(row + 1, col) && qrcode.isDark(row + 2, col) && qrcode.isDark(row + 3, col) && qrcode.isDark(row + 4, col) && !qrcode.isDark(row + 5, col) && qrcode.isDark(row + 6, col)) lostPoint += 40;
|
|
883
|
+
let darkCount = 0;
|
|
884
|
+
for (let col = 0; col < moduleCount; col += 1) for (let row = 0; row < moduleCount; row += 1) if (qrcode.isDark(row, col)) darkCount += 1;
|
|
885
|
+
const ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
|
|
886
|
+
lostPoint += ratio * 10;
|
|
887
|
+
return lostPoint;
|
|
888
|
+
};
|
|
889
|
+
return _this;
|
|
890
|
+
}();
|
|
891
|
+
const QRMath = function() {
|
|
892
|
+
const EXP_TABLE = new Array(256);
|
|
893
|
+
const LOG_TABLE = new Array(256);
|
|
894
|
+
for (let i = 0; i < 8; i += 1) EXP_TABLE[i] = 1 << i;
|
|
895
|
+
for (let i = 8; i < 256; i += 1) EXP_TABLE[i] = EXP_TABLE[i - 4] ^ EXP_TABLE[i - 5] ^ EXP_TABLE[i - 6] ^ EXP_TABLE[i - 8];
|
|
896
|
+
for (let i = 0; i < 255; i += 1) LOG_TABLE[EXP_TABLE[i]] = i;
|
|
897
|
+
const _this = {};
|
|
898
|
+
_this.glog = function(n) {
|
|
899
|
+
if (n < 1) throw "glog(" + n + ")";
|
|
900
|
+
return LOG_TABLE[n];
|
|
901
|
+
};
|
|
902
|
+
_this.gexp = function(n) {
|
|
903
|
+
while (n < 0) n += 255;
|
|
904
|
+
while (n >= 256) n -= 255;
|
|
905
|
+
return EXP_TABLE[n];
|
|
906
|
+
};
|
|
907
|
+
return _this;
|
|
908
|
+
}();
|
|
909
|
+
const qrPolynomial = function(num, shift) {
|
|
910
|
+
if (typeof num.length == "undefined") throw num.length + "/" + shift;
|
|
911
|
+
const _num = function() {
|
|
912
|
+
let offset = 0;
|
|
913
|
+
while (offset < num.length && num[offset] == 0) offset += 1;
|
|
914
|
+
const _num = new Array(num.length - offset + shift);
|
|
915
|
+
for (let i = 0; i < num.length - offset; i += 1) _num[i] = num[i + offset];
|
|
916
|
+
return _num;
|
|
917
|
+
}();
|
|
918
|
+
const _this = {};
|
|
919
|
+
_this.getAt = function(index) {
|
|
920
|
+
return _num[index];
|
|
921
|
+
};
|
|
922
|
+
_this.getLength = function() {
|
|
923
|
+
return _num.length;
|
|
924
|
+
};
|
|
925
|
+
_this.multiply = function(e) {
|
|
926
|
+
const num = new Array(_this.getLength() + e.getLength() - 1);
|
|
927
|
+
for (let i = 0; i < _this.getLength(); i += 1) for (let j = 0; j < e.getLength(); j += 1) num[i + j] ^= QRMath.gexp(QRMath.glog(_this.getAt(i)) + QRMath.glog(e.getAt(j)));
|
|
928
|
+
return qrPolynomial(num, 0);
|
|
929
|
+
};
|
|
930
|
+
_this.mod = function(e) {
|
|
931
|
+
if (_this.getLength() - e.getLength() < 0) return _this;
|
|
932
|
+
const ratio = QRMath.glog(_this.getAt(0)) - QRMath.glog(e.getAt(0));
|
|
933
|
+
const num = new Array(_this.getLength());
|
|
934
|
+
for (let i = 0; i < _this.getLength(); i += 1) num[i] = _this.getAt(i);
|
|
935
|
+
for (let i = 0; i < e.getLength(); i += 1) num[i] ^= QRMath.gexp(QRMath.glog(e.getAt(i)) + ratio);
|
|
936
|
+
return qrPolynomial(num, 0).mod(e);
|
|
937
|
+
};
|
|
938
|
+
return _this;
|
|
939
|
+
};
|
|
940
|
+
const QRRSBlock = function() {
|
|
941
|
+
const RS_BLOCK_TABLE = [
|
|
942
|
+
[
|
|
943
|
+
1,
|
|
944
|
+
26,
|
|
945
|
+
19
|
|
946
|
+
],
|
|
947
|
+
[
|
|
948
|
+
1,
|
|
949
|
+
26,
|
|
950
|
+
16
|
|
951
|
+
],
|
|
952
|
+
[
|
|
953
|
+
1,
|
|
954
|
+
26,
|
|
955
|
+
13
|
|
956
|
+
],
|
|
957
|
+
[
|
|
958
|
+
1,
|
|
959
|
+
26,
|
|
960
|
+
9
|
|
961
|
+
],
|
|
962
|
+
[
|
|
963
|
+
1,
|
|
964
|
+
44,
|
|
965
|
+
34
|
|
966
|
+
],
|
|
967
|
+
[
|
|
968
|
+
1,
|
|
969
|
+
44,
|
|
970
|
+
28
|
|
971
|
+
],
|
|
972
|
+
[
|
|
973
|
+
1,
|
|
974
|
+
44,
|
|
975
|
+
22
|
|
976
|
+
],
|
|
977
|
+
[
|
|
978
|
+
1,
|
|
979
|
+
44,
|
|
980
|
+
16
|
|
981
|
+
],
|
|
982
|
+
[
|
|
983
|
+
1,
|
|
984
|
+
70,
|
|
985
|
+
55
|
|
986
|
+
],
|
|
987
|
+
[
|
|
988
|
+
1,
|
|
989
|
+
70,
|
|
990
|
+
44
|
|
991
|
+
],
|
|
992
|
+
[
|
|
993
|
+
2,
|
|
994
|
+
35,
|
|
995
|
+
17
|
|
996
|
+
],
|
|
997
|
+
[
|
|
998
|
+
2,
|
|
999
|
+
35,
|
|
1000
|
+
13
|
|
1001
|
+
],
|
|
1002
|
+
[
|
|
1003
|
+
1,
|
|
1004
|
+
100,
|
|
1005
|
+
80
|
|
1006
|
+
],
|
|
1007
|
+
[
|
|
1008
|
+
2,
|
|
1009
|
+
50,
|
|
1010
|
+
32
|
|
1011
|
+
],
|
|
1012
|
+
[
|
|
1013
|
+
2,
|
|
1014
|
+
50,
|
|
1015
|
+
24
|
|
1016
|
+
],
|
|
1017
|
+
[
|
|
1018
|
+
4,
|
|
1019
|
+
25,
|
|
1020
|
+
9
|
|
1021
|
+
],
|
|
1022
|
+
[
|
|
1023
|
+
1,
|
|
1024
|
+
134,
|
|
1025
|
+
108
|
|
1026
|
+
],
|
|
1027
|
+
[
|
|
1028
|
+
2,
|
|
1029
|
+
67,
|
|
1030
|
+
43
|
|
1031
|
+
],
|
|
1032
|
+
[
|
|
1033
|
+
2,
|
|
1034
|
+
33,
|
|
1035
|
+
15,
|
|
1036
|
+
2,
|
|
1037
|
+
34,
|
|
1038
|
+
16
|
|
1039
|
+
],
|
|
1040
|
+
[
|
|
1041
|
+
2,
|
|
1042
|
+
33,
|
|
1043
|
+
11,
|
|
1044
|
+
2,
|
|
1045
|
+
34,
|
|
1046
|
+
12
|
|
1047
|
+
],
|
|
1048
|
+
[
|
|
1049
|
+
2,
|
|
1050
|
+
86,
|
|
1051
|
+
68
|
|
1052
|
+
],
|
|
1053
|
+
[
|
|
1054
|
+
4,
|
|
1055
|
+
43,
|
|
1056
|
+
27
|
|
1057
|
+
],
|
|
1058
|
+
[
|
|
1059
|
+
4,
|
|
1060
|
+
43,
|
|
1061
|
+
19
|
|
1062
|
+
],
|
|
1063
|
+
[
|
|
1064
|
+
4,
|
|
1065
|
+
43,
|
|
1066
|
+
15
|
|
1067
|
+
],
|
|
1068
|
+
[
|
|
1069
|
+
2,
|
|
1070
|
+
98,
|
|
1071
|
+
78
|
|
1072
|
+
],
|
|
1073
|
+
[
|
|
1074
|
+
4,
|
|
1075
|
+
49,
|
|
1076
|
+
31
|
|
1077
|
+
],
|
|
1078
|
+
[
|
|
1079
|
+
2,
|
|
1080
|
+
32,
|
|
1081
|
+
14,
|
|
1082
|
+
4,
|
|
1083
|
+
33,
|
|
1084
|
+
15
|
|
1085
|
+
],
|
|
1086
|
+
[
|
|
1087
|
+
4,
|
|
1088
|
+
39,
|
|
1089
|
+
13,
|
|
1090
|
+
1,
|
|
1091
|
+
40,
|
|
1092
|
+
14
|
|
1093
|
+
],
|
|
1094
|
+
[
|
|
1095
|
+
2,
|
|
1096
|
+
121,
|
|
1097
|
+
97
|
|
1098
|
+
],
|
|
1099
|
+
[
|
|
1100
|
+
2,
|
|
1101
|
+
60,
|
|
1102
|
+
38,
|
|
1103
|
+
2,
|
|
1104
|
+
61,
|
|
1105
|
+
39
|
|
1106
|
+
],
|
|
1107
|
+
[
|
|
1108
|
+
4,
|
|
1109
|
+
40,
|
|
1110
|
+
18,
|
|
1111
|
+
2,
|
|
1112
|
+
41,
|
|
1113
|
+
19
|
|
1114
|
+
],
|
|
1115
|
+
[
|
|
1116
|
+
4,
|
|
1117
|
+
40,
|
|
1118
|
+
14,
|
|
1119
|
+
2,
|
|
1120
|
+
41,
|
|
1121
|
+
15
|
|
1122
|
+
],
|
|
1123
|
+
[
|
|
1124
|
+
2,
|
|
1125
|
+
146,
|
|
1126
|
+
116
|
|
1127
|
+
],
|
|
1128
|
+
[
|
|
1129
|
+
3,
|
|
1130
|
+
58,
|
|
1131
|
+
36,
|
|
1132
|
+
2,
|
|
1133
|
+
59,
|
|
1134
|
+
37
|
|
1135
|
+
],
|
|
1136
|
+
[
|
|
1137
|
+
4,
|
|
1138
|
+
36,
|
|
1139
|
+
16,
|
|
1140
|
+
4,
|
|
1141
|
+
37,
|
|
1142
|
+
17
|
|
1143
|
+
],
|
|
1144
|
+
[
|
|
1145
|
+
4,
|
|
1146
|
+
36,
|
|
1147
|
+
12,
|
|
1148
|
+
4,
|
|
1149
|
+
37,
|
|
1150
|
+
13
|
|
1151
|
+
],
|
|
1152
|
+
[
|
|
1153
|
+
2,
|
|
1154
|
+
86,
|
|
1155
|
+
68,
|
|
1156
|
+
2,
|
|
1157
|
+
87,
|
|
1158
|
+
69
|
|
1159
|
+
],
|
|
1160
|
+
[
|
|
1161
|
+
4,
|
|
1162
|
+
69,
|
|
1163
|
+
43,
|
|
1164
|
+
1,
|
|
1165
|
+
70,
|
|
1166
|
+
44
|
|
1167
|
+
],
|
|
1168
|
+
[
|
|
1169
|
+
6,
|
|
1170
|
+
43,
|
|
1171
|
+
19,
|
|
1172
|
+
2,
|
|
1173
|
+
44,
|
|
1174
|
+
20
|
|
1175
|
+
],
|
|
1176
|
+
[
|
|
1177
|
+
6,
|
|
1178
|
+
43,
|
|
1179
|
+
15,
|
|
1180
|
+
2,
|
|
1181
|
+
44,
|
|
1182
|
+
16
|
|
1183
|
+
],
|
|
1184
|
+
[
|
|
1185
|
+
4,
|
|
1186
|
+
101,
|
|
1187
|
+
81
|
|
1188
|
+
],
|
|
1189
|
+
[
|
|
1190
|
+
1,
|
|
1191
|
+
80,
|
|
1192
|
+
50,
|
|
1193
|
+
4,
|
|
1194
|
+
81,
|
|
1195
|
+
51
|
|
1196
|
+
],
|
|
1197
|
+
[
|
|
1198
|
+
4,
|
|
1199
|
+
50,
|
|
1200
|
+
22,
|
|
1201
|
+
4,
|
|
1202
|
+
51,
|
|
1203
|
+
23
|
|
1204
|
+
],
|
|
1205
|
+
[
|
|
1206
|
+
3,
|
|
1207
|
+
36,
|
|
1208
|
+
12,
|
|
1209
|
+
8,
|
|
1210
|
+
37,
|
|
1211
|
+
13
|
|
1212
|
+
],
|
|
1213
|
+
[
|
|
1214
|
+
2,
|
|
1215
|
+
116,
|
|
1216
|
+
92,
|
|
1217
|
+
2,
|
|
1218
|
+
117,
|
|
1219
|
+
93
|
|
1220
|
+
],
|
|
1221
|
+
[
|
|
1222
|
+
6,
|
|
1223
|
+
58,
|
|
1224
|
+
36,
|
|
1225
|
+
2,
|
|
1226
|
+
59,
|
|
1227
|
+
37
|
|
1228
|
+
],
|
|
1229
|
+
[
|
|
1230
|
+
4,
|
|
1231
|
+
46,
|
|
1232
|
+
20,
|
|
1233
|
+
6,
|
|
1234
|
+
47,
|
|
1235
|
+
21
|
|
1236
|
+
],
|
|
1237
|
+
[
|
|
1238
|
+
7,
|
|
1239
|
+
42,
|
|
1240
|
+
14,
|
|
1241
|
+
4,
|
|
1242
|
+
43,
|
|
1243
|
+
15
|
|
1244
|
+
],
|
|
1245
|
+
[
|
|
1246
|
+
4,
|
|
1247
|
+
133,
|
|
1248
|
+
107
|
|
1249
|
+
],
|
|
1250
|
+
[
|
|
1251
|
+
8,
|
|
1252
|
+
59,
|
|
1253
|
+
37,
|
|
1254
|
+
1,
|
|
1255
|
+
60,
|
|
1256
|
+
38
|
|
1257
|
+
],
|
|
1258
|
+
[
|
|
1259
|
+
8,
|
|
1260
|
+
44,
|
|
1261
|
+
20,
|
|
1262
|
+
4,
|
|
1263
|
+
45,
|
|
1264
|
+
21
|
|
1265
|
+
],
|
|
1266
|
+
[
|
|
1267
|
+
12,
|
|
1268
|
+
33,
|
|
1269
|
+
11,
|
|
1270
|
+
4,
|
|
1271
|
+
34,
|
|
1272
|
+
12
|
|
1273
|
+
],
|
|
1274
|
+
[
|
|
1275
|
+
3,
|
|
1276
|
+
145,
|
|
1277
|
+
115,
|
|
1278
|
+
1,
|
|
1279
|
+
146,
|
|
1280
|
+
116
|
|
1281
|
+
],
|
|
1282
|
+
[
|
|
1283
|
+
4,
|
|
1284
|
+
64,
|
|
1285
|
+
40,
|
|
1286
|
+
5,
|
|
1287
|
+
65,
|
|
1288
|
+
41
|
|
1289
|
+
],
|
|
1290
|
+
[
|
|
1291
|
+
11,
|
|
1292
|
+
36,
|
|
1293
|
+
16,
|
|
1294
|
+
5,
|
|
1295
|
+
37,
|
|
1296
|
+
17
|
|
1297
|
+
],
|
|
1298
|
+
[
|
|
1299
|
+
11,
|
|
1300
|
+
36,
|
|
1301
|
+
12,
|
|
1302
|
+
5,
|
|
1303
|
+
37,
|
|
1304
|
+
13
|
|
1305
|
+
],
|
|
1306
|
+
[
|
|
1307
|
+
5,
|
|
1308
|
+
109,
|
|
1309
|
+
87,
|
|
1310
|
+
1,
|
|
1311
|
+
110,
|
|
1312
|
+
88
|
|
1313
|
+
],
|
|
1314
|
+
[
|
|
1315
|
+
5,
|
|
1316
|
+
65,
|
|
1317
|
+
41,
|
|
1318
|
+
5,
|
|
1319
|
+
66,
|
|
1320
|
+
42
|
|
1321
|
+
],
|
|
1322
|
+
[
|
|
1323
|
+
5,
|
|
1324
|
+
54,
|
|
1325
|
+
24,
|
|
1326
|
+
7,
|
|
1327
|
+
55,
|
|
1328
|
+
25
|
|
1329
|
+
],
|
|
1330
|
+
[
|
|
1331
|
+
11,
|
|
1332
|
+
36,
|
|
1333
|
+
12,
|
|
1334
|
+
7,
|
|
1335
|
+
37,
|
|
1336
|
+
13
|
|
1337
|
+
],
|
|
1338
|
+
[
|
|
1339
|
+
5,
|
|
1340
|
+
122,
|
|
1341
|
+
98,
|
|
1342
|
+
1,
|
|
1343
|
+
123,
|
|
1344
|
+
99
|
|
1345
|
+
],
|
|
1346
|
+
[
|
|
1347
|
+
7,
|
|
1348
|
+
73,
|
|
1349
|
+
45,
|
|
1350
|
+
3,
|
|
1351
|
+
74,
|
|
1352
|
+
46
|
|
1353
|
+
],
|
|
1354
|
+
[
|
|
1355
|
+
15,
|
|
1356
|
+
43,
|
|
1357
|
+
19,
|
|
1358
|
+
2,
|
|
1359
|
+
44,
|
|
1360
|
+
20
|
|
1361
|
+
],
|
|
1362
|
+
[
|
|
1363
|
+
3,
|
|
1364
|
+
45,
|
|
1365
|
+
15,
|
|
1366
|
+
13,
|
|
1367
|
+
46,
|
|
1368
|
+
16
|
|
1369
|
+
],
|
|
1370
|
+
[
|
|
1371
|
+
1,
|
|
1372
|
+
135,
|
|
1373
|
+
107,
|
|
1374
|
+
5,
|
|
1375
|
+
136,
|
|
1376
|
+
108
|
|
1377
|
+
],
|
|
1378
|
+
[
|
|
1379
|
+
10,
|
|
1380
|
+
74,
|
|
1381
|
+
46,
|
|
1382
|
+
1,
|
|
1383
|
+
75,
|
|
1384
|
+
47
|
|
1385
|
+
],
|
|
1386
|
+
[
|
|
1387
|
+
1,
|
|
1388
|
+
50,
|
|
1389
|
+
22,
|
|
1390
|
+
15,
|
|
1391
|
+
51,
|
|
1392
|
+
23
|
|
1393
|
+
],
|
|
1394
|
+
[
|
|
1395
|
+
2,
|
|
1396
|
+
42,
|
|
1397
|
+
14,
|
|
1398
|
+
17,
|
|
1399
|
+
43,
|
|
1400
|
+
15
|
|
1401
|
+
],
|
|
1402
|
+
[
|
|
1403
|
+
5,
|
|
1404
|
+
150,
|
|
1405
|
+
120,
|
|
1406
|
+
1,
|
|
1407
|
+
151,
|
|
1408
|
+
121
|
|
1409
|
+
],
|
|
1410
|
+
[
|
|
1411
|
+
9,
|
|
1412
|
+
69,
|
|
1413
|
+
43,
|
|
1414
|
+
4,
|
|
1415
|
+
70,
|
|
1416
|
+
44
|
|
1417
|
+
],
|
|
1418
|
+
[
|
|
1419
|
+
17,
|
|
1420
|
+
50,
|
|
1421
|
+
22,
|
|
1422
|
+
1,
|
|
1423
|
+
51,
|
|
1424
|
+
23
|
|
1425
|
+
],
|
|
1426
|
+
[
|
|
1427
|
+
2,
|
|
1428
|
+
42,
|
|
1429
|
+
14,
|
|
1430
|
+
19,
|
|
1431
|
+
43,
|
|
1432
|
+
15
|
|
1433
|
+
],
|
|
1434
|
+
[
|
|
1435
|
+
3,
|
|
1436
|
+
141,
|
|
1437
|
+
113,
|
|
1438
|
+
4,
|
|
1439
|
+
142,
|
|
1440
|
+
114
|
|
1441
|
+
],
|
|
1442
|
+
[
|
|
1443
|
+
3,
|
|
1444
|
+
70,
|
|
1445
|
+
44,
|
|
1446
|
+
11,
|
|
1447
|
+
71,
|
|
1448
|
+
45
|
|
1449
|
+
],
|
|
1450
|
+
[
|
|
1451
|
+
17,
|
|
1452
|
+
47,
|
|
1453
|
+
21,
|
|
1454
|
+
4,
|
|
1455
|
+
48,
|
|
1456
|
+
22
|
|
1457
|
+
],
|
|
1458
|
+
[
|
|
1459
|
+
9,
|
|
1460
|
+
39,
|
|
1461
|
+
13,
|
|
1462
|
+
16,
|
|
1463
|
+
40,
|
|
1464
|
+
14
|
|
1465
|
+
],
|
|
1466
|
+
[
|
|
1467
|
+
3,
|
|
1468
|
+
135,
|
|
1469
|
+
107,
|
|
1470
|
+
5,
|
|
1471
|
+
136,
|
|
1472
|
+
108
|
|
1473
|
+
],
|
|
1474
|
+
[
|
|
1475
|
+
3,
|
|
1476
|
+
67,
|
|
1477
|
+
41,
|
|
1478
|
+
13,
|
|
1479
|
+
68,
|
|
1480
|
+
42
|
|
1481
|
+
],
|
|
1482
|
+
[
|
|
1483
|
+
15,
|
|
1484
|
+
54,
|
|
1485
|
+
24,
|
|
1486
|
+
5,
|
|
1487
|
+
55,
|
|
1488
|
+
25
|
|
1489
|
+
],
|
|
1490
|
+
[
|
|
1491
|
+
15,
|
|
1492
|
+
43,
|
|
1493
|
+
15,
|
|
1494
|
+
10,
|
|
1495
|
+
44,
|
|
1496
|
+
16
|
|
1497
|
+
],
|
|
1498
|
+
[
|
|
1499
|
+
4,
|
|
1500
|
+
144,
|
|
1501
|
+
116,
|
|
1502
|
+
4,
|
|
1503
|
+
145,
|
|
1504
|
+
117
|
|
1505
|
+
],
|
|
1506
|
+
[
|
|
1507
|
+
17,
|
|
1508
|
+
68,
|
|
1509
|
+
42
|
|
1510
|
+
],
|
|
1511
|
+
[
|
|
1512
|
+
17,
|
|
1513
|
+
50,
|
|
1514
|
+
22,
|
|
1515
|
+
6,
|
|
1516
|
+
51,
|
|
1517
|
+
23
|
|
1518
|
+
],
|
|
1519
|
+
[
|
|
1520
|
+
19,
|
|
1521
|
+
46,
|
|
1522
|
+
16,
|
|
1523
|
+
6,
|
|
1524
|
+
47,
|
|
1525
|
+
17
|
|
1526
|
+
],
|
|
1527
|
+
[
|
|
1528
|
+
2,
|
|
1529
|
+
139,
|
|
1530
|
+
111,
|
|
1531
|
+
7,
|
|
1532
|
+
140,
|
|
1533
|
+
112
|
|
1534
|
+
],
|
|
1535
|
+
[
|
|
1536
|
+
17,
|
|
1537
|
+
74,
|
|
1538
|
+
46
|
|
1539
|
+
],
|
|
1540
|
+
[
|
|
1541
|
+
7,
|
|
1542
|
+
54,
|
|
1543
|
+
24,
|
|
1544
|
+
16,
|
|
1545
|
+
55,
|
|
1546
|
+
25
|
|
1547
|
+
],
|
|
1548
|
+
[
|
|
1549
|
+
34,
|
|
1550
|
+
37,
|
|
1551
|
+
13
|
|
1552
|
+
],
|
|
1553
|
+
[
|
|
1554
|
+
4,
|
|
1555
|
+
151,
|
|
1556
|
+
121,
|
|
1557
|
+
5,
|
|
1558
|
+
152,
|
|
1559
|
+
122
|
|
1560
|
+
],
|
|
1561
|
+
[
|
|
1562
|
+
4,
|
|
1563
|
+
75,
|
|
1564
|
+
47,
|
|
1565
|
+
14,
|
|
1566
|
+
76,
|
|
1567
|
+
48
|
|
1568
|
+
],
|
|
1569
|
+
[
|
|
1570
|
+
11,
|
|
1571
|
+
54,
|
|
1572
|
+
24,
|
|
1573
|
+
14,
|
|
1574
|
+
55,
|
|
1575
|
+
25
|
|
1576
|
+
],
|
|
1577
|
+
[
|
|
1578
|
+
16,
|
|
1579
|
+
45,
|
|
1580
|
+
15,
|
|
1581
|
+
14,
|
|
1582
|
+
46,
|
|
1583
|
+
16
|
|
1584
|
+
],
|
|
1585
|
+
[
|
|
1586
|
+
6,
|
|
1587
|
+
147,
|
|
1588
|
+
117,
|
|
1589
|
+
4,
|
|
1590
|
+
148,
|
|
1591
|
+
118
|
|
1592
|
+
],
|
|
1593
|
+
[
|
|
1594
|
+
6,
|
|
1595
|
+
73,
|
|
1596
|
+
45,
|
|
1597
|
+
14,
|
|
1598
|
+
74,
|
|
1599
|
+
46
|
|
1600
|
+
],
|
|
1601
|
+
[
|
|
1602
|
+
11,
|
|
1603
|
+
54,
|
|
1604
|
+
24,
|
|
1605
|
+
16,
|
|
1606
|
+
55,
|
|
1607
|
+
25
|
|
1608
|
+
],
|
|
1609
|
+
[
|
|
1610
|
+
30,
|
|
1611
|
+
46,
|
|
1612
|
+
16,
|
|
1613
|
+
2,
|
|
1614
|
+
47,
|
|
1615
|
+
17
|
|
1616
|
+
],
|
|
1617
|
+
[
|
|
1618
|
+
8,
|
|
1619
|
+
132,
|
|
1620
|
+
106,
|
|
1621
|
+
4,
|
|
1622
|
+
133,
|
|
1623
|
+
107
|
|
1624
|
+
],
|
|
1625
|
+
[
|
|
1626
|
+
8,
|
|
1627
|
+
75,
|
|
1628
|
+
47,
|
|
1629
|
+
13,
|
|
1630
|
+
76,
|
|
1631
|
+
48
|
|
1632
|
+
],
|
|
1633
|
+
[
|
|
1634
|
+
7,
|
|
1635
|
+
54,
|
|
1636
|
+
24,
|
|
1637
|
+
22,
|
|
1638
|
+
55,
|
|
1639
|
+
25
|
|
1640
|
+
],
|
|
1641
|
+
[
|
|
1642
|
+
22,
|
|
1643
|
+
45,
|
|
1644
|
+
15,
|
|
1645
|
+
13,
|
|
1646
|
+
46,
|
|
1647
|
+
16
|
|
1648
|
+
],
|
|
1649
|
+
[
|
|
1650
|
+
10,
|
|
1651
|
+
142,
|
|
1652
|
+
114,
|
|
1653
|
+
2,
|
|
1654
|
+
143,
|
|
1655
|
+
115
|
|
1656
|
+
],
|
|
1657
|
+
[
|
|
1658
|
+
19,
|
|
1659
|
+
74,
|
|
1660
|
+
46,
|
|
1661
|
+
4,
|
|
1662
|
+
75,
|
|
1663
|
+
47
|
|
1664
|
+
],
|
|
1665
|
+
[
|
|
1666
|
+
28,
|
|
1667
|
+
50,
|
|
1668
|
+
22,
|
|
1669
|
+
6,
|
|
1670
|
+
51,
|
|
1671
|
+
23
|
|
1672
|
+
],
|
|
1673
|
+
[
|
|
1674
|
+
33,
|
|
1675
|
+
46,
|
|
1676
|
+
16,
|
|
1677
|
+
4,
|
|
1678
|
+
47,
|
|
1679
|
+
17
|
|
1680
|
+
],
|
|
1681
|
+
[
|
|
1682
|
+
8,
|
|
1683
|
+
152,
|
|
1684
|
+
122,
|
|
1685
|
+
4,
|
|
1686
|
+
153,
|
|
1687
|
+
123
|
|
1688
|
+
],
|
|
1689
|
+
[
|
|
1690
|
+
22,
|
|
1691
|
+
73,
|
|
1692
|
+
45,
|
|
1693
|
+
3,
|
|
1694
|
+
74,
|
|
1695
|
+
46
|
|
1696
|
+
],
|
|
1697
|
+
[
|
|
1698
|
+
8,
|
|
1699
|
+
53,
|
|
1700
|
+
23,
|
|
1701
|
+
26,
|
|
1702
|
+
54,
|
|
1703
|
+
24
|
|
1704
|
+
],
|
|
1705
|
+
[
|
|
1706
|
+
12,
|
|
1707
|
+
45,
|
|
1708
|
+
15,
|
|
1709
|
+
28,
|
|
1710
|
+
46,
|
|
1711
|
+
16
|
|
1712
|
+
],
|
|
1713
|
+
[
|
|
1714
|
+
3,
|
|
1715
|
+
147,
|
|
1716
|
+
117,
|
|
1717
|
+
10,
|
|
1718
|
+
148,
|
|
1719
|
+
118
|
|
1720
|
+
],
|
|
1721
|
+
[
|
|
1722
|
+
3,
|
|
1723
|
+
73,
|
|
1724
|
+
45,
|
|
1725
|
+
23,
|
|
1726
|
+
74,
|
|
1727
|
+
46
|
|
1728
|
+
],
|
|
1729
|
+
[
|
|
1730
|
+
4,
|
|
1731
|
+
54,
|
|
1732
|
+
24,
|
|
1733
|
+
31,
|
|
1734
|
+
55,
|
|
1735
|
+
25
|
|
1736
|
+
],
|
|
1737
|
+
[
|
|
1738
|
+
11,
|
|
1739
|
+
45,
|
|
1740
|
+
15,
|
|
1741
|
+
31,
|
|
1742
|
+
46,
|
|
1743
|
+
16
|
|
1744
|
+
],
|
|
1745
|
+
[
|
|
1746
|
+
7,
|
|
1747
|
+
146,
|
|
1748
|
+
116,
|
|
1749
|
+
7,
|
|
1750
|
+
147,
|
|
1751
|
+
117
|
|
1752
|
+
],
|
|
1753
|
+
[
|
|
1754
|
+
21,
|
|
1755
|
+
73,
|
|
1756
|
+
45,
|
|
1757
|
+
7,
|
|
1758
|
+
74,
|
|
1759
|
+
46
|
|
1760
|
+
],
|
|
1761
|
+
[
|
|
1762
|
+
1,
|
|
1763
|
+
53,
|
|
1764
|
+
23,
|
|
1765
|
+
37,
|
|
1766
|
+
54,
|
|
1767
|
+
24
|
|
1768
|
+
],
|
|
1769
|
+
[
|
|
1770
|
+
19,
|
|
1771
|
+
45,
|
|
1772
|
+
15,
|
|
1773
|
+
26,
|
|
1774
|
+
46,
|
|
1775
|
+
16
|
|
1776
|
+
],
|
|
1777
|
+
[
|
|
1778
|
+
5,
|
|
1779
|
+
145,
|
|
1780
|
+
115,
|
|
1781
|
+
10,
|
|
1782
|
+
146,
|
|
1783
|
+
116
|
|
1784
|
+
],
|
|
1785
|
+
[
|
|
1786
|
+
19,
|
|
1787
|
+
75,
|
|
1788
|
+
47,
|
|
1789
|
+
10,
|
|
1790
|
+
76,
|
|
1791
|
+
48
|
|
1792
|
+
],
|
|
1793
|
+
[
|
|
1794
|
+
15,
|
|
1795
|
+
54,
|
|
1796
|
+
24,
|
|
1797
|
+
25,
|
|
1798
|
+
55,
|
|
1799
|
+
25
|
|
1800
|
+
],
|
|
1801
|
+
[
|
|
1802
|
+
23,
|
|
1803
|
+
45,
|
|
1804
|
+
15,
|
|
1805
|
+
25,
|
|
1806
|
+
46,
|
|
1807
|
+
16
|
|
1808
|
+
],
|
|
1809
|
+
[
|
|
1810
|
+
13,
|
|
1811
|
+
145,
|
|
1812
|
+
115,
|
|
1813
|
+
3,
|
|
1814
|
+
146,
|
|
1815
|
+
116
|
|
1816
|
+
],
|
|
1817
|
+
[
|
|
1818
|
+
2,
|
|
1819
|
+
74,
|
|
1820
|
+
46,
|
|
1821
|
+
29,
|
|
1822
|
+
75,
|
|
1823
|
+
47
|
|
1824
|
+
],
|
|
1825
|
+
[
|
|
1826
|
+
42,
|
|
1827
|
+
54,
|
|
1828
|
+
24,
|
|
1829
|
+
1,
|
|
1830
|
+
55,
|
|
1831
|
+
25
|
|
1832
|
+
],
|
|
1833
|
+
[
|
|
1834
|
+
23,
|
|
1835
|
+
45,
|
|
1836
|
+
15,
|
|
1837
|
+
28,
|
|
1838
|
+
46,
|
|
1839
|
+
16
|
|
1840
|
+
],
|
|
1841
|
+
[
|
|
1842
|
+
17,
|
|
1843
|
+
145,
|
|
1844
|
+
115
|
|
1845
|
+
],
|
|
1846
|
+
[
|
|
1847
|
+
10,
|
|
1848
|
+
74,
|
|
1849
|
+
46,
|
|
1850
|
+
23,
|
|
1851
|
+
75,
|
|
1852
|
+
47
|
|
1853
|
+
],
|
|
1854
|
+
[
|
|
1855
|
+
10,
|
|
1856
|
+
54,
|
|
1857
|
+
24,
|
|
1858
|
+
35,
|
|
1859
|
+
55,
|
|
1860
|
+
25
|
|
1861
|
+
],
|
|
1862
|
+
[
|
|
1863
|
+
19,
|
|
1864
|
+
45,
|
|
1865
|
+
15,
|
|
1866
|
+
35,
|
|
1867
|
+
46,
|
|
1868
|
+
16
|
|
1869
|
+
],
|
|
1870
|
+
[
|
|
1871
|
+
17,
|
|
1872
|
+
145,
|
|
1873
|
+
115,
|
|
1874
|
+
1,
|
|
1875
|
+
146,
|
|
1876
|
+
116
|
|
1877
|
+
],
|
|
1878
|
+
[
|
|
1879
|
+
14,
|
|
1880
|
+
74,
|
|
1881
|
+
46,
|
|
1882
|
+
21,
|
|
1883
|
+
75,
|
|
1884
|
+
47
|
|
1885
|
+
],
|
|
1886
|
+
[
|
|
1887
|
+
29,
|
|
1888
|
+
54,
|
|
1889
|
+
24,
|
|
1890
|
+
19,
|
|
1891
|
+
55,
|
|
1892
|
+
25
|
|
1893
|
+
],
|
|
1894
|
+
[
|
|
1895
|
+
11,
|
|
1896
|
+
45,
|
|
1897
|
+
15,
|
|
1898
|
+
46,
|
|
1899
|
+
46,
|
|
1900
|
+
16
|
|
1901
|
+
],
|
|
1902
|
+
[
|
|
1903
|
+
13,
|
|
1904
|
+
145,
|
|
1905
|
+
115,
|
|
1906
|
+
6,
|
|
1907
|
+
146,
|
|
1908
|
+
116
|
|
1909
|
+
],
|
|
1910
|
+
[
|
|
1911
|
+
14,
|
|
1912
|
+
74,
|
|
1913
|
+
46,
|
|
1914
|
+
23,
|
|
1915
|
+
75,
|
|
1916
|
+
47
|
|
1917
|
+
],
|
|
1918
|
+
[
|
|
1919
|
+
44,
|
|
1920
|
+
54,
|
|
1921
|
+
24,
|
|
1922
|
+
7,
|
|
1923
|
+
55,
|
|
1924
|
+
25
|
|
1925
|
+
],
|
|
1926
|
+
[
|
|
1927
|
+
59,
|
|
1928
|
+
46,
|
|
1929
|
+
16,
|
|
1930
|
+
1,
|
|
1931
|
+
47,
|
|
1932
|
+
17
|
|
1933
|
+
],
|
|
1934
|
+
[
|
|
1935
|
+
12,
|
|
1936
|
+
151,
|
|
1937
|
+
121,
|
|
1938
|
+
7,
|
|
1939
|
+
152,
|
|
1940
|
+
122
|
|
1941
|
+
],
|
|
1942
|
+
[
|
|
1943
|
+
12,
|
|
1944
|
+
75,
|
|
1945
|
+
47,
|
|
1946
|
+
26,
|
|
1947
|
+
76,
|
|
1948
|
+
48
|
|
1949
|
+
],
|
|
1950
|
+
[
|
|
1951
|
+
39,
|
|
1952
|
+
54,
|
|
1953
|
+
24,
|
|
1954
|
+
14,
|
|
1955
|
+
55,
|
|
1956
|
+
25
|
|
1957
|
+
],
|
|
1958
|
+
[
|
|
1959
|
+
22,
|
|
1960
|
+
45,
|
|
1961
|
+
15,
|
|
1962
|
+
41,
|
|
1963
|
+
46,
|
|
1964
|
+
16
|
|
1965
|
+
],
|
|
1966
|
+
[
|
|
1967
|
+
6,
|
|
1968
|
+
151,
|
|
1969
|
+
121,
|
|
1970
|
+
14,
|
|
1971
|
+
152,
|
|
1972
|
+
122
|
|
1973
|
+
],
|
|
1974
|
+
[
|
|
1975
|
+
6,
|
|
1976
|
+
75,
|
|
1977
|
+
47,
|
|
1978
|
+
34,
|
|
1979
|
+
76,
|
|
1980
|
+
48
|
|
1981
|
+
],
|
|
1982
|
+
[
|
|
1983
|
+
46,
|
|
1984
|
+
54,
|
|
1985
|
+
24,
|
|
1986
|
+
10,
|
|
1987
|
+
55,
|
|
1988
|
+
25
|
|
1989
|
+
],
|
|
1990
|
+
[
|
|
1991
|
+
2,
|
|
1992
|
+
45,
|
|
1993
|
+
15,
|
|
1994
|
+
64,
|
|
1995
|
+
46,
|
|
1996
|
+
16
|
|
1997
|
+
],
|
|
1998
|
+
[
|
|
1999
|
+
17,
|
|
2000
|
+
152,
|
|
2001
|
+
122,
|
|
2002
|
+
4,
|
|
2003
|
+
153,
|
|
2004
|
+
123
|
|
2005
|
+
],
|
|
2006
|
+
[
|
|
2007
|
+
29,
|
|
2008
|
+
74,
|
|
2009
|
+
46,
|
|
2010
|
+
14,
|
|
2011
|
+
75,
|
|
2012
|
+
47
|
|
2013
|
+
],
|
|
2014
|
+
[
|
|
2015
|
+
49,
|
|
2016
|
+
54,
|
|
2017
|
+
24,
|
|
2018
|
+
10,
|
|
2019
|
+
55,
|
|
2020
|
+
25
|
|
2021
|
+
],
|
|
2022
|
+
[
|
|
2023
|
+
24,
|
|
2024
|
+
45,
|
|
2025
|
+
15,
|
|
2026
|
+
46,
|
|
2027
|
+
46,
|
|
2028
|
+
16
|
|
2029
|
+
],
|
|
2030
|
+
[
|
|
2031
|
+
4,
|
|
2032
|
+
152,
|
|
2033
|
+
122,
|
|
2034
|
+
18,
|
|
2035
|
+
153,
|
|
2036
|
+
123
|
|
2037
|
+
],
|
|
2038
|
+
[
|
|
2039
|
+
13,
|
|
2040
|
+
74,
|
|
2041
|
+
46,
|
|
2042
|
+
32,
|
|
2043
|
+
75,
|
|
2044
|
+
47
|
|
2045
|
+
],
|
|
2046
|
+
[
|
|
2047
|
+
48,
|
|
2048
|
+
54,
|
|
2049
|
+
24,
|
|
2050
|
+
14,
|
|
2051
|
+
55,
|
|
2052
|
+
25
|
|
2053
|
+
],
|
|
2054
|
+
[
|
|
2055
|
+
42,
|
|
2056
|
+
45,
|
|
2057
|
+
15,
|
|
2058
|
+
32,
|
|
2059
|
+
46,
|
|
2060
|
+
16
|
|
2061
|
+
],
|
|
2062
|
+
[
|
|
2063
|
+
20,
|
|
2064
|
+
147,
|
|
2065
|
+
117,
|
|
2066
|
+
4,
|
|
2067
|
+
148,
|
|
2068
|
+
118
|
|
2069
|
+
],
|
|
2070
|
+
[
|
|
2071
|
+
40,
|
|
2072
|
+
75,
|
|
2073
|
+
47,
|
|
2074
|
+
7,
|
|
2075
|
+
76,
|
|
2076
|
+
48
|
|
2077
|
+
],
|
|
2078
|
+
[
|
|
2079
|
+
43,
|
|
2080
|
+
54,
|
|
2081
|
+
24,
|
|
2082
|
+
22,
|
|
2083
|
+
55,
|
|
2084
|
+
25
|
|
2085
|
+
],
|
|
2086
|
+
[
|
|
2087
|
+
10,
|
|
2088
|
+
45,
|
|
2089
|
+
15,
|
|
2090
|
+
67,
|
|
2091
|
+
46,
|
|
2092
|
+
16
|
|
2093
|
+
],
|
|
2094
|
+
[
|
|
2095
|
+
19,
|
|
2096
|
+
148,
|
|
2097
|
+
118,
|
|
2098
|
+
6,
|
|
2099
|
+
149,
|
|
2100
|
+
119
|
|
2101
|
+
],
|
|
2102
|
+
[
|
|
2103
|
+
18,
|
|
2104
|
+
75,
|
|
2105
|
+
47,
|
|
2106
|
+
31,
|
|
2107
|
+
76,
|
|
2108
|
+
48
|
|
2109
|
+
],
|
|
2110
|
+
[
|
|
2111
|
+
34,
|
|
2112
|
+
54,
|
|
2113
|
+
24,
|
|
2114
|
+
34,
|
|
2115
|
+
55,
|
|
2116
|
+
25
|
|
2117
|
+
],
|
|
2118
|
+
[
|
|
2119
|
+
20,
|
|
2120
|
+
45,
|
|
2121
|
+
15,
|
|
2122
|
+
61,
|
|
2123
|
+
46,
|
|
2124
|
+
16
|
|
2125
|
+
]
|
|
2126
|
+
];
|
|
2127
|
+
const qrRSBlock = function(totalCount, dataCount) {
|
|
2128
|
+
const _this = {};
|
|
2129
|
+
_this.totalCount = totalCount;
|
|
2130
|
+
_this.dataCount = dataCount;
|
|
2131
|
+
return _this;
|
|
2132
|
+
};
|
|
2133
|
+
const _this = {};
|
|
2134
|
+
const getRsBlockTable = function(typeNumber, errorCorrectionLevel) {
|
|
2135
|
+
switch (errorCorrectionLevel) {
|
|
2136
|
+
case QRErrorCorrectionLevel.L: return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
|
|
2137
|
+
case QRErrorCorrectionLevel.M: return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
|
|
2138
|
+
case QRErrorCorrectionLevel.Q: return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
|
|
2139
|
+
case QRErrorCorrectionLevel.H: return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
|
|
2140
|
+
default: return;
|
|
2141
|
+
}
|
|
2142
|
+
};
|
|
2143
|
+
_this.getRSBlocks = function(typeNumber, errorCorrectionLevel) {
|
|
2144
|
+
const rsBlock = getRsBlockTable(typeNumber, errorCorrectionLevel);
|
|
2145
|
+
if (typeof rsBlock == "undefined") throw "bad rs block @ typeNumber:" + typeNumber + "/errorCorrectionLevel:" + errorCorrectionLevel;
|
|
2146
|
+
const length = rsBlock.length / 3;
|
|
2147
|
+
const list = [];
|
|
2148
|
+
for (let i = 0; i < length; i += 1) {
|
|
2149
|
+
const count = rsBlock[i * 3 + 0];
|
|
2150
|
+
const totalCount = rsBlock[i * 3 + 1];
|
|
2151
|
+
const dataCount = rsBlock[i * 3 + 2];
|
|
2152
|
+
for (let j = 0; j < count; j += 1) list.push(qrRSBlock(totalCount, dataCount));
|
|
2153
|
+
}
|
|
2154
|
+
return list;
|
|
2155
|
+
};
|
|
2156
|
+
return _this;
|
|
2157
|
+
}();
|
|
2158
|
+
const qrBitBuffer = function() {
|
|
2159
|
+
const _buffer = [];
|
|
2160
|
+
let _length = 0;
|
|
2161
|
+
const _this = {};
|
|
2162
|
+
_this.getBuffer = function() {
|
|
2163
|
+
return _buffer;
|
|
2164
|
+
};
|
|
2165
|
+
_this.getAt = function(index) {
|
|
2166
|
+
const bufIndex = Math.floor(index / 8);
|
|
2167
|
+
return (_buffer[bufIndex] >>> 7 - index % 8 & 1) == 1;
|
|
2168
|
+
};
|
|
2169
|
+
_this.put = function(num, length) {
|
|
2170
|
+
for (let i = 0; i < length; i += 1) _this.putBit((num >>> length - i - 1 & 1) == 1);
|
|
2171
|
+
};
|
|
2172
|
+
_this.getLengthInBits = function() {
|
|
2173
|
+
return _length;
|
|
2174
|
+
};
|
|
2175
|
+
_this.putBit = function(bit) {
|
|
2176
|
+
const bufIndex = Math.floor(_length / 8);
|
|
2177
|
+
if (_buffer.length <= bufIndex) _buffer.push(0);
|
|
2178
|
+
if (bit) _buffer[bufIndex] |= 128 >>> _length % 8;
|
|
2179
|
+
_length += 1;
|
|
2180
|
+
};
|
|
2181
|
+
return _this;
|
|
2182
|
+
};
|
|
2183
|
+
const qrNumber = function(data) {
|
|
2184
|
+
const _mode = QRMode.MODE_NUMBER;
|
|
2185
|
+
const _data = data;
|
|
2186
|
+
const _this = {};
|
|
2187
|
+
_this.getMode = function() {
|
|
2188
|
+
return _mode;
|
|
2189
|
+
};
|
|
2190
|
+
_this.getLength = function(buffer) {
|
|
2191
|
+
return _data.length;
|
|
2192
|
+
};
|
|
2193
|
+
_this.write = function(buffer) {
|
|
2194
|
+
const data = _data;
|
|
2195
|
+
let i = 0;
|
|
2196
|
+
while (i + 2 < data.length) {
|
|
2197
|
+
buffer.put(strToNum(data.substring(i, i + 3)), 10);
|
|
2198
|
+
i += 3;
|
|
2199
|
+
}
|
|
2200
|
+
if (i < data.length) {
|
|
2201
|
+
if (data.length - i == 1) buffer.put(strToNum(data.substring(i, i + 1)), 4);
|
|
2202
|
+
else if (data.length - i == 2) buffer.put(strToNum(data.substring(i, i + 2)), 7);
|
|
2203
|
+
}
|
|
2204
|
+
};
|
|
2205
|
+
const strToNum = function(s) {
|
|
2206
|
+
let num = 0;
|
|
2207
|
+
for (let i = 0; i < s.length; i += 1) num = num * 10 + chatToNum(s.charAt(i));
|
|
2208
|
+
return num;
|
|
2209
|
+
};
|
|
2210
|
+
const chatToNum = function(c) {
|
|
2211
|
+
if ("0" <= c && c <= "9") return c.charCodeAt(0) - "0".charCodeAt(0);
|
|
2212
|
+
throw "illegal char :" + c;
|
|
2213
|
+
};
|
|
2214
|
+
return _this;
|
|
2215
|
+
};
|
|
2216
|
+
const qrAlphaNum = function(data) {
|
|
2217
|
+
const _mode = QRMode.MODE_ALPHA_NUM;
|
|
2218
|
+
const _data = data;
|
|
2219
|
+
const _this = {};
|
|
2220
|
+
_this.getMode = function() {
|
|
2221
|
+
return _mode;
|
|
2222
|
+
};
|
|
2223
|
+
_this.getLength = function(buffer) {
|
|
2224
|
+
return _data.length;
|
|
2225
|
+
};
|
|
2226
|
+
_this.write = function(buffer) {
|
|
2227
|
+
const s = _data;
|
|
2228
|
+
let i = 0;
|
|
2229
|
+
while (i + 1 < s.length) {
|
|
2230
|
+
buffer.put(getCode(s.charAt(i)) * 45 + getCode(s.charAt(i + 1)), 11);
|
|
2231
|
+
i += 2;
|
|
2232
|
+
}
|
|
2233
|
+
if (i < s.length) buffer.put(getCode(s.charAt(i)), 6);
|
|
2234
|
+
};
|
|
2235
|
+
const getCode = function(c) {
|
|
2236
|
+
if ("0" <= c && c <= "9") return c.charCodeAt(0) - "0".charCodeAt(0);
|
|
2237
|
+
else if ("A" <= c && c <= "Z") return c.charCodeAt(0) - "A".charCodeAt(0) + 10;
|
|
2238
|
+
else switch (c) {
|
|
2239
|
+
case " ": return 36;
|
|
2240
|
+
case "$": return 37;
|
|
2241
|
+
case "%": return 38;
|
|
2242
|
+
case "*": return 39;
|
|
2243
|
+
case "+": return 40;
|
|
2244
|
+
case "-": return 41;
|
|
2245
|
+
case ".": return 42;
|
|
2246
|
+
case "/": return 43;
|
|
2247
|
+
case ":": return 44;
|
|
2248
|
+
default: throw "illegal char :" + c;
|
|
2249
|
+
}
|
|
2250
|
+
};
|
|
2251
|
+
return _this;
|
|
2252
|
+
};
|
|
2253
|
+
const qr8BitByte = function(data) {
|
|
2254
|
+
const _mode = QRMode.MODE_8BIT_BYTE;
|
|
2255
|
+
const _bytes = qrcode.stringToBytes(data);
|
|
2256
|
+
const _this = {};
|
|
2257
|
+
_this.getMode = function() {
|
|
2258
|
+
return _mode;
|
|
2259
|
+
};
|
|
2260
|
+
_this.getLength = function(buffer) {
|
|
2261
|
+
return _bytes.length;
|
|
2262
|
+
};
|
|
2263
|
+
_this.write = function(buffer) {
|
|
2264
|
+
for (let i = 0; i < _bytes.length; i += 1) buffer.put(_bytes[i], 8);
|
|
2265
|
+
};
|
|
2266
|
+
return _this;
|
|
2267
|
+
};
|
|
2268
|
+
const qrKanji = function(data) {
|
|
2269
|
+
const _mode = QRMode.MODE_KANJI;
|
|
2270
|
+
const stringToBytes = qrcode.stringToBytes;
|
|
2271
|
+
(function(c, code) {
|
|
2272
|
+
const test = stringToBytes(c);
|
|
2273
|
+
if (test.length != 2 || (test[0] << 8 | test[1]) != code) throw "sjis not supported.";
|
|
2274
|
+
})("友", 38726);
|
|
2275
|
+
const _bytes = stringToBytes(data);
|
|
2276
|
+
const _this = {};
|
|
2277
|
+
_this.getMode = function() {
|
|
2278
|
+
return _mode;
|
|
2279
|
+
};
|
|
2280
|
+
_this.getLength = function(buffer) {
|
|
2281
|
+
return ~~(_bytes.length / 2);
|
|
2282
|
+
};
|
|
2283
|
+
_this.write = function(buffer) {
|
|
2284
|
+
const data = _bytes;
|
|
2285
|
+
let i = 0;
|
|
2286
|
+
while (i + 1 < data.length) {
|
|
2287
|
+
let c = (255 & data[i]) << 8 | 255 & data[i + 1];
|
|
2288
|
+
if (33088 <= c && c <= 40956) c -= 33088;
|
|
2289
|
+
else if (57408 <= c && c <= 60351) c -= 49472;
|
|
2290
|
+
else throw "illegal char at " + (i + 1) + "/" + c;
|
|
2291
|
+
c = (c >>> 8 & 255) * 192 + (c & 255);
|
|
2292
|
+
buffer.put(c, 13);
|
|
2293
|
+
i += 2;
|
|
2294
|
+
}
|
|
2295
|
+
if (i < data.length) throw "illegal char at " + (i + 1);
|
|
2296
|
+
};
|
|
2297
|
+
return _this;
|
|
2298
|
+
};
|
|
2299
|
+
const byteArrayOutputStream = function() {
|
|
2300
|
+
const _bytes = [];
|
|
2301
|
+
const _this = {};
|
|
2302
|
+
_this.writeByte = function(b) {
|
|
2303
|
+
_bytes.push(b & 255);
|
|
2304
|
+
};
|
|
2305
|
+
_this.writeShort = function(i) {
|
|
2306
|
+
_this.writeByte(i);
|
|
2307
|
+
_this.writeByte(i >>> 8);
|
|
2308
|
+
};
|
|
2309
|
+
_this.writeBytes = function(b, off, len) {
|
|
2310
|
+
off = off || 0;
|
|
2311
|
+
len = len || b.length;
|
|
2312
|
+
for (let i = 0; i < len; i += 1) _this.writeByte(b[i + off]);
|
|
2313
|
+
};
|
|
2314
|
+
_this.writeString = function(s) {
|
|
2315
|
+
for (let i = 0; i < s.length; i += 1) _this.writeByte(s.charCodeAt(i));
|
|
2316
|
+
};
|
|
2317
|
+
_this.toByteArray = function() {
|
|
2318
|
+
return _bytes;
|
|
2319
|
+
};
|
|
2320
|
+
_this.toString = function() {
|
|
2321
|
+
let s = "";
|
|
2322
|
+
s += "[";
|
|
2323
|
+
for (let i = 0; i < _bytes.length; i += 1) {
|
|
2324
|
+
if (i > 0) s += ",";
|
|
2325
|
+
s += _bytes[i];
|
|
2326
|
+
}
|
|
2327
|
+
s += "]";
|
|
2328
|
+
return s;
|
|
2329
|
+
};
|
|
2330
|
+
return _this;
|
|
2331
|
+
};
|
|
2332
|
+
const base64EncodeOutputStream = function() {
|
|
2333
|
+
let _buffer = 0;
|
|
2334
|
+
let _buflen = 0;
|
|
2335
|
+
let _length = 0;
|
|
2336
|
+
let _base64 = "";
|
|
2337
|
+
const _this = {};
|
|
2338
|
+
const writeEncoded = function(b) {
|
|
2339
|
+
_base64 += String.fromCharCode(encode(b & 63));
|
|
2340
|
+
};
|
|
2341
|
+
const encode = function(n) {
|
|
2342
|
+
if (n < 0) throw "n:" + n;
|
|
2343
|
+
else if (n < 26) return 65 + n;
|
|
2344
|
+
else if (n < 52) return 97 + (n - 26);
|
|
2345
|
+
else if (n < 62) return 48 + (n - 52);
|
|
2346
|
+
else if (n == 62) return 43;
|
|
2347
|
+
else if (n == 63) return 47;
|
|
2348
|
+
else throw "n:" + n;
|
|
2349
|
+
};
|
|
2350
|
+
_this.writeByte = function(n) {
|
|
2351
|
+
_buffer = _buffer << 8 | n & 255;
|
|
2352
|
+
_buflen += 8;
|
|
2353
|
+
_length += 1;
|
|
2354
|
+
while (_buflen >= 6) {
|
|
2355
|
+
writeEncoded(_buffer >>> _buflen - 6);
|
|
2356
|
+
_buflen -= 6;
|
|
2357
|
+
}
|
|
2358
|
+
};
|
|
2359
|
+
_this.flush = function() {
|
|
2360
|
+
if (_buflen > 0) {
|
|
2361
|
+
writeEncoded(_buffer << 6 - _buflen);
|
|
2362
|
+
_buffer = 0;
|
|
2363
|
+
_buflen = 0;
|
|
2364
|
+
}
|
|
2365
|
+
if (_length % 3 != 0) {
|
|
2366
|
+
const padlen = 3 - _length % 3;
|
|
2367
|
+
for (let i = 0; i < padlen; i += 1) _base64 += "=";
|
|
2368
|
+
}
|
|
2369
|
+
};
|
|
2370
|
+
_this.toString = function() {
|
|
2371
|
+
return _base64;
|
|
2372
|
+
};
|
|
2373
|
+
return _this;
|
|
2374
|
+
};
|
|
2375
|
+
const base64DecodeInputStream = function(str) {
|
|
2376
|
+
const _str = str;
|
|
2377
|
+
let _pos = 0;
|
|
2378
|
+
let _buffer = 0;
|
|
2379
|
+
let _buflen = 0;
|
|
2380
|
+
const _this = {};
|
|
2381
|
+
_this.read = function() {
|
|
2382
|
+
while (_buflen < 8) {
|
|
2383
|
+
if (_pos >= _str.length) {
|
|
2384
|
+
if (_buflen == 0) return -1;
|
|
2385
|
+
throw "unexpected end of file./" + _buflen;
|
|
2386
|
+
}
|
|
2387
|
+
const c = _str.charAt(_pos);
|
|
2388
|
+
_pos += 1;
|
|
2389
|
+
if (c == "=") {
|
|
2390
|
+
_buflen = 0;
|
|
2391
|
+
return -1;
|
|
2392
|
+
} else if (c.match(/^\s$/)) continue;
|
|
2393
|
+
_buffer = _buffer << 6 | decode(c.charCodeAt(0));
|
|
2394
|
+
_buflen += 6;
|
|
2395
|
+
}
|
|
2396
|
+
const n = _buffer >>> _buflen - 8 & 255;
|
|
2397
|
+
_buflen -= 8;
|
|
2398
|
+
return n;
|
|
2399
|
+
};
|
|
2400
|
+
const decode = function(c) {
|
|
2401
|
+
if (65 <= c && c <= 90) return c - 65;
|
|
2402
|
+
else if (97 <= c && c <= 122) return c - 97 + 26;
|
|
2403
|
+
else if (48 <= c && c <= 57) return c - 48 + 52;
|
|
2404
|
+
else if (c == 43) return 62;
|
|
2405
|
+
else if (c == 47) return 63;
|
|
2406
|
+
else throw "c:" + c;
|
|
2407
|
+
};
|
|
2408
|
+
return _this;
|
|
2409
|
+
};
|
|
2410
|
+
const gifImage = function(width, height) {
|
|
2411
|
+
const _width = width;
|
|
2412
|
+
const _height = height;
|
|
2413
|
+
const _data = new Array(width * height);
|
|
2414
|
+
const _this = {};
|
|
2415
|
+
_this.setPixel = function(x, y, pixel) {
|
|
2416
|
+
_data[y * _width + x] = pixel;
|
|
2417
|
+
};
|
|
2418
|
+
_this.write = function(out) {
|
|
2419
|
+
out.writeString("GIF87a");
|
|
2420
|
+
out.writeShort(_width);
|
|
2421
|
+
out.writeShort(_height);
|
|
2422
|
+
out.writeByte(128);
|
|
2423
|
+
out.writeByte(0);
|
|
2424
|
+
out.writeByte(0);
|
|
2425
|
+
out.writeByte(0);
|
|
2426
|
+
out.writeByte(0);
|
|
2427
|
+
out.writeByte(0);
|
|
2428
|
+
out.writeByte(255);
|
|
2429
|
+
out.writeByte(255);
|
|
2430
|
+
out.writeByte(255);
|
|
2431
|
+
out.writeString(",");
|
|
2432
|
+
out.writeShort(0);
|
|
2433
|
+
out.writeShort(0);
|
|
2434
|
+
out.writeShort(_width);
|
|
2435
|
+
out.writeShort(_height);
|
|
2436
|
+
out.writeByte(0);
|
|
2437
|
+
const lzwMinCodeSize = 2;
|
|
2438
|
+
const raster = getLZWRaster(lzwMinCodeSize);
|
|
2439
|
+
out.writeByte(lzwMinCodeSize);
|
|
2440
|
+
let offset = 0;
|
|
2441
|
+
while (raster.length - offset > 255) {
|
|
2442
|
+
out.writeByte(255);
|
|
2443
|
+
out.writeBytes(raster, offset, 255);
|
|
2444
|
+
offset += 255;
|
|
2445
|
+
}
|
|
2446
|
+
out.writeByte(raster.length - offset);
|
|
2447
|
+
out.writeBytes(raster, offset, raster.length - offset);
|
|
2448
|
+
out.writeByte(0);
|
|
2449
|
+
out.writeString(";");
|
|
2450
|
+
};
|
|
2451
|
+
const bitOutputStream = function(out) {
|
|
2452
|
+
const _out = out;
|
|
2453
|
+
let _bitLength = 0;
|
|
2454
|
+
let _bitBuffer = 0;
|
|
2455
|
+
const _this = {};
|
|
2456
|
+
_this.write = function(data, length) {
|
|
2457
|
+
if (data >>> length != 0) throw "length over";
|
|
2458
|
+
while (_bitLength + length >= 8) {
|
|
2459
|
+
_out.writeByte(255 & (data << _bitLength | _bitBuffer));
|
|
2460
|
+
length -= 8 - _bitLength;
|
|
2461
|
+
data >>>= 8 - _bitLength;
|
|
2462
|
+
_bitBuffer = 0;
|
|
2463
|
+
_bitLength = 0;
|
|
2464
|
+
}
|
|
2465
|
+
_bitBuffer = data << _bitLength | _bitBuffer;
|
|
2466
|
+
_bitLength = _bitLength + length;
|
|
2467
|
+
};
|
|
2468
|
+
_this.flush = function() {
|
|
2469
|
+
if (_bitLength > 0) _out.writeByte(_bitBuffer);
|
|
2470
|
+
};
|
|
2471
|
+
return _this;
|
|
2472
|
+
};
|
|
2473
|
+
const getLZWRaster = function(lzwMinCodeSize) {
|
|
2474
|
+
const clearCode = 1 << lzwMinCodeSize;
|
|
2475
|
+
const endCode = (1 << lzwMinCodeSize) + 1;
|
|
2476
|
+
let bitLength = lzwMinCodeSize + 1;
|
|
2477
|
+
const table = lzwTable();
|
|
2478
|
+
for (let i = 0; i < clearCode; i += 1) table.add(String.fromCharCode(i));
|
|
2479
|
+
table.add(String.fromCharCode(clearCode));
|
|
2480
|
+
table.add(String.fromCharCode(endCode));
|
|
2481
|
+
const byteOut = byteArrayOutputStream();
|
|
2482
|
+
const bitOut = bitOutputStream(byteOut);
|
|
2483
|
+
bitOut.write(clearCode, bitLength);
|
|
2484
|
+
let dataIndex = 0;
|
|
2485
|
+
let s = String.fromCharCode(_data[dataIndex]);
|
|
2486
|
+
dataIndex += 1;
|
|
2487
|
+
while (dataIndex < _data.length) {
|
|
2488
|
+
const c = String.fromCharCode(_data[dataIndex]);
|
|
2489
|
+
dataIndex += 1;
|
|
2490
|
+
if (table.contains(s + c)) s = s + c;
|
|
2491
|
+
else {
|
|
2492
|
+
bitOut.write(table.indexOf(s), bitLength);
|
|
2493
|
+
if (table.size() < 4095) {
|
|
2494
|
+
if (table.size() == 1 << bitLength) bitLength += 1;
|
|
2495
|
+
table.add(s + c);
|
|
2496
|
+
}
|
|
2497
|
+
s = c;
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
bitOut.write(table.indexOf(s), bitLength);
|
|
2501
|
+
bitOut.write(endCode, bitLength);
|
|
2502
|
+
bitOut.flush();
|
|
2503
|
+
return byteOut.toByteArray();
|
|
2504
|
+
};
|
|
2505
|
+
const lzwTable = function() {
|
|
2506
|
+
const _map = {};
|
|
2507
|
+
let _size = 0;
|
|
2508
|
+
const _this = {};
|
|
2509
|
+
_this.add = function(key) {
|
|
2510
|
+
if (_this.contains(key)) throw "dup key:" + key;
|
|
2511
|
+
_map[key] = _size;
|
|
2512
|
+
_size += 1;
|
|
2513
|
+
};
|
|
2514
|
+
_this.size = function() {
|
|
2515
|
+
return _size;
|
|
2516
|
+
};
|
|
2517
|
+
_this.indexOf = function(key) {
|
|
2518
|
+
return _map[key];
|
|
2519
|
+
};
|
|
2520
|
+
_this.contains = function(key) {
|
|
2521
|
+
return typeof _map[key] != "undefined";
|
|
2522
|
+
};
|
|
2523
|
+
return _this;
|
|
2524
|
+
};
|
|
2525
|
+
return _this;
|
|
2526
|
+
};
|
|
2527
|
+
const createDataURL = function(width, height, getPixel) {
|
|
2528
|
+
const gif = gifImage(width, height);
|
|
2529
|
+
for (let y = 0; y < height; y += 1) for (let x = 0; x < width; x += 1) gif.setPixel(x, y, getPixel(x, y));
|
|
2530
|
+
const b = byteArrayOutputStream();
|
|
2531
|
+
gif.write(b);
|
|
2532
|
+
const base64 = base64EncodeOutputStream();
|
|
2533
|
+
const bytes = b.toByteArray();
|
|
2534
|
+
for (let i = 0; i < bytes.length; i += 1) base64.writeByte(bytes[i]);
|
|
2535
|
+
base64.flush();
|
|
2536
|
+
return "data:image/gif;base64," + base64;
|
|
2537
|
+
};
|
|
2538
|
+
const stringToBytes = qrcode.stringToBytes;
|
|
2539
|
+
|
|
2540
|
+
// src/client/index.tsx
|
|
2541
|
+
const name = "meshy-dsh-client";
|
|
2542
|
+
const inject = ["slots", "locale"];
|
|
2543
|
+
const NS = "meshy";
|
|
2544
|
+
const GLB_ID = "meshy-dsh/glb";
|
|
2545
|
+
/** The left-sidebar entry and its page in the main column share this id. */
|
|
2546
|
+
const PAGE_ID = "meshy";
|
|
2547
|
+
const EXAMPLES = [
|
|
2548
|
+
"chest",
|
|
2549
|
+
"photo",
|
|
2550
|
+
"character",
|
|
2551
|
+
"print"
|
|
2552
|
+
];
|
|
2553
|
+
const SITES = {
|
|
2554
|
+
global: {
|
|
2555
|
+
web: "https://www.meshy.ai",
|
|
2556
|
+
docs: "https://docs.meshy.ai",
|
|
2557
|
+
host: "meshy.ai"
|
|
2558
|
+
},
|
|
2559
|
+
cn: {
|
|
2560
|
+
web: "https://meshy.cn",
|
|
2561
|
+
docs: "https://docs.meshy.cn",
|
|
2562
|
+
host: "meshy.cn"
|
|
2563
|
+
}
|
|
2564
|
+
};
|
|
2565
|
+
const CN_ZONES = /* @__PURE__ */ new Set([
|
|
2566
|
+
"Asia/Shanghai",
|
|
2567
|
+
"Asia/Chongqing",
|
|
2568
|
+
"Asia/Chungking",
|
|
2569
|
+
"Asia/Harbin",
|
|
2570
|
+
"Asia/Urumqi",
|
|
2571
|
+
"Asia/Kashgar",
|
|
2572
|
+
"PRC"
|
|
2573
|
+
]);
|
|
2574
|
+
function guessSite() {
|
|
2575
|
+
try {
|
|
2576
|
+
return CN_ZONES.has(Intl.DateTimeFormat().resolvedOptions().timeZone) ? "cn" : "global";
|
|
2577
|
+
} catch {
|
|
2578
|
+
return "global";
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
let currentSite = guessSite();
|
|
2582
|
+
const siteListeners = /* @__PURE__ */ new Set();
|
|
2583
|
+
function setSite(next) {
|
|
2584
|
+
if (next === currentSite) return;
|
|
2585
|
+
currentSite = next;
|
|
2586
|
+
for (const notify of siteListeners) notify();
|
|
2587
|
+
}
|
|
2588
|
+
function useSite() {
|
|
2589
|
+
return (0, react.useSyncExternalStore)((notify) => {
|
|
2590
|
+
siteListeners.add(notify);
|
|
2591
|
+
return () => {
|
|
2592
|
+
siteListeners.delete(notify);
|
|
2593
|
+
};
|
|
2594
|
+
}, () => currentSite);
|
|
2595
|
+
}
|
|
2596
|
+
/** Docs in the reader's language on the global site; the China site serves Chinese by default. */
|
|
2597
|
+
function docsUrl(site) {
|
|
2598
|
+
return site === "global" && /^zh/i.test(globalThis.navigator?.language ?? "") ? `${SITES.global.docs}/zh` : SITES[site].docs;
|
|
2599
|
+
}
|
|
2600
|
+
const en = {
|
|
2601
|
+
nav: "Meshy",
|
|
2602
|
+
accountTitle: "Meshy account",
|
|
2603
|
+
summary: "Sign in to Meshy and preview GLB models in 3D.",
|
|
2604
|
+
tagline: "Text and images to 3D models, right in DeepSeek Harness",
|
|
2605
|
+
checking: "Checking…",
|
|
2606
|
+
signedIn: "Signed in",
|
|
2607
|
+
signedOut: "Not signed in",
|
|
2608
|
+
unverified: "Needs attention",
|
|
2609
|
+
"unverified.hint": "The saved sign-in could not be verified. Refresh, or sign in again.",
|
|
2610
|
+
site: "Site",
|
|
2611
|
+
"site.global": "Global",
|
|
2612
|
+
"site.cn": "China",
|
|
2613
|
+
credits: "Credits",
|
|
2614
|
+
"credits.get": "Get credits",
|
|
2615
|
+
account: "Account",
|
|
2616
|
+
more: "Manage account",
|
|
2617
|
+
signIn: "Sign in to Meshy",
|
|
2618
|
+
"signIn.hint": "Approve in your browser once; the Meshy skills then use this sign-in.",
|
|
2619
|
+
"signIn.scan": "Scan with your phone, or open the link",
|
|
2620
|
+
"signIn.scanHint": "Sign in to {host} and approve. This page finishes on its own.",
|
|
2621
|
+
"signIn.code": "Code",
|
|
2622
|
+
"signIn.open": "Open in browser",
|
|
2623
|
+
"signIn.waiting": "Waiting for your approval…",
|
|
2624
|
+
copy: "Copy code",
|
|
2625
|
+
copied: "Copied",
|
|
2626
|
+
cancel: "Cancel",
|
|
2627
|
+
retry: "Try again",
|
|
2628
|
+
refresh: "Refresh",
|
|
2629
|
+
signOut: "Sign out",
|
|
2630
|
+
"signOut.title": "Sign out of Meshy?",
|
|
2631
|
+
"signOut.body": "The Meshy skills in DeepSeek Harness will ask you to sign in again before they generate.",
|
|
2632
|
+
close: "Close",
|
|
2633
|
+
cli: "Meshy CLI {version}",
|
|
2634
|
+
"cli.temporary": "run through npm exec",
|
|
2635
|
+
"error.cli": "Meshy CLI not found",
|
|
2636
|
+
"error.cliHint": "Install Node.js 22.12 or newer, then run this and refresh:",
|
|
2637
|
+
"error.expired": "The code expired. Start again for a new one.",
|
|
2638
|
+
"error.generic": "Something went wrong: {message}",
|
|
2639
|
+
"viewer.title": "3D model",
|
|
2640
|
+
"viewer.loading": "Loading model…",
|
|
2641
|
+
"viewer.failed": "This model cannot be shown",
|
|
2642
|
+
"viewer.triangles": "{count} triangles",
|
|
2643
|
+
"viewer.reset": "Reset view",
|
|
2644
|
+
"viewer.spin": "Auto-rotate",
|
|
2645
|
+
"viewer.stop": "Stop rotating",
|
|
2646
|
+
"page.tagline": "Turn text and images into 3D models, rig and animate them, or get them ready to print.",
|
|
2647
|
+
"page.start": "Start creating",
|
|
2648
|
+
"page.startHint": "Pick one to open a new session with it filled in. Edit it, then send.",
|
|
2649
|
+
"page.copyHint": "Copy one into a session, edit it, then send.",
|
|
2650
|
+
"page.try": "Start a session",
|
|
2651
|
+
"page.docs": "Documentation",
|
|
2652
|
+
"page.site": "Meshy website",
|
|
2653
|
+
"example.chest.title": "Game asset",
|
|
2654
|
+
"example.chest.prompt": "Make a low-poly cartoon treasure chest for my game and export it as GLB.",
|
|
2655
|
+
"example.photo.title": "Photo to 3D",
|
|
2656
|
+
"example.photo.prompt": "Turn the photo I attach into a textured 3D model.",
|
|
2657
|
+
"example.character.title": "Animated character",
|
|
2658
|
+
"example.character.prompt": "Create a cartoon knight, rig it, add a walking animation and export FBX.",
|
|
2659
|
+
"example.print.title": "3D print",
|
|
2660
|
+
"example.print.prompt": "Make a 10 cm tall shiba inu figurine and prepare a print-ready 3MF."
|
|
2661
|
+
};
|
|
2662
|
+
const zh = {
|
|
2663
|
+
nav: "Meshy",
|
|
2664
|
+
accountTitle: "Meshy 账号",
|
|
2665
|
+
summary: "登录 Meshy,并在 3D 中预览 GLB 模型。",
|
|
2666
|
+
tagline: "在 DeepSeek Harness 里用文字或图片生成 3D 模型",
|
|
2667
|
+
checking: "检查中…",
|
|
2668
|
+
signedIn: "已登录",
|
|
2669
|
+
signedOut: "未登录",
|
|
2670
|
+
unverified: "需要处理",
|
|
2671
|
+
"unverified.hint": "已保存的登录无法验证。请刷新,或重新登录。",
|
|
2672
|
+
site: "站点",
|
|
2673
|
+
"site.global": "国际站",
|
|
2674
|
+
"site.cn": "中国站",
|
|
2675
|
+
credits: "积分",
|
|
2676
|
+
"credits.get": "获取积分",
|
|
2677
|
+
account: "账号",
|
|
2678
|
+
more: "管理账号",
|
|
2679
|
+
signIn: "登录 Meshy",
|
|
2680
|
+
"signIn.hint": "在浏览器里批准一次,Meshy 技能之后都会使用这个登录。",
|
|
2681
|
+
"signIn.scan": "用手机扫码,或打开链接",
|
|
2682
|
+
"signIn.scanHint": "登录 {host} 并批准,本页会自动完成。",
|
|
2683
|
+
"signIn.code": "验证码",
|
|
2684
|
+
"signIn.open": "在浏览器中打开",
|
|
2685
|
+
"signIn.waiting": "正在等待你的批准…",
|
|
2686
|
+
copy: "复制验证码",
|
|
2687
|
+
copied: "已复制",
|
|
2688
|
+
cancel: "取消",
|
|
2689
|
+
retry: "重试",
|
|
2690
|
+
refresh: "刷新",
|
|
2691
|
+
signOut: "退出登录",
|
|
2692
|
+
"signOut.title": "退出 Meshy 登录?",
|
|
2693
|
+
"signOut.body": "退出后,DeepSeek Harness 里的 Meshy 技能在生成前会要求你重新登录。",
|
|
2694
|
+
close: "关闭",
|
|
2695
|
+
cli: "Meshy CLI {version}",
|
|
2696
|
+
"cli.temporary": "通过 npm exec 运行",
|
|
2697
|
+
"error.cli": "找不到 Meshy CLI",
|
|
2698
|
+
"error.cliHint": "请安装 Node.js 22.12 或更新版本,运行下面的命令后刷新:",
|
|
2699
|
+
"error.expired": "验证码已过期,请重新开始。",
|
|
2700
|
+
"error.generic": "出错了:{message}",
|
|
2701
|
+
"viewer.title": "3D 模型",
|
|
2702
|
+
"viewer.loading": "正在加载模型…",
|
|
2703
|
+
"viewer.failed": "无法显示这个模型",
|
|
2704
|
+
"viewer.triangles": "{count} 个三角面",
|
|
2705
|
+
"viewer.reset": "重置视角",
|
|
2706
|
+
"viewer.spin": "自动旋转",
|
|
2707
|
+
"viewer.stop": "停止旋转",
|
|
2708
|
+
"page.tagline": "用文字或图片生成 3D 模型,绑骨做动画,或者准备好直接 3D 打印。",
|
|
2709
|
+
"page.start": "开始创作",
|
|
2710
|
+
"page.startHint": "选一个,会新开一个会话并填好需求,改一改再发送。",
|
|
2711
|
+
"page.copyHint": "复制到会话里,改一改再发送。",
|
|
2712
|
+
"page.try": "新开会话",
|
|
2713
|
+
"page.docs": "文档",
|
|
2714
|
+
"page.site": "Meshy 官网",
|
|
2715
|
+
"example.chest.title": "游戏资产",
|
|
2716
|
+
"example.chest.prompt": "做一个低多边形的卡通宝箱,用在我的游戏里,导出 GLB。",
|
|
2717
|
+
"example.photo.title": "照片转 3D",
|
|
2718
|
+
"example.photo.prompt": "把我附上的这张照片做成带贴图的 3D 模型。",
|
|
2719
|
+
"example.character.title": "动画角色",
|
|
2720
|
+
"example.character.prompt": "生成一个卡通骑士,绑骨并加上走路动画,导出 FBX。",
|
|
2721
|
+
"example.print.title": "3D 打印",
|
|
2722
|
+
"example.print.prompt": "做一个 10 厘米高的柴犬手办,并准备好可以直接打印的 3MF。"
|
|
2723
|
+
};
|
|
2724
|
+
const CSS = `
|
|
2725
|
+
.meshy-root{--meshy-accent:#beef54;--meshy-accent-hover:#b1ed30;--meshy-accent-label:#000;color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family);font-size:13px;line-height:22px}
|
|
2726
|
+
body[data-ds-dark-theme] .meshy-root{--meshy-accent:#c5f955;--meshy-accent-hover:#a8e328}
|
|
2727
|
+
.meshy-section{display:flex;flex-direction:column;gap:16px;padding:8px 0}
|
|
2728
|
+
.meshy-card{border:.5px solid var(--dsw-alias-settings-card-stroke);border-radius:var(--dsw-radius-xl);background:var(--dsw-alias-settings-card-fill);padding:12px 16px}
|
|
2729
|
+
.meshy-head,.meshy-row{display:flex;justify-content:space-between;align-items:center;gap:16px}
|
|
2730
|
+
.meshy-identity{display:flex;align-items:center;gap:10px;min-width:0;min-height:44px}
|
|
2731
|
+
.meshy-logo{width:32px;height:32px;flex:none;border-radius:9px}
|
|
2732
|
+
.meshy-copy{display:flex;flex-direction:column;min-width:0}
|
|
2733
|
+
.meshy-name{font-size:14px;font-weight:500}
|
|
2734
|
+
.meshy-muted{color:var(--dsw-alias-label-tertiary)}
|
|
2735
|
+
.meshy-small{font-size:12px;line-height:18px}
|
|
2736
|
+
.meshy-pill{display:inline-flex;align-items:center;gap:6px;flex:none;white-space:nowrap}
|
|
2737
|
+
.meshy-dot{width:8px;height:8px;border-radius:50%;background:var(--dsw-alias-label-tertiary)}
|
|
2738
|
+
.meshy-dot[data-on]{background:var(--meshy-accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--meshy-accent) 25%,transparent)}
|
|
2739
|
+
.meshy-dot[data-warn]{background:var(--dsw-alias-state-warn-primary)}
|
|
2740
|
+
.meshy-rows{display:flex;flex-direction:column;gap:8px}
|
|
2741
|
+
.meshy-row{box-sizing:border-box;min-height:40px;padding:6px 0}
|
|
2742
|
+
.meshy-divider{border-top:.5px solid var(--dsw-alias-border-l2)}
|
|
2743
|
+
.meshy-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:10px}
|
|
2744
|
+
.meshy-amount{display:inline-flex;align-items:center;gap:8px;font-size:18px;font-weight:510;line-height:28px}
|
|
2745
|
+
.meshy-coin{width:12px;height:12px;border-radius:50%;background:linear-gradient(135deg,#f9e855,#e99430)}
|
|
2746
|
+
.meshy-link{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;gap:4px;height:36px;padding:0 14px;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md);color:var(--dsw-alias-label-primary);font-size:14px;line-height:22px;text-decoration:none;white-space:nowrap}
|
|
2747
|
+
.meshy-link:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
2748
|
+
.meshy-link:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
|
|
2749
|
+
.meshy-root .meshy-accent{flex:none;white-space:nowrap;border-color:transparent;background:var(--meshy-accent);color:var(--meshy-accent-label);font-weight:500}
|
|
2750
|
+
.meshy-root .meshy-accent:hover:not(:disabled){background:var(--meshy-accent-hover)}
|
|
2751
|
+
.meshy-signin{display:flex;align-items:center;gap:20px}
|
|
2752
|
+
.meshy-qr{flex:none;width:136px;height:136px;padding:10px;border-radius:var(--dsw-radius-lg);background:#fff;border:.5px solid var(--dsw-alias-border-l2);image-rendering:pixelated}
|
|
2753
|
+
.meshy-signin .meshy-copy{gap:10px}
|
|
2754
|
+
.meshy-code{display:inline-flex;align-items:center;gap:8px}
|
|
2755
|
+
.meshy-code code{font-family:var(--ds-font-family-code);font-size:16px;letter-spacing:.08em;padding:2px 10px;border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-bg-module-platform)}
|
|
2756
|
+
.meshy-waiting{display:inline-flex;align-items:center;gap:8px;color:var(--dsw-alias-label-secondary)}
|
|
2757
|
+
.meshy-alert{display:flex;align-items:flex-start;gap:8px;padding:10px 12px;border-radius:var(--dsw-radius-lg);background:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 10%,transparent)}
|
|
2758
|
+
.meshy-alert svg{flex:none;margin-top:3px;color:var(--dsw-alias-state-warn-primary)}
|
|
2759
|
+
.meshy-alert code{align-self:flex-start;margin-top:4px;padding:1px 6px;border-radius:var(--dsw-radius-xs);font-family:var(--ds-font-family-code);font-size:12px;background:color-mix(in srgb,var(--dsw-alias-label-primary) 8%,transparent)}
|
|
2760
|
+
.meshy-foot{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:0 4px}
|
|
2761
|
+
.meshy-skeleton{display:block;border-radius:6px;background:var(--dsw-alias-bg-skeleton);animation:meshy-pulse 1.4s ease-in-out infinite}
|
|
2762
|
+
@keyframes meshy-pulse{50%{opacity:.45}}
|
|
2763
|
+
.meshy-viewer{position:relative;width:100%;height:100%;min-height:360px}
|
|
2764
|
+
.meshy-stage{position:absolute;inset:0}
|
|
2765
|
+
.meshy-overlay{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:16px;text-align:center}
|
|
2766
|
+
.meshy-overlay .meshy-logo{width:40px;height:40px;animation:meshy-pulse 1.4s ease-in-out infinite}
|
|
2767
|
+
.meshy-bar{position:absolute;left:12px;right:12px;bottom:12px;display:flex;align-items:center;justify-content:space-between;gap:8px;pointer-events:none}
|
|
2768
|
+
.meshy-bar>*{pointer-events:auto}
|
|
2769
|
+
.meshy-chip{padding:2px 10px;border-radius:999px;background:color-mix(in srgb,var(--dsw-alias-bg-base) 80%,transparent);backdrop-filter:blur(8px);font-size:12px;line-height:20px;color:var(--dsw-alias-label-secondary)}
|
|
2770
|
+
.meshy-page{box-sizing:border-box;height:100%;overflow-y:auto}
|
|
2771
|
+
.meshy-page-inner{box-sizing:border-box;max-width:760px;margin:0 auto;padding:56px 32px 48px;display:flex;flex-direction:column;gap:32px}
|
|
2772
|
+
.meshy-hero{display:flex;align-items:center;gap:16px}
|
|
2773
|
+
.meshy-hero .meshy-logo{width:56px;height:56px;border-radius:14px}
|
|
2774
|
+
.meshy-hero h1{margin:0;font-size:24px;font-weight:600;line-height:32px;color:var(--dsw-alias-label-primary)}
|
|
2775
|
+
.meshy-h2{margin:0;font-size:15px;font-weight:500;line-height:24px}
|
|
2776
|
+
.meshy-block{display:flex;flex-direction:column;gap:12px}
|
|
2777
|
+
.meshy-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:12px}
|
|
2778
|
+
.meshy-example{box-sizing:border-box;display:flex;flex-direction:column;align-items:flex-start;gap:6px;width:100%;margin:0;padding:14px 16px;border:.5px solid var(--dsw-alias-settings-card-stroke);border-radius:var(--dsw-radius-xl);background:var(--dsw-alias-settings-card-fill);color:var(--dsw-alias-label-primary);font:inherit;text-align:left;cursor:pointer;transition:background-color .15s,border-color .15s}
|
|
2779
|
+
.meshy-example:hover{background:var(--dsw-alias-interactive-bg-hover);border-color:color-mix(in srgb,var(--meshy-accent) 70%,transparent)}
|
|
2780
|
+
.meshy-example:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
|
|
2781
|
+
.meshy-example-title{display:inline-flex;align-items:center;gap:8px;font-weight:500}
|
|
2782
|
+
.meshy-example-title::before{content:"";width:6px;height:6px;border-radius:50%;background:var(--meshy-accent)}
|
|
2783
|
+
.meshy-example-cta{display:inline-flex;align-items:center;gap:4px;margin-top:4px;font-size:12px;color:var(--dsw-alias-label-tertiary)}
|
|
2784
|
+
.meshy-example:hover .meshy-example-cta{color:var(--dsw-alias-label-primary)}
|
|
2785
|
+
.meshy-links{display:flex;gap:16px}
|
|
2786
|
+
.meshy-textlink{display:inline-flex;align-items:center;gap:4px;color:var(--dsw-alias-label-secondary);text-decoration:none}
|
|
2787
|
+
.meshy-textlink:hover{color:var(--dsw-alias-label-primary)}
|
|
2788
|
+
.meshy-mark{display:inline-flex;flex:none}
|
|
2789
|
+
.meshy-tools{display:flex;gap:4px;padding:2px;border-radius:var(--dsw-radius-md);background:color-mix(in srgb,var(--dsw-alias-bg-base) 80%,transparent);backdrop-filter:blur(8px)}
|
|
2790
|
+
`;
|
|
2791
|
+
if (typeof document !== "undefined" && !document.querySelector("style[data-plugin-css=\"meshy-dsh/client.css\"]")) {
|
|
2792
|
+
const tag = document.createElement("style");
|
|
2793
|
+
tag.dataset.plugin = "meshy-dsh";
|
|
2794
|
+
tag.dataset.pluginCss = "meshy-dsh/client.css";
|
|
2795
|
+
tag.textContent = CSS;
|
|
2796
|
+
document.head.append(tag);
|
|
2797
|
+
}
|
|
2798
|
+
async function api(path, body) {
|
|
2799
|
+
const res = await fetch(`api/${path}`, body === void 0 ? { cache: "no-store" } : {
|
|
2800
|
+
method: "POST",
|
|
2801
|
+
cache: "no-store",
|
|
2802
|
+
headers: { "content-type": "application/json" },
|
|
2803
|
+
body: JSON.stringify(body)
|
|
2804
|
+
});
|
|
2805
|
+
return {
|
|
2806
|
+
status: res.status,
|
|
2807
|
+
data: await res.json().catch(() => ({}))
|
|
2808
|
+
};
|
|
2809
|
+
}
|
|
2810
|
+
function qr(text) {
|
|
2811
|
+
const code = qrcode(0, "M");
|
|
2812
|
+
code.addData(text);
|
|
2813
|
+
code.make();
|
|
2814
|
+
return code.createDataURL(6, 0);
|
|
2815
|
+
}
|
|
2816
|
+
const Logo = () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
2817
|
+
className: "meshy-logo",
|
|
2818
|
+
src: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMjguNTkzNCA0NC44NTA0QzI5Ljg1ODYgNDEuODgxNyAzMS40MzggMzguOTU4OSAzMy4zMTI0IDM2LjE2MDJMMzMuMzQ0MSAzNi4xMTIyTDMzLjM0NDMgMzYuMTExOUMzMy41NDgzIDM1LjgwMjggMzMuNzU0NSAzNS40OTcgMzMuOTYyNiAzNS4xOTQ1QzQ2LjI4MjQgMTYuMDg1NSA3Mi43MzI0IDQuNjM0NzQgOTUuMDk1NyAxNC43Nzg3QzExMi43NyAyMi4zNDM2IDEyMS4yNCAzNy43OTEzIDEyMC45OTYgNTEuNTQ0N0MxMjAuODczIDU4LjQwMjggMTE4LjU1NSA2NS4wOTMzIDExMy43NjkgNjkuOTI5N0MxMTIuOTQ5IDcwLjc1NzUgMTEyLjA3MiA3MS41MTY0IDExMS4xNCA3Mi4yMDI1QzExNS40NTkgNzUuNjMxNyAxMTguMjg0I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LjA0MTNDNTguMjQ3NiA0MS4wNDEzIDU5LjMxMTQgNDEuNjgyOCA2MC44MzYxIDQwLjg2NTVDNjMuMjk5MiAzOS41NDUyIDYzLjg3MzkgMzEuNTkwOSA2My44NzM5IDI2Ljk0NTJDNjMuODczOSAyNS42OTAyIDYyLjMyOTUgMjUuNjY4NCA2Mi4zMjk1IDI1LjY2ODRDNjQuMDcxNiAyNS41MjUyIDY1LjUzNjQgMjYuMjExMyA2NS42Mjk4IDI3LjIzMTlDNjYuMDE1OSAzMS40NDggNjUuMjk0NyAzNi42MDMyIDY0LjMyOTkgNDAuMDAxNkM2NC4wMjg0IDQxLjA2MzQgNjIuMzQ0NiA0MS44ODc1IDYwLjU2OSA0MS44NDIzQzU5LjU0MTggNDEuODE2MSA1OC43MDg5IDQxLjUwNDcgNTguMjQ3NiA0MS4wNDEzWiIgZmlsbD0iI0ZGM0U4RiIvPgo8cGF0aCBkPSJNMjMuODk1MSAxMUwyNi41NjE3IDE4LjI1NDVMMzMuNzY4MiAyMC45Mzg5TDI2LjU2MTcgMjMuNjIzNEwyMy44OTUxIDMwLjg3NzlMMjEuMjI4NSAyMy42MjM0TDE0LjAyMiAyMC45Mzg5TDIxLjIyODUgMTguMjU0NUwyMy44OTUxIDExWiIgZmlsbD0iI0M1Rjk1NSIvPgo8cGF0aCBkPSJNMTIuNjI4NiAyOS43NzMzTDE0LjE0ODggMzMuOTM4TDE4LjI1NzIgMzUuNDc5TDE0LjE0ODggMzcuMDIwMUwxMi42Mjg2IDQxLjE4NDdMMTEuMTA4NCAzNy4wMjAxTDcgMzUuNDc5TDExLjEwODQgMzMuOTM4TDEyLjYyODYgMjkuNzczM1oiIGZpbGw9IiNDNUY5NTUiLz4KPC9zdmc+Cg==",
|
|
2819
|
+
alt: ""
|
|
2820
|
+
});
|
|
2821
|
+
function Identity({ t, page, line, pill }) {
|
|
2822
|
+
const title = page ? t("accountTitle") : "Meshy";
|
|
2823
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2824
|
+
className: "meshy-card meshy-head",
|
|
2825
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2826
|
+
className: "meshy-identity",
|
|
2827
|
+
children: [!page && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Logo, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2828
|
+
className: "meshy-copy",
|
|
2829
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2830
|
+
className: "meshy-name",
|
|
2831
|
+
children: title
|
|
2832
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2833
|
+
className: "meshy-muted",
|
|
2834
|
+
children: line
|
|
2835
|
+
})]
|
|
2836
|
+
})]
|
|
2837
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2838
|
+
className: "meshy-pill meshy-muted",
|
|
2839
|
+
children: [pill === "checking" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, {
|
|
2840
|
+
state: "ongoing",
|
|
2841
|
+
size: 12
|
|
2842
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2843
|
+
className: "meshy-dot",
|
|
2844
|
+
"data-on": pill === "on" || void 0,
|
|
2845
|
+
"data-warn": pill === "warn" || void 0
|
|
2846
|
+
}), t(pill === "checking" ? "checking" : pill === "on" ? "signedIn" : pill === "warn" ? "unverified" : "signedOut")]
|
|
2847
|
+
})]
|
|
2848
|
+
});
|
|
2849
|
+
}
|
|
2850
|
+
function Skeleton() {
|
|
2851
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2852
|
+
className: "meshy-card meshy-rows",
|
|
2853
|
+
"aria-hidden": "true",
|
|
2854
|
+
children: [
|
|
2855
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2856
|
+
className: "meshy-row",
|
|
2857
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2858
|
+
className: "meshy-skeleton",
|
|
2859
|
+
style: {
|
|
2860
|
+
width: 64,
|
|
2861
|
+
height: 14
|
|
2862
|
+
}
|
|
2863
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2864
|
+
className: "meshy-skeleton",
|
|
2865
|
+
style: {
|
|
2866
|
+
width: 120,
|
|
2867
|
+
height: 22
|
|
2868
|
+
}
|
|
2869
|
+
})]
|
|
2870
|
+
}),
|
|
2871
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "meshy-divider" }),
|
|
2872
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2873
|
+
className: "meshy-row",
|
|
2874
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2875
|
+
className: "meshy-skeleton",
|
|
2876
|
+
style: {
|
|
2877
|
+
width: 48,
|
|
2878
|
+
height: 14
|
|
2879
|
+
}
|
|
2880
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2881
|
+
className: "meshy-skeleton",
|
|
2882
|
+
style: {
|
|
2883
|
+
width: 180,
|
|
2884
|
+
height: 36
|
|
2885
|
+
}
|
|
2886
|
+
})]
|
|
2887
|
+
})
|
|
2888
|
+
]
|
|
2889
|
+
});
|
|
2890
|
+
}
|
|
2891
|
+
function Alert({ children, action }) {
|
|
2892
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2893
|
+
className: "meshy-alert",
|
|
2894
|
+
role: "alert",
|
|
2895
|
+
children: [
|
|
2896
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconWarningOutlineRegular, { size: 14 }),
|
|
2897
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2898
|
+
className: "meshy-copy",
|
|
2899
|
+
style: { flex: 1 },
|
|
2900
|
+
children
|
|
2901
|
+
}),
|
|
2902
|
+
action
|
|
2903
|
+
]
|
|
2904
|
+
});
|
|
2905
|
+
}
|
|
2906
|
+
function MeshyPanel({ t, view }) {
|
|
2907
|
+
const [status, setStatus] = (0, react.useState)();
|
|
2908
|
+
const site = useSite();
|
|
2909
|
+
const [flow, setFlow] = (0, react.useState)();
|
|
2910
|
+
const [busy, setBusy] = (0, react.useState)(false);
|
|
2911
|
+
const [problem, setProblem] = (0, react.useState)();
|
|
2912
|
+
const [copied, setCopied] = (0, react.useState)(false);
|
|
2913
|
+
const [confirmOut, setConfirmOut] = (0, react.useState)(false);
|
|
2914
|
+
const polling = (0, react.useRef)(0);
|
|
2915
|
+
(0, react.useEffect)(() => {
|
|
2916
|
+
if (status?.auth?.authenticated) setSite(status.auth.region);
|
|
2917
|
+
}, [status]);
|
|
2918
|
+
const refresh = (0, react.useCallback)(async () => {
|
|
2919
|
+
setStatus(void 0);
|
|
2920
|
+
setProblem(void 0);
|
|
2921
|
+
try {
|
|
2922
|
+
const next = (await api("meshy.status")).data;
|
|
2923
|
+
setStatus(next);
|
|
2924
|
+
if (!next.cli) setProblem({ kind: "cli" });
|
|
2925
|
+
} catch (err) {
|
|
2926
|
+
setStatus({ cli: null });
|
|
2927
|
+
setProblem({
|
|
2928
|
+
kind: "generic",
|
|
2929
|
+
message: String(err)
|
|
2930
|
+
});
|
|
2931
|
+
}
|
|
2932
|
+
}, []);
|
|
2933
|
+
(0, react.useEffect)(() => {
|
|
2934
|
+
if (view !== "summary") refresh();
|
|
2935
|
+
return () => {
|
|
2936
|
+
polling.current++;
|
|
2937
|
+
};
|
|
2938
|
+
}, [refresh, view]);
|
|
2939
|
+
if (view === "summary") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("summary") });
|
|
2940
|
+
const signIn = async () => {
|
|
2941
|
+
setBusy(true);
|
|
2942
|
+
setProblem(void 0);
|
|
2943
|
+
try {
|
|
2944
|
+
const { status: code, data } = await api("meshy.login", { region: site });
|
|
2945
|
+
if (code !== 200) throw new Error(data.error ?? String(code));
|
|
2946
|
+
setFlow(data);
|
|
2947
|
+
const run = ++polling.current;
|
|
2948
|
+
const deadline = Date.now() + (data.expires_in ?? 600) * 1e3;
|
|
2949
|
+
while (run === polling.current) {
|
|
2950
|
+
if (Date.now() > deadline) {
|
|
2951
|
+
setFlow(void 0);
|
|
2952
|
+
setProblem({ kind: "expired" });
|
|
2953
|
+
return;
|
|
2954
|
+
}
|
|
2955
|
+
const done = await api("meshy.login.finish", { flow_id: data.flow_id });
|
|
2956
|
+
if (run !== polling.current) return;
|
|
2957
|
+
if (done.status === 202) continue;
|
|
2958
|
+
if (done.status !== 200) {
|
|
2959
|
+
setFlow(void 0);
|
|
2960
|
+
setProblem(/expir/i.test(done.data.error ?? "") ? { kind: "expired" } : {
|
|
2961
|
+
kind: "generic",
|
|
2962
|
+
message: done.data.error ?? String(done.status)
|
|
2963
|
+
});
|
|
2964
|
+
return;
|
|
2965
|
+
}
|
|
2966
|
+
setFlow(void 0);
|
|
2967
|
+
await refresh();
|
|
2968
|
+
return;
|
|
2969
|
+
}
|
|
2970
|
+
} catch (err) {
|
|
2971
|
+
setFlow(void 0);
|
|
2972
|
+
setProblem({
|
|
2973
|
+
kind: "generic",
|
|
2974
|
+
message: String(err?.message ?? err)
|
|
2975
|
+
});
|
|
2976
|
+
} finally {
|
|
2977
|
+
setBusy(false);
|
|
2978
|
+
}
|
|
2979
|
+
};
|
|
2980
|
+
const cancel = () => {
|
|
2981
|
+
polling.current++;
|
|
2982
|
+
setFlow(void 0);
|
|
2983
|
+
setBusy(false);
|
|
2984
|
+
};
|
|
2985
|
+
const signOut = async () => {
|
|
2986
|
+
setConfirmOut(false);
|
|
2987
|
+
setBusy(true);
|
|
2988
|
+
try {
|
|
2989
|
+
const { status: code, data } = await api("meshy.logout", {});
|
|
2990
|
+
if (code !== 200) throw new Error(data.error ?? String(code));
|
|
2991
|
+
await refresh();
|
|
2992
|
+
} catch (err) {
|
|
2993
|
+
setProblem({
|
|
2994
|
+
kind: "generic",
|
|
2995
|
+
message: String(err?.message ?? err)
|
|
2996
|
+
});
|
|
2997
|
+
} finally {
|
|
2998
|
+
setBusy(false);
|
|
2999
|
+
}
|
|
3000
|
+
};
|
|
3001
|
+
const copy = async () => {
|
|
3002
|
+
if (flow && await (0, _deepseek_ai_dsh_client_ui_primitives.writeClipboard)(flow.user_code)) {
|
|
3003
|
+
setCopied(true);
|
|
3004
|
+
setTimeout(() => setCopied(false), 1500);
|
|
3005
|
+
}
|
|
3006
|
+
};
|
|
3007
|
+
const auth = status?.auth;
|
|
3008
|
+
const signedIn = !!auth?.authenticated;
|
|
3009
|
+
const shownSite = auth?.region ?? site;
|
|
3010
|
+
const problemText = problem && (problem.kind === "expired" ? t("error.expired") : problem.kind === "cli" ? t("error.cli") : t("error.generic", { message: problem.message ?? "" }));
|
|
3011
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
3012
|
+
className: "meshy-root meshy-section",
|
|
3013
|
+
"aria-label": t("nav"),
|
|
3014
|
+
children: [!status ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Identity, {
|
|
3015
|
+
t,
|
|
3016
|
+
page: view === "page",
|
|
3017
|
+
line: t(view === "page" ? "summary" : "tagline"),
|
|
3018
|
+
pill: "checking"
|
|
3019
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Skeleton, {})] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
3020
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Identity, {
|
|
3021
|
+
t,
|
|
3022
|
+
page: view === "page",
|
|
3023
|
+
line: signedIn ? `${t(`site.${shownSite}`)} · ${SITES[shownSite].host}` : t(view === "page" ? "summary" : "tagline"),
|
|
3024
|
+
pill: !status.cli ? "off" : !signedIn ? "off" : auth.verified ? "on" : "warn"
|
|
3025
|
+
}),
|
|
3026
|
+
problem && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Alert, {
|
|
3027
|
+
action: problem.kind === "cli" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
3028
|
+
variant: "outline",
|
|
3029
|
+
size: "sm",
|
|
3030
|
+
onClick: refresh,
|
|
3031
|
+
children: t("refresh")
|
|
3032
|
+
}) : problem.kind === "expired" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
3033
|
+
variant: "outline",
|
|
3034
|
+
size: "sm",
|
|
3035
|
+
onClick: signIn,
|
|
3036
|
+
children: t("retry")
|
|
3037
|
+
}) : void 0,
|
|
3038
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: problemText }), problem.kind === "cli" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3039
|
+
className: "meshy-muted meshy-small",
|
|
3040
|
+
children: t("error.cliHint")
|
|
3041
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: "npm install -g meshy-cli@0.7" })] })]
|
|
3042
|
+
}),
|
|
3043
|
+
status.cli && signedIn && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3044
|
+
className: "meshy-card meshy-rows",
|
|
3045
|
+
children: [
|
|
3046
|
+
!auth.verified && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Alert, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("unverified.hint") }) }),
|
|
3047
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3048
|
+
className: "meshy-row",
|
|
3049
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("credits") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3050
|
+
className: "meshy-amount",
|
|
3051
|
+
children: auth.balance === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3052
|
+
className: "meshy-muted meshy-small",
|
|
3053
|
+
children: "—"
|
|
3054
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "meshy-coin" }), auth.balance.toLocaleString()] })
|
|
3055
|
+
})]
|
|
3056
|
+
}),
|
|
3057
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "meshy-divider" }),
|
|
3058
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3059
|
+
className: "meshy-row",
|
|
3060
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("account") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3061
|
+
className: "meshy-muted",
|
|
3062
|
+
children: auth.credential ?? auth.source ?? "—"
|
|
3063
|
+
})]
|
|
3064
|
+
}),
|
|
3065
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "meshy-divider" }),
|
|
3066
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3067
|
+
className: "meshy-row",
|
|
3068
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3069
|
+
className: "meshy-muted",
|
|
3070
|
+
children: t("more")
|
|
3071
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3072
|
+
className: "meshy-actions",
|
|
3073
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
3074
|
+
variant: "outline",
|
|
3075
|
+
disabled: busy,
|
|
3076
|
+
onClick: () => setConfirmOut(true),
|
|
3077
|
+
children: t("signOut")
|
|
3078
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
|
|
3079
|
+
className: "meshy-link meshy-accent",
|
|
3080
|
+
href: `${SITES[shownSite].web}/pricing`,
|
|
3081
|
+
target: "_blank",
|
|
3082
|
+
rel: "noreferrer",
|
|
3083
|
+
children: [t("credits.get"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRightUpOutlineRegular, { size: 12 })]
|
|
3084
|
+
})]
|
|
3085
|
+
})]
|
|
3086
|
+
})
|
|
3087
|
+
]
|
|
3088
|
+
}),
|
|
3089
|
+
status.cli && !signedIn && !flow && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3090
|
+
className: "meshy-card meshy-rows",
|
|
3091
|
+
children: [
|
|
3092
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3093
|
+
className: "meshy-row",
|
|
3094
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("site") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.SegmentedControl, {
|
|
3095
|
+
id: "meshy-site",
|
|
3096
|
+
label: t("site"),
|
|
3097
|
+
value: site,
|
|
3098
|
+
disabled: busy,
|
|
3099
|
+
onChange: (value) => setSite(value),
|
|
3100
|
+
options: [{
|
|
3101
|
+
value: "global",
|
|
3102
|
+
label: `${t("site.global")} · meshy.ai`
|
|
3103
|
+
}, {
|
|
3104
|
+
value: "cn",
|
|
3105
|
+
label: `${t("site.cn")} · meshy.cn`
|
|
3106
|
+
}]
|
|
3107
|
+
})]
|
|
3108
|
+
}),
|
|
3109
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "meshy-divider" }),
|
|
3110
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3111
|
+
className: "meshy-row",
|
|
3112
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3113
|
+
className: "meshy-muted",
|
|
3114
|
+
children: t("signIn.hint")
|
|
3115
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
3116
|
+
variant: "primary",
|
|
3117
|
+
className: "meshy-accent",
|
|
3118
|
+
disabled: busy,
|
|
3119
|
+
onClick: signIn,
|
|
3120
|
+
children: t("signIn")
|
|
3121
|
+
})]
|
|
3122
|
+
})
|
|
3123
|
+
]
|
|
3124
|
+
}),
|
|
3125
|
+
flow && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3126
|
+
className: "meshy-card meshy-signin",
|
|
3127
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
3128
|
+
className: "meshy-qr",
|
|
3129
|
+
src: qr(flow.verification_url),
|
|
3130
|
+
alt: ""
|
|
3131
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3132
|
+
className: "meshy-copy",
|
|
3133
|
+
children: [
|
|
3134
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3135
|
+
className: "meshy-name",
|
|
3136
|
+
children: t("signIn.scan")
|
|
3137
|
+
}),
|
|
3138
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3139
|
+
className: "meshy-muted",
|
|
3140
|
+
children: t("signIn.scanHint", { host: SITES[site].host })
|
|
3141
|
+
}),
|
|
3142
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3143
|
+
className: "meshy-code",
|
|
3144
|
+
children: [
|
|
3145
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3146
|
+
className: "meshy-muted",
|
|
3147
|
+
children: t("signIn.code")
|
|
3148
|
+
}),
|
|
3149
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: flow.user_code }),
|
|
3150
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
3151
|
+
label: copied ? t("copied") : t("copy"),
|
|
3152
|
+
side: "top",
|
|
3153
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
3154
|
+
variant: "ghost",
|
|
3155
|
+
size: "sm",
|
|
3156
|
+
"aria-label": t("copy"),
|
|
3157
|
+
icon: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutlineRegular, { size: 14 }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCopyOutlineRegular, { size: 14 }),
|
|
3158
|
+
onClick: copy
|
|
3159
|
+
})
|
|
3160
|
+
})
|
|
3161
|
+
]
|
|
3162
|
+
}),
|
|
3163
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3164
|
+
className: "meshy-waiting",
|
|
3165
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, {
|
|
3166
|
+
state: "ongoing",
|
|
3167
|
+
size: 12
|
|
3168
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.TextShimmer, {
|
|
3169
|
+
active: true,
|
|
3170
|
+
children: t("signIn.waiting")
|
|
3171
|
+
})]
|
|
3172
|
+
}),
|
|
3173
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3174
|
+
className: "meshy-actions",
|
|
3175
|
+
style: { justifyContent: "flex-start" },
|
|
3176
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
|
|
3177
|
+
className: "meshy-link meshy-accent",
|
|
3178
|
+
href: flow.verification_url,
|
|
3179
|
+
target: "_blank",
|
|
3180
|
+
rel: "noreferrer",
|
|
3181
|
+
children: [t("signIn.open"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRightUpOutlineRegular, { size: 12 })]
|
|
3182
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
3183
|
+
variant: "outline",
|
|
3184
|
+
onClick: cancel,
|
|
3185
|
+
children: t("cancel")
|
|
3186
|
+
})]
|
|
3187
|
+
})
|
|
3188
|
+
]
|
|
3189
|
+
})]
|
|
3190
|
+
}),
|
|
3191
|
+
status.cli && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3192
|
+
className: "meshy-foot meshy-muted meshy-small",
|
|
3193
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [t("cli", { version: status.cli.version }), status.cli.runner === "npm exec" ? ` · ${t("cli.temporary")}` : ""] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
3194
|
+
label: t("refresh"),
|
|
3195
|
+
side: "top",
|
|
3196
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
3197
|
+
variant: "ghost",
|
|
3198
|
+
size: "sm",
|
|
3199
|
+
"aria-label": t("refresh"),
|
|
3200
|
+
disabled: busy,
|
|
3201
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRefreshOutlineRegular, { size: 14 }),
|
|
3202
|
+
onClick: refresh
|
|
3203
|
+
})
|
|
3204
|
+
})]
|
|
3205
|
+
})
|
|
3206
|
+
] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
|
|
3207
|
+
open: confirmOut,
|
|
3208
|
+
onClose: () => setConfirmOut(false),
|
|
3209
|
+
title: t("signOut.title"),
|
|
3210
|
+
closeLabel: t("close"),
|
|
3211
|
+
description: t("signOut.body"),
|
|
3212
|
+
footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
3213
|
+
variant: "outline",
|
|
3214
|
+
onClick: () => setConfirmOut(false),
|
|
3215
|
+
children: t("cancel")
|
|
3216
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
3217
|
+
variant: "primary",
|
|
3218
|
+
onClick: signOut,
|
|
3219
|
+
children: t("signOut")
|
|
3220
|
+
})] })
|
|
3221
|
+
})]
|
|
3222
|
+
});
|
|
3223
|
+
}
|
|
3224
|
+
/** Set while the workspace navigation service is mounted: opens a new session with the prompt filled in. */
|
|
3225
|
+
let startSession;
|
|
3226
|
+
/** Left-sidebar icon: the host passes the edge size (18 expanded, 16 collapsed); colour follows the row. */
|
|
3227
|
+
function MeshySidebarIcon({ size = 16 }) {
|
|
3228
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3229
|
+
className: "meshy-mark",
|
|
3230
|
+
"aria-hidden": "true",
|
|
3231
|
+
style: {
|
|
3232
|
+
width: size,
|
|
3233
|
+
height: size
|
|
3234
|
+
},
|
|
3235
|
+
dangerouslySetInnerHTML: { __html: "<svg fill=\"currentColor\" fill-rule=\"evenodd\" height=\"100%\" style=\"flex:none;line-height:1\" viewBox=\"0 0 24 24\" width=\"100%\" xmlns=\"http://www.w3.org/2000/svg\"><title>Meshy</title><path d=\"M3.214.358l.59 1.606 1.597.595-1.596.594-.59 1.607-.591-1.607-1.596-.594 1.596-.595.59-1.606zM16.3 1.691a8.04 8.04 0 012.178.641c6.94 2.96 6.273 11.893.308 11.306l-.008-.007c.09.247.177.51.25.779.803 2.395-2.534 3.633-4.663 3.785l.138-.078c2.107-1.3 2.17-6.033-.175-5.56-.855.303-1.641 1.093-2 2.503a6.199 6.199 0 00-.093.436 25.87 25.87 0 00-.102.614c-.147.94-.32 2.038-.821 2.66-.578.041-1.153.043-1.711.001.737-.577 1.098-1.385 1.377-2.584-3.215.395-6.084-.384-6.257-4.094.17.809.509 1.431.972 1.896.267.133.61.252 1.043.345.911.196 1.928.07 2.646-.116.36.237.648.518.823.843.23-.027.464-.061.7-.102a4.523 4.523 0 00-.01-.197 3.115 3.115 0 01-.06-.209c-.108-.395-.278-1.023-.953-1.476-.391-.261-.76-.609-.696-1.075.064-.459.478-.731.93-.84 2.84-.683 4.568-2.988 5.45-5.648C14.988 6.75 14.129 8 13.032 8.947c-2.062 1.781-5.857 1.971-7.106.487.364.217.776.359 1.219.431-.299-.122-.54-.291-.665-.52 3.221.894 6.802-2.252 8.148-6.784-2.963-.128-6.335 1.44-8.25 4.01 2.084-3.387 6.04-5.44 9.916-4.88h.007zm2.57 5.476c-.357 1.21-.224 2.564.444 3.459.058.078.121.154.188.225l-.89.809c-1.327-.571-1.541-2.22-.99-3.741a5.04 5.04 0 011.32-1.997 3.822 3.822 0 011.195-.747l.003.004a3.511 3.511 0 00-.559.574c-.322.415-.56.902-.711 1.414z\"></path><path d=\"M20.352 14.028c6.788 3.227-.077 9.51-10.095 8.441-.36-.033-.72-.08-1.077-.142 3.05-.146 5.386-.591 7.887-2.766-5.111 3.23-14.152 2.117-12.294-1.535-.236 3.143 10.482 2.832 15.062-1.501-.73 2.168-1.945 3.664-3.423 4.62 3.978-1.476 6.496-4.16 3.94-7.117zM7.742 8.427s.236.142.573-.039c.546-.292.673-2.054.673-3.083 0-.278-.342-.283-.342-.283l-.029.003c-.398.042-.704.264-.682.495.079.862-.071 1.94-.27 2.64-.028.1.003.192.077.267zM11.395 6.972c-.338.181-.573.039-.573.039a.263.263 0 01-.078-.267c.2-.7.349-1.778.27-2.64-.021-.231.285-.453.683-.495.01 0 .019-.002.028-.003 0 0 .343.005.343.283 0 1.029-.128 2.79-.673 3.083zM1.056 5.438l-.337-.922-.337.922-.91.341.91.341.337.923.337-.923.91-.34-.91-.342z\"></path></svg>" }
|
|
3236
|
+
});
|
|
3237
|
+
}
|
|
3238
|
+
function ExampleCard({ t, id }) {
|
|
3239
|
+
const prompt = t(`example.${id}.prompt`);
|
|
3240
|
+
const [copied, setCopied] = (0, react.useState)(false);
|
|
3241
|
+
const run = async () => {
|
|
3242
|
+
if (startSession) return startSession(prompt);
|
|
3243
|
+
if (await (0, _deepseek_ai_dsh_client_ui_primitives.writeClipboard)(prompt)) {
|
|
3244
|
+
setCopied(true);
|
|
3245
|
+
setTimeout(() => setCopied(false), 1500);
|
|
3246
|
+
}
|
|
3247
|
+
};
|
|
3248
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
3249
|
+
type: "button",
|
|
3250
|
+
className: "meshy-example",
|
|
3251
|
+
onClick: run,
|
|
3252
|
+
children: [
|
|
3253
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3254
|
+
className: "meshy-example-title",
|
|
3255
|
+
children: t(`example.${id}.title`)
|
|
3256
|
+
}),
|
|
3257
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3258
|
+
className: "meshy-muted",
|
|
3259
|
+
children: prompt
|
|
3260
|
+
}),
|
|
3261
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3262
|
+
className: "meshy-example-cta",
|
|
3263
|
+
children: startSession ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [t("page.try"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutlineRegular, { size: 12 })] }) : copied ? t("copied") : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [t("copy"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCopyOutlineRegular, { size: 12 })] })
|
|
3264
|
+
})
|
|
3265
|
+
]
|
|
3266
|
+
});
|
|
3267
|
+
}
|
|
3268
|
+
/** The page the sidebar entry opens in the main column: the account card plus ways to start. */
|
|
3269
|
+
function MeshyPage({ t }) {
|
|
3270
|
+
const site = useSite();
|
|
3271
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3272
|
+
className: "meshy-root meshy-page",
|
|
3273
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3274
|
+
className: "meshy-page-inner",
|
|
3275
|
+
children: [
|
|
3276
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
|
|
3277
|
+
className: "meshy-hero",
|
|
3278
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Logo, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3279
|
+
className: "meshy-copy",
|
|
3280
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", { children: "Meshy" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3281
|
+
className: "meshy-muted",
|
|
3282
|
+
children: t("page.tagline")
|
|
3283
|
+
})]
|
|
3284
|
+
})]
|
|
3285
|
+
}),
|
|
3286
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MeshyPanel, {
|
|
3287
|
+
t,
|
|
3288
|
+
view: "page"
|
|
3289
|
+
}),
|
|
3290
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
3291
|
+
className: "meshy-block",
|
|
3292
|
+
"aria-labelledby": "meshy-start",
|
|
3293
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3294
|
+
className: "meshy-copy",
|
|
3295
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
|
|
3296
|
+
id: "meshy-start",
|
|
3297
|
+
className: "meshy-h2",
|
|
3298
|
+
children: t("page.start")
|
|
3299
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3300
|
+
className: "meshy-muted",
|
|
3301
|
+
children: t(startSession ? "page.startHint" : "page.copyHint")
|
|
3302
|
+
})]
|
|
3303
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3304
|
+
className: "meshy-grid",
|
|
3305
|
+
children: EXAMPLES.map((id) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExampleCard, {
|
|
3306
|
+
t,
|
|
3307
|
+
id
|
|
3308
|
+
}, id))
|
|
3309
|
+
})]
|
|
3310
|
+
}),
|
|
3311
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("footer", {
|
|
3312
|
+
className: "meshy-links meshy-small",
|
|
3313
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
|
|
3314
|
+
className: "meshy-textlink",
|
|
3315
|
+
href: docsUrl(site),
|
|
3316
|
+
target: "_blank",
|
|
3317
|
+
rel: "noreferrer",
|
|
3318
|
+
children: [t("page.docs"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRightUpOutlineRegular, { size: 12 })]
|
|
3319
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
|
|
3320
|
+
className: "meshy-textlink",
|
|
3321
|
+
href: SITES[site].web,
|
|
3322
|
+
target: "_blank",
|
|
3323
|
+
rel: "noreferrer",
|
|
3324
|
+
children: [t("page.site"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRightUpOutlineRegular, { size: 12 })]
|
|
3325
|
+
})]
|
|
3326
|
+
})
|
|
3327
|
+
]
|
|
3328
|
+
})
|
|
3329
|
+
});
|
|
3330
|
+
}
|
|
3331
|
+
/** The keyed `sidebar.right.tab.document` body for .glb, fed the file's complete bytes. */
|
|
3332
|
+
function GlbBody({ content, t }) {
|
|
3333
|
+
const host = (0, react.useRef)(null);
|
|
3334
|
+
const [viewer, setViewer] = (0, react.useState)();
|
|
3335
|
+
const [error, setError] = (0, react.useState)();
|
|
3336
|
+
const [spinning, setSpinning] = (0, react.useState)(false);
|
|
3337
|
+
(0, react.useEffect)(() => {
|
|
3338
|
+
const el = host.current;
|
|
3339
|
+
if (content.kind !== "bytes" || !content.data || !el) return;
|
|
3340
|
+
let mounted;
|
|
3341
|
+
let cancelled = false;
|
|
3342
|
+
setError(void 0);
|
|
3343
|
+
setViewer(void 0);
|
|
3344
|
+
setSpinning(false);
|
|
3345
|
+
require.async("./client.viewer.js").then((module) => module.mountViewer(el, content.data)).then((v) => {
|
|
3346
|
+
if (cancelled) v.dispose();
|
|
3347
|
+
else {
|
|
3348
|
+
mounted = v;
|
|
3349
|
+
setViewer(v);
|
|
3350
|
+
}
|
|
3351
|
+
}).catch((err) => {
|
|
3352
|
+
if (!cancelled) setError(String(err?.message ?? err));
|
|
3353
|
+
});
|
|
3354
|
+
return () => {
|
|
3355
|
+
cancelled = true;
|
|
3356
|
+
mounted?.dispose();
|
|
3357
|
+
};
|
|
3358
|
+
}, [content]);
|
|
3359
|
+
const toggle = () => {
|
|
3360
|
+
viewer?.setAutoRotate(!spinning);
|
|
3361
|
+
setSpinning(!spinning);
|
|
3362
|
+
};
|
|
3363
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3364
|
+
className: "meshy-root meshy-viewer",
|
|
3365
|
+
children: [
|
|
3366
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3367
|
+
ref: host,
|
|
3368
|
+
className: "meshy-stage"
|
|
3369
|
+
}),
|
|
3370
|
+
!viewer && !error && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3371
|
+
className: "meshy-overlay meshy-muted",
|
|
3372
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Logo, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.TextShimmer, {
|
|
3373
|
+
active: true,
|
|
3374
|
+
children: t("viewer.loading")
|
|
3375
|
+
})]
|
|
3376
|
+
}),
|
|
3377
|
+
error && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3378
|
+
className: "meshy-overlay",
|
|
3379
|
+
role: "alert",
|
|
3380
|
+
children: [
|
|
3381
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconWarningOutlineRegular, { size: 20 }),
|
|
3382
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("viewer.failed") }),
|
|
3383
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3384
|
+
className: "meshy-muted meshy-small",
|
|
3385
|
+
children: error
|
|
3386
|
+
})
|
|
3387
|
+
]
|
|
3388
|
+
}),
|
|
3389
|
+
viewer && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3390
|
+
className: "meshy-bar",
|
|
3391
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3392
|
+
className: "meshy-chip",
|
|
3393
|
+
children: [content.data ? `${(0, _deepseek_ai_dsh_client_ui_primitives.fileSizeText)(content.data.byteLength)} · ` : "", t("viewer.triangles", { count: viewer.triangles.toLocaleString() })]
|
|
3394
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3395
|
+
className: "meshy-tools",
|
|
3396
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
3397
|
+
label: t("viewer.reset"),
|
|
3398
|
+
side: "top",
|
|
3399
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
3400
|
+
variant: "ghost",
|
|
3401
|
+
size: "sm",
|
|
3402
|
+
"aria-label": t("viewer.reset"),
|
|
3403
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRefreshOutlineRegular, { size: 14 }),
|
|
3404
|
+
onClick: () => viewer.reset()
|
|
3405
|
+
})
|
|
3406
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
3407
|
+
label: spinning ? t("viewer.stop") : t("viewer.spin"),
|
|
3408
|
+
side: "top",
|
|
3409
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
3410
|
+
variant: "ghost",
|
|
3411
|
+
size: "sm",
|
|
3412
|
+
"aria-label": spinning ? t("viewer.stop") : t("viewer.spin"),
|
|
3413
|
+
"aria-pressed": spinning,
|
|
3414
|
+
icon: spinning ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPauseOutlineRegular, { size: 14 }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPlayOutlineRegular, { size: 14 }),
|
|
3415
|
+
onClick: toggle
|
|
3416
|
+
})
|
|
3417
|
+
})]
|
|
3418
|
+
})]
|
|
3419
|
+
})
|
|
3420
|
+
]
|
|
3421
|
+
});
|
|
3422
|
+
}
|
|
3423
|
+
function apply(ctx) {
|
|
3424
|
+
ctx.effect(() => ctx.locale.register(NS, {
|
|
3425
|
+
zh,
|
|
3426
|
+
en
|
|
3427
|
+
}), "meshy-dsh: dictionaries");
|
|
3428
|
+
ctx.effect(() => ctx.slots.inject("settings.section", () => ctx.slots.register({
|
|
3429
|
+
name: "settings.section",
|
|
3430
|
+
id: "meshy",
|
|
3431
|
+
order: 40,
|
|
3432
|
+
label: () => ctx.locale.bind(NS)("nav"),
|
|
3433
|
+
locale: NS
|
|
3434
|
+
}, MeshyPanel)), "meshy-dsh: settings section");
|
|
3435
|
+
ctx.effect(() => ctx.slots.inject("plugins.bundle.config", () => ctx.slots.register({
|
|
3436
|
+
name: "plugins.bundle.config",
|
|
3437
|
+
key: "meshy-dsh",
|
|
3438
|
+
locale: NS
|
|
3439
|
+
}, MeshyPanel)), "meshy-dsh: bundle page");
|
|
3440
|
+
ctx.inject([
|
|
3441
|
+
"layout",
|
|
3442
|
+
"slots",
|
|
3443
|
+
"locale"
|
|
3444
|
+
], (ctx) => {
|
|
3445
|
+
ctx.effect(() => ctx.slots.inject("main", () => ctx.slots.register({
|
|
3446
|
+
name: "main",
|
|
3447
|
+
key: PAGE_ID,
|
|
3448
|
+
locale: NS
|
|
3449
|
+
}, MeshyPage)), "meshy-dsh: page");
|
|
3450
|
+
ctx.effect(() => ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
|
|
3451
|
+
name: "sidebar.panellist",
|
|
3452
|
+
id: PAGE_ID,
|
|
3453
|
+
order: 20,
|
|
3454
|
+
label: "Meshy"
|
|
3455
|
+
}, MeshySidebarIcon)), "meshy-dsh: sidebar entry");
|
|
3456
|
+
});
|
|
3457
|
+
ctx.inject(["uiWorkspace"], (ctx) => {
|
|
3458
|
+
ctx.effect(() => {
|
|
3459
|
+
startSession = (prompt) => ctx.uiWorkspace.startSession(void 0, {
|
|
3460
|
+
prompt,
|
|
3461
|
+
whenDraftExists: "replace"
|
|
3462
|
+
});
|
|
3463
|
+
return () => {
|
|
3464
|
+
startSession = void 0;
|
|
3465
|
+
};
|
|
3466
|
+
}, "meshy-dsh: start a session from an example");
|
|
3467
|
+
});
|
|
3468
|
+
ctx.inject([
|
|
3469
|
+
"documentPreviews",
|
|
3470
|
+
"slots",
|
|
3471
|
+
"locale"
|
|
3472
|
+
], (ctx) => {
|
|
3473
|
+
ctx.effect(() => ctx.documentPreviews.register({
|
|
3474
|
+
id: GLB_ID,
|
|
3475
|
+
extensions: ["glb"],
|
|
3476
|
+
binaryExtensions: ["glb"],
|
|
3477
|
+
priority: "extension",
|
|
3478
|
+
title: () => ctx.locale.bind(NS)("viewer.title"),
|
|
3479
|
+
loading: "bytes-complete"
|
|
3480
|
+
}), "meshy-dsh: glb preview");
|
|
3481
|
+
ctx.effect(() => ctx.slots.inject("sidebar.right.tab.document", () => ctx.slots.register({
|
|
3482
|
+
name: "sidebar.right.tab.document",
|
|
3483
|
+
key: GLB_ID,
|
|
3484
|
+
locale: NS
|
|
3485
|
+
}, GlbBody)), "meshy-dsh: glb body");
|
|
3486
|
+
});
|
|
3487
|
+
}
|
|
3488
|
+
|
|
3489
|
+
exports.apply = apply;
|
|
3490
|
+
exports.inject = inject;
|
|
3491
|
+
exports.name = name;
|
|
3492
|
+
return module.exports; } });
|