dsh-qr-share 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -0
- package/LICENSE +21 -0
- package/README.md +146 -0
- package/README.zh.md +109 -0
- package/THIRD_PARTY_NOTICES.md +38 -0
- package/cordis.patch.yml +22 -0
- package/dsh.plugin.json +16 -0
- package/lib/client-registry.js +2804 -0
- package/lib/client.js +2804 -0
- package/lib/index.js +78 -0
- package/lib/invariant.js +24 -0
- package/lib/types/client/QrButton.d.ts +13 -0
- package/lib/types/client/QrDialog.d.ts +20 -0
- package/lib/types/client/api.d.ts +17 -0
- package/lib/types/client/index.d.ts +32 -0
- package/lib/types/client/locales.d.ts +16 -0
- package/lib/types/config.d.ts +28 -0
- package/lib/types/context-types.d.ts +34 -0
- package/lib/types/index.d.ts +14 -0
- package/lib/types/invariant.d.ts +9 -0
- package/package.json +135 -0
- package/src/client/QrButton.tsx +49 -0
- package/src/client/QrDialog.tsx +105 -0
- package/src/client/api.ts +41 -0
- package/src/client/index.tsx +107 -0
- package/src/client/locales.ts +38 -0
- package/src/client/styles.module.css +158 -0
- package/src/config.ts +37 -0
- package/src/context-types.ts +39 -0
- package/src/index.ts +107 -0
- package/src/invariant.ts +27 -0
|
@@ -0,0 +1,2804 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "dsh-external/dsh-qr-share",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
//#region \0rolldown/runtime.js
|
|
8
|
+
var __create = Object.create;
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
17
|
+
key = keys[i];
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
19
|
+
get: ((k) => from[k]).bind(null, key),
|
|
20
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: true
|
|
28
|
+
}) : target, mod));
|
|
29
|
+
//#endregion
|
|
30
|
+
let react = require("react");
|
|
31
|
+
react = __toESM(react, 1);
|
|
32
|
+
//#region node_modules/.pnpm/react-icons@5.7.0_react@18.3.0/node_modules/react-icons/lib/iconContext.mjs
|
|
33
|
+
var DefaultContext = {
|
|
34
|
+
color: void 0,
|
|
35
|
+
size: void 0,
|
|
36
|
+
className: void 0,
|
|
37
|
+
style: void 0,
|
|
38
|
+
attr: void 0
|
|
39
|
+
};
|
|
40
|
+
var IconContext = react.default.createContext && /*#__PURE__*/ react.default.createContext(DefaultContext);
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region node_modules/.pnpm/react-icons@5.7.0_react@18.3.0/node_modules/react-icons/lib/iconBase.mjs
|
|
43
|
+
var _excluded = [
|
|
44
|
+
"attr",
|
|
45
|
+
"size",
|
|
46
|
+
"title"
|
|
47
|
+
];
|
|
48
|
+
function _objectWithoutProperties(e, t) {
|
|
49
|
+
if (null == e) return {};
|
|
50
|
+
var o, r, i = _objectWithoutPropertiesLoose(e, t);
|
|
51
|
+
if (Object.getOwnPropertySymbols) {
|
|
52
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
53
|
+
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
54
|
+
}
|
|
55
|
+
return i;
|
|
56
|
+
}
|
|
57
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
58
|
+
if (null == r) return {};
|
|
59
|
+
var t = {};
|
|
60
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
61
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
62
|
+
t[n] = r[n];
|
|
63
|
+
}
|
|
64
|
+
return t;
|
|
65
|
+
}
|
|
66
|
+
function _extends() {
|
|
67
|
+
return _extends = Object.assign ? Object.assign.bind() : function(n) {
|
|
68
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
69
|
+
var t = arguments[e];
|
|
70
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
71
|
+
}
|
|
72
|
+
return n;
|
|
73
|
+
}, _extends.apply(null, arguments);
|
|
74
|
+
}
|
|
75
|
+
function ownKeys(e, r) {
|
|
76
|
+
var t = Object.keys(e);
|
|
77
|
+
if (Object.getOwnPropertySymbols) {
|
|
78
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
79
|
+
r && (o = o.filter(function(r) {
|
|
80
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
81
|
+
})), t.push.apply(t, o);
|
|
82
|
+
}
|
|
83
|
+
return t;
|
|
84
|
+
}
|
|
85
|
+
function _objectSpread(e) {
|
|
86
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
87
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
88
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
89
|
+
_defineProperty(e, r, t[r]);
|
|
90
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
91
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return e;
|
|
95
|
+
}
|
|
96
|
+
function _defineProperty(e, r, t) {
|
|
97
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
98
|
+
value: t,
|
|
99
|
+
enumerable: !0,
|
|
100
|
+
configurable: !0,
|
|
101
|
+
writable: !0
|
|
102
|
+
}) : e[r] = t, e;
|
|
103
|
+
}
|
|
104
|
+
function _toPropertyKey(t) {
|
|
105
|
+
var i = _toPrimitive(t, "string");
|
|
106
|
+
return "symbol" == typeof i ? i : i + "";
|
|
107
|
+
}
|
|
108
|
+
function _toPrimitive(t, r) {
|
|
109
|
+
if ("object" != typeof t || !t) return t;
|
|
110
|
+
var e = t[Symbol.toPrimitive];
|
|
111
|
+
if (void 0 !== e) {
|
|
112
|
+
var i = e.call(t, r || "default");
|
|
113
|
+
if ("object" != typeof i) return i;
|
|
114
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
115
|
+
}
|
|
116
|
+
return ("string" === r ? String : Number)(t);
|
|
117
|
+
}
|
|
118
|
+
function Tree2Element(tree) {
|
|
119
|
+
return tree && tree.map((node, i) => /*#__PURE__*/ react.default.createElement(node.tag, _objectSpread({ key: i }, node.attr), Tree2Element(node.child)));
|
|
120
|
+
}
|
|
121
|
+
function GenIcon(data) {
|
|
122
|
+
return (props) => /*#__PURE__*/ react.default.createElement(IconBase, _extends({ attr: _objectSpread({}, data.attr) }, props), Tree2Element(data.child));
|
|
123
|
+
}
|
|
124
|
+
function IconBase(props) {
|
|
125
|
+
var elem = (conf) => {
|
|
126
|
+
var attr = props.attr, size = props.size, title = props.title, svgProps = _objectWithoutProperties(props, _excluded);
|
|
127
|
+
var computedSize = size || conf.size || "1em";
|
|
128
|
+
var className;
|
|
129
|
+
if (conf.className) className = conf.className;
|
|
130
|
+
if (props.className) className = (className ? className + " " : "") + props.className;
|
|
131
|
+
return /*#__PURE__*/ react.default.createElement("svg", _extends({
|
|
132
|
+
stroke: "currentColor",
|
|
133
|
+
fill: "currentColor",
|
|
134
|
+
strokeWidth: "0"
|
|
135
|
+
}, conf.attr, attr, svgProps, {
|
|
136
|
+
className,
|
|
137
|
+
style: _objectSpread(_objectSpread({ color: props.color || conf.color }, conf.style), props.style),
|
|
138
|
+
height: computedSize,
|
|
139
|
+
width: computedSize,
|
|
140
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
141
|
+
}), title && /*#__PURE__*/ react.default.createElement("title", null, title), props.children);
|
|
142
|
+
};
|
|
143
|
+
return IconContext !== void 0 ? /*#__PURE__*/ react.default.createElement(IconContext.Consumer, null, (conf) => elem(conf)) : elem(DefaultContext);
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region node_modules/.pnpm/react-icons@5.7.0_react@18.3.0/node_modules/react-icons/hi2/index.mjs
|
|
147
|
+
function HiOutlineQrCode(props) {
|
|
148
|
+
return GenIcon({
|
|
149
|
+
"tag": "svg",
|
|
150
|
+
"attr": {
|
|
151
|
+
"fill": "none",
|
|
152
|
+
"viewBox": "0 0 24 24",
|
|
153
|
+
"strokeWidth": "1.5",
|
|
154
|
+
"stroke": "currentColor",
|
|
155
|
+
"aria-hidden": "true"
|
|
156
|
+
},
|
|
157
|
+
"child": [{
|
|
158
|
+
"tag": "path",
|
|
159
|
+
"attr": {
|
|
160
|
+
"strokeLinecap": "round",
|
|
161
|
+
"strokeLinejoin": "round",
|
|
162
|
+
"d": "M3.75 4.875c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5A1.125 1.125 0 0 1 3.75 9.375v-4.5ZM3.75 14.625c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5a1.125 1.125 0 0 1-1.125-1.125v-4.5ZM13.5 4.875c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5A1.125 1.125 0 0 1 13.5 9.375v-4.5Z"
|
|
163
|
+
},
|
|
164
|
+
"child": []
|
|
165
|
+
}, {
|
|
166
|
+
"tag": "path",
|
|
167
|
+
"attr": {
|
|
168
|
+
"strokeLinecap": "round",
|
|
169
|
+
"strokeLinejoin": "round",
|
|
170
|
+
"d": "M6.75 6.75h.75v.75h-.75v-.75ZM6.75 16.5h.75v.75h-.75v-.75ZM16.5 6.75h.75v.75h-.75v-.75ZM13.5 13.5h.75v.75h-.75v-.75ZM13.5 19.5h.75v.75h-.75v-.75ZM19.5 13.5h.75v.75h-.75v-.75ZM19.5 19.5h.75v.75h-.75v-.75ZM16.5 16.5h.75v.75h-.75v-.75Z"
|
|
171
|
+
},
|
|
172
|
+
"child": []
|
|
173
|
+
}]
|
|
174
|
+
})(props);
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js
|
|
178
|
+
var require_can_promise = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
179
|
+
module.exports = function() {
|
|
180
|
+
return typeof Promise === "function" && Promise.prototype && Promise.prototype.then;
|
|
181
|
+
};
|
|
182
|
+
}));
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js
|
|
185
|
+
var require_utils$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
186
|
+
let toSJISFunction;
|
|
187
|
+
const CODEWORDS_COUNT = [
|
|
188
|
+
0,
|
|
189
|
+
26,
|
|
190
|
+
44,
|
|
191
|
+
70,
|
|
192
|
+
100,
|
|
193
|
+
134,
|
|
194
|
+
172,
|
|
195
|
+
196,
|
|
196
|
+
242,
|
|
197
|
+
292,
|
|
198
|
+
346,
|
|
199
|
+
404,
|
|
200
|
+
466,
|
|
201
|
+
532,
|
|
202
|
+
581,
|
|
203
|
+
655,
|
|
204
|
+
733,
|
|
205
|
+
815,
|
|
206
|
+
901,
|
|
207
|
+
991,
|
|
208
|
+
1085,
|
|
209
|
+
1156,
|
|
210
|
+
1258,
|
|
211
|
+
1364,
|
|
212
|
+
1474,
|
|
213
|
+
1588,
|
|
214
|
+
1706,
|
|
215
|
+
1828,
|
|
216
|
+
1921,
|
|
217
|
+
2051,
|
|
218
|
+
2185,
|
|
219
|
+
2323,
|
|
220
|
+
2465,
|
|
221
|
+
2611,
|
|
222
|
+
2761,
|
|
223
|
+
2876,
|
|
224
|
+
3034,
|
|
225
|
+
3196,
|
|
226
|
+
3362,
|
|
227
|
+
3532,
|
|
228
|
+
3706
|
|
229
|
+
];
|
|
230
|
+
/**
|
|
231
|
+
* Returns the QR Code size for the specified version
|
|
232
|
+
*
|
|
233
|
+
* @param {Number} version QR Code version
|
|
234
|
+
* @return {Number} size of QR code
|
|
235
|
+
*/
|
|
236
|
+
exports.getSymbolSize = function getSymbolSize(version) {
|
|
237
|
+
if (!version) throw new Error("\"version\" cannot be null or undefined");
|
|
238
|
+
if (version < 1 || version > 40) throw new Error("\"version\" should be in range from 1 to 40");
|
|
239
|
+
return version * 4 + 17;
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Returns the total number of codewords used to store data and EC information.
|
|
243
|
+
*
|
|
244
|
+
* @param {Number} version QR Code version
|
|
245
|
+
* @return {Number} Data length in bits
|
|
246
|
+
*/
|
|
247
|
+
exports.getSymbolTotalCodewords = function getSymbolTotalCodewords(version) {
|
|
248
|
+
return CODEWORDS_COUNT[version];
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* Encode data with Bose-Chaudhuri-Hocquenghem
|
|
252
|
+
*
|
|
253
|
+
* @param {Number} data Value to encode
|
|
254
|
+
* @return {Number} Encoded value
|
|
255
|
+
*/
|
|
256
|
+
exports.getBCHDigit = function(data) {
|
|
257
|
+
let digit = 0;
|
|
258
|
+
while (data !== 0) {
|
|
259
|
+
digit++;
|
|
260
|
+
data >>>= 1;
|
|
261
|
+
}
|
|
262
|
+
return digit;
|
|
263
|
+
};
|
|
264
|
+
exports.setToSJISFunction = function setToSJISFunction(f) {
|
|
265
|
+
if (typeof f !== "function") throw new Error("\"toSJISFunc\" is not a valid function.");
|
|
266
|
+
toSJISFunction = f;
|
|
267
|
+
};
|
|
268
|
+
exports.isKanjiModeEnabled = function() {
|
|
269
|
+
return typeof toSJISFunction !== "undefined";
|
|
270
|
+
};
|
|
271
|
+
exports.toSJIS = function toSJIS(kanji) {
|
|
272
|
+
return toSJISFunction(kanji);
|
|
273
|
+
};
|
|
274
|
+
}));
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js
|
|
277
|
+
var require_error_correction_level = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
278
|
+
exports.L = { bit: 1 };
|
|
279
|
+
exports.M = { bit: 0 };
|
|
280
|
+
exports.Q = { bit: 3 };
|
|
281
|
+
exports.H = { bit: 2 };
|
|
282
|
+
function fromString(string) {
|
|
283
|
+
if (typeof string !== "string") throw new Error("Param is not a string");
|
|
284
|
+
switch (string.toLowerCase()) {
|
|
285
|
+
case "l":
|
|
286
|
+
case "low": return exports.L;
|
|
287
|
+
case "m":
|
|
288
|
+
case "medium": return exports.M;
|
|
289
|
+
case "q":
|
|
290
|
+
case "quartile": return exports.Q;
|
|
291
|
+
case "h":
|
|
292
|
+
case "high": return exports.H;
|
|
293
|
+
default: throw new Error("Unknown EC Level: " + string);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
exports.isValid = function isValid(level) {
|
|
297
|
+
return level && typeof level.bit !== "undefined" && level.bit >= 0 && level.bit < 4;
|
|
298
|
+
};
|
|
299
|
+
exports.from = function from(value, defaultValue) {
|
|
300
|
+
if (exports.isValid(value)) return value;
|
|
301
|
+
try {
|
|
302
|
+
return fromString(value);
|
|
303
|
+
} catch (e) {
|
|
304
|
+
return defaultValue;
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
}));
|
|
308
|
+
//#endregion
|
|
309
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js
|
|
310
|
+
var require_bit_buffer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
311
|
+
function BitBuffer() {
|
|
312
|
+
this.buffer = [];
|
|
313
|
+
this.length = 0;
|
|
314
|
+
}
|
|
315
|
+
BitBuffer.prototype = {
|
|
316
|
+
get: function(index) {
|
|
317
|
+
const bufIndex = Math.floor(index / 8);
|
|
318
|
+
return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) === 1;
|
|
319
|
+
},
|
|
320
|
+
put: function(num, length) {
|
|
321
|
+
for (let i = 0; i < length; i++) this.putBit((num >>> length - i - 1 & 1) === 1);
|
|
322
|
+
},
|
|
323
|
+
getLengthInBits: function() {
|
|
324
|
+
return this.length;
|
|
325
|
+
},
|
|
326
|
+
putBit: function(bit) {
|
|
327
|
+
const bufIndex = Math.floor(this.length / 8);
|
|
328
|
+
if (this.buffer.length <= bufIndex) this.buffer.push(0);
|
|
329
|
+
if (bit) this.buffer[bufIndex] |= 128 >>> this.length % 8;
|
|
330
|
+
this.length++;
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
module.exports = BitBuffer;
|
|
334
|
+
}));
|
|
335
|
+
//#endregion
|
|
336
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js
|
|
337
|
+
var require_bit_matrix = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
338
|
+
/**
|
|
339
|
+
* Helper class to handle QR Code symbol modules
|
|
340
|
+
*
|
|
341
|
+
* @param {Number} size Symbol size
|
|
342
|
+
*/
|
|
343
|
+
function BitMatrix(size) {
|
|
344
|
+
if (!size || size < 1) throw new Error("BitMatrix size must be defined and greater than 0");
|
|
345
|
+
this.size = size;
|
|
346
|
+
this.data = new Uint8Array(size * size);
|
|
347
|
+
this.reservedBit = new Uint8Array(size * size);
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Set bit value at specified location
|
|
351
|
+
* If reserved flag is set, this bit will be ignored during masking process
|
|
352
|
+
*
|
|
353
|
+
* @param {Number} row
|
|
354
|
+
* @param {Number} col
|
|
355
|
+
* @param {Boolean} value
|
|
356
|
+
* @param {Boolean} reserved
|
|
357
|
+
*/
|
|
358
|
+
BitMatrix.prototype.set = function(row, col, value, reserved) {
|
|
359
|
+
const index = row * this.size + col;
|
|
360
|
+
this.data[index] = value;
|
|
361
|
+
if (reserved) this.reservedBit[index] = true;
|
|
362
|
+
};
|
|
363
|
+
/**
|
|
364
|
+
* Returns bit value at specified location
|
|
365
|
+
*
|
|
366
|
+
* @param {Number} row
|
|
367
|
+
* @param {Number} col
|
|
368
|
+
* @return {Boolean}
|
|
369
|
+
*/
|
|
370
|
+
BitMatrix.prototype.get = function(row, col) {
|
|
371
|
+
return this.data[row * this.size + col];
|
|
372
|
+
};
|
|
373
|
+
/**
|
|
374
|
+
* Applies xor operator at specified location
|
|
375
|
+
* (used during masking process)
|
|
376
|
+
*
|
|
377
|
+
* @param {Number} row
|
|
378
|
+
* @param {Number} col
|
|
379
|
+
* @param {Boolean} value
|
|
380
|
+
*/
|
|
381
|
+
BitMatrix.prototype.xor = function(row, col, value) {
|
|
382
|
+
this.data[row * this.size + col] ^= value;
|
|
383
|
+
};
|
|
384
|
+
/**
|
|
385
|
+
* Check if bit at specified location is reserved
|
|
386
|
+
*
|
|
387
|
+
* @param {Number} row
|
|
388
|
+
* @param {Number} col
|
|
389
|
+
* @return {Boolean}
|
|
390
|
+
*/
|
|
391
|
+
BitMatrix.prototype.isReserved = function(row, col) {
|
|
392
|
+
return this.reservedBit[row * this.size + col];
|
|
393
|
+
};
|
|
394
|
+
module.exports = BitMatrix;
|
|
395
|
+
}));
|
|
396
|
+
//#endregion
|
|
397
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js
|
|
398
|
+
var require_alignment_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
399
|
+
/**
|
|
400
|
+
* Alignment pattern are fixed reference pattern in defined positions
|
|
401
|
+
* in a matrix symbology, which enables the decode software to re-synchronise
|
|
402
|
+
* the coordinate mapping of the image modules in the event of moderate amounts
|
|
403
|
+
* of distortion of the image.
|
|
404
|
+
*
|
|
405
|
+
* Alignment patterns are present only in QR Code symbols of version 2 or larger
|
|
406
|
+
* and their number depends on the symbol version.
|
|
407
|
+
*/
|
|
408
|
+
const getSymbolSize = require_utils$1().getSymbolSize;
|
|
409
|
+
/**
|
|
410
|
+
* Calculate the row/column coordinates of the center module of each alignment pattern
|
|
411
|
+
* for the specified QR Code version.
|
|
412
|
+
*
|
|
413
|
+
* The alignment patterns are positioned symmetrically on either side of the diagonal
|
|
414
|
+
* running from the top left corner of the symbol to the bottom right corner.
|
|
415
|
+
*
|
|
416
|
+
* Since positions are simmetrical only half of the coordinates are returned.
|
|
417
|
+
* Each item of the array will represent in turn the x and y coordinate.
|
|
418
|
+
* @see {@link getPositions}
|
|
419
|
+
*
|
|
420
|
+
* @param {Number} version QR Code version
|
|
421
|
+
* @return {Array} Array of coordinate
|
|
422
|
+
*/
|
|
423
|
+
exports.getRowColCoords = function getRowColCoords(version) {
|
|
424
|
+
if (version === 1) return [];
|
|
425
|
+
const posCount = Math.floor(version / 7) + 2;
|
|
426
|
+
const size = getSymbolSize(version);
|
|
427
|
+
const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2;
|
|
428
|
+
const positions = [size - 7];
|
|
429
|
+
for (let i = 1; i < posCount - 1; i++) positions[i] = positions[i - 1] - intervals;
|
|
430
|
+
positions.push(6);
|
|
431
|
+
return positions.reverse();
|
|
432
|
+
};
|
|
433
|
+
/**
|
|
434
|
+
* Returns an array containing the positions of each alignment pattern.
|
|
435
|
+
* Each array's element represent the center point of the pattern as (x, y) coordinates
|
|
436
|
+
*
|
|
437
|
+
* Coordinates are calculated expanding the row/column coordinates returned by {@link getRowColCoords}
|
|
438
|
+
* and filtering out the items that overlaps with finder pattern
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* For a Version 7 symbol {@link getRowColCoords} returns values 6, 22 and 38.
|
|
442
|
+
* The alignment patterns, therefore, are to be centered on (row, column)
|
|
443
|
+
* positions (6,22), (22,6), (22,22), (22,38), (38,22), (38,38).
|
|
444
|
+
* Note that the coordinates (6,6), (6,38), (38,6) are occupied by finder patterns
|
|
445
|
+
* and are not therefore used for alignment patterns.
|
|
446
|
+
*
|
|
447
|
+
* let pos = getPositions(7)
|
|
448
|
+
* // [[6,22], [22,6], [22,22], [22,38], [38,22], [38,38]]
|
|
449
|
+
*
|
|
450
|
+
* @param {Number} version QR Code version
|
|
451
|
+
* @return {Array} Array of coordinates
|
|
452
|
+
*/
|
|
453
|
+
exports.getPositions = function getPositions(version) {
|
|
454
|
+
const coords = [];
|
|
455
|
+
const pos = exports.getRowColCoords(version);
|
|
456
|
+
const posLength = pos.length;
|
|
457
|
+
for (let i = 0; i < posLength; i++) for (let j = 0; j < posLength; j++) {
|
|
458
|
+
if (i === 0 && j === 0 || i === 0 && j === posLength - 1 || i === posLength - 1 && j === 0) continue;
|
|
459
|
+
coords.push([pos[i], pos[j]]);
|
|
460
|
+
}
|
|
461
|
+
return coords;
|
|
462
|
+
};
|
|
463
|
+
}));
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js
|
|
466
|
+
var require_finder_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
467
|
+
const getSymbolSize = require_utils$1().getSymbolSize;
|
|
468
|
+
const FINDER_PATTERN_SIZE = 7;
|
|
469
|
+
/**
|
|
470
|
+
* Returns an array containing the positions of each finder pattern.
|
|
471
|
+
* Each array's element represent the top-left point of the pattern as (x, y) coordinates
|
|
472
|
+
*
|
|
473
|
+
* @param {Number} version QR Code version
|
|
474
|
+
* @return {Array} Array of coordinates
|
|
475
|
+
*/
|
|
476
|
+
exports.getPositions = function getPositions(version) {
|
|
477
|
+
const size = getSymbolSize(version);
|
|
478
|
+
return [
|
|
479
|
+
[0, 0],
|
|
480
|
+
[size - FINDER_PATTERN_SIZE, 0],
|
|
481
|
+
[0, size - FINDER_PATTERN_SIZE]
|
|
482
|
+
];
|
|
483
|
+
};
|
|
484
|
+
}));
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js
|
|
487
|
+
var require_mask_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
488
|
+
/**
|
|
489
|
+
* Data mask pattern reference
|
|
490
|
+
* @type {Object}
|
|
491
|
+
*/
|
|
492
|
+
exports.Patterns = {
|
|
493
|
+
PATTERN000: 0,
|
|
494
|
+
PATTERN001: 1,
|
|
495
|
+
PATTERN010: 2,
|
|
496
|
+
PATTERN011: 3,
|
|
497
|
+
PATTERN100: 4,
|
|
498
|
+
PATTERN101: 5,
|
|
499
|
+
PATTERN110: 6,
|
|
500
|
+
PATTERN111: 7
|
|
501
|
+
};
|
|
502
|
+
/**
|
|
503
|
+
* Weighted penalty scores for the undesirable features
|
|
504
|
+
* @type {Object}
|
|
505
|
+
*/
|
|
506
|
+
const PenaltyScores = {
|
|
507
|
+
N1: 3,
|
|
508
|
+
N2: 3,
|
|
509
|
+
N3: 40,
|
|
510
|
+
N4: 10
|
|
511
|
+
};
|
|
512
|
+
/**
|
|
513
|
+
* Check if mask pattern value is valid
|
|
514
|
+
*
|
|
515
|
+
* @param {Number} mask Mask pattern
|
|
516
|
+
* @return {Boolean} true if valid, false otherwise
|
|
517
|
+
*/
|
|
518
|
+
exports.isValid = function isValid(mask) {
|
|
519
|
+
return mask != null && mask !== "" && !isNaN(mask) && mask >= 0 && mask <= 7;
|
|
520
|
+
};
|
|
521
|
+
/**
|
|
522
|
+
* Returns mask pattern from a value.
|
|
523
|
+
* If value is not valid, returns undefined
|
|
524
|
+
*
|
|
525
|
+
* @param {Number|String} value Mask pattern value
|
|
526
|
+
* @return {Number} Valid mask pattern or undefined
|
|
527
|
+
*/
|
|
528
|
+
exports.from = function from(value) {
|
|
529
|
+
return exports.isValid(value) ? parseInt(value, 10) : void 0;
|
|
530
|
+
};
|
|
531
|
+
/**
|
|
532
|
+
* Find adjacent modules in row/column with the same color
|
|
533
|
+
* and assign a penalty value.
|
|
534
|
+
*
|
|
535
|
+
* Points: N1 + i
|
|
536
|
+
* i is the amount by which the number of adjacent modules of the same color exceeds 5
|
|
537
|
+
*/
|
|
538
|
+
exports.getPenaltyN1 = function getPenaltyN1(data) {
|
|
539
|
+
const size = data.size;
|
|
540
|
+
let points = 0;
|
|
541
|
+
let sameCountCol = 0;
|
|
542
|
+
let sameCountRow = 0;
|
|
543
|
+
let lastCol = null;
|
|
544
|
+
let lastRow = null;
|
|
545
|
+
for (let row = 0; row < size; row++) {
|
|
546
|
+
sameCountCol = sameCountRow = 0;
|
|
547
|
+
lastCol = lastRow = null;
|
|
548
|
+
for (let col = 0; col < size; col++) {
|
|
549
|
+
let module$1 = data.get(row, col);
|
|
550
|
+
if (module$1 === lastCol) sameCountCol++;
|
|
551
|
+
else {
|
|
552
|
+
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
|
|
553
|
+
lastCol = module$1;
|
|
554
|
+
sameCountCol = 1;
|
|
555
|
+
}
|
|
556
|
+
module$1 = data.get(col, row);
|
|
557
|
+
if (module$1 === lastRow) sameCountRow++;
|
|
558
|
+
else {
|
|
559
|
+
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
|
|
560
|
+
lastRow = module$1;
|
|
561
|
+
sameCountRow = 1;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
|
|
565
|
+
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
|
|
566
|
+
}
|
|
567
|
+
return points;
|
|
568
|
+
};
|
|
569
|
+
/**
|
|
570
|
+
* Find 2x2 blocks with the same color and assign a penalty value
|
|
571
|
+
*
|
|
572
|
+
* Points: N2 * (m - 1) * (n - 1)
|
|
573
|
+
*/
|
|
574
|
+
exports.getPenaltyN2 = function getPenaltyN2(data) {
|
|
575
|
+
const size = data.size;
|
|
576
|
+
let points = 0;
|
|
577
|
+
for (let row = 0; row < size - 1; row++) for (let col = 0; col < size - 1; col++) {
|
|
578
|
+
const last = data.get(row, col) + data.get(row, col + 1) + data.get(row + 1, col) + data.get(row + 1, col + 1);
|
|
579
|
+
if (last === 4 || last === 0) points++;
|
|
580
|
+
}
|
|
581
|
+
return points * PenaltyScores.N2;
|
|
582
|
+
};
|
|
583
|
+
/**
|
|
584
|
+
* Find 1:1:3:1:1 ratio (dark:light:dark:light:dark) pattern in row/column,
|
|
585
|
+
* preceded or followed by light area 4 modules wide
|
|
586
|
+
*
|
|
587
|
+
* Points: N3 * number of pattern found
|
|
588
|
+
*/
|
|
589
|
+
exports.getPenaltyN3 = function getPenaltyN3(data) {
|
|
590
|
+
const size = data.size;
|
|
591
|
+
let points = 0;
|
|
592
|
+
let bitsCol = 0;
|
|
593
|
+
let bitsRow = 0;
|
|
594
|
+
for (let row = 0; row < size; row++) {
|
|
595
|
+
bitsCol = bitsRow = 0;
|
|
596
|
+
for (let col = 0; col < size; col++) {
|
|
597
|
+
bitsCol = bitsCol << 1 & 2047 | data.get(row, col);
|
|
598
|
+
if (col >= 10 && (bitsCol === 1488 || bitsCol === 93)) points++;
|
|
599
|
+
bitsRow = bitsRow << 1 & 2047 | data.get(col, row);
|
|
600
|
+
if (col >= 10 && (bitsRow === 1488 || bitsRow === 93)) points++;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
return points * PenaltyScores.N3;
|
|
604
|
+
};
|
|
605
|
+
/**
|
|
606
|
+
* Calculate proportion of dark modules in entire symbol
|
|
607
|
+
*
|
|
608
|
+
* Points: N4 * k
|
|
609
|
+
*
|
|
610
|
+
* k is the rating of the deviation of the proportion of dark modules
|
|
611
|
+
* in the symbol from 50% in steps of 5%
|
|
612
|
+
*/
|
|
613
|
+
exports.getPenaltyN4 = function getPenaltyN4(data) {
|
|
614
|
+
let darkCount = 0;
|
|
615
|
+
const modulesCount = data.data.length;
|
|
616
|
+
for (let i = 0; i < modulesCount; i++) darkCount += data.data[i];
|
|
617
|
+
return Math.abs(Math.ceil(darkCount * 100 / modulesCount / 5) - 10) * PenaltyScores.N4;
|
|
618
|
+
};
|
|
619
|
+
/**
|
|
620
|
+
* Return mask value at given position
|
|
621
|
+
*
|
|
622
|
+
* @param {Number} maskPattern Pattern reference value
|
|
623
|
+
* @param {Number} i Row
|
|
624
|
+
* @param {Number} j Column
|
|
625
|
+
* @return {Boolean} Mask value
|
|
626
|
+
*/
|
|
627
|
+
function getMaskAt(maskPattern, i, j) {
|
|
628
|
+
switch (maskPattern) {
|
|
629
|
+
case exports.Patterns.PATTERN000: return (i + j) % 2 === 0;
|
|
630
|
+
case exports.Patterns.PATTERN001: return i % 2 === 0;
|
|
631
|
+
case exports.Patterns.PATTERN010: return j % 3 === 0;
|
|
632
|
+
case exports.Patterns.PATTERN011: return (i + j) % 3 === 0;
|
|
633
|
+
case exports.Patterns.PATTERN100: return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0;
|
|
634
|
+
case exports.Patterns.PATTERN101: return i * j % 2 + i * j % 3 === 0;
|
|
635
|
+
case exports.Patterns.PATTERN110: return (i * j % 2 + i * j % 3) % 2 === 0;
|
|
636
|
+
case exports.Patterns.PATTERN111: return (i * j % 3 + (i + j) % 2) % 2 === 0;
|
|
637
|
+
default: throw new Error("bad maskPattern:" + maskPattern);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Apply a mask pattern to a BitMatrix
|
|
642
|
+
*
|
|
643
|
+
* @param {Number} pattern Pattern reference number
|
|
644
|
+
* @param {BitMatrix} data BitMatrix data
|
|
645
|
+
*/
|
|
646
|
+
exports.applyMask = function applyMask(pattern, data) {
|
|
647
|
+
const size = data.size;
|
|
648
|
+
for (let col = 0; col < size; col++) for (let row = 0; row < size; row++) {
|
|
649
|
+
if (data.isReserved(row, col)) continue;
|
|
650
|
+
data.xor(row, col, getMaskAt(pattern, row, col));
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
/**
|
|
654
|
+
* Returns the best mask pattern for data
|
|
655
|
+
*
|
|
656
|
+
* @param {BitMatrix} data
|
|
657
|
+
* @return {Number} Mask pattern reference number
|
|
658
|
+
*/
|
|
659
|
+
exports.getBestMask = function getBestMask(data, setupFormatFunc) {
|
|
660
|
+
const numPatterns = Object.keys(exports.Patterns).length;
|
|
661
|
+
let bestPattern = 0;
|
|
662
|
+
let lowerPenalty = Infinity;
|
|
663
|
+
for (let p = 0; p < numPatterns; p++) {
|
|
664
|
+
setupFormatFunc(p);
|
|
665
|
+
exports.applyMask(p, data);
|
|
666
|
+
const penalty = exports.getPenaltyN1(data) + exports.getPenaltyN2(data) + exports.getPenaltyN3(data) + exports.getPenaltyN4(data);
|
|
667
|
+
exports.applyMask(p, data);
|
|
668
|
+
if (penalty < lowerPenalty) {
|
|
669
|
+
lowerPenalty = penalty;
|
|
670
|
+
bestPattern = p;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
return bestPattern;
|
|
674
|
+
};
|
|
675
|
+
}));
|
|
676
|
+
//#endregion
|
|
677
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js
|
|
678
|
+
var require_error_correction_code = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
679
|
+
const ECLevel = require_error_correction_level();
|
|
680
|
+
const EC_BLOCKS_TABLE = [
|
|
681
|
+
1,
|
|
682
|
+
1,
|
|
683
|
+
1,
|
|
684
|
+
1,
|
|
685
|
+
1,
|
|
686
|
+
1,
|
|
687
|
+
1,
|
|
688
|
+
1,
|
|
689
|
+
1,
|
|
690
|
+
1,
|
|
691
|
+
2,
|
|
692
|
+
2,
|
|
693
|
+
1,
|
|
694
|
+
2,
|
|
695
|
+
2,
|
|
696
|
+
4,
|
|
697
|
+
1,
|
|
698
|
+
2,
|
|
699
|
+
4,
|
|
700
|
+
4,
|
|
701
|
+
2,
|
|
702
|
+
4,
|
|
703
|
+
4,
|
|
704
|
+
4,
|
|
705
|
+
2,
|
|
706
|
+
4,
|
|
707
|
+
6,
|
|
708
|
+
5,
|
|
709
|
+
2,
|
|
710
|
+
4,
|
|
711
|
+
6,
|
|
712
|
+
6,
|
|
713
|
+
2,
|
|
714
|
+
5,
|
|
715
|
+
8,
|
|
716
|
+
8,
|
|
717
|
+
4,
|
|
718
|
+
5,
|
|
719
|
+
8,
|
|
720
|
+
8,
|
|
721
|
+
4,
|
|
722
|
+
5,
|
|
723
|
+
8,
|
|
724
|
+
11,
|
|
725
|
+
4,
|
|
726
|
+
8,
|
|
727
|
+
10,
|
|
728
|
+
11,
|
|
729
|
+
4,
|
|
730
|
+
9,
|
|
731
|
+
12,
|
|
732
|
+
16,
|
|
733
|
+
4,
|
|
734
|
+
9,
|
|
735
|
+
16,
|
|
736
|
+
16,
|
|
737
|
+
6,
|
|
738
|
+
10,
|
|
739
|
+
12,
|
|
740
|
+
18,
|
|
741
|
+
6,
|
|
742
|
+
10,
|
|
743
|
+
17,
|
|
744
|
+
16,
|
|
745
|
+
6,
|
|
746
|
+
11,
|
|
747
|
+
16,
|
|
748
|
+
19,
|
|
749
|
+
6,
|
|
750
|
+
13,
|
|
751
|
+
18,
|
|
752
|
+
21,
|
|
753
|
+
7,
|
|
754
|
+
14,
|
|
755
|
+
21,
|
|
756
|
+
25,
|
|
757
|
+
8,
|
|
758
|
+
16,
|
|
759
|
+
20,
|
|
760
|
+
25,
|
|
761
|
+
8,
|
|
762
|
+
17,
|
|
763
|
+
23,
|
|
764
|
+
25,
|
|
765
|
+
9,
|
|
766
|
+
17,
|
|
767
|
+
23,
|
|
768
|
+
34,
|
|
769
|
+
9,
|
|
770
|
+
18,
|
|
771
|
+
25,
|
|
772
|
+
30,
|
|
773
|
+
10,
|
|
774
|
+
20,
|
|
775
|
+
27,
|
|
776
|
+
32,
|
|
777
|
+
12,
|
|
778
|
+
21,
|
|
779
|
+
29,
|
|
780
|
+
35,
|
|
781
|
+
12,
|
|
782
|
+
23,
|
|
783
|
+
34,
|
|
784
|
+
37,
|
|
785
|
+
12,
|
|
786
|
+
25,
|
|
787
|
+
34,
|
|
788
|
+
40,
|
|
789
|
+
13,
|
|
790
|
+
26,
|
|
791
|
+
35,
|
|
792
|
+
42,
|
|
793
|
+
14,
|
|
794
|
+
28,
|
|
795
|
+
38,
|
|
796
|
+
45,
|
|
797
|
+
15,
|
|
798
|
+
29,
|
|
799
|
+
40,
|
|
800
|
+
48,
|
|
801
|
+
16,
|
|
802
|
+
31,
|
|
803
|
+
43,
|
|
804
|
+
51,
|
|
805
|
+
17,
|
|
806
|
+
33,
|
|
807
|
+
45,
|
|
808
|
+
54,
|
|
809
|
+
18,
|
|
810
|
+
35,
|
|
811
|
+
48,
|
|
812
|
+
57,
|
|
813
|
+
19,
|
|
814
|
+
37,
|
|
815
|
+
51,
|
|
816
|
+
60,
|
|
817
|
+
19,
|
|
818
|
+
38,
|
|
819
|
+
53,
|
|
820
|
+
63,
|
|
821
|
+
20,
|
|
822
|
+
40,
|
|
823
|
+
56,
|
|
824
|
+
66,
|
|
825
|
+
21,
|
|
826
|
+
43,
|
|
827
|
+
59,
|
|
828
|
+
70,
|
|
829
|
+
22,
|
|
830
|
+
45,
|
|
831
|
+
62,
|
|
832
|
+
74,
|
|
833
|
+
24,
|
|
834
|
+
47,
|
|
835
|
+
65,
|
|
836
|
+
77,
|
|
837
|
+
25,
|
|
838
|
+
49,
|
|
839
|
+
68,
|
|
840
|
+
81
|
|
841
|
+
];
|
|
842
|
+
const EC_CODEWORDS_TABLE = [
|
|
843
|
+
7,
|
|
844
|
+
10,
|
|
845
|
+
13,
|
|
846
|
+
17,
|
|
847
|
+
10,
|
|
848
|
+
16,
|
|
849
|
+
22,
|
|
850
|
+
28,
|
|
851
|
+
15,
|
|
852
|
+
26,
|
|
853
|
+
36,
|
|
854
|
+
44,
|
|
855
|
+
20,
|
|
856
|
+
36,
|
|
857
|
+
52,
|
|
858
|
+
64,
|
|
859
|
+
26,
|
|
860
|
+
48,
|
|
861
|
+
72,
|
|
862
|
+
88,
|
|
863
|
+
36,
|
|
864
|
+
64,
|
|
865
|
+
96,
|
|
866
|
+
112,
|
|
867
|
+
40,
|
|
868
|
+
72,
|
|
869
|
+
108,
|
|
870
|
+
130,
|
|
871
|
+
48,
|
|
872
|
+
88,
|
|
873
|
+
132,
|
|
874
|
+
156,
|
|
875
|
+
60,
|
|
876
|
+
110,
|
|
877
|
+
160,
|
|
878
|
+
192,
|
|
879
|
+
72,
|
|
880
|
+
130,
|
|
881
|
+
192,
|
|
882
|
+
224,
|
|
883
|
+
80,
|
|
884
|
+
150,
|
|
885
|
+
224,
|
|
886
|
+
264,
|
|
887
|
+
96,
|
|
888
|
+
176,
|
|
889
|
+
260,
|
|
890
|
+
308,
|
|
891
|
+
104,
|
|
892
|
+
198,
|
|
893
|
+
288,
|
|
894
|
+
352,
|
|
895
|
+
120,
|
|
896
|
+
216,
|
|
897
|
+
320,
|
|
898
|
+
384,
|
|
899
|
+
132,
|
|
900
|
+
240,
|
|
901
|
+
360,
|
|
902
|
+
432,
|
|
903
|
+
144,
|
|
904
|
+
280,
|
|
905
|
+
408,
|
|
906
|
+
480,
|
|
907
|
+
168,
|
|
908
|
+
308,
|
|
909
|
+
448,
|
|
910
|
+
532,
|
|
911
|
+
180,
|
|
912
|
+
338,
|
|
913
|
+
504,
|
|
914
|
+
588,
|
|
915
|
+
196,
|
|
916
|
+
364,
|
|
917
|
+
546,
|
|
918
|
+
650,
|
|
919
|
+
224,
|
|
920
|
+
416,
|
|
921
|
+
600,
|
|
922
|
+
700,
|
|
923
|
+
224,
|
|
924
|
+
442,
|
|
925
|
+
644,
|
|
926
|
+
750,
|
|
927
|
+
252,
|
|
928
|
+
476,
|
|
929
|
+
690,
|
|
930
|
+
816,
|
|
931
|
+
270,
|
|
932
|
+
504,
|
|
933
|
+
750,
|
|
934
|
+
900,
|
|
935
|
+
300,
|
|
936
|
+
560,
|
|
937
|
+
810,
|
|
938
|
+
960,
|
|
939
|
+
312,
|
|
940
|
+
588,
|
|
941
|
+
870,
|
|
942
|
+
1050,
|
|
943
|
+
336,
|
|
944
|
+
644,
|
|
945
|
+
952,
|
|
946
|
+
1110,
|
|
947
|
+
360,
|
|
948
|
+
700,
|
|
949
|
+
1020,
|
|
950
|
+
1200,
|
|
951
|
+
390,
|
|
952
|
+
728,
|
|
953
|
+
1050,
|
|
954
|
+
1260,
|
|
955
|
+
420,
|
|
956
|
+
784,
|
|
957
|
+
1140,
|
|
958
|
+
1350,
|
|
959
|
+
450,
|
|
960
|
+
812,
|
|
961
|
+
1200,
|
|
962
|
+
1440,
|
|
963
|
+
480,
|
|
964
|
+
868,
|
|
965
|
+
1290,
|
|
966
|
+
1530,
|
|
967
|
+
510,
|
|
968
|
+
924,
|
|
969
|
+
1350,
|
|
970
|
+
1620,
|
|
971
|
+
540,
|
|
972
|
+
980,
|
|
973
|
+
1440,
|
|
974
|
+
1710,
|
|
975
|
+
570,
|
|
976
|
+
1036,
|
|
977
|
+
1530,
|
|
978
|
+
1800,
|
|
979
|
+
570,
|
|
980
|
+
1064,
|
|
981
|
+
1590,
|
|
982
|
+
1890,
|
|
983
|
+
600,
|
|
984
|
+
1120,
|
|
985
|
+
1680,
|
|
986
|
+
1980,
|
|
987
|
+
630,
|
|
988
|
+
1204,
|
|
989
|
+
1770,
|
|
990
|
+
2100,
|
|
991
|
+
660,
|
|
992
|
+
1260,
|
|
993
|
+
1860,
|
|
994
|
+
2220,
|
|
995
|
+
720,
|
|
996
|
+
1316,
|
|
997
|
+
1950,
|
|
998
|
+
2310,
|
|
999
|
+
750,
|
|
1000
|
+
1372,
|
|
1001
|
+
2040,
|
|
1002
|
+
2430
|
|
1003
|
+
];
|
|
1004
|
+
/**
|
|
1005
|
+
* Returns the number of error correction block that the QR Code should contain
|
|
1006
|
+
* for the specified version and error correction level.
|
|
1007
|
+
*
|
|
1008
|
+
* @param {Number} version QR Code version
|
|
1009
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
1010
|
+
* @return {Number} Number of error correction blocks
|
|
1011
|
+
*/
|
|
1012
|
+
exports.getBlocksCount = function getBlocksCount(version, errorCorrectionLevel) {
|
|
1013
|
+
switch (errorCorrectionLevel) {
|
|
1014
|
+
case ECLevel.L: return EC_BLOCKS_TABLE[(version - 1) * 4 + 0];
|
|
1015
|
+
case ECLevel.M: return EC_BLOCKS_TABLE[(version - 1) * 4 + 1];
|
|
1016
|
+
case ECLevel.Q: return EC_BLOCKS_TABLE[(version - 1) * 4 + 2];
|
|
1017
|
+
case ECLevel.H: return EC_BLOCKS_TABLE[(version - 1) * 4 + 3];
|
|
1018
|
+
default: return;
|
|
1019
|
+
}
|
|
1020
|
+
};
|
|
1021
|
+
/**
|
|
1022
|
+
* Returns the number of error correction codewords to use for the specified
|
|
1023
|
+
* version and error correction level.
|
|
1024
|
+
*
|
|
1025
|
+
* @param {Number} version QR Code version
|
|
1026
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
1027
|
+
* @return {Number} Number of error correction codewords
|
|
1028
|
+
*/
|
|
1029
|
+
exports.getTotalCodewordsCount = function getTotalCodewordsCount(version, errorCorrectionLevel) {
|
|
1030
|
+
switch (errorCorrectionLevel) {
|
|
1031
|
+
case ECLevel.L: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0];
|
|
1032
|
+
case ECLevel.M: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1];
|
|
1033
|
+
case ECLevel.Q: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2];
|
|
1034
|
+
case ECLevel.H: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3];
|
|
1035
|
+
default: return;
|
|
1036
|
+
}
|
|
1037
|
+
};
|
|
1038
|
+
}));
|
|
1039
|
+
//#endregion
|
|
1040
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js
|
|
1041
|
+
var require_galois_field = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1042
|
+
const EXP_TABLE = /* @__PURE__ */ new Uint8Array(512);
|
|
1043
|
+
const LOG_TABLE = /* @__PURE__ */ new Uint8Array(256);
|
|
1044
|
+
(function initTables() {
|
|
1045
|
+
let x = 1;
|
|
1046
|
+
for (let i = 0; i < 255; i++) {
|
|
1047
|
+
EXP_TABLE[i] = x;
|
|
1048
|
+
LOG_TABLE[x] = i;
|
|
1049
|
+
x <<= 1;
|
|
1050
|
+
if (x & 256) x ^= 285;
|
|
1051
|
+
}
|
|
1052
|
+
for (let i = 255; i < 512; i++) EXP_TABLE[i] = EXP_TABLE[i - 255];
|
|
1053
|
+
})();
|
|
1054
|
+
/**
|
|
1055
|
+
* Returns log value of n inside Galois Field
|
|
1056
|
+
*
|
|
1057
|
+
* @param {Number} n
|
|
1058
|
+
* @return {Number}
|
|
1059
|
+
*/
|
|
1060
|
+
exports.log = function log(n) {
|
|
1061
|
+
if (n < 1) throw new Error("log(" + n + ")");
|
|
1062
|
+
return LOG_TABLE[n];
|
|
1063
|
+
};
|
|
1064
|
+
/**
|
|
1065
|
+
* Returns anti-log value of n inside Galois Field
|
|
1066
|
+
*
|
|
1067
|
+
* @param {Number} n
|
|
1068
|
+
* @return {Number}
|
|
1069
|
+
*/
|
|
1070
|
+
exports.exp = function exp(n) {
|
|
1071
|
+
return EXP_TABLE[n];
|
|
1072
|
+
};
|
|
1073
|
+
/**
|
|
1074
|
+
* Multiplies two number inside Galois Field
|
|
1075
|
+
*
|
|
1076
|
+
* @param {Number} x
|
|
1077
|
+
* @param {Number} y
|
|
1078
|
+
* @return {Number}
|
|
1079
|
+
*/
|
|
1080
|
+
exports.mul = function mul(x, y) {
|
|
1081
|
+
if (x === 0 || y === 0) return 0;
|
|
1082
|
+
return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]];
|
|
1083
|
+
};
|
|
1084
|
+
}));
|
|
1085
|
+
//#endregion
|
|
1086
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js
|
|
1087
|
+
var require_polynomial = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1088
|
+
const GF = require_galois_field();
|
|
1089
|
+
/**
|
|
1090
|
+
* Multiplies two polynomials inside Galois Field
|
|
1091
|
+
*
|
|
1092
|
+
* @param {Uint8Array} p1 Polynomial
|
|
1093
|
+
* @param {Uint8Array} p2 Polynomial
|
|
1094
|
+
* @return {Uint8Array} Product of p1 and p2
|
|
1095
|
+
*/
|
|
1096
|
+
exports.mul = function mul(p1, p2) {
|
|
1097
|
+
const coeff = new Uint8Array(p1.length + p2.length - 1);
|
|
1098
|
+
for (let i = 0; i < p1.length; i++) for (let j = 0; j < p2.length; j++) coeff[i + j] ^= GF.mul(p1[i], p2[j]);
|
|
1099
|
+
return coeff;
|
|
1100
|
+
};
|
|
1101
|
+
/**
|
|
1102
|
+
* Calculate the remainder of polynomials division
|
|
1103
|
+
*
|
|
1104
|
+
* @param {Uint8Array} divident Polynomial
|
|
1105
|
+
* @param {Uint8Array} divisor Polynomial
|
|
1106
|
+
* @return {Uint8Array} Remainder
|
|
1107
|
+
*/
|
|
1108
|
+
exports.mod = function mod(divident, divisor) {
|
|
1109
|
+
let result = new Uint8Array(divident);
|
|
1110
|
+
while (result.length - divisor.length >= 0) {
|
|
1111
|
+
const coeff = result[0];
|
|
1112
|
+
for (let i = 0; i < divisor.length; i++) result[i] ^= GF.mul(divisor[i], coeff);
|
|
1113
|
+
let offset = 0;
|
|
1114
|
+
while (offset < result.length && result[offset] === 0) offset++;
|
|
1115
|
+
result = result.slice(offset);
|
|
1116
|
+
}
|
|
1117
|
+
return result;
|
|
1118
|
+
};
|
|
1119
|
+
/**
|
|
1120
|
+
* Generate an irreducible generator polynomial of specified degree
|
|
1121
|
+
* (used by Reed-Solomon encoder)
|
|
1122
|
+
*
|
|
1123
|
+
* @param {Number} degree Degree of the generator polynomial
|
|
1124
|
+
* @return {Uint8Array} Buffer containing polynomial coefficients
|
|
1125
|
+
*/
|
|
1126
|
+
exports.generateECPolynomial = function generateECPolynomial(degree) {
|
|
1127
|
+
let poly = new Uint8Array([1]);
|
|
1128
|
+
for (let i = 0; i < degree; i++) poly = exports.mul(poly, new Uint8Array([1, GF.exp(i)]));
|
|
1129
|
+
return poly;
|
|
1130
|
+
};
|
|
1131
|
+
}));
|
|
1132
|
+
//#endregion
|
|
1133
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js
|
|
1134
|
+
var require_reed_solomon_encoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1135
|
+
const Polynomial = require_polynomial();
|
|
1136
|
+
function ReedSolomonEncoder(degree) {
|
|
1137
|
+
this.genPoly = void 0;
|
|
1138
|
+
this.degree = degree;
|
|
1139
|
+
if (this.degree) this.initialize(this.degree);
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* Initialize the encoder.
|
|
1143
|
+
* The input param should correspond to the number of error correction codewords.
|
|
1144
|
+
*
|
|
1145
|
+
* @param {Number} degree
|
|
1146
|
+
*/
|
|
1147
|
+
ReedSolomonEncoder.prototype.initialize = function initialize(degree) {
|
|
1148
|
+
this.degree = degree;
|
|
1149
|
+
this.genPoly = Polynomial.generateECPolynomial(this.degree);
|
|
1150
|
+
};
|
|
1151
|
+
/**
|
|
1152
|
+
* Encodes a chunk of data
|
|
1153
|
+
*
|
|
1154
|
+
* @param {Uint8Array} data Buffer containing input data
|
|
1155
|
+
* @return {Uint8Array} Buffer containing encoded data
|
|
1156
|
+
*/
|
|
1157
|
+
ReedSolomonEncoder.prototype.encode = function encode(data) {
|
|
1158
|
+
if (!this.genPoly) throw new Error("Encoder not initialized");
|
|
1159
|
+
const paddedData = new Uint8Array(data.length + this.degree);
|
|
1160
|
+
paddedData.set(data);
|
|
1161
|
+
const remainder = Polynomial.mod(paddedData, this.genPoly);
|
|
1162
|
+
const start = this.degree - remainder.length;
|
|
1163
|
+
if (start > 0) {
|
|
1164
|
+
const buff = new Uint8Array(this.degree);
|
|
1165
|
+
buff.set(remainder, start);
|
|
1166
|
+
return buff;
|
|
1167
|
+
}
|
|
1168
|
+
return remainder;
|
|
1169
|
+
};
|
|
1170
|
+
module.exports = ReedSolomonEncoder;
|
|
1171
|
+
}));
|
|
1172
|
+
//#endregion
|
|
1173
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js
|
|
1174
|
+
var require_version_check = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1175
|
+
/**
|
|
1176
|
+
* Check if QR Code version is valid
|
|
1177
|
+
*
|
|
1178
|
+
* @param {Number} version QR Code version
|
|
1179
|
+
* @return {Boolean} true if valid version, false otherwise
|
|
1180
|
+
*/
|
|
1181
|
+
exports.isValid = function isValid(version) {
|
|
1182
|
+
return !isNaN(version) && version >= 1 && version <= 40;
|
|
1183
|
+
};
|
|
1184
|
+
}));
|
|
1185
|
+
//#endregion
|
|
1186
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js
|
|
1187
|
+
var require_regex = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1188
|
+
const numeric = "[0-9]+";
|
|
1189
|
+
const alphanumeric = "[A-Z $%*+\\-./:]+";
|
|
1190
|
+
let kanji = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";
|
|
1191
|
+
kanji = kanji.replace(/u/g, "\\u");
|
|
1192
|
+
const byte = "(?:(?![A-Z0-9 $%*+\\-./:]|" + kanji + ")(?:.|[\r\n]))+";
|
|
1193
|
+
exports.KANJI = new RegExp(kanji, "g");
|
|
1194
|
+
exports.BYTE_KANJI = /* @__PURE__ */ new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g");
|
|
1195
|
+
exports.BYTE = new RegExp(byte, "g");
|
|
1196
|
+
exports.NUMERIC = new RegExp(numeric, "g");
|
|
1197
|
+
exports.ALPHANUMERIC = new RegExp(alphanumeric, "g");
|
|
1198
|
+
const TEST_KANJI = new RegExp("^" + kanji + "$");
|
|
1199
|
+
const TEST_NUMERIC = /* @__PURE__ */ new RegExp("^[0-9]+$");
|
|
1200
|
+
const TEST_ALPHANUMERIC = /* @__PURE__ */ new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
|
|
1201
|
+
exports.testKanji = function testKanji(str) {
|
|
1202
|
+
return TEST_KANJI.test(str);
|
|
1203
|
+
};
|
|
1204
|
+
exports.testNumeric = function testNumeric(str) {
|
|
1205
|
+
return TEST_NUMERIC.test(str);
|
|
1206
|
+
};
|
|
1207
|
+
exports.testAlphanumeric = function testAlphanumeric(str) {
|
|
1208
|
+
return TEST_ALPHANUMERIC.test(str);
|
|
1209
|
+
};
|
|
1210
|
+
}));
|
|
1211
|
+
//#endregion
|
|
1212
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js
|
|
1213
|
+
var require_mode = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1214
|
+
const VersionCheck = require_version_check();
|
|
1215
|
+
const Regex = require_regex();
|
|
1216
|
+
/**
|
|
1217
|
+
* Numeric mode encodes data from the decimal digit set (0 - 9)
|
|
1218
|
+
* (byte values 30HEX to 39HEX).
|
|
1219
|
+
* Normally, 3 data characters are represented by 10 bits.
|
|
1220
|
+
*
|
|
1221
|
+
* @type {Object}
|
|
1222
|
+
*/
|
|
1223
|
+
exports.NUMERIC = {
|
|
1224
|
+
id: "Numeric",
|
|
1225
|
+
bit: 1,
|
|
1226
|
+
ccBits: [
|
|
1227
|
+
10,
|
|
1228
|
+
12,
|
|
1229
|
+
14
|
|
1230
|
+
]
|
|
1231
|
+
};
|
|
1232
|
+
/**
|
|
1233
|
+
* Alphanumeric mode encodes data from a set of 45 characters,
|
|
1234
|
+
* i.e. 10 numeric digits (0 - 9),
|
|
1235
|
+
* 26 alphabetic characters (A - Z),
|
|
1236
|
+
* and 9 symbols (SP, $, %, *, +, -, ., /, :).
|
|
1237
|
+
* Normally, two input characters are represented by 11 bits.
|
|
1238
|
+
*
|
|
1239
|
+
* @type {Object}
|
|
1240
|
+
*/
|
|
1241
|
+
exports.ALPHANUMERIC = {
|
|
1242
|
+
id: "Alphanumeric",
|
|
1243
|
+
bit: 2,
|
|
1244
|
+
ccBits: [
|
|
1245
|
+
9,
|
|
1246
|
+
11,
|
|
1247
|
+
13
|
|
1248
|
+
]
|
|
1249
|
+
};
|
|
1250
|
+
/**
|
|
1251
|
+
* In byte mode, data is encoded at 8 bits per character.
|
|
1252
|
+
*
|
|
1253
|
+
* @type {Object}
|
|
1254
|
+
*/
|
|
1255
|
+
exports.BYTE = {
|
|
1256
|
+
id: "Byte",
|
|
1257
|
+
bit: 4,
|
|
1258
|
+
ccBits: [
|
|
1259
|
+
8,
|
|
1260
|
+
16,
|
|
1261
|
+
16
|
|
1262
|
+
]
|
|
1263
|
+
};
|
|
1264
|
+
/**
|
|
1265
|
+
* The Kanji mode efficiently encodes Kanji characters in accordance with
|
|
1266
|
+
* the Shift JIS system based on JIS X 0208.
|
|
1267
|
+
* The Shift JIS values are shifted from the JIS X 0208 values.
|
|
1268
|
+
* JIS X 0208 gives details of the shift coded representation.
|
|
1269
|
+
* Each two-byte character value is compacted to a 13-bit binary codeword.
|
|
1270
|
+
*
|
|
1271
|
+
* @type {Object}
|
|
1272
|
+
*/
|
|
1273
|
+
exports.KANJI = {
|
|
1274
|
+
id: "Kanji",
|
|
1275
|
+
bit: 8,
|
|
1276
|
+
ccBits: [
|
|
1277
|
+
8,
|
|
1278
|
+
10,
|
|
1279
|
+
12
|
|
1280
|
+
]
|
|
1281
|
+
};
|
|
1282
|
+
/**
|
|
1283
|
+
* Mixed mode will contain a sequences of data in a combination of any of
|
|
1284
|
+
* the modes described above
|
|
1285
|
+
*
|
|
1286
|
+
* @type {Object}
|
|
1287
|
+
*/
|
|
1288
|
+
exports.MIXED = { bit: -1 };
|
|
1289
|
+
/**
|
|
1290
|
+
* Returns the number of bits needed to store the data length
|
|
1291
|
+
* according to QR Code specifications.
|
|
1292
|
+
*
|
|
1293
|
+
* @param {Mode} mode Data mode
|
|
1294
|
+
* @param {Number} version QR Code version
|
|
1295
|
+
* @return {Number} Number of bits
|
|
1296
|
+
*/
|
|
1297
|
+
exports.getCharCountIndicator = function getCharCountIndicator(mode, version) {
|
|
1298
|
+
if (!mode.ccBits) throw new Error("Invalid mode: " + mode);
|
|
1299
|
+
if (!VersionCheck.isValid(version)) throw new Error("Invalid version: " + version);
|
|
1300
|
+
if (version >= 1 && version < 10) return mode.ccBits[0];
|
|
1301
|
+
else if (version < 27) return mode.ccBits[1];
|
|
1302
|
+
return mode.ccBits[2];
|
|
1303
|
+
};
|
|
1304
|
+
/**
|
|
1305
|
+
* Returns the most efficient mode to store the specified data
|
|
1306
|
+
*
|
|
1307
|
+
* @param {String} dataStr Input data string
|
|
1308
|
+
* @return {Mode} Best mode
|
|
1309
|
+
*/
|
|
1310
|
+
exports.getBestModeForData = function getBestModeForData(dataStr) {
|
|
1311
|
+
if (Regex.testNumeric(dataStr)) return exports.NUMERIC;
|
|
1312
|
+
else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC;
|
|
1313
|
+
else if (Regex.testKanji(dataStr)) return exports.KANJI;
|
|
1314
|
+
else return exports.BYTE;
|
|
1315
|
+
};
|
|
1316
|
+
/**
|
|
1317
|
+
* Return mode name as string
|
|
1318
|
+
*
|
|
1319
|
+
* @param {Mode} mode Mode object
|
|
1320
|
+
* @returns {String} Mode name
|
|
1321
|
+
*/
|
|
1322
|
+
exports.toString = function toString(mode) {
|
|
1323
|
+
if (mode && mode.id) return mode.id;
|
|
1324
|
+
throw new Error("Invalid mode");
|
|
1325
|
+
};
|
|
1326
|
+
/**
|
|
1327
|
+
* Check if input param is a valid mode object
|
|
1328
|
+
*
|
|
1329
|
+
* @param {Mode} mode Mode object
|
|
1330
|
+
* @returns {Boolean} True if valid mode, false otherwise
|
|
1331
|
+
*/
|
|
1332
|
+
exports.isValid = function isValid(mode) {
|
|
1333
|
+
return mode && mode.bit && mode.ccBits;
|
|
1334
|
+
};
|
|
1335
|
+
/**
|
|
1336
|
+
* Get mode object from its name
|
|
1337
|
+
*
|
|
1338
|
+
* @param {String} string Mode name
|
|
1339
|
+
* @returns {Mode} Mode object
|
|
1340
|
+
*/
|
|
1341
|
+
function fromString(string) {
|
|
1342
|
+
if (typeof string !== "string") throw new Error("Param is not a string");
|
|
1343
|
+
switch (string.toLowerCase()) {
|
|
1344
|
+
case "numeric": return exports.NUMERIC;
|
|
1345
|
+
case "alphanumeric": return exports.ALPHANUMERIC;
|
|
1346
|
+
case "kanji": return exports.KANJI;
|
|
1347
|
+
case "byte": return exports.BYTE;
|
|
1348
|
+
default: throw new Error("Unknown mode: " + string);
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Returns mode from a value.
|
|
1353
|
+
* If value is not a valid mode, returns defaultValue
|
|
1354
|
+
*
|
|
1355
|
+
* @param {Mode|String} value Encoding mode
|
|
1356
|
+
* @param {Mode} defaultValue Fallback value
|
|
1357
|
+
* @return {Mode} Encoding mode
|
|
1358
|
+
*/
|
|
1359
|
+
exports.from = function from(value, defaultValue) {
|
|
1360
|
+
if (exports.isValid(value)) return value;
|
|
1361
|
+
try {
|
|
1362
|
+
return fromString(value);
|
|
1363
|
+
} catch (e) {
|
|
1364
|
+
return defaultValue;
|
|
1365
|
+
}
|
|
1366
|
+
};
|
|
1367
|
+
}));
|
|
1368
|
+
//#endregion
|
|
1369
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js
|
|
1370
|
+
var require_version = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1371
|
+
const Utils = require_utils$1();
|
|
1372
|
+
const ECCode = require_error_correction_code();
|
|
1373
|
+
const ECLevel = require_error_correction_level();
|
|
1374
|
+
const Mode = require_mode();
|
|
1375
|
+
const VersionCheck = require_version_check();
|
|
1376
|
+
const G18 = 7973;
|
|
1377
|
+
const G18_BCH = Utils.getBCHDigit(G18);
|
|
1378
|
+
function getBestVersionForDataLength(mode, length, errorCorrectionLevel) {
|
|
1379
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++) if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) return currentVersion;
|
|
1380
|
+
}
|
|
1381
|
+
function getReservedBitsCount(mode, version) {
|
|
1382
|
+
return Mode.getCharCountIndicator(mode, version) + 4;
|
|
1383
|
+
}
|
|
1384
|
+
function getTotalBitsFromDataArray(segments, version) {
|
|
1385
|
+
let totalBits = 0;
|
|
1386
|
+
segments.forEach(function(data) {
|
|
1387
|
+
const reservedBits = getReservedBitsCount(data.mode, version);
|
|
1388
|
+
totalBits += reservedBits + data.getBitsLength();
|
|
1389
|
+
});
|
|
1390
|
+
return totalBits;
|
|
1391
|
+
}
|
|
1392
|
+
function getBestVersionForMixedData(segments, errorCorrectionLevel) {
|
|
1393
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++) if (getTotalBitsFromDataArray(segments, currentVersion) <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) return currentVersion;
|
|
1394
|
+
}
|
|
1395
|
+
/**
|
|
1396
|
+
* Returns version number from a value.
|
|
1397
|
+
* If value is not a valid version, returns defaultValue
|
|
1398
|
+
*
|
|
1399
|
+
* @param {Number|String} value QR Code version
|
|
1400
|
+
* @param {Number} defaultValue Fallback value
|
|
1401
|
+
* @return {Number} QR Code version number
|
|
1402
|
+
*/
|
|
1403
|
+
exports.from = function from(value, defaultValue) {
|
|
1404
|
+
if (VersionCheck.isValid(value)) return parseInt(value, 10);
|
|
1405
|
+
return defaultValue;
|
|
1406
|
+
};
|
|
1407
|
+
/**
|
|
1408
|
+
* Returns how much data can be stored with the specified QR code version
|
|
1409
|
+
* and error correction level
|
|
1410
|
+
*
|
|
1411
|
+
* @param {Number} version QR Code version (1-40)
|
|
1412
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
1413
|
+
* @param {Mode} mode Data mode
|
|
1414
|
+
* @return {Number} Quantity of storable data
|
|
1415
|
+
*/
|
|
1416
|
+
exports.getCapacity = function getCapacity(version, errorCorrectionLevel, mode) {
|
|
1417
|
+
if (!VersionCheck.isValid(version)) throw new Error("Invalid QR Code version");
|
|
1418
|
+
if (typeof mode === "undefined") mode = Mode.BYTE;
|
|
1419
|
+
const dataTotalCodewordsBits = (Utils.getSymbolTotalCodewords(version) - ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)) * 8;
|
|
1420
|
+
if (mode === Mode.MIXED) return dataTotalCodewordsBits;
|
|
1421
|
+
const usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version);
|
|
1422
|
+
switch (mode) {
|
|
1423
|
+
case Mode.NUMERIC: return Math.floor(usableBits / 10 * 3);
|
|
1424
|
+
case Mode.ALPHANUMERIC: return Math.floor(usableBits / 11 * 2);
|
|
1425
|
+
case Mode.KANJI: return Math.floor(usableBits / 13);
|
|
1426
|
+
case Mode.BYTE:
|
|
1427
|
+
default: return Math.floor(usableBits / 8);
|
|
1428
|
+
}
|
|
1429
|
+
};
|
|
1430
|
+
/**
|
|
1431
|
+
* Returns the minimum version needed to contain the amount of data
|
|
1432
|
+
*
|
|
1433
|
+
* @param {Segment} data Segment of data
|
|
1434
|
+
* @param {Number} [errorCorrectionLevel=H] Error correction level
|
|
1435
|
+
* @param {Mode} mode Data mode
|
|
1436
|
+
* @return {Number} QR Code version
|
|
1437
|
+
*/
|
|
1438
|
+
exports.getBestVersionForData = function getBestVersionForData(data, errorCorrectionLevel) {
|
|
1439
|
+
let seg;
|
|
1440
|
+
const ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M);
|
|
1441
|
+
if (Array.isArray(data)) {
|
|
1442
|
+
if (data.length > 1) return getBestVersionForMixedData(data, ecl);
|
|
1443
|
+
if (data.length === 0) return 1;
|
|
1444
|
+
seg = data[0];
|
|
1445
|
+
} else seg = data;
|
|
1446
|
+
return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl);
|
|
1447
|
+
};
|
|
1448
|
+
/**
|
|
1449
|
+
* Returns version information with relative error correction bits
|
|
1450
|
+
*
|
|
1451
|
+
* The version information is included in QR Code symbols of version 7 or larger.
|
|
1452
|
+
* It consists of an 18-bit sequence containing 6 data bits,
|
|
1453
|
+
* with 12 error correction bits calculated using the (18, 6) Golay code.
|
|
1454
|
+
*
|
|
1455
|
+
* @param {Number} version QR Code version
|
|
1456
|
+
* @return {Number} Encoded version info bits
|
|
1457
|
+
*/
|
|
1458
|
+
exports.getEncodedBits = function getEncodedBits(version) {
|
|
1459
|
+
if (!VersionCheck.isValid(version) || version < 7) throw new Error("Invalid QR Code version");
|
|
1460
|
+
let d = version << 12;
|
|
1461
|
+
while (Utils.getBCHDigit(d) - G18_BCH >= 0) d ^= G18 << Utils.getBCHDigit(d) - G18_BCH;
|
|
1462
|
+
return version << 12 | d;
|
|
1463
|
+
};
|
|
1464
|
+
}));
|
|
1465
|
+
//#endregion
|
|
1466
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js
|
|
1467
|
+
var require_format_info = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1468
|
+
const Utils = require_utils$1();
|
|
1469
|
+
const G15 = 1335;
|
|
1470
|
+
const G15_MASK = 21522;
|
|
1471
|
+
const G15_BCH = Utils.getBCHDigit(G15);
|
|
1472
|
+
/**
|
|
1473
|
+
* Returns format information with relative error correction bits
|
|
1474
|
+
*
|
|
1475
|
+
* The format information is a 15-bit sequence containing 5 data bits,
|
|
1476
|
+
* with 10 error correction bits calculated using the (15, 5) BCH code.
|
|
1477
|
+
*
|
|
1478
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
1479
|
+
* @param {Number} mask Mask pattern
|
|
1480
|
+
* @return {Number} Encoded format information bits
|
|
1481
|
+
*/
|
|
1482
|
+
exports.getEncodedBits = function getEncodedBits(errorCorrectionLevel, mask) {
|
|
1483
|
+
const data = errorCorrectionLevel.bit << 3 | mask;
|
|
1484
|
+
let d = data << 10;
|
|
1485
|
+
while (Utils.getBCHDigit(d) - G15_BCH >= 0) d ^= G15 << Utils.getBCHDigit(d) - G15_BCH;
|
|
1486
|
+
return (data << 10 | d) ^ G15_MASK;
|
|
1487
|
+
};
|
|
1488
|
+
}));
|
|
1489
|
+
//#endregion
|
|
1490
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js
|
|
1491
|
+
var require_numeric_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1492
|
+
const Mode = require_mode();
|
|
1493
|
+
function NumericData(data) {
|
|
1494
|
+
this.mode = Mode.NUMERIC;
|
|
1495
|
+
this.data = data.toString();
|
|
1496
|
+
}
|
|
1497
|
+
NumericData.getBitsLength = function getBitsLength(length) {
|
|
1498
|
+
return 10 * Math.floor(length / 3) + (length % 3 ? length % 3 * 3 + 1 : 0);
|
|
1499
|
+
};
|
|
1500
|
+
NumericData.prototype.getLength = function getLength() {
|
|
1501
|
+
return this.data.length;
|
|
1502
|
+
};
|
|
1503
|
+
NumericData.prototype.getBitsLength = function getBitsLength() {
|
|
1504
|
+
return NumericData.getBitsLength(this.data.length);
|
|
1505
|
+
};
|
|
1506
|
+
NumericData.prototype.write = function write(bitBuffer) {
|
|
1507
|
+
let i, group, value;
|
|
1508
|
+
for (i = 0; i + 3 <= this.data.length; i += 3) {
|
|
1509
|
+
group = this.data.substr(i, 3);
|
|
1510
|
+
value = parseInt(group, 10);
|
|
1511
|
+
bitBuffer.put(value, 10);
|
|
1512
|
+
}
|
|
1513
|
+
const remainingNum = this.data.length - i;
|
|
1514
|
+
if (remainingNum > 0) {
|
|
1515
|
+
group = this.data.substr(i);
|
|
1516
|
+
value = parseInt(group, 10);
|
|
1517
|
+
bitBuffer.put(value, remainingNum * 3 + 1);
|
|
1518
|
+
}
|
|
1519
|
+
};
|
|
1520
|
+
module.exports = NumericData;
|
|
1521
|
+
}));
|
|
1522
|
+
//#endregion
|
|
1523
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js
|
|
1524
|
+
var require_alphanumeric_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1525
|
+
const Mode = require_mode();
|
|
1526
|
+
/**
|
|
1527
|
+
* Array of characters available in alphanumeric mode
|
|
1528
|
+
*
|
|
1529
|
+
* As per QR Code specification, to each character
|
|
1530
|
+
* is assigned a value from 0 to 44 which in this case coincides
|
|
1531
|
+
* with the array index
|
|
1532
|
+
*
|
|
1533
|
+
* @type {Array}
|
|
1534
|
+
*/
|
|
1535
|
+
const ALPHA_NUM_CHARS = [
|
|
1536
|
+
"0",
|
|
1537
|
+
"1",
|
|
1538
|
+
"2",
|
|
1539
|
+
"3",
|
|
1540
|
+
"4",
|
|
1541
|
+
"5",
|
|
1542
|
+
"6",
|
|
1543
|
+
"7",
|
|
1544
|
+
"8",
|
|
1545
|
+
"9",
|
|
1546
|
+
"A",
|
|
1547
|
+
"B",
|
|
1548
|
+
"C",
|
|
1549
|
+
"D",
|
|
1550
|
+
"E",
|
|
1551
|
+
"F",
|
|
1552
|
+
"G",
|
|
1553
|
+
"H",
|
|
1554
|
+
"I",
|
|
1555
|
+
"J",
|
|
1556
|
+
"K",
|
|
1557
|
+
"L",
|
|
1558
|
+
"M",
|
|
1559
|
+
"N",
|
|
1560
|
+
"O",
|
|
1561
|
+
"P",
|
|
1562
|
+
"Q",
|
|
1563
|
+
"R",
|
|
1564
|
+
"S",
|
|
1565
|
+
"T",
|
|
1566
|
+
"U",
|
|
1567
|
+
"V",
|
|
1568
|
+
"W",
|
|
1569
|
+
"X",
|
|
1570
|
+
"Y",
|
|
1571
|
+
"Z",
|
|
1572
|
+
" ",
|
|
1573
|
+
"$",
|
|
1574
|
+
"%",
|
|
1575
|
+
"*",
|
|
1576
|
+
"+",
|
|
1577
|
+
"-",
|
|
1578
|
+
".",
|
|
1579
|
+
"/",
|
|
1580
|
+
":"
|
|
1581
|
+
];
|
|
1582
|
+
function AlphanumericData(data) {
|
|
1583
|
+
this.mode = Mode.ALPHANUMERIC;
|
|
1584
|
+
this.data = data;
|
|
1585
|
+
}
|
|
1586
|
+
AlphanumericData.getBitsLength = function getBitsLength(length) {
|
|
1587
|
+
return 11 * Math.floor(length / 2) + 6 * (length % 2);
|
|
1588
|
+
};
|
|
1589
|
+
AlphanumericData.prototype.getLength = function getLength() {
|
|
1590
|
+
return this.data.length;
|
|
1591
|
+
};
|
|
1592
|
+
AlphanumericData.prototype.getBitsLength = function getBitsLength() {
|
|
1593
|
+
return AlphanumericData.getBitsLength(this.data.length);
|
|
1594
|
+
};
|
|
1595
|
+
AlphanumericData.prototype.write = function write(bitBuffer) {
|
|
1596
|
+
let i;
|
|
1597
|
+
for (i = 0; i + 2 <= this.data.length; i += 2) {
|
|
1598
|
+
let value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45;
|
|
1599
|
+
value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1]);
|
|
1600
|
+
bitBuffer.put(value, 11);
|
|
1601
|
+
}
|
|
1602
|
+
if (this.data.length % 2) bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6);
|
|
1603
|
+
};
|
|
1604
|
+
module.exports = AlphanumericData;
|
|
1605
|
+
}));
|
|
1606
|
+
//#endregion
|
|
1607
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js
|
|
1608
|
+
var require_byte_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1609
|
+
const Mode = require_mode();
|
|
1610
|
+
function ByteData(data) {
|
|
1611
|
+
this.mode = Mode.BYTE;
|
|
1612
|
+
if (typeof data === "string") this.data = new TextEncoder().encode(data);
|
|
1613
|
+
else this.data = new Uint8Array(data);
|
|
1614
|
+
}
|
|
1615
|
+
ByteData.getBitsLength = function getBitsLength(length) {
|
|
1616
|
+
return length * 8;
|
|
1617
|
+
};
|
|
1618
|
+
ByteData.prototype.getLength = function getLength() {
|
|
1619
|
+
return this.data.length;
|
|
1620
|
+
};
|
|
1621
|
+
ByteData.prototype.getBitsLength = function getBitsLength() {
|
|
1622
|
+
return ByteData.getBitsLength(this.data.length);
|
|
1623
|
+
};
|
|
1624
|
+
ByteData.prototype.write = function(bitBuffer) {
|
|
1625
|
+
for (let i = 0, l = this.data.length; i < l; i++) bitBuffer.put(this.data[i], 8);
|
|
1626
|
+
};
|
|
1627
|
+
module.exports = ByteData;
|
|
1628
|
+
}));
|
|
1629
|
+
//#endregion
|
|
1630
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js
|
|
1631
|
+
var require_kanji_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1632
|
+
const Mode = require_mode();
|
|
1633
|
+
const Utils = require_utils$1();
|
|
1634
|
+
function KanjiData(data) {
|
|
1635
|
+
this.mode = Mode.KANJI;
|
|
1636
|
+
this.data = data;
|
|
1637
|
+
}
|
|
1638
|
+
KanjiData.getBitsLength = function getBitsLength(length) {
|
|
1639
|
+
return length * 13;
|
|
1640
|
+
};
|
|
1641
|
+
KanjiData.prototype.getLength = function getLength() {
|
|
1642
|
+
return this.data.length;
|
|
1643
|
+
};
|
|
1644
|
+
KanjiData.prototype.getBitsLength = function getBitsLength() {
|
|
1645
|
+
return KanjiData.getBitsLength(this.data.length);
|
|
1646
|
+
};
|
|
1647
|
+
KanjiData.prototype.write = function(bitBuffer) {
|
|
1648
|
+
let i;
|
|
1649
|
+
for (i = 0; i < this.data.length; i++) {
|
|
1650
|
+
let value = Utils.toSJIS(this.data[i]);
|
|
1651
|
+
if (value >= 33088 && value <= 40956) value -= 33088;
|
|
1652
|
+
else if (value >= 57408 && value <= 60351) value -= 49472;
|
|
1653
|
+
else throw new Error("Invalid SJIS character: " + this.data[i] + "\nMake sure your charset is UTF-8");
|
|
1654
|
+
value = (value >>> 8 & 255) * 192 + (value & 255);
|
|
1655
|
+
bitBuffer.put(value, 13);
|
|
1656
|
+
}
|
|
1657
|
+
};
|
|
1658
|
+
module.exports = KanjiData;
|
|
1659
|
+
}));
|
|
1660
|
+
//#endregion
|
|
1661
|
+
//#region node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js
|
|
1662
|
+
var require_dijkstra = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1663
|
+
/******************************************************************************
|
|
1664
|
+
* Created 2008-08-19.
|
|
1665
|
+
*
|
|
1666
|
+
* Dijkstra path-finding functions. Adapted from the Dijkstar Python project.
|
|
1667
|
+
*
|
|
1668
|
+
* Copyright (C) 2008
|
|
1669
|
+
* Wyatt Baldwin <self@wyattbaldwin.com>
|
|
1670
|
+
* All rights reserved
|
|
1671
|
+
*
|
|
1672
|
+
* Licensed under the MIT license.
|
|
1673
|
+
*
|
|
1674
|
+
* http://www.opensource.org/licenses/mit-license.php
|
|
1675
|
+
*
|
|
1676
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1677
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1678
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1679
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1680
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1681
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1682
|
+
* THE SOFTWARE.
|
|
1683
|
+
*****************************************************************************/
|
|
1684
|
+
var dijkstra = {
|
|
1685
|
+
single_source_shortest_paths: function(graph, s, d) {
|
|
1686
|
+
var predecessors = {};
|
|
1687
|
+
var costs = {};
|
|
1688
|
+
costs[s] = 0;
|
|
1689
|
+
var open = dijkstra.PriorityQueue.make();
|
|
1690
|
+
open.push(s, 0);
|
|
1691
|
+
var closest, u, v, cost_of_s_to_u, adjacent_nodes, cost_of_e, cost_of_s_to_u_plus_cost_of_e, cost_of_s_to_v, first_visit;
|
|
1692
|
+
while (!open.empty()) {
|
|
1693
|
+
closest = open.pop();
|
|
1694
|
+
u = closest.value;
|
|
1695
|
+
cost_of_s_to_u = closest.cost;
|
|
1696
|
+
adjacent_nodes = graph[u] || {};
|
|
1697
|
+
for (v in adjacent_nodes) if (adjacent_nodes.hasOwnProperty(v)) {
|
|
1698
|
+
cost_of_e = adjacent_nodes[v];
|
|
1699
|
+
cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
|
|
1700
|
+
cost_of_s_to_v = costs[v];
|
|
1701
|
+
first_visit = typeof costs[v] === "undefined";
|
|
1702
|
+
if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
|
|
1703
|
+
costs[v] = cost_of_s_to_u_plus_cost_of_e;
|
|
1704
|
+
open.push(v, cost_of_s_to_u_plus_cost_of_e);
|
|
1705
|
+
predecessors[v] = u;
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
if (typeof d !== "undefined" && typeof costs[d] === "undefined") {
|
|
1710
|
+
var msg = [
|
|
1711
|
+
"Could not find a path from ",
|
|
1712
|
+
s,
|
|
1713
|
+
" to ",
|
|
1714
|
+
d,
|
|
1715
|
+
"."
|
|
1716
|
+
].join("");
|
|
1717
|
+
throw new Error(msg);
|
|
1718
|
+
}
|
|
1719
|
+
return predecessors;
|
|
1720
|
+
},
|
|
1721
|
+
extract_shortest_path_from_predecessor_list: function(predecessors, d) {
|
|
1722
|
+
var nodes = [];
|
|
1723
|
+
var u = d;
|
|
1724
|
+
while (u) {
|
|
1725
|
+
nodes.push(u);
|
|
1726
|
+
predecessors[u];
|
|
1727
|
+
u = predecessors[u];
|
|
1728
|
+
}
|
|
1729
|
+
nodes.reverse();
|
|
1730
|
+
return nodes;
|
|
1731
|
+
},
|
|
1732
|
+
find_path: function(graph, s, d) {
|
|
1733
|
+
var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
|
|
1734
|
+
return dijkstra.extract_shortest_path_from_predecessor_list(predecessors, d);
|
|
1735
|
+
},
|
|
1736
|
+
/**
|
|
1737
|
+
* A very naive priority queue implementation.
|
|
1738
|
+
*/
|
|
1739
|
+
PriorityQueue: {
|
|
1740
|
+
make: function(opts) {
|
|
1741
|
+
var T = dijkstra.PriorityQueue, t = {}, key;
|
|
1742
|
+
opts = opts || {};
|
|
1743
|
+
for (key in T) if (T.hasOwnProperty(key)) t[key] = T[key];
|
|
1744
|
+
t.queue = [];
|
|
1745
|
+
t.sorter = opts.sorter || T.default_sorter;
|
|
1746
|
+
return t;
|
|
1747
|
+
},
|
|
1748
|
+
default_sorter: function(a, b) {
|
|
1749
|
+
return a.cost - b.cost;
|
|
1750
|
+
},
|
|
1751
|
+
/**
|
|
1752
|
+
* Add a new item to the queue and ensure the highest priority element
|
|
1753
|
+
* is at the front of the queue.
|
|
1754
|
+
*/
|
|
1755
|
+
push: function(value, cost) {
|
|
1756
|
+
var item = {
|
|
1757
|
+
value,
|
|
1758
|
+
cost
|
|
1759
|
+
};
|
|
1760
|
+
this.queue.push(item);
|
|
1761
|
+
this.queue.sort(this.sorter);
|
|
1762
|
+
},
|
|
1763
|
+
/**
|
|
1764
|
+
* Return the highest priority element in the queue.
|
|
1765
|
+
*/
|
|
1766
|
+
pop: function() {
|
|
1767
|
+
return this.queue.shift();
|
|
1768
|
+
},
|
|
1769
|
+
empty: function() {
|
|
1770
|
+
return this.queue.length === 0;
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
};
|
|
1774
|
+
if (typeof module !== "undefined") module.exports = dijkstra;
|
|
1775
|
+
}));
|
|
1776
|
+
//#endregion
|
|
1777
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js
|
|
1778
|
+
var require_segments = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1779
|
+
const Mode = require_mode();
|
|
1780
|
+
const NumericData = require_numeric_data();
|
|
1781
|
+
const AlphanumericData = require_alphanumeric_data();
|
|
1782
|
+
const ByteData = require_byte_data();
|
|
1783
|
+
const KanjiData = require_kanji_data();
|
|
1784
|
+
const Regex = require_regex();
|
|
1785
|
+
const Utils = require_utils$1();
|
|
1786
|
+
const dijkstra = require_dijkstra();
|
|
1787
|
+
/**
|
|
1788
|
+
* Returns UTF8 byte length
|
|
1789
|
+
*
|
|
1790
|
+
* @param {String} str Input string
|
|
1791
|
+
* @return {Number} Number of byte
|
|
1792
|
+
*/
|
|
1793
|
+
function getStringByteLength(str) {
|
|
1794
|
+
return unescape(encodeURIComponent(str)).length;
|
|
1795
|
+
}
|
|
1796
|
+
/**
|
|
1797
|
+
* Get a list of segments of the specified mode
|
|
1798
|
+
* from a string
|
|
1799
|
+
*
|
|
1800
|
+
* @param {Mode} mode Segment mode
|
|
1801
|
+
* @param {String} str String to process
|
|
1802
|
+
* @return {Array} Array of object with segments data
|
|
1803
|
+
*/
|
|
1804
|
+
function getSegments(regex, mode, str) {
|
|
1805
|
+
const segments = [];
|
|
1806
|
+
let result;
|
|
1807
|
+
while ((result = regex.exec(str)) !== null) segments.push({
|
|
1808
|
+
data: result[0],
|
|
1809
|
+
index: result.index,
|
|
1810
|
+
mode,
|
|
1811
|
+
length: result[0].length
|
|
1812
|
+
});
|
|
1813
|
+
return segments;
|
|
1814
|
+
}
|
|
1815
|
+
/**
|
|
1816
|
+
* Extracts a series of segments with the appropriate
|
|
1817
|
+
* modes from a string
|
|
1818
|
+
*
|
|
1819
|
+
* @param {String} dataStr Input string
|
|
1820
|
+
* @return {Array} Array of object with segments data
|
|
1821
|
+
*/
|
|
1822
|
+
function getSegmentsFromString(dataStr) {
|
|
1823
|
+
const numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr);
|
|
1824
|
+
const alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr);
|
|
1825
|
+
let byteSegs;
|
|
1826
|
+
let kanjiSegs;
|
|
1827
|
+
if (Utils.isKanjiModeEnabled()) {
|
|
1828
|
+
byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr);
|
|
1829
|
+
kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr);
|
|
1830
|
+
} else {
|
|
1831
|
+
byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr);
|
|
1832
|
+
kanjiSegs = [];
|
|
1833
|
+
}
|
|
1834
|
+
return numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs).sort(function(s1, s2) {
|
|
1835
|
+
return s1.index - s2.index;
|
|
1836
|
+
}).map(function(obj) {
|
|
1837
|
+
return {
|
|
1838
|
+
data: obj.data,
|
|
1839
|
+
mode: obj.mode,
|
|
1840
|
+
length: obj.length
|
|
1841
|
+
};
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
/**
|
|
1845
|
+
* Returns how many bits are needed to encode a string of
|
|
1846
|
+
* specified length with the specified mode
|
|
1847
|
+
*
|
|
1848
|
+
* @param {Number} length String length
|
|
1849
|
+
* @param {Mode} mode Segment mode
|
|
1850
|
+
* @return {Number} Bit length
|
|
1851
|
+
*/
|
|
1852
|
+
function getSegmentBitsLength(length, mode) {
|
|
1853
|
+
switch (mode) {
|
|
1854
|
+
case Mode.NUMERIC: return NumericData.getBitsLength(length);
|
|
1855
|
+
case Mode.ALPHANUMERIC: return AlphanumericData.getBitsLength(length);
|
|
1856
|
+
case Mode.KANJI: return KanjiData.getBitsLength(length);
|
|
1857
|
+
case Mode.BYTE: return ByteData.getBitsLength(length);
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
/**
|
|
1861
|
+
* Merges adjacent segments which have the same mode
|
|
1862
|
+
*
|
|
1863
|
+
* @param {Array} segs Array of object with segments data
|
|
1864
|
+
* @return {Array} Array of object with segments data
|
|
1865
|
+
*/
|
|
1866
|
+
function mergeSegments(segs) {
|
|
1867
|
+
return segs.reduce(function(acc, curr) {
|
|
1868
|
+
const prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null;
|
|
1869
|
+
if (prevSeg && prevSeg.mode === curr.mode) {
|
|
1870
|
+
acc[acc.length - 1].data += curr.data;
|
|
1871
|
+
return acc;
|
|
1872
|
+
}
|
|
1873
|
+
acc.push(curr);
|
|
1874
|
+
return acc;
|
|
1875
|
+
}, []);
|
|
1876
|
+
}
|
|
1877
|
+
/**
|
|
1878
|
+
* Generates a list of all possible nodes combination which
|
|
1879
|
+
* will be used to build a segments graph.
|
|
1880
|
+
*
|
|
1881
|
+
* Nodes are divided by groups. Each group will contain a list of all the modes
|
|
1882
|
+
* in which is possible to encode the given text.
|
|
1883
|
+
*
|
|
1884
|
+
* For example the text '12345' can be encoded as Numeric, Alphanumeric or Byte.
|
|
1885
|
+
* The group for '12345' will contain then 3 objects, one for each
|
|
1886
|
+
* possible encoding mode.
|
|
1887
|
+
*
|
|
1888
|
+
* Each node represents a possible segment.
|
|
1889
|
+
*
|
|
1890
|
+
* @param {Array} segs Array of object with segments data
|
|
1891
|
+
* @return {Array} Array of object with segments data
|
|
1892
|
+
*/
|
|
1893
|
+
function buildNodes(segs) {
|
|
1894
|
+
const nodes = [];
|
|
1895
|
+
for (let i = 0; i < segs.length; i++) {
|
|
1896
|
+
const seg = segs[i];
|
|
1897
|
+
switch (seg.mode) {
|
|
1898
|
+
case Mode.NUMERIC:
|
|
1899
|
+
nodes.push([
|
|
1900
|
+
seg,
|
|
1901
|
+
{
|
|
1902
|
+
data: seg.data,
|
|
1903
|
+
mode: Mode.ALPHANUMERIC,
|
|
1904
|
+
length: seg.length
|
|
1905
|
+
},
|
|
1906
|
+
{
|
|
1907
|
+
data: seg.data,
|
|
1908
|
+
mode: Mode.BYTE,
|
|
1909
|
+
length: seg.length
|
|
1910
|
+
}
|
|
1911
|
+
]);
|
|
1912
|
+
break;
|
|
1913
|
+
case Mode.ALPHANUMERIC:
|
|
1914
|
+
nodes.push([seg, {
|
|
1915
|
+
data: seg.data,
|
|
1916
|
+
mode: Mode.BYTE,
|
|
1917
|
+
length: seg.length
|
|
1918
|
+
}]);
|
|
1919
|
+
break;
|
|
1920
|
+
case Mode.KANJI:
|
|
1921
|
+
nodes.push([seg, {
|
|
1922
|
+
data: seg.data,
|
|
1923
|
+
mode: Mode.BYTE,
|
|
1924
|
+
length: getStringByteLength(seg.data)
|
|
1925
|
+
}]);
|
|
1926
|
+
break;
|
|
1927
|
+
case Mode.BYTE: nodes.push([{
|
|
1928
|
+
data: seg.data,
|
|
1929
|
+
mode: Mode.BYTE,
|
|
1930
|
+
length: getStringByteLength(seg.data)
|
|
1931
|
+
}]);
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
return nodes;
|
|
1935
|
+
}
|
|
1936
|
+
/**
|
|
1937
|
+
* Builds a graph from a list of nodes.
|
|
1938
|
+
* All segments in each node group will be connected with all the segments of
|
|
1939
|
+
* the next group and so on.
|
|
1940
|
+
*
|
|
1941
|
+
* At each connection will be assigned a weight depending on the
|
|
1942
|
+
* segment's byte length.
|
|
1943
|
+
*
|
|
1944
|
+
* @param {Array} nodes Array of object with segments data
|
|
1945
|
+
* @param {Number} version QR Code version
|
|
1946
|
+
* @return {Object} Graph of all possible segments
|
|
1947
|
+
*/
|
|
1948
|
+
function buildGraph(nodes, version) {
|
|
1949
|
+
const table = {};
|
|
1950
|
+
const graph = { start: {} };
|
|
1951
|
+
let prevNodeIds = ["start"];
|
|
1952
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
1953
|
+
const nodeGroup = nodes[i];
|
|
1954
|
+
const currentNodeIds = [];
|
|
1955
|
+
for (let j = 0; j < nodeGroup.length; j++) {
|
|
1956
|
+
const node = nodeGroup[j];
|
|
1957
|
+
const key = "" + i + j;
|
|
1958
|
+
currentNodeIds.push(key);
|
|
1959
|
+
table[key] = {
|
|
1960
|
+
node,
|
|
1961
|
+
lastCount: 0
|
|
1962
|
+
};
|
|
1963
|
+
graph[key] = {};
|
|
1964
|
+
for (let n = 0; n < prevNodeIds.length; n++) {
|
|
1965
|
+
const prevNodeId = prevNodeIds[n];
|
|
1966
|
+
if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
|
|
1967
|
+
graph[prevNodeId][key] = getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) - getSegmentBitsLength(table[prevNodeId].lastCount, node.mode);
|
|
1968
|
+
table[prevNodeId].lastCount += node.length;
|
|
1969
|
+
} else {
|
|
1970
|
+
if (table[prevNodeId]) table[prevNodeId].lastCount = node.length;
|
|
1971
|
+
graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) + 4 + Mode.getCharCountIndicator(node.mode, version);
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
prevNodeIds = currentNodeIds;
|
|
1976
|
+
}
|
|
1977
|
+
for (let n = 0; n < prevNodeIds.length; n++) graph[prevNodeIds[n]].end = 0;
|
|
1978
|
+
return {
|
|
1979
|
+
map: graph,
|
|
1980
|
+
table
|
|
1981
|
+
};
|
|
1982
|
+
}
|
|
1983
|
+
/**
|
|
1984
|
+
* Builds a segment from a specified data and mode.
|
|
1985
|
+
* If a mode is not specified, the more suitable will be used.
|
|
1986
|
+
*
|
|
1987
|
+
* @param {String} data Input data
|
|
1988
|
+
* @param {Mode | String} modesHint Data mode
|
|
1989
|
+
* @return {Segment} Segment
|
|
1990
|
+
*/
|
|
1991
|
+
function buildSingleSegment(data, modesHint) {
|
|
1992
|
+
let mode;
|
|
1993
|
+
const bestMode = Mode.getBestModeForData(data);
|
|
1994
|
+
mode = Mode.from(modesHint, bestMode);
|
|
1995
|
+
if (mode !== Mode.BYTE && mode.bit < bestMode.bit) throw new Error("\"" + data + "\" cannot be encoded with mode " + Mode.toString(mode) + ".\n Suggested mode is: " + Mode.toString(bestMode));
|
|
1996
|
+
if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) mode = Mode.BYTE;
|
|
1997
|
+
switch (mode) {
|
|
1998
|
+
case Mode.NUMERIC: return new NumericData(data);
|
|
1999
|
+
case Mode.ALPHANUMERIC: return new AlphanumericData(data);
|
|
2000
|
+
case Mode.KANJI: return new KanjiData(data);
|
|
2001
|
+
case Mode.BYTE: return new ByteData(data);
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
/**
|
|
2005
|
+
* Builds a list of segments from an array.
|
|
2006
|
+
* Array can contain Strings or Objects with segment's info.
|
|
2007
|
+
*
|
|
2008
|
+
* For each item which is a string, will be generated a segment with the given
|
|
2009
|
+
* string and the more appropriate encoding mode.
|
|
2010
|
+
*
|
|
2011
|
+
* For each item which is an object, will be generated a segment with the given
|
|
2012
|
+
* data and mode.
|
|
2013
|
+
* Objects must contain at least the property "data".
|
|
2014
|
+
* If property "mode" is not present, the more suitable mode will be used.
|
|
2015
|
+
*
|
|
2016
|
+
* @param {Array} array Array of objects with segments data
|
|
2017
|
+
* @return {Array} Array of Segments
|
|
2018
|
+
*/
|
|
2019
|
+
exports.fromArray = function fromArray(array) {
|
|
2020
|
+
return array.reduce(function(acc, seg) {
|
|
2021
|
+
if (typeof seg === "string") acc.push(buildSingleSegment(seg, null));
|
|
2022
|
+
else if (seg.data) acc.push(buildSingleSegment(seg.data, seg.mode));
|
|
2023
|
+
return acc;
|
|
2024
|
+
}, []);
|
|
2025
|
+
};
|
|
2026
|
+
/**
|
|
2027
|
+
* Builds an optimized sequence of segments from a string,
|
|
2028
|
+
* which will produce the shortest possible bitstream.
|
|
2029
|
+
*
|
|
2030
|
+
* @param {String} data Input string
|
|
2031
|
+
* @param {Number} version QR Code version
|
|
2032
|
+
* @return {Array} Array of segments
|
|
2033
|
+
*/
|
|
2034
|
+
exports.fromString = function fromString(data, version) {
|
|
2035
|
+
const graph = buildGraph(buildNodes(getSegmentsFromString(data, Utils.isKanjiModeEnabled())), version);
|
|
2036
|
+
const path = dijkstra.find_path(graph.map, "start", "end");
|
|
2037
|
+
const optimizedSegs = [];
|
|
2038
|
+
for (let i = 1; i < path.length - 1; i++) optimizedSegs.push(graph.table[path[i]].node);
|
|
2039
|
+
return exports.fromArray(mergeSegments(optimizedSegs));
|
|
2040
|
+
};
|
|
2041
|
+
/**
|
|
2042
|
+
* Splits a string in various segments with the modes which
|
|
2043
|
+
* best represent their content.
|
|
2044
|
+
* The produced segments are far from being optimized.
|
|
2045
|
+
* The output of this function is only used to estimate a QR Code version
|
|
2046
|
+
* which may contain the data.
|
|
2047
|
+
*
|
|
2048
|
+
* @param {string} data Input string
|
|
2049
|
+
* @return {Array} Array of segments
|
|
2050
|
+
*/
|
|
2051
|
+
exports.rawSplit = function rawSplit(data) {
|
|
2052
|
+
return exports.fromArray(getSegmentsFromString(data, Utils.isKanjiModeEnabled()));
|
|
2053
|
+
};
|
|
2054
|
+
}));
|
|
2055
|
+
//#endregion
|
|
2056
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js
|
|
2057
|
+
var require_qrcode = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2058
|
+
const Utils = require_utils$1();
|
|
2059
|
+
const ECLevel = require_error_correction_level();
|
|
2060
|
+
const BitBuffer = require_bit_buffer();
|
|
2061
|
+
const BitMatrix = require_bit_matrix();
|
|
2062
|
+
const AlignmentPattern = require_alignment_pattern();
|
|
2063
|
+
const FinderPattern = require_finder_pattern();
|
|
2064
|
+
const MaskPattern = require_mask_pattern();
|
|
2065
|
+
const ECCode = require_error_correction_code();
|
|
2066
|
+
const ReedSolomonEncoder = require_reed_solomon_encoder();
|
|
2067
|
+
const Version = require_version();
|
|
2068
|
+
const FormatInfo = require_format_info();
|
|
2069
|
+
const Mode = require_mode();
|
|
2070
|
+
const Segments = require_segments();
|
|
2071
|
+
/**
|
|
2072
|
+
* QRCode for JavaScript
|
|
2073
|
+
*
|
|
2074
|
+
* modified by Ryan Day for nodejs support
|
|
2075
|
+
* Copyright (c) 2011 Ryan Day
|
|
2076
|
+
*
|
|
2077
|
+
* Licensed under the MIT license:
|
|
2078
|
+
* http://www.opensource.org/licenses/mit-license.php
|
|
2079
|
+
*
|
|
2080
|
+
//---------------------------------------------------------------------
|
|
2081
|
+
// QRCode for JavaScript
|
|
2082
|
+
//
|
|
2083
|
+
// Copyright (c) 2009 Kazuhiko Arase
|
|
2084
|
+
//
|
|
2085
|
+
// URL: http://www.d-project.com/
|
|
2086
|
+
//
|
|
2087
|
+
// Licensed under the MIT license:
|
|
2088
|
+
// http://www.opensource.org/licenses/mit-license.php
|
|
2089
|
+
//
|
|
2090
|
+
// The word "QR Code" is registered trademark of
|
|
2091
|
+
// DENSO WAVE INCORPORATED
|
|
2092
|
+
// http://www.denso-wave.com/qrcode/faqpatent-e.html
|
|
2093
|
+
//
|
|
2094
|
+
//---------------------------------------------------------------------
|
|
2095
|
+
*/
|
|
2096
|
+
/**
|
|
2097
|
+
* Add finder patterns bits to matrix
|
|
2098
|
+
*
|
|
2099
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
2100
|
+
* @param {Number} version QR Code version
|
|
2101
|
+
*/
|
|
2102
|
+
function setupFinderPattern(matrix, version) {
|
|
2103
|
+
const size = matrix.size;
|
|
2104
|
+
const pos = FinderPattern.getPositions(version);
|
|
2105
|
+
for (let i = 0; i < pos.length; i++) {
|
|
2106
|
+
const row = pos[i][0];
|
|
2107
|
+
const col = pos[i][1];
|
|
2108
|
+
for (let r = -1; r <= 7; r++) {
|
|
2109
|
+
if (row + r <= -1 || size <= row + r) continue;
|
|
2110
|
+
for (let c = -1; c <= 7; c++) {
|
|
2111
|
+
if (col + c <= -1 || size <= col + c) continue;
|
|
2112
|
+
if (r >= 0 && r <= 6 && (c === 0 || c === 6) || c >= 0 && c <= 6 && (r === 0 || r === 6) || r >= 2 && r <= 4 && c >= 2 && c <= 4) matrix.set(row + r, col + c, true, true);
|
|
2113
|
+
else matrix.set(row + r, col + c, false, true);
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
/**
|
|
2119
|
+
* Add timing pattern bits to matrix
|
|
2120
|
+
*
|
|
2121
|
+
* Note: this function must be called before {@link setupAlignmentPattern}
|
|
2122
|
+
*
|
|
2123
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
2124
|
+
*/
|
|
2125
|
+
function setupTimingPattern(matrix) {
|
|
2126
|
+
const size = matrix.size;
|
|
2127
|
+
for (let r = 8; r < size - 8; r++) {
|
|
2128
|
+
const value = r % 2 === 0;
|
|
2129
|
+
matrix.set(r, 6, value, true);
|
|
2130
|
+
matrix.set(6, r, value, true);
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
/**
|
|
2134
|
+
* Add alignment patterns bits to matrix
|
|
2135
|
+
*
|
|
2136
|
+
* Note: this function must be called after {@link setupTimingPattern}
|
|
2137
|
+
*
|
|
2138
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
2139
|
+
* @param {Number} version QR Code version
|
|
2140
|
+
*/
|
|
2141
|
+
function setupAlignmentPattern(matrix, version) {
|
|
2142
|
+
const pos = AlignmentPattern.getPositions(version);
|
|
2143
|
+
for (let i = 0; i < pos.length; i++) {
|
|
2144
|
+
const row = pos[i][0];
|
|
2145
|
+
const col = pos[i][1];
|
|
2146
|
+
for (let r = -2; r <= 2; r++) for (let c = -2; c <= 2; c++) if (r === -2 || r === 2 || c === -2 || c === 2 || r === 0 && c === 0) matrix.set(row + r, col + c, true, true);
|
|
2147
|
+
else matrix.set(row + r, col + c, false, true);
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
/**
|
|
2151
|
+
* Add version info bits to matrix
|
|
2152
|
+
*
|
|
2153
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
2154
|
+
* @param {Number} version QR Code version
|
|
2155
|
+
*/
|
|
2156
|
+
function setupVersionInfo(matrix, version) {
|
|
2157
|
+
const size = matrix.size;
|
|
2158
|
+
const bits = Version.getEncodedBits(version);
|
|
2159
|
+
let row, col, mod;
|
|
2160
|
+
for (let i = 0; i < 18; i++) {
|
|
2161
|
+
row = Math.floor(i / 3);
|
|
2162
|
+
col = i % 3 + size - 8 - 3;
|
|
2163
|
+
mod = (bits >> i & 1) === 1;
|
|
2164
|
+
matrix.set(row, col, mod, true);
|
|
2165
|
+
matrix.set(col, row, mod, true);
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
/**
|
|
2169
|
+
* Add format info bits to matrix
|
|
2170
|
+
*
|
|
2171
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
2172
|
+
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
|
|
2173
|
+
* @param {Number} maskPattern Mask pattern reference value
|
|
2174
|
+
*/
|
|
2175
|
+
function setupFormatInfo(matrix, errorCorrectionLevel, maskPattern) {
|
|
2176
|
+
const size = matrix.size;
|
|
2177
|
+
const bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern);
|
|
2178
|
+
let i, mod;
|
|
2179
|
+
for (i = 0; i < 15; i++) {
|
|
2180
|
+
mod = (bits >> i & 1) === 1;
|
|
2181
|
+
if (i < 6) matrix.set(i, 8, mod, true);
|
|
2182
|
+
else if (i < 8) matrix.set(i + 1, 8, mod, true);
|
|
2183
|
+
else matrix.set(size - 15 + i, 8, mod, true);
|
|
2184
|
+
if (i < 8) matrix.set(8, size - i - 1, mod, true);
|
|
2185
|
+
else if (i < 9) matrix.set(8, 15 - i - 1 + 1, mod, true);
|
|
2186
|
+
else matrix.set(8, 15 - i - 1, mod, true);
|
|
2187
|
+
}
|
|
2188
|
+
matrix.set(size - 8, 8, 1, true);
|
|
2189
|
+
}
|
|
2190
|
+
/**
|
|
2191
|
+
* Add encoded data bits to matrix
|
|
2192
|
+
*
|
|
2193
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
2194
|
+
* @param {Uint8Array} data Data codewords
|
|
2195
|
+
*/
|
|
2196
|
+
function setupData(matrix, data) {
|
|
2197
|
+
const size = matrix.size;
|
|
2198
|
+
let inc = -1;
|
|
2199
|
+
let row = size - 1;
|
|
2200
|
+
let bitIndex = 7;
|
|
2201
|
+
let byteIndex = 0;
|
|
2202
|
+
for (let col = size - 1; col > 0; col -= 2) {
|
|
2203
|
+
if (col === 6) col--;
|
|
2204
|
+
while (true) {
|
|
2205
|
+
for (let c = 0; c < 2; c++) if (!matrix.isReserved(row, col - c)) {
|
|
2206
|
+
let dark = false;
|
|
2207
|
+
if (byteIndex < data.length) dark = (data[byteIndex] >>> bitIndex & 1) === 1;
|
|
2208
|
+
matrix.set(row, col - c, dark);
|
|
2209
|
+
bitIndex--;
|
|
2210
|
+
if (bitIndex === -1) {
|
|
2211
|
+
byteIndex++;
|
|
2212
|
+
bitIndex = 7;
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
row += inc;
|
|
2216
|
+
if (row < 0 || size <= row) {
|
|
2217
|
+
row -= inc;
|
|
2218
|
+
inc = -inc;
|
|
2219
|
+
break;
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
/**
|
|
2225
|
+
* Create encoded codewords from data input
|
|
2226
|
+
*
|
|
2227
|
+
* @param {Number} version QR Code version
|
|
2228
|
+
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
|
|
2229
|
+
* @param {ByteData} data Data input
|
|
2230
|
+
* @return {Uint8Array} Buffer containing encoded codewords
|
|
2231
|
+
*/
|
|
2232
|
+
function createData(version, errorCorrectionLevel, segments) {
|
|
2233
|
+
const buffer = new BitBuffer();
|
|
2234
|
+
segments.forEach(function(data) {
|
|
2235
|
+
buffer.put(data.mode.bit, 4);
|
|
2236
|
+
buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version));
|
|
2237
|
+
data.write(buffer);
|
|
2238
|
+
});
|
|
2239
|
+
const dataTotalCodewordsBits = (Utils.getSymbolTotalCodewords(version) - ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)) * 8;
|
|
2240
|
+
if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) buffer.put(0, 4);
|
|
2241
|
+
while (buffer.getLengthInBits() % 8 !== 0) buffer.putBit(0);
|
|
2242
|
+
const remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8;
|
|
2243
|
+
for (let i = 0; i < remainingByte; i++) buffer.put(i % 2 ? 17 : 236, 8);
|
|
2244
|
+
return createCodewords(buffer, version, errorCorrectionLevel);
|
|
2245
|
+
}
|
|
2246
|
+
/**
|
|
2247
|
+
* Encode input data with Reed-Solomon and return codewords with
|
|
2248
|
+
* relative error correction bits
|
|
2249
|
+
*
|
|
2250
|
+
* @param {BitBuffer} bitBuffer Data to encode
|
|
2251
|
+
* @param {Number} version QR Code version
|
|
2252
|
+
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
|
|
2253
|
+
* @return {Uint8Array} Buffer containing encoded codewords
|
|
2254
|
+
*/
|
|
2255
|
+
function createCodewords(bitBuffer, version, errorCorrectionLevel) {
|
|
2256
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version);
|
|
2257
|
+
const dataTotalCodewords = totalCodewords - ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
|
|
2258
|
+
const ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel);
|
|
2259
|
+
const blocksInGroup1 = ecTotalBlocks - totalCodewords % ecTotalBlocks;
|
|
2260
|
+
const totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks);
|
|
2261
|
+
const dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks);
|
|
2262
|
+
const dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1;
|
|
2263
|
+
const ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1;
|
|
2264
|
+
const rs = new ReedSolomonEncoder(ecCount);
|
|
2265
|
+
let offset = 0;
|
|
2266
|
+
const dcData = new Array(ecTotalBlocks);
|
|
2267
|
+
const ecData = new Array(ecTotalBlocks);
|
|
2268
|
+
let maxDataSize = 0;
|
|
2269
|
+
const buffer = new Uint8Array(bitBuffer.buffer);
|
|
2270
|
+
for (let b = 0; b < ecTotalBlocks; b++) {
|
|
2271
|
+
const dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2;
|
|
2272
|
+
dcData[b] = buffer.slice(offset, offset + dataSize);
|
|
2273
|
+
ecData[b] = rs.encode(dcData[b]);
|
|
2274
|
+
offset += dataSize;
|
|
2275
|
+
maxDataSize = Math.max(maxDataSize, dataSize);
|
|
2276
|
+
}
|
|
2277
|
+
const data = new Uint8Array(totalCodewords);
|
|
2278
|
+
let index = 0;
|
|
2279
|
+
let i, r;
|
|
2280
|
+
for (i = 0; i < maxDataSize; i++) for (r = 0; r < ecTotalBlocks; r++) if (i < dcData[r].length) data[index++] = dcData[r][i];
|
|
2281
|
+
for (i = 0; i < ecCount; i++) for (r = 0; r < ecTotalBlocks; r++) data[index++] = ecData[r][i];
|
|
2282
|
+
return data;
|
|
2283
|
+
}
|
|
2284
|
+
/**
|
|
2285
|
+
* Build QR Code symbol
|
|
2286
|
+
*
|
|
2287
|
+
* @param {String} data Input string
|
|
2288
|
+
* @param {Number} version QR Code version
|
|
2289
|
+
* @param {ErrorCorretionLevel} errorCorrectionLevel Error level
|
|
2290
|
+
* @param {MaskPattern} maskPattern Mask pattern
|
|
2291
|
+
* @return {Object} Object containing symbol data
|
|
2292
|
+
*/
|
|
2293
|
+
function createSymbol(data, version, errorCorrectionLevel, maskPattern) {
|
|
2294
|
+
let segments;
|
|
2295
|
+
if (Array.isArray(data)) segments = Segments.fromArray(data);
|
|
2296
|
+
else if (typeof data === "string") {
|
|
2297
|
+
let estimatedVersion = version;
|
|
2298
|
+
if (!estimatedVersion) {
|
|
2299
|
+
const rawSegments = Segments.rawSplit(data);
|
|
2300
|
+
estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel);
|
|
2301
|
+
}
|
|
2302
|
+
segments = Segments.fromString(data, estimatedVersion || 40);
|
|
2303
|
+
} else throw new Error("Invalid data");
|
|
2304
|
+
const bestVersion = Version.getBestVersionForData(segments, errorCorrectionLevel);
|
|
2305
|
+
if (!bestVersion) throw new Error("The amount of data is too big to be stored in a QR Code");
|
|
2306
|
+
if (!version) version = bestVersion;
|
|
2307
|
+
else if (version < bestVersion) throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: " + bestVersion + ".\n");
|
|
2308
|
+
const dataBits = createData(version, errorCorrectionLevel, segments);
|
|
2309
|
+
const moduleCount = Utils.getSymbolSize(version);
|
|
2310
|
+
const modules = new BitMatrix(moduleCount);
|
|
2311
|
+
setupFinderPattern(modules, version);
|
|
2312
|
+
setupTimingPattern(modules);
|
|
2313
|
+
setupAlignmentPattern(modules, version);
|
|
2314
|
+
setupFormatInfo(modules, errorCorrectionLevel, 0);
|
|
2315
|
+
if (version >= 7) setupVersionInfo(modules, version);
|
|
2316
|
+
setupData(modules, dataBits);
|
|
2317
|
+
if (isNaN(maskPattern)) maskPattern = MaskPattern.getBestMask(modules, setupFormatInfo.bind(null, modules, errorCorrectionLevel));
|
|
2318
|
+
MaskPattern.applyMask(maskPattern, modules);
|
|
2319
|
+
setupFormatInfo(modules, errorCorrectionLevel, maskPattern);
|
|
2320
|
+
return {
|
|
2321
|
+
modules,
|
|
2322
|
+
version,
|
|
2323
|
+
errorCorrectionLevel,
|
|
2324
|
+
maskPattern,
|
|
2325
|
+
segments
|
|
2326
|
+
};
|
|
2327
|
+
}
|
|
2328
|
+
/**
|
|
2329
|
+
* QR Code
|
|
2330
|
+
*
|
|
2331
|
+
* @param {String | Array} data Input data
|
|
2332
|
+
* @param {Object} options Optional configurations
|
|
2333
|
+
* @param {Number} options.version QR Code version
|
|
2334
|
+
* @param {String} options.errorCorrectionLevel Error correction level
|
|
2335
|
+
* @param {Function} options.toSJISFunc Helper func to convert utf8 to sjis
|
|
2336
|
+
*/
|
|
2337
|
+
exports.create = function create(data, options) {
|
|
2338
|
+
if (typeof data === "undefined" || data === "") throw new Error("No input text");
|
|
2339
|
+
let errorCorrectionLevel = ECLevel.M;
|
|
2340
|
+
let version;
|
|
2341
|
+
let mask;
|
|
2342
|
+
if (typeof options !== "undefined") {
|
|
2343
|
+
errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M);
|
|
2344
|
+
version = Version.from(options.version);
|
|
2345
|
+
mask = MaskPattern.from(options.maskPattern);
|
|
2346
|
+
if (options.toSJISFunc) Utils.setToSJISFunction(options.toSJISFunc);
|
|
2347
|
+
}
|
|
2348
|
+
return createSymbol(data, version, errorCorrectionLevel, mask);
|
|
2349
|
+
};
|
|
2350
|
+
}));
|
|
2351
|
+
//#endregion
|
|
2352
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js
|
|
2353
|
+
var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2354
|
+
function hex2rgba(hex) {
|
|
2355
|
+
if (typeof hex === "number") hex = hex.toString();
|
|
2356
|
+
if (typeof hex !== "string") throw new Error("Color should be defined as hex string");
|
|
2357
|
+
let hexCode = hex.slice().replace("#", "").split("");
|
|
2358
|
+
if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) throw new Error("Invalid hex color: " + hex);
|
|
2359
|
+
if (hexCode.length === 3 || hexCode.length === 4) hexCode = Array.prototype.concat.apply([], hexCode.map(function(c) {
|
|
2360
|
+
return [c, c];
|
|
2361
|
+
}));
|
|
2362
|
+
if (hexCode.length === 6) hexCode.push("F", "F");
|
|
2363
|
+
const hexValue = parseInt(hexCode.join(""), 16);
|
|
2364
|
+
return {
|
|
2365
|
+
r: hexValue >> 24 & 255,
|
|
2366
|
+
g: hexValue >> 16 & 255,
|
|
2367
|
+
b: hexValue >> 8 & 255,
|
|
2368
|
+
a: hexValue & 255,
|
|
2369
|
+
hex: "#" + hexCode.slice(0, 6).join("")
|
|
2370
|
+
};
|
|
2371
|
+
}
|
|
2372
|
+
exports.getOptions = function getOptions(options) {
|
|
2373
|
+
if (!options) options = {};
|
|
2374
|
+
if (!options.color) options.color = {};
|
|
2375
|
+
const margin = typeof options.margin === "undefined" || options.margin === null || options.margin < 0 ? 4 : options.margin;
|
|
2376
|
+
const width = options.width && options.width >= 21 ? options.width : void 0;
|
|
2377
|
+
const scale = options.scale || 4;
|
|
2378
|
+
return {
|
|
2379
|
+
width,
|
|
2380
|
+
scale: width ? 4 : scale,
|
|
2381
|
+
margin,
|
|
2382
|
+
color: {
|
|
2383
|
+
dark: hex2rgba(options.color.dark || "#000000ff"),
|
|
2384
|
+
light: hex2rgba(options.color.light || "#ffffffff")
|
|
2385
|
+
},
|
|
2386
|
+
type: options.type,
|
|
2387
|
+
rendererOpts: options.rendererOpts || {}
|
|
2388
|
+
};
|
|
2389
|
+
};
|
|
2390
|
+
exports.getScale = function getScale(qrSize, opts) {
|
|
2391
|
+
return opts.width && opts.width >= qrSize + opts.margin * 2 ? opts.width / (qrSize + opts.margin * 2) : opts.scale;
|
|
2392
|
+
};
|
|
2393
|
+
exports.getImageWidth = function getImageWidth(qrSize, opts) {
|
|
2394
|
+
const scale = exports.getScale(qrSize, opts);
|
|
2395
|
+
return Math.floor((qrSize + opts.margin * 2) * scale);
|
|
2396
|
+
};
|
|
2397
|
+
exports.qrToImageData = function qrToImageData(imgData, qr, opts) {
|
|
2398
|
+
const size = qr.modules.size;
|
|
2399
|
+
const data = qr.modules.data;
|
|
2400
|
+
const scale = exports.getScale(size, opts);
|
|
2401
|
+
const symbolSize = Math.floor((size + opts.margin * 2) * scale);
|
|
2402
|
+
const scaledMargin = opts.margin * scale;
|
|
2403
|
+
const palette = [opts.color.light, opts.color.dark];
|
|
2404
|
+
for (let i = 0; i < symbolSize; i++) for (let j = 0; j < symbolSize; j++) {
|
|
2405
|
+
let posDst = (i * symbolSize + j) * 4;
|
|
2406
|
+
let pxColor = opts.color.light;
|
|
2407
|
+
if (i >= scaledMargin && j >= scaledMargin && i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) {
|
|
2408
|
+
const iSrc = Math.floor((i - scaledMargin) / scale);
|
|
2409
|
+
const jSrc = Math.floor((j - scaledMargin) / scale);
|
|
2410
|
+
pxColor = palette[data[iSrc * size + jSrc] ? 1 : 0];
|
|
2411
|
+
}
|
|
2412
|
+
imgData[posDst++] = pxColor.r;
|
|
2413
|
+
imgData[posDst++] = pxColor.g;
|
|
2414
|
+
imgData[posDst++] = pxColor.b;
|
|
2415
|
+
imgData[posDst] = pxColor.a;
|
|
2416
|
+
}
|
|
2417
|
+
};
|
|
2418
|
+
}));
|
|
2419
|
+
//#endregion
|
|
2420
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js
|
|
2421
|
+
var require_canvas = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2422
|
+
const Utils = require_utils();
|
|
2423
|
+
function clearCanvas(ctx, canvas, size) {
|
|
2424
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
2425
|
+
if (!canvas.style) canvas.style = {};
|
|
2426
|
+
canvas.height = size;
|
|
2427
|
+
canvas.width = size;
|
|
2428
|
+
canvas.style.height = size + "px";
|
|
2429
|
+
canvas.style.width = size + "px";
|
|
2430
|
+
}
|
|
2431
|
+
function getCanvasElement() {
|
|
2432
|
+
try {
|
|
2433
|
+
return document.createElement("canvas");
|
|
2434
|
+
} catch (e) {
|
|
2435
|
+
throw new Error("You need to specify a canvas element");
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
exports.render = function render(qrData, canvas, options) {
|
|
2439
|
+
let opts = options;
|
|
2440
|
+
let canvasEl = canvas;
|
|
2441
|
+
if (typeof opts === "undefined" && (!canvas || !canvas.getContext)) {
|
|
2442
|
+
opts = canvas;
|
|
2443
|
+
canvas = void 0;
|
|
2444
|
+
}
|
|
2445
|
+
if (!canvas) canvasEl = getCanvasElement();
|
|
2446
|
+
opts = Utils.getOptions(opts);
|
|
2447
|
+
const size = Utils.getImageWidth(qrData.modules.size, opts);
|
|
2448
|
+
const ctx = canvasEl.getContext("2d");
|
|
2449
|
+
const image = ctx.createImageData(size, size);
|
|
2450
|
+
Utils.qrToImageData(image.data, qrData, opts);
|
|
2451
|
+
clearCanvas(ctx, canvasEl, size);
|
|
2452
|
+
ctx.putImageData(image, 0, 0);
|
|
2453
|
+
return canvasEl;
|
|
2454
|
+
};
|
|
2455
|
+
exports.renderToDataURL = function renderToDataURL(qrData, canvas, options) {
|
|
2456
|
+
let opts = options;
|
|
2457
|
+
if (typeof opts === "undefined" && (!canvas || !canvas.getContext)) {
|
|
2458
|
+
opts = canvas;
|
|
2459
|
+
canvas = void 0;
|
|
2460
|
+
}
|
|
2461
|
+
if (!opts) opts = {};
|
|
2462
|
+
const canvasEl = exports.render(qrData, canvas, opts);
|
|
2463
|
+
const type = opts.type || "image/png";
|
|
2464
|
+
const rendererOpts = opts.rendererOpts || {};
|
|
2465
|
+
return canvasEl.toDataURL(type, rendererOpts.quality);
|
|
2466
|
+
};
|
|
2467
|
+
}));
|
|
2468
|
+
//#endregion
|
|
2469
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js
|
|
2470
|
+
var require_svg_tag = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2471
|
+
const Utils = require_utils();
|
|
2472
|
+
function getColorAttrib(color, attrib) {
|
|
2473
|
+
const alpha = color.a / 255;
|
|
2474
|
+
const str = attrib + "=\"" + color.hex + "\"";
|
|
2475
|
+
return alpha < 1 ? str + " " + attrib + "-opacity=\"" + alpha.toFixed(2).slice(1) + "\"" : str;
|
|
2476
|
+
}
|
|
2477
|
+
function svgCmd(cmd, x, y) {
|
|
2478
|
+
let str = cmd + x;
|
|
2479
|
+
if (typeof y !== "undefined") str += " " + y;
|
|
2480
|
+
return str;
|
|
2481
|
+
}
|
|
2482
|
+
function qrToPath(data, size, margin) {
|
|
2483
|
+
let path = "";
|
|
2484
|
+
let moveBy = 0;
|
|
2485
|
+
let newRow = false;
|
|
2486
|
+
let lineLength = 0;
|
|
2487
|
+
for (let i = 0; i < data.length; i++) {
|
|
2488
|
+
const col = Math.floor(i % size);
|
|
2489
|
+
const row = Math.floor(i / size);
|
|
2490
|
+
if (!col && !newRow) newRow = true;
|
|
2491
|
+
if (data[i]) {
|
|
2492
|
+
lineLength++;
|
|
2493
|
+
if (!(i > 0 && col > 0 && data[i - 1])) {
|
|
2494
|
+
path += newRow ? svgCmd("M", col + margin, .5 + row + margin) : svgCmd("m", moveBy, 0);
|
|
2495
|
+
moveBy = 0;
|
|
2496
|
+
newRow = false;
|
|
2497
|
+
}
|
|
2498
|
+
if (!(col + 1 < size && data[i + 1])) {
|
|
2499
|
+
path += svgCmd("h", lineLength);
|
|
2500
|
+
lineLength = 0;
|
|
2501
|
+
}
|
|
2502
|
+
} else moveBy++;
|
|
2503
|
+
}
|
|
2504
|
+
return path;
|
|
2505
|
+
}
|
|
2506
|
+
exports.render = function render(qrData, options, cb) {
|
|
2507
|
+
const opts = Utils.getOptions(options);
|
|
2508
|
+
const size = qrData.modules.size;
|
|
2509
|
+
const data = qrData.modules.data;
|
|
2510
|
+
const qrcodesize = size + opts.margin * 2;
|
|
2511
|
+
const bg = !opts.color.light.a ? "" : "<path " + getColorAttrib(opts.color.light, "fill") + " d=\"M0 0h" + qrcodesize + "v" + qrcodesize + "H0z\"/>";
|
|
2512
|
+
const path = "<path " + getColorAttrib(opts.color.dark, "stroke") + " d=\"" + qrToPath(data, size, opts.margin) + "\"/>";
|
|
2513
|
+
const viewBox = "viewBox=\"0 0 " + qrcodesize + " " + qrcodesize + "\"";
|
|
2514
|
+
const svgTag = "<svg xmlns=\"http://www.w3.org/2000/svg\" " + (!opts.width ? "" : "width=\"" + opts.width + "\" height=\"" + opts.width + "\" ") + viewBox + " shape-rendering=\"crispEdges\">" + bg + path + "</svg>\n";
|
|
2515
|
+
if (typeof cb === "function") cb(null, svgTag);
|
|
2516
|
+
return svgTag;
|
|
2517
|
+
};
|
|
2518
|
+
}));
|
|
2519
|
+
//#endregion
|
|
2520
|
+
//#region src/client/locales.ts
|
|
2521
|
+
var import_browser = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2522
|
+
const canPromise = require_can_promise();
|
|
2523
|
+
const QRCode = require_qrcode();
|
|
2524
|
+
const CanvasRenderer = require_canvas();
|
|
2525
|
+
const SvgRenderer = require_svg_tag();
|
|
2526
|
+
function renderCanvas(renderFunc, canvas, text, opts, cb) {
|
|
2527
|
+
const args = [].slice.call(arguments, 1);
|
|
2528
|
+
const argsNum = args.length;
|
|
2529
|
+
const isLastArgCb = typeof args[argsNum - 1] === "function";
|
|
2530
|
+
if (!isLastArgCb && !canPromise()) throw new Error("Callback required as last argument");
|
|
2531
|
+
if (isLastArgCb) {
|
|
2532
|
+
if (argsNum < 2) throw new Error("Too few arguments provided");
|
|
2533
|
+
if (argsNum === 2) {
|
|
2534
|
+
cb = text;
|
|
2535
|
+
text = canvas;
|
|
2536
|
+
canvas = opts = void 0;
|
|
2537
|
+
} else if (argsNum === 3) {
|
|
2538
|
+
if (canvas.getContext && typeof cb === "undefined") {
|
|
2539
|
+
cb = opts;
|
|
2540
|
+
opts = void 0;
|
|
2541
|
+
} else {
|
|
2542
|
+
cb = opts;
|
|
2543
|
+
opts = text;
|
|
2544
|
+
text = canvas;
|
|
2545
|
+
canvas = void 0;
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
} else {
|
|
2549
|
+
if (argsNum < 1) throw new Error("Too few arguments provided");
|
|
2550
|
+
if (argsNum === 1) {
|
|
2551
|
+
text = canvas;
|
|
2552
|
+
canvas = opts = void 0;
|
|
2553
|
+
} else if (argsNum === 2 && !canvas.getContext) {
|
|
2554
|
+
opts = text;
|
|
2555
|
+
text = canvas;
|
|
2556
|
+
canvas = void 0;
|
|
2557
|
+
}
|
|
2558
|
+
return new Promise(function(resolve, reject) {
|
|
2559
|
+
try {
|
|
2560
|
+
resolve(renderFunc(QRCode.create(text, opts), canvas, opts));
|
|
2561
|
+
} catch (e) {
|
|
2562
|
+
reject(e);
|
|
2563
|
+
}
|
|
2564
|
+
});
|
|
2565
|
+
}
|
|
2566
|
+
try {
|
|
2567
|
+
const data = QRCode.create(text, opts);
|
|
2568
|
+
cb(null, renderFunc(data, canvas, opts));
|
|
2569
|
+
} catch (e) {
|
|
2570
|
+
cb(e);
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
exports.create = QRCode.create;
|
|
2574
|
+
exports.toCanvas = renderCanvas.bind(null, CanvasRenderer.render);
|
|
2575
|
+
exports.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL);
|
|
2576
|
+
exports.toString = renderCanvas.bind(null, function(data, _, opts) {
|
|
2577
|
+
return SvgRenderer.render(data, opts);
|
|
2578
|
+
});
|
|
2579
|
+
})))(), 1);
|
|
2580
|
+
/**
|
|
2581
|
+
* dsh-qr-share dictionaries: zh-Hans + en. The shell's locale service
|
|
2582
|
+
* drives the active language; the footer action reads via `ctx.locale.bind`.
|
|
2583
|
+
*/
|
|
2584
|
+
const LOCALE_NS = "qr-share";
|
|
2585
|
+
const zh = {
|
|
2586
|
+
"button.label": "扫码登录",
|
|
2587
|
+
"button.tooltip": "用手机扫码以同一账号登录",
|
|
2588
|
+
"dialog.title": "用手机扫码登录",
|
|
2589
|
+
"dialog.hint": "用手机相机扫描下方二维码。手机打开后会自动以当前账号登录,token 与浏览器 cookie 同寿命。",
|
|
2590
|
+
"dialog.urlLabel": "链接",
|
|
2591
|
+
"dialog.close": "关闭",
|
|
2592
|
+
"dialog.error": "二维码生成失败"
|
|
2593
|
+
};
|
|
2594
|
+
const en = {
|
|
2595
|
+
"button.label": "Mobile Login",
|
|
2596
|
+
"button.tooltip": "Scan with a phone to log in to this session",
|
|
2597
|
+
"dialog.title": "Scan to log in on mobile",
|
|
2598
|
+
"dialog.hint": "Scan the QR code below with your phone camera. The phone will log in to this session; the token lives as long as the browser cookie.",
|
|
2599
|
+
"dialog.urlLabel": "URL",
|
|
2600
|
+
"dialog.close": "Close",
|
|
2601
|
+
"dialog.error": "Failed to render QR code"
|
|
2602
|
+
};
|
|
2603
|
+
//#endregion
|
|
2604
|
+
//#region src/client/QrDialog.tsx
|
|
2605
|
+
/**
|
|
2606
|
+
* QR-code modal: a fixed-position overlay with a canvas, the resolved URL
|
|
2607
|
+
* as plain text (so the user can type it manually if scanning fails), and
|
|
2608
|
+
* a Close button. The URL is composed from `window.location.origin` —
|
|
2609
|
+
* not from the host — so it always matches whatever authority the
|
|
2610
|
+
* desktop just used to reach this page.
|
|
2611
|
+
*
|
|
2612
|
+
* Server-side constraint: BrowserAuth.authorizeIndex only accepts token
|
|
2613
|
+
* exchanges on path `/` (see browser-auth.ts). We enforce that here so a
|
|
2614
|
+
* future reverse-proxy sub-path does NOT silently produce a 401 on the
|
|
2615
|
+
* phone.
|
|
2616
|
+
*/
|
|
2617
|
+
function composeQrUrl(token) {
|
|
2618
|
+
const url = new URL("/", window.location.origin);
|
|
2619
|
+
url.searchParams.set("token", token);
|
|
2620
|
+
return url.toString();
|
|
2621
|
+
}
|
|
2622
|
+
function QrDialog({ token, tokenTtlMs, t, onClose }) {
|
|
2623
|
+
const canvasRef = (0, react.useRef)(null);
|
|
2624
|
+
const [payload, setPayload] = (0, react.useState)("");
|
|
2625
|
+
const [error, setError] = (0, react.useState)(null);
|
|
2626
|
+
(0, react.useEffect)(() => {
|
|
2627
|
+
if (token === "") return;
|
|
2628
|
+
const url = composeQrUrl(token);
|
|
2629
|
+
setPayload(url);
|
|
2630
|
+
const canvas = canvasRef.current;
|
|
2631
|
+
if (canvas !== null) import_browser.toCanvas(canvas, url, {
|
|
2632
|
+
errorCorrectionLevel: "M",
|
|
2633
|
+
margin: 1,
|
|
2634
|
+
width: 256,
|
|
2635
|
+
color: {
|
|
2636
|
+
dark: "#000000",
|
|
2637
|
+
light: "#ffffff"
|
|
2638
|
+
}
|
|
2639
|
+
}).catch((reason) => {
|
|
2640
|
+
setError(reason instanceof Error ? reason.message : String(reason));
|
|
2641
|
+
});
|
|
2642
|
+
}, [token]);
|
|
2643
|
+
(0, react.useEffect)(() => {
|
|
2644
|
+
const onKey = (e) => {
|
|
2645
|
+
if (e.key === "Escape") onClose();
|
|
2646
|
+
};
|
|
2647
|
+
window.addEventListener("keydown", onKey);
|
|
2648
|
+
return () => {
|
|
2649
|
+
window.removeEventListener("keydown", onKey);
|
|
2650
|
+
};
|
|
2651
|
+
}, [onClose]);
|
|
2652
|
+
const onBackdropClick = (e) => {
|
|
2653
|
+
if (e.target === e.currentTarget) onClose();
|
|
2654
|
+
};
|
|
2655
|
+
return (0, react.createElement)("div", {
|
|
2656
|
+
className: "dsh-qr-share-backdrop",
|
|
2657
|
+
role: "presentation",
|
|
2658
|
+
onClick: onBackdropClick
|
|
2659
|
+
}, (0, react.createElement)("div", {
|
|
2660
|
+
className: "dsh-qr-share-dialog",
|
|
2661
|
+
role: "dialog",
|
|
2662
|
+
"aria-modal": "true",
|
|
2663
|
+
"aria-labelledby": "dsh-qr-share-title"
|
|
2664
|
+
}, (0, react.createElement)("h2", {
|
|
2665
|
+
id: "dsh-qr-share-title",
|
|
2666
|
+
className: "dsh-qr-share-title"
|
|
2667
|
+
}, t("dialog.title")), error !== null ? (0, react.createElement)("p", { className: "dsh-qr-share-err" }, `${t("dialog.error")}: ${error}`) : (0, react.createElement)("canvas", {
|
|
2668
|
+
ref: canvasRef,
|
|
2669
|
+
className: "dsh-qr-share-canvas",
|
|
2670
|
+
width: 256,
|
|
2671
|
+
height: 256
|
|
2672
|
+
}), (0, react.createElement)("div", { className: "dsh-qr-share-url-block" }, (0, react.createElement)("span", { className: "dsh-qr-share-url-label" }, t("dialog.urlLabel")), (0, react.createElement)("code", { className: "dsh-qr-share-url" }, payload)), (0, react.createElement)("p", { className: "dsh-qr-share-hint" }, t("dialog.hint")), (0, react.createElement)("button", {
|
|
2673
|
+
type: "button",
|
|
2674
|
+
className: "dsh-qr-share-close",
|
|
2675
|
+
onClick: onClose
|
|
2676
|
+
}, t("dialog.close"))));
|
|
2677
|
+
}
|
|
2678
|
+
//#endregion
|
|
2679
|
+
//#region src/client/QrButton.tsx
|
|
2680
|
+
/**
|
|
2681
|
+
* Sidebar footer action: a QR-code icon button. Clicking opens the
|
|
2682
|
+
* `QrDialog`. The button renders only when the server reports `ready`
|
|
2683
|
+
* (i.e. the browser is past the launch-token exchange AND a token is
|
|
2684
|
+
* available); otherwise it stays mounted-but-empty so the slot ledger
|
|
2685
|
+
* remains stable across the login → main transition.
|
|
2686
|
+
*/
|
|
2687
|
+
function QrButton({ info, wide, t }) {
|
|
2688
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
2689
|
+
return (0, react.createElement)(react.Fragment, null, (0, react.createElement)("button", {
|
|
2690
|
+
type: "button",
|
|
2691
|
+
className: "dsh-qr-share-button",
|
|
2692
|
+
"aria-label": t("button.label"),
|
|
2693
|
+
title: t("button.tooltip"),
|
|
2694
|
+
onClick: () => {
|
|
2695
|
+
setOpen(true);
|
|
2696
|
+
}
|
|
2697
|
+
}, (0, react.createElement)(HiOutlineQrCode, { size: wide ? 18 : 20 }), wide ? (0, react.createElement)("span", { className: "dsh-qr-share-button-label" }, t("button.label")) : null), open ? (0, react.createElement)(QrDialog, {
|
|
2698
|
+
token: info.token,
|
|
2699
|
+
tokenTtlMs: info.tokenTtlMs,
|
|
2700
|
+
t,
|
|
2701
|
+
onClose: () => {
|
|
2702
|
+
setOpen(false);
|
|
2703
|
+
}
|
|
2704
|
+
}) : null);
|
|
2705
|
+
}
|
|
2706
|
+
//#endregion
|
|
2707
|
+
//#region src/client/api.ts
|
|
2708
|
+
const ROUTE_PATH = "/_qr/share";
|
|
2709
|
+
async function fetchShareInfo(signal) {
|
|
2710
|
+
try {
|
|
2711
|
+
const res = await fetch(ROUTE_PATH, {
|
|
2712
|
+
method: "GET",
|
|
2713
|
+
credentials: "same-origin",
|
|
2714
|
+
cache: "no-store",
|
|
2715
|
+
headers: { "accept": "application/json" },
|
|
2716
|
+
...signal === void 0 ? {} : { signal }
|
|
2717
|
+
});
|
|
2718
|
+
if (!res.ok) return null;
|
|
2719
|
+
const data = await res.json();
|
|
2720
|
+
if (typeof data.token !== "string" || typeof data.ready !== "boolean") return null;
|
|
2721
|
+
return {
|
|
2722
|
+
ready: data.ready,
|
|
2723
|
+
token: data.token,
|
|
2724
|
+
tokenTtlMs: typeof data.tokenTtlMs === "number" ? data.tokenTtlMs : 0
|
|
2725
|
+
};
|
|
2726
|
+
} catch {
|
|
2727
|
+
return null;
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
//#endregion
|
|
2731
|
+
//#region src/client/index.tsx
|
|
2732
|
+
/**
|
|
2733
|
+
* dsh-qr-share client half.
|
|
2734
|
+
*
|
|
2735
|
+
* Registers a single `sidebar.footer.action` slot occupant that renders
|
|
2736
|
+
* the QR-code button. The button stays mounted but hidden until the host
|
|
2737
|
+
* half's `/_qr/share` returns `ready: true` — that happens exactly when
|
|
2738
|
+
* (a) the request passed `connection.requestRejection` (Host/Origin
|
|
2739
|
+
* trusted AND browser cookie valid), AND
|
|
2740
|
+
* (b) a non-empty launch token was minted.
|
|
2741
|
+
* Both conditions jointly mean "the desktop has already completed the
|
|
2742
|
+
* token-exchange redirect and now lives on /, not on /?token=…".
|
|
2743
|
+
*/
|
|
2744
|
+
/** Services required before this entry activates. */
|
|
2745
|
+
const inject = [
|
|
2746
|
+
"slots",
|
|
2747
|
+
"locale",
|
|
2748
|
+
"connection"
|
|
2749
|
+
];
|
|
2750
|
+
/**
|
|
2751
|
+
* The footer-action component. Mounted by the slot registry; receives the
|
|
2752
|
+
* sidebar's wide/rail state via the slot owner props.
|
|
2753
|
+
* @param owner - slot owner props from the sidebar shell.
|
|
2754
|
+
* @param t - locale reader bound by the apply function below.
|
|
2755
|
+
*/
|
|
2756
|
+
function FooterAction(owner, t) {
|
|
2757
|
+
const [info, setInfo] = (0, react.useState)(null);
|
|
2758
|
+
(0, react.useEffect)(() => {
|
|
2759
|
+
let cancelled = false;
|
|
2760
|
+
const refresh = () => {
|
|
2761
|
+
fetchShareInfo().then((next) => {
|
|
2762
|
+
if (!cancelled) setInfo(next);
|
|
2763
|
+
});
|
|
2764
|
+
};
|
|
2765
|
+
refresh();
|
|
2766
|
+
window.addEventListener("focus", refresh);
|
|
2767
|
+
return () => {
|
|
2768
|
+
cancelled = true;
|
|
2769
|
+
window.removeEventListener("focus", refresh);
|
|
2770
|
+
};
|
|
2771
|
+
}, []);
|
|
2772
|
+
if (info === null) return null;
|
|
2773
|
+
if (!info.ready) return null;
|
|
2774
|
+
return (0, react.createElement)(QrButton, {
|
|
2775
|
+
info,
|
|
2776
|
+
wide: owner.wide,
|
|
2777
|
+
t
|
|
2778
|
+
});
|
|
2779
|
+
}
|
|
2780
|
+
/**
|
|
2781
|
+
* Register dictionaries and the slot occupant.
|
|
2782
|
+
* @param ctx - client root context (slots + locale + connection injected).
|
|
2783
|
+
*/
|
|
2784
|
+
function apply(ctx) {
|
|
2785
|
+
ctx.effect(() => ctx.locale.register(LOCALE_NS, {
|
|
2786
|
+
zh,
|
|
2787
|
+
en
|
|
2788
|
+
}), "qr-share: dictionaries");
|
|
2789
|
+
const t = ctx.locale.bind(LOCALE_NS);
|
|
2790
|
+
ctx.slots.inject("sidebar.footer.action", () => ctx.slots.register({
|
|
2791
|
+
name: "sidebar.footer.action",
|
|
2792
|
+
id: "qr-share",
|
|
2793
|
+
order: 100,
|
|
2794
|
+
locale: LOCALE_NS
|
|
2795
|
+
}, (owner) => FooterAction(owner, t)));
|
|
2796
|
+
}
|
|
2797
|
+
//#endregion
|
|
2798
|
+
exports.apply = apply;
|
|
2799
|
+
exports.inject = inject;
|
|
2800
|
+
return module.exports;
|
|
2801
|
+
}
|
|
2802
|
+
});
|
|
2803
|
+
|
|
2804
|
+
//# sourceMappingURL=client-registry.js.map
|