@bigbinary/neeto-molecules 4.1.42 → 4.1.43
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/dist/BrowserSupport.js +1 -1
- package/dist/DownloadMobileAppCallout.js +1 -1
- package/dist/ErrorPage.js +3 -3
- package/dist/ErrorPage.js.map +1 -1
- package/dist/FloatingActionMenu.js +3 -3
- package/dist/FloatingActionMenu.js.map +1 -1
- package/dist/KeyboardShortcuts.js +2 -2
- package/dist/ProductEmbed.js +15 -15
- package/dist/ProductEmbed.js.map +1 -1
- package/dist/ShareViaLink.js +446 -179
- package/dist/ShareViaLink.js.map +1 -1
- package/dist/Sidebar.js +1 -1
- package/dist/StickyRibbonsContainer.js +3 -3
- package/dist/StickyRibbonsContainer.js.map +1 -1
- package/dist/cjs/BrowserSupport.js +1 -1
- package/dist/cjs/DownloadMobileAppCallout.js +1 -1
- package/dist/cjs/ErrorPage.js +2 -2
- package/dist/cjs/ErrorPage.js.map +1 -1
- package/dist/cjs/FloatingActionMenu.js +3 -3
- package/dist/cjs/FloatingActionMenu.js.map +1 -1
- package/dist/cjs/KeyboardShortcuts.js +2 -2
- package/dist/cjs/ProductEmbed.js +14 -14
- package/dist/cjs/ProductEmbed.js.map +1 -1
- package/dist/cjs/ShareViaLink.js +446 -179
- package/dist/cjs/ShareViaLink.js.map +1 -1
- package/dist/cjs/Sidebar.js +1 -1
- package/dist/cjs/StickyRibbonsContainer.js +2 -2
- package/dist/cjs/StickyRibbonsContainer.js.map +1 -1
- package/dist/cjs/{ua-parser-E0eEtHJZ.js → ua-parser-DgQ3nYoO.js} +327 -306
- package/dist/cjs/ua-parser-DgQ3nYoO.js.map +1 -0
- package/dist/cjs/{useKeyboardShortcutsPaneState-YnXpWOcs.js → useKeyboardShortcutsPaneState-BrgdLb9F.js} +3 -3
- package/dist/cjs/{useKeyboardShortcutsPaneState-YnXpWOcs.js.map → useKeyboardShortcutsPaneState-BrgdLb9F.js.map} +1 -1
- package/dist/{ua-parser-rRwDJPFB.js → ua-parser-OzUiuIwt.js} +327 -306
- package/dist/ua-parser-OzUiuIwt.js.map +1 -0
- package/dist/{useKeyboardShortcutsPaneState-C_eLceJQ.js → useKeyboardShortcutsPaneState-Ckzn5mVZ.js} +4 -4
- package/dist/{useKeyboardShortcutsPaneState-C_eLceJQ.js.map → useKeyboardShortcutsPaneState-Ckzn5mVZ.js.map} +1 -1
- package/package.json +57 -57
- package/dist/cjs/ua-parser-E0eEtHJZ.js.map +0 -1
- package/dist/ua-parser-rRwDJPFB.js.map +0 -1
package/dist/cjs/ShareViaLink.js
CHANGED
|
@@ -806,11 +806,19 @@ var __objRest = (source, exclude) => {
|
|
|
806
806
|
*/
|
|
807
807
|
var qrcodegen;
|
|
808
808
|
((qrcodegen2) => {
|
|
809
|
-
const _QrCode = class {
|
|
809
|
+
const _QrCode = class _QrCode {
|
|
810
|
+
/*-- Constructor (low level) and fields --*/
|
|
811
|
+
// Creates a new QR Code with the given version number,
|
|
812
|
+
// error correction level, data codeword bytes, and mask number.
|
|
813
|
+
// This is a low-level API that most users should not use directly.
|
|
814
|
+
// A mid-level API is the encodeSegments() function.
|
|
810
815
|
constructor(version, errorCorrectionLevel, dataCodewords, msk) {
|
|
811
816
|
this.version = version;
|
|
812
817
|
this.errorCorrectionLevel = errorCorrectionLevel;
|
|
818
|
+
// The modules of this QR Code (false = light, true = dark).
|
|
819
|
+
// Immutable after constructor finishes. Accessed through getModule().
|
|
813
820
|
this.modules = [];
|
|
821
|
+
// Indicates function modules that are not subjected to masking. Discarded when constructor finishes.
|
|
814
822
|
this.isFunction = [];
|
|
815
823
|
if (version < _QrCode.MIN_VERSION || version > _QrCode.MAX_VERSION)
|
|
816
824
|
throw new RangeError("Version value out of range");
|
|
@@ -846,14 +854,34 @@ var qrcodegen;
|
|
|
846
854
|
this.drawFormatBits(msk);
|
|
847
855
|
this.isFunction = [];
|
|
848
856
|
}
|
|
857
|
+
/*-- Static factory functions (high level) --*/
|
|
858
|
+
// Returns a QR Code representing the given Unicode text string at the given error correction level.
|
|
859
|
+
// As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer
|
|
860
|
+
// Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible
|
|
861
|
+
// QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
|
|
862
|
+
// ecl argument if it can be done without increasing the version.
|
|
849
863
|
static encodeText(text, ecl) {
|
|
850
864
|
const segs = qrcodegen2.QrSegment.makeSegments(text);
|
|
851
865
|
return _QrCode.encodeSegments(segs, ecl);
|
|
852
866
|
}
|
|
867
|
+
// Returns a QR Code representing the given binary data at the given error correction level.
|
|
868
|
+
// This function always encodes using the binary segment mode, not any text mode. The maximum number of
|
|
869
|
+
// bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
|
|
870
|
+
// The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
|
|
853
871
|
static encodeBinary(data, ecl) {
|
|
854
872
|
const seg = qrcodegen2.QrSegment.makeBytes(data);
|
|
855
873
|
return _QrCode.encodeSegments([seg], ecl);
|
|
856
874
|
}
|
|
875
|
+
/*-- Static factory functions (mid level) --*/
|
|
876
|
+
// Returns a QR Code representing the given segments with the given encoding parameters.
|
|
877
|
+
// The smallest possible QR Code version within the given range is automatically
|
|
878
|
+
// chosen for the output. Iff boostEcl is true, then the ECC level of the result
|
|
879
|
+
// may be higher than the ecl argument if it can be done without increasing the
|
|
880
|
+
// version. The mask number is either between 0 to 7 (inclusive) to force that
|
|
881
|
+
// mask, or -1 to automatically choose an appropriate mask (which may be slow).
|
|
882
|
+
// This function allows the user to create a custom sequence of segments that switches
|
|
883
|
+
// between modes (such as alphanumeric and byte) to encode text in less space.
|
|
884
|
+
// This is a mid-level API; the high-level API is encodeText() and encodeBinary().
|
|
857
885
|
static encodeSegments(segs, ecl, minVersion = 1, maxVersion = 40, mask = -1, boostEcl = true) {
|
|
858
886
|
if (!(_QrCode.MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= _QrCode.MAX_VERSION) || mask < -1 || mask > 7)
|
|
859
887
|
throw new RangeError("Invalid value");
|
|
@@ -894,12 +922,19 @@ var qrcodegen;
|
|
|
894
922
|
bb.forEach((b, i) => dataCodewords[i >>> 3] |= b << 7 - (i & 7));
|
|
895
923
|
return new _QrCode(version, ecl, dataCodewords, mask);
|
|
896
924
|
}
|
|
925
|
+
/*-- Accessor methods --*/
|
|
926
|
+
// Returns the color of the module (pixel) at the given coordinates, which is false
|
|
927
|
+
// for light or true for dark. The top left corner has the coordinates (x=0, y=0).
|
|
928
|
+
// If the given coordinates are out of bounds, then false (light) is returned.
|
|
897
929
|
getModule(x, y) {
|
|
898
930
|
return 0 <= x && x < this.size && 0 <= y && y < this.size && this.modules[y][x];
|
|
899
931
|
}
|
|
932
|
+
// Modified to expose modules for easy access
|
|
900
933
|
getModules() {
|
|
901
934
|
return this.modules;
|
|
902
935
|
}
|
|
936
|
+
/*-- Private helper methods for constructor: Drawing function modules --*/
|
|
937
|
+
// Reads this object's version field, and draws and marks all function modules.
|
|
903
938
|
drawFunctionPatterns() {
|
|
904
939
|
for (let i = 0; i < this.size; i++) {
|
|
905
940
|
this.setFunctionModule(6, i, i % 2 == 0);
|
|
@@ -919,6 +954,8 @@ var qrcodegen;
|
|
|
919
954
|
this.drawFormatBits(0);
|
|
920
955
|
this.drawVersion();
|
|
921
956
|
}
|
|
957
|
+
// Draws two copies of the format bits (with its own error correction code)
|
|
958
|
+
// based on the given mask and this object's error correction level field.
|
|
922
959
|
drawFormatBits(mask) {
|
|
923
960
|
const data = this.errorCorrectionLevel.formatBits << 3 | mask;
|
|
924
961
|
let rem = data;
|
|
@@ -939,6 +976,8 @@ var qrcodegen;
|
|
|
939
976
|
this.setFunctionModule(8, this.size - 15 + i, getBit(bits, i));
|
|
940
977
|
this.setFunctionModule(8, this.size - 8, true);
|
|
941
978
|
}
|
|
979
|
+
// Draws two copies of the version bits (with its own error correction code),
|
|
980
|
+
// based on this object's version field, iff 7 <= version <= 40.
|
|
942
981
|
drawVersion() {
|
|
943
982
|
if (this.version < 7)
|
|
944
983
|
return;
|
|
@@ -955,6 +994,8 @@ var qrcodegen;
|
|
|
955
994
|
this.setFunctionModule(b, a, color);
|
|
956
995
|
}
|
|
957
996
|
}
|
|
997
|
+
// Draws a 9*9 finder pattern including the border separator,
|
|
998
|
+
// with the center module at (x, y). Modules can be out of bounds.
|
|
958
999
|
drawFinderPattern(x, y) {
|
|
959
1000
|
for (let dy = -4; dy <= 4; dy++) {
|
|
960
1001
|
for (let dx = -4; dx <= 4; dx++) {
|
|
@@ -966,16 +1007,23 @@ var qrcodegen;
|
|
|
966
1007
|
}
|
|
967
1008
|
}
|
|
968
1009
|
}
|
|
1010
|
+
// Draws a 5*5 alignment pattern, with the center module
|
|
1011
|
+
// at (x, y). All modules must be in bounds.
|
|
969
1012
|
drawAlignmentPattern(x, y) {
|
|
970
1013
|
for (let dy = -2; dy <= 2; dy++) {
|
|
971
1014
|
for (let dx = -2; dx <= 2; dx++)
|
|
972
1015
|
this.setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dx), Math.abs(dy)) != 1);
|
|
973
1016
|
}
|
|
974
1017
|
}
|
|
1018
|
+
// Sets the color of a module and marks it as a function module.
|
|
1019
|
+
// Only used by the constructor. Coordinates must be in bounds.
|
|
975
1020
|
setFunctionModule(x, y, isDark) {
|
|
976
1021
|
this.modules[y][x] = isDark;
|
|
977
1022
|
this.isFunction[y][x] = true;
|
|
978
1023
|
}
|
|
1024
|
+
/*-- Private helper methods for constructor: Codewords and masking --*/
|
|
1025
|
+
// Returns a new byte string representing the given data with the appropriate error correction
|
|
1026
|
+
// codewords appended to it, based on this object's version and error correction level.
|
|
979
1027
|
addEccAndInterleave(data) {
|
|
980
1028
|
const ver = this.version;
|
|
981
1029
|
const ecl = this.errorCorrectionLevel;
|
|
@@ -1006,6 +1054,8 @@ var qrcodegen;
|
|
|
1006
1054
|
assert(result.length == rawCodewords);
|
|
1007
1055
|
return result;
|
|
1008
1056
|
}
|
|
1057
|
+
// Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
|
|
1058
|
+
// data area of this QR Code. Function modules need to be marked off before this is called.
|
|
1009
1059
|
drawCodewords(data) {
|
|
1010
1060
|
if (data.length != Math.floor(_QrCode.getNumRawDataModules(this.version) / 8))
|
|
1011
1061
|
throw new RangeError("Invalid argument");
|
|
@@ -1027,6 +1077,11 @@ var qrcodegen;
|
|
|
1027
1077
|
}
|
|
1028
1078
|
assert(i == data.length * 8);
|
|
1029
1079
|
}
|
|
1080
|
+
// XORs the codeword modules in this QR Code with the given mask pattern.
|
|
1081
|
+
// The function modules must be marked and the codeword bits must be drawn
|
|
1082
|
+
// before masking. Due to the arithmetic of XOR, calling applyMask() with
|
|
1083
|
+
// the same mask value a second time will undo the mask. A final well-formed
|
|
1084
|
+
// QR Code needs exactly one (not zero, two, etc.) mask applied.
|
|
1030
1085
|
applyMask(mask) {
|
|
1031
1086
|
if (mask < 0 || mask > 7)
|
|
1032
1087
|
throw new RangeError("Mask value out of range");
|
|
@@ -1066,6 +1121,8 @@ var qrcodegen;
|
|
|
1066
1121
|
}
|
|
1067
1122
|
}
|
|
1068
1123
|
}
|
|
1124
|
+
// Calculates and returns the penalty score based on state of this QR Code's current modules.
|
|
1125
|
+
// This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
|
|
1069
1126
|
getPenaltyScore() {
|
|
1070
1127
|
let result = 0;
|
|
1071
1128
|
for (let y = 0; y < this.size; y++) {
|
|
@@ -1127,6 +1184,10 @@ var qrcodegen;
|
|
|
1127
1184
|
assert(0 <= result && result <= 2568888);
|
|
1128
1185
|
return result;
|
|
1129
1186
|
}
|
|
1187
|
+
/*-- Private helper functions --*/
|
|
1188
|
+
// Returns an ascending list of positions of alignment patterns for this version number.
|
|
1189
|
+
// Each position is in the range [0,177), and are used on both the x and y axes.
|
|
1190
|
+
// This could be implemented as lookup table of 40 variable-length lists of integers.
|
|
1130
1191
|
getAlignmentPatternPositions() {
|
|
1131
1192
|
if (this.version == 1)
|
|
1132
1193
|
return [];
|
|
@@ -1139,6 +1200,9 @@ var qrcodegen;
|
|
|
1139
1200
|
return result;
|
|
1140
1201
|
}
|
|
1141
1202
|
}
|
|
1203
|
+
// Returns the number of data bits that can be stored in a QR Code of the given version number, after
|
|
1204
|
+
// all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
|
|
1205
|
+
// The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
|
|
1142
1206
|
static getNumRawDataModules(ver) {
|
|
1143
1207
|
if (ver < _QrCode.MIN_VERSION || ver > _QrCode.MAX_VERSION)
|
|
1144
1208
|
throw new RangeError("Version number out of range");
|
|
@@ -1152,9 +1216,14 @@ var qrcodegen;
|
|
|
1152
1216
|
assert(208 <= result && result <= 29648);
|
|
1153
1217
|
return result;
|
|
1154
1218
|
}
|
|
1219
|
+
// Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
|
|
1220
|
+
// QR Code of the given version number and error correction level, with remainder bits discarded.
|
|
1221
|
+
// This stateless pure function could be implemented as a (40*4)-cell lookup table.
|
|
1155
1222
|
static getNumDataCodewords(ver, ecl) {
|
|
1156
1223
|
return Math.floor(_QrCode.getNumRawDataModules(ver) / 8) - _QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] * _QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
|
|
1157
1224
|
}
|
|
1225
|
+
// Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be
|
|
1226
|
+
// implemented as a lookup table over all possible parameter values, instead of as an algorithm.
|
|
1158
1227
|
static reedSolomonComputeDivisor(degree) {
|
|
1159
1228
|
if (degree < 1 || degree > 255)
|
|
1160
1229
|
throw new RangeError("Degree out of range");
|
|
@@ -1173,6 +1242,7 @@ var qrcodegen;
|
|
|
1173
1242
|
}
|
|
1174
1243
|
return result;
|
|
1175
1244
|
}
|
|
1245
|
+
// Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.
|
|
1176
1246
|
static reedSolomonComputeRemainder(data, divisor) {
|
|
1177
1247
|
let result = divisor.map((_) => 0);
|
|
1178
1248
|
for (const b of data) {
|
|
@@ -1182,6 +1252,8 @@ var qrcodegen;
|
|
|
1182
1252
|
}
|
|
1183
1253
|
return result;
|
|
1184
1254
|
}
|
|
1255
|
+
// Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result
|
|
1256
|
+
// are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.
|
|
1185
1257
|
static reedSolomonMultiply(x, y) {
|
|
1186
1258
|
if (x >>> 8 != 0 || y >>> 8 != 0)
|
|
1187
1259
|
throw new RangeError("Byte out of range");
|
|
@@ -1193,12 +1265,15 @@ var qrcodegen;
|
|
|
1193
1265
|
assert(z >>> 8 == 0);
|
|
1194
1266
|
return z;
|
|
1195
1267
|
}
|
|
1268
|
+
// Can only be called immediately after a light run is added, and
|
|
1269
|
+
// returns either 0, 1, or 2. A helper function for getPenaltyScore().
|
|
1196
1270
|
finderPenaltyCountPatterns(runHistory) {
|
|
1197
1271
|
const n = runHistory[1];
|
|
1198
1272
|
assert(n <= this.size * 3);
|
|
1199
1273
|
const core = n > 0 && runHistory[2] == n && runHistory[3] == n * 3 && runHistory[4] == n && runHistory[5] == n;
|
|
1200
1274
|
return (core && runHistory[0] >= n * 4 && runHistory[6] >= n ? 1 : 0) + (core && runHistory[6] >= n * 4 && runHistory[0] >= n ? 1 : 0);
|
|
1201
1275
|
}
|
|
1276
|
+
// Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore().
|
|
1202
1277
|
finderPenaltyTerminateAndCount(currentRunColor, currentRunLength, runHistory) {
|
|
1203
1278
|
if (currentRunColor) {
|
|
1204
1279
|
this.finderPenaltyAddHistory(currentRunLength, runHistory);
|
|
@@ -1208,6 +1283,7 @@ var qrcodegen;
|
|
|
1208
1283
|
this.finderPenaltyAddHistory(currentRunLength, runHistory);
|
|
1209
1284
|
return this.finderPenaltyCountPatterns(runHistory);
|
|
1210
1285
|
}
|
|
1286
|
+
// Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().
|
|
1211
1287
|
finderPenaltyAddHistory(currentRunLength, runHistory) {
|
|
1212
1288
|
if (runHistory[0] == 0)
|
|
1213
1289
|
currentRunLength += this.size;
|
|
@@ -1215,26 +1291,41 @@ var qrcodegen;
|
|
|
1215
1291
|
runHistory.unshift(currentRunLength);
|
|
1216
1292
|
}
|
|
1217
1293
|
};
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1294
|
+
/*-- Constants and tables --*/
|
|
1295
|
+
// The minimum version number supported in the QR Code Model 2 standard.
|
|
1296
|
+
_QrCode.MIN_VERSION = 1;
|
|
1297
|
+
// The maximum version number supported in the QR Code Model 2 standard.
|
|
1298
|
+
_QrCode.MAX_VERSION = 40;
|
|
1299
|
+
// For use in getPenaltyScore(), when evaluating which mask is best.
|
|
1300
|
+
_QrCode.PENALTY_N1 = 3;
|
|
1301
|
+
_QrCode.PENALTY_N2 = 3;
|
|
1302
|
+
_QrCode.PENALTY_N3 = 40;
|
|
1303
|
+
_QrCode.PENALTY_N4 = 10;
|
|
1304
|
+
_QrCode.ECC_CODEWORDS_PER_BLOCK = [
|
|
1305
|
+
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
|
1306
|
+
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
|
|
1226
1307
|
[-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
|
1308
|
+
// Low
|
|
1227
1309
|
[-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28],
|
|
1310
|
+
// Medium
|
|
1228
1311
|
[-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
|
1312
|
+
// Quartile
|
|
1229
1313
|
[-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]
|
|
1314
|
+
// High
|
|
1230
1315
|
];
|
|
1231
|
-
|
|
1316
|
+
_QrCode.NUM_ERROR_CORRECTION_BLOCKS = [
|
|
1317
|
+
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
|
1318
|
+
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
|
|
1232
1319
|
[-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
|
|
1320
|
+
// Low
|
|
1233
1321
|
[-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49],
|
|
1322
|
+
// Medium
|
|
1234
1323
|
[-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68],
|
|
1324
|
+
// Quartile
|
|
1235
1325
|
[-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81]
|
|
1326
|
+
// High
|
|
1236
1327
|
];
|
|
1237
|
-
qrcodegen2.QrCode =
|
|
1328
|
+
qrcodegen2.QrCode = _QrCode;
|
|
1238
1329
|
function appendBits(val, len, bb) {
|
|
1239
1330
|
if (len < 0 || len > 31 || val >>> len != 0)
|
|
1240
1331
|
throw new RangeError("Value out of range");
|
|
@@ -1248,7 +1339,11 @@ var qrcodegen;
|
|
|
1248
1339
|
if (!cond)
|
|
1249
1340
|
throw new Error("Assertion error");
|
|
1250
1341
|
}
|
|
1251
|
-
const _QrSegment = class {
|
|
1342
|
+
const _QrSegment = class _QrSegment {
|
|
1343
|
+
/*-- Constructor (low level) and fields --*/
|
|
1344
|
+
// Creates a new QR Code segment with the given attributes and data.
|
|
1345
|
+
// The character count (numChars) must agree with the mode and the bit buffer length,
|
|
1346
|
+
// but the constraint isn't checked. The given bit buffer is cloned and stored.
|
|
1252
1347
|
constructor(mode, numChars, bitData) {
|
|
1253
1348
|
this.mode = mode;
|
|
1254
1349
|
this.numChars = numChars;
|
|
@@ -1257,23 +1352,31 @@ var qrcodegen;
|
|
|
1257
1352
|
throw new RangeError("Invalid argument");
|
|
1258
1353
|
this.bitData = bitData.slice();
|
|
1259
1354
|
}
|
|
1355
|
+
/*-- Static factory functions (mid level) --*/
|
|
1356
|
+
// Returns a segment representing the given binary data encoded in
|
|
1357
|
+
// byte mode. All input byte arrays are acceptable. Any text string
|
|
1358
|
+
// can be converted to UTF-8 bytes and encoded as a byte mode segment.
|
|
1260
1359
|
static makeBytes(data) {
|
|
1261
1360
|
let bb = [];
|
|
1262
1361
|
for (const b of data)
|
|
1263
1362
|
appendBits(b, 8, bb);
|
|
1264
1363
|
return new _QrSegment(_QrSegment.Mode.BYTE, data.length, bb);
|
|
1265
1364
|
}
|
|
1365
|
+
// Returns a segment representing the given string of decimal digits encoded in numeric mode.
|
|
1266
1366
|
static makeNumeric(digits) {
|
|
1267
1367
|
if (!_QrSegment.isNumeric(digits))
|
|
1268
1368
|
throw new RangeError("String contains non-numeric characters");
|
|
1269
1369
|
let bb = [];
|
|
1270
1370
|
for (let i = 0; i < digits.length; ) {
|
|
1271
1371
|
const n = Math.min(digits.length - i, 3);
|
|
1272
|
-
appendBits(parseInt(digits.
|
|
1372
|
+
appendBits(parseInt(digits.substring(i, i + n), 10), n * 3 + 1, bb);
|
|
1273
1373
|
i += n;
|
|
1274
1374
|
}
|
|
1275
1375
|
return new _QrSegment(_QrSegment.Mode.NUMERIC, digits.length, bb);
|
|
1276
1376
|
}
|
|
1377
|
+
// Returns a segment representing the given text string encoded in alphanumeric mode.
|
|
1378
|
+
// The characters allowed are: 0 to 9, A to Z (uppercase only), space,
|
|
1379
|
+
// dollar, percent, asterisk, plus, hyphen, period, slash, colon.
|
|
1277
1380
|
static makeAlphanumeric(text) {
|
|
1278
1381
|
if (!_QrSegment.isAlphanumeric(text))
|
|
1279
1382
|
throw new RangeError("String contains unencodable characters in alphanumeric mode");
|
|
@@ -1288,6 +1391,8 @@ var qrcodegen;
|
|
|
1288
1391
|
appendBits(_QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)), 6, bb);
|
|
1289
1392
|
return new _QrSegment(_QrSegment.Mode.ALPHANUMERIC, text.length, bb);
|
|
1290
1393
|
}
|
|
1394
|
+
// Returns a new mutable list of zero or more segments to represent the given Unicode text string.
|
|
1395
|
+
// The result may use various segment modes and switch modes to optimize the length of the bit stream.
|
|
1291
1396
|
static makeSegments(text) {
|
|
1292
1397
|
if (text == "")
|
|
1293
1398
|
return [];
|
|
@@ -1298,6 +1403,8 @@ var qrcodegen;
|
|
|
1298
1403
|
else
|
|
1299
1404
|
return [_QrSegment.makeBytes(_QrSegment.toUtf8ByteArray(text))];
|
|
1300
1405
|
}
|
|
1406
|
+
// Returns a segment representing an Extended Channel Interpretation
|
|
1407
|
+
// (ECI) designator with the given assignment value.
|
|
1301
1408
|
static makeEci(assignVal) {
|
|
1302
1409
|
let bb = [];
|
|
1303
1410
|
if (assignVal < 0)
|
|
@@ -1314,15 +1421,24 @@ var qrcodegen;
|
|
|
1314
1421
|
throw new RangeError("ECI assignment value out of range");
|
|
1315
1422
|
return new _QrSegment(_QrSegment.Mode.ECI, 0, bb);
|
|
1316
1423
|
}
|
|
1424
|
+
// Tests whether the given string can be encoded as a segment in numeric mode.
|
|
1425
|
+
// A string is encodable iff each character is in the range 0 to 9.
|
|
1317
1426
|
static isNumeric(text) {
|
|
1318
1427
|
return _QrSegment.NUMERIC_REGEX.test(text);
|
|
1319
1428
|
}
|
|
1429
|
+
// Tests whether the given string can be encoded as a segment in alphanumeric mode.
|
|
1430
|
+
// A string is encodable iff each character is in the following set: 0 to 9, A to Z
|
|
1431
|
+
// (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
|
|
1320
1432
|
static isAlphanumeric(text) {
|
|
1321
1433
|
return _QrSegment.ALPHANUMERIC_REGEX.test(text);
|
|
1322
1434
|
}
|
|
1435
|
+
/*-- Methods --*/
|
|
1436
|
+
// Returns a new copy of the data bits of this segment.
|
|
1323
1437
|
getData() {
|
|
1324
1438
|
return this.bitData.slice();
|
|
1325
1439
|
}
|
|
1440
|
+
// (Package-private) Calculates and returns the number of bits needed to encode the given segments at
|
|
1441
|
+
// the given version. The result is infinity if a segment has too many characters to fit its length field.
|
|
1326
1442
|
static getTotalBits(segs, version) {
|
|
1327
1443
|
let result = 0;
|
|
1328
1444
|
for (const seg of segs) {
|
|
@@ -1333,6 +1449,7 @@ var qrcodegen;
|
|
|
1333
1449
|
}
|
|
1334
1450
|
return result;
|
|
1335
1451
|
}
|
|
1452
|
+
// Returns a new array of bytes representing the given string encoded in UTF-8.
|
|
1336
1453
|
static toUtf8ByteArray(str) {
|
|
1337
1454
|
str = encodeURI(str);
|
|
1338
1455
|
let result = [];
|
|
@@ -1340,53 +1457,67 @@ var qrcodegen;
|
|
|
1340
1457
|
if (str.charAt(i) != "%")
|
|
1341
1458
|
result.push(str.charCodeAt(i));
|
|
1342
1459
|
else {
|
|
1343
|
-
result.push(parseInt(str.
|
|
1460
|
+
result.push(parseInt(str.substring(i + 1, i + 3), 16));
|
|
1344
1461
|
i += 2;
|
|
1345
1462
|
}
|
|
1346
1463
|
}
|
|
1347
1464
|
return result;
|
|
1348
1465
|
}
|
|
1349
1466
|
};
|
|
1467
|
+
/*-- Constants --*/
|
|
1468
|
+
// Describes precisely all strings that are encodable in numeric mode.
|
|
1469
|
+
_QrSegment.NUMERIC_REGEX = /^[0-9]*$/;
|
|
1470
|
+
// Describes precisely all strings that are encodable in alphanumeric mode.
|
|
1471
|
+
_QrSegment.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/;
|
|
1472
|
+
// The set of all legal characters in alphanumeric mode,
|
|
1473
|
+
// where each character value maps to the index in the string.
|
|
1474
|
+
_QrSegment.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
|
1350
1475
|
let QrSegment = _QrSegment;
|
|
1351
|
-
QrSegment
|
|
1352
|
-
QrSegment.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/;
|
|
1353
|
-
QrSegment.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
|
1354
|
-
qrcodegen2.QrSegment = QrSegment;
|
|
1476
|
+
qrcodegen2.QrSegment = _QrSegment;
|
|
1355
1477
|
})(qrcodegen || (qrcodegen = {}));
|
|
1356
1478
|
((qrcodegen2) => {
|
|
1357
1479
|
((QrCode2) => {
|
|
1358
|
-
const _Ecc = class {
|
|
1480
|
+
const _Ecc = class _Ecc {
|
|
1481
|
+
// The QR Code can tolerate about 30% erroneous codewords
|
|
1482
|
+
/*-- Constructor and fields --*/
|
|
1359
1483
|
constructor(ordinal, formatBits) {
|
|
1360
1484
|
this.ordinal = ordinal;
|
|
1361
1485
|
this.formatBits = formatBits;
|
|
1362
1486
|
}
|
|
1363
1487
|
};
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1488
|
+
/*-- Constants --*/
|
|
1489
|
+
_Ecc.LOW = new _Ecc(0, 1);
|
|
1490
|
+
// The QR Code can tolerate about 7% erroneous codewords
|
|
1491
|
+
_Ecc.MEDIUM = new _Ecc(1, 0);
|
|
1492
|
+
// The QR Code can tolerate about 15% erroneous codewords
|
|
1493
|
+
_Ecc.QUARTILE = new _Ecc(2, 3);
|
|
1494
|
+
// The QR Code can tolerate about 25% erroneous codewords
|
|
1495
|
+
_Ecc.HIGH = new _Ecc(3, 2);
|
|
1496
|
+
QrCode2.Ecc = _Ecc;
|
|
1370
1497
|
})(qrcodegen2.QrCode || (qrcodegen2.QrCode = {}));
|
|
1371
1498
|
})(qrcodegen || (qrcodegen = {}));
|
|
1372
1499
|
((qrcodegen2) => {
|
|
1373
1500
|
((QrSegment2) => {
|
|
1374
|
-
const _Mode = class {
|
|
1501
|
+
const _Mode = class _Mode {
|
|
1502
|
+
/*-- Constructor and fields --*/
|
|
1375
1503
|
constructor(modeBits, numBitsCharCount) {
|
|
1376
1504
|
this.modeBits = modeBits;
|
|
1377
1505
|
this.numBitsCharCount = numBitsCharCount;
|
|
1378
1506
|
}
|
|
1507
|
+
/*-- Method --*/
|
|
1508
|
+
// (Package-private) Returns the bit width of the character count field for a segment in
|
|
1509
|
+
// this mode in a QR Code at the given version number. The result is in the range [0, 16].
|
|
1379
1510
|
numCharCountBits(ver) {
|
|
1380
1511
|
return this.numBitsCharCount[Math.floor((ver + 7) / 17)];
|
|
1381
1512
|
}
|
|
1382
1513
|
};
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
QrSegment2.Mode =
|
|
1514
|
+
/*-- Constants --*/
|
|
1515
|
+
_Mode.NUMERIC = new _Mode(1, [10, 12, 14]);
|
|
1516
|
+
_Mode.ALPHANUMERIC = new _Mode(2, [9, 11, 13]);
|
|
1517
|
+
_Mode.BYTE = new _Mode(4, [8, 16, 16]);
|
|
1518
|
+
_Mode.KANJI = new _Mode(8, [8, 10, 12]);
|
|
1519
|
+
_Mode.ECI = new _Mode(7, [0, 0, 0]);
|
|
1520
|
+
QrSegment2.Mode = _Mode;
|
|
1390
1521
|
})(qrcodegen2.QrSegment || (qrcodegen2.QrSegment = {}));
|
|
1391
1522
|
})(qrcodegen || (qrcodegen = {}));
|
|
1392
1523
|
var qrcodegen_default = qrcodegen;
|
|
@@ -1408,7 +1539,9 @@ var DEFAULT_LEVEL = "L";
|
|
|
1408
1539
|
var DEFAULT_BGCOLOR = "#FFFFFF";
|
|
1409
1540
|
var DEFAULT_FGCOLOR = "#000000";
|
|
1410
1541
|
var DEFAULT_INCLUDEMARGIN = false;
|
|
1411
|
-
var
|
|
1542
|
+
var DEFAULT_MINVERSION = 1;
|
|
1543
|
+
var SPEC_MARGIN_SIZE = 4;
|
|
1544
|
+
var DEFAULT_MARGIN_SIZE = 0;
|
|
1412
1545
|
var DEFAULT_IMG_SCALE = 0.1;
|
|
1413
1546
|
function generatePath(modules, margin = 0) {
|
|
1414
1547
|
const ops = [];
|
|
@@ -1416,7 +1549,9 @@ function generatePath(modules, margin = 0) {
|
|
|
1416
1549
|
let start = null;
|
|
1417
1550
|
row.forEach(function(cell, x) {
|
|
1418
1551
|
if (!cell && start !== null) {
|
|
1419
|
-
ops.push(
|
|
1552
|
+
ops.push(
|
|
1553
|
+
`M${start + margin} ${y + margin}h${x - start}v1H${start + margin}z`
|
|
1554
|
+
);
|
|
1420
1555
|
start = null;
|
|
1421
1556
|
return;
|
|
1422
1557
|
}
|
|
@@ -1427,7 +1562,9 @@ function generatePath(modules, margin = 0) {
|
|
|
1427
1562
|
if (start === null) {
|
|
1428
1563
|
ops.push(`M${x + margin},${y + margin} h1v1H${x + margin}z`);
|
|
1429
1564
|
} else {
|
|
1430
|
-
ops.push(
|
|
1565
|
+
ops.push(
|
|
1566
|
+
`M${start + margin},${y + margin} h${x + 1 - start}v1H${start + margin}z`
|
|
1567
|
+
);
|
|
1431
1568
|
}
|
|
1432
1569
|
return;
|
|
1433
1570
|
}
|
|
@@ -1451,11 +1588,10 @@ function excavateModules(modules, excavation) {
|
|
|
1451
1588
|
});
|
|
1452
1589
|
});
|
|
1453
1590
|
}
|
|
1454
|
-
function getImageSettings(cells, size,
|
|
1591
|
+
function getImageSettings(cells, size, margin, imageSettings) {
|
|
1455
1592
|
if (imageSettings == null) {
|
|
1456
1593
|
return null;
|
|
1457
1594
|
}
|
|
1458
|
-
const margin = includeMargin ? MARGIN_SIZE : 0;
|
|
1459
1595
|
const numCells = cells.length + margin * 2;
|
|
1460
1596
|
const defaultSize = Math.floor(size * DEFAULT_IMG_SCALE);
|
|
1461
1597
|
const scale = numCells / size;
|
|
@@ -1463,6 +1599,7 @@ function getImageSettings(cells, size, includeMargin, imageSettings) {
|
|
|
1463
1599
|
const h = (imageSettings.height || defaultSize) * scale;
|
|
1464
1600
|
const x = imageSettings.x == null ? cells.length / 2 - w / 2 : imageSettings.x * scale;
|
|
1465
1601
|
const y = imageSettings.y == null ? cells.length / 2 - h / 2 : imageSettings.y * scale;
|
|
1602
|
+
const opacity = imageSettings.opacity == null ? 1 : imageSettings.opacity;
|
|
1466
1603
|
let excavation = null;
|
|
1467
1604
|
if (imageSettings.excavate) {
|
|
1468
1605
|
let floorX = Math.floor(x);
|
|
@@ -1471,7 +1608,64 @@ function getImageSettings(cells, size, includeMargin, imageSettings) {
|
|
|
1471
1608
|
let ceilH = Math.ceil(h + y - floorY);
|
|
1472
1609
|
excavation = { x: floorX, y: floorY, w: ceilW, h: ceilH };
|
|
1473
1610
|
}
|
|
1474
|
-
|
|
1611
|
+
const crossOrigin = imageSettings.crossOrigin;
|
|
1612
|
+
return { x, y, h, w, excavation, opacity, crossOrigin };
|
|
1613
|
+
}
|
|
1614
|
+
function getMarginSize(includeMargin, marginSize) {
|
|
1615
|
+
if (marginSize != null) {
|
|
1616
|
+
return Math.max(Math.floor(marginSize), 0);
|
|
1617
|
+
}
|
|
1618
|
+
return includeMargin ? SPEC_MARGIN_SIZE : DEFAULT_MARGIN_SIZE;
|
|
1619
|
+
}
|
|
1620
|
+
function useQRCode({
|
|
1621
|
+
value,
|
|
1622
|
+
level,
|
|
1623
|
+
minVersion,
|
|
1624
|
+
includeMargin,
|
|
1625
|
+
marginSize,
|
|
1626
|
+
imageSettings,
|
|
1627
|
+
size,
|
|
1628
|
+
boostLevel
|
|
1629
|
+
}) {
|
|
1630
|
+
let qrcode = React.useMemo(() => {
|
|
1631
|
+
const values = Array.isArray(value) ? value : [value];
|
|
1632
|
+
const segments = values.reduce((accum, v) => {
|
|
1633
|
+
accum.push(...qrcodegen_default.QrSegment.makeSegments(v));
|
|
1634
|
+
return accum;
|
|
1635
|
+
}, []);
|
|
1636
|
+
return qrcodegen_default.QrCode.encodeSegments(
|
|
1637
|
+
segments,
|
|
1638
|
+
ERROR_LEVEL_MAP[level],
|
|
1639
|
+
minVersion,
|
|
1640
|
+
void 0,
|
|
1641
|
+
void 0,
|
|
1642
|
+
boostLevel
|
|
1643
|
+
);
|
|
1644
|
+
}, [value, level, minVersion, boostLevel]);
|
|
1645
|
+
const { cells, margin, numCells, calculatedImageSettings } = React.useMemo(() => {
|
|
1646
|
+
let cells2 = qrcode.getModules();
|
|
1647
|
+
const margin2 = getMarginSize(includeMargin, marginSize);
|
|
1648
|
+
const numCells2 = cells2.length + margin2 * 2;
|
|
1649
|
+
const calculatedImageSettings2 = getImageSettings(
|
|
1650
|
+
cells2,
|
|
1651
|
+
size,
|
|
1652
|
+
margin2,
|
|
1653
|
+
imageSettings
|
|
1654
|
+
);
|
|
1655
|
+
return {
|
|
1656
|
+
cells: cells2,
|
|
1657
|
+
margin: margin2,
|
|
1658
|
+
numCells: numCells2,
|
|
1659
|
+
calculatedImageSettings: calculatedImageSettings2
|
|
1660
|
+
};
|
|
1661
|
+
}, [qrcode, size, imageSettings, includeMargin, marginSize]);
|
|
1662
|
+
return {
|
|
1663
|
+
qrcode,
|
|
1664
|
+
margin,
|
|
1665
|
+
cells,
|
|
1666
|
+
numCells,
|
|
1667
|
+
calculatedImageSettings
|
|
1668
|
+
};
|
|
1475
1669
|
}
|
|
1476
1670
|
var SUPPORTS_PATH2D = function() {
|
|
1477
1671
|
try {
|
|
@@ -1481,152 +1675,225 @@ var SUPPORTS_PATH2D = function() {
|
|
|
1481
1675
|
}
|
|
1482
1676
|
return true;
|
|
1483
1677
|
}();
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
const haveImageToRender = calculatedImageSettings != null && image !== null && image.complete && image.naturalHeight !== 0 && image.naturalWidth !== 0;
|
|
1521
|
-
if (haveImageToRender) {
|
|
1522
|
-
if (calculatedImageSettings.excavation != null) {
|
|
1523
|
-
cells = excavateModules(cells, calculatedImageSettings.excavation);
|
|
1678
|
+
var QRCodeCanvas = React.forwardRef(
|
|
1679
|
+
function QRCodeCanvas2(props, forwardedRef) {
|
|
1680
|
+
const _a = props, {
|
|
1681
|
+
value,
|
|
1682
|
+
size = DEFAULT_SIZE,
|
|
1683
|
+
level = DEFAULT_LEVEL,
|
|
1684
|
+
bgColor = DEFAULT_BGCOLOR,
|
|
1685
|
+
fgColor = DEFAULT_FGCOLOR,
|
|
1686
|
+
includeMargin = DEFAULT_INCLUDEMARGIN,
|
|
1687
|
+
minVersion = DEFAULT_MINVERSION,
|
|
1688
|
+
boostLevel,
|
|
1689
|
+
marginSize,
|
|
1690
|
+
imageSettings
|
|
1691
|
+
} = _a, extraProps = __objRest(_a, [
|
|
1692
|
+
"value",
|
|
1693
|
+
"size",
|
|
1694
|
+
"level",
|
|
1695
|
+
"bgColor",
|
|
1696
|
+
"fgColor",
|
|
1697
|
+
"includeMargin",
|
|
1698
|
+
"minVersion",
|
|
1699
|
+
"boostLevel",
|
|
1700
|
+
"marginSize",
|
|
1701
|
+
"imageSettings"
|
|
1702
|
+
]);
|
|
1703
|
+
const _b = extraProps, { style } = _b, otherProps = __objRest(_b, ["style"]);
|
|
1704
|
+
const imgSrc = imageSettings == null ? void 0 : imageSettings.src;
|
|
1705
|
+
const _canvas = React.useRef(null);
|
|
1706
|
+
const _image = React.useRef(null);
|
|
1707
|
+
const setCanvasRef = React.useCallback(
|
|
1708
|
+
(node) => {
|
|
1709
|
+
_canvas.current = node;
|
|
1710
|
+
if (typeof forwardedRef === "function") {
|
|
1711
|
+
forwardedRef(node);
|
|
1712
|
+
} else if (forwardedRef) {
|
|
1713
|
+
forwardedRef.current = node;
|
|
1524
1714
|
}
|
|
1525
|
-
}
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1715
|
+
},
|
|
1716
|
+
[forwardedRef]
|
|
1717
|
+
);
|
|
1718
|
+
const [isImgLoaded, setIsImageLoaded] = React.useState(false);
|
|
1719
|
+
const { margin, cells, numCells, calculatedImageSettings } = useQRCode({
|
|
1720
|
+
value,
|
|
1721
|
+
level,
|
|
1722
|
+
minVersion,
|
|
1723
|
+
boostLevel,
|
|
1724
|
+
includeMargin,
|
|
1725
|
+
marginSize,
|
|
1726
|
+
imageSettings,
|
|
1727
|
+
size
|
|
1728
|
+
});
|
|
1729
|
+
React.useEffect(() => {
|
|
1730
|
+
if (_canvas.current != null) {
|
|
1731
|
+
const canvas = _canvas.current;
|
|
1732
|
+
const ctx = canvas.getContext("2d");
|
|
1733
|
+
if (!ctx) {
|
|
1734
|
+
return;
|
|
1735
|
+
}
|
|
1736
|
+
let cellsToDraw = cells;
|
|
1737
|
+
const image = _image.current;
|
|
1738
|
+
const haveImageToRender = calculatedImageSettings != null && image !== null && image.complete && image.naturalHeight !== 0 && image.naturalWidth !== 0;
|
|
1739
|
+
if (haveImageToRender) {
|
|
1740
|
+
if (calculatedImageSettings.excavation != null) {
|
|
1741
|
+
cellsToDraw = excavateModules(
|
|
1742
|
+
cells,
|
|
1743
|
+
calculatedImageSettings.excavation
|
|
1744
|
+
);
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
const pixelRatio = window.devicePixelRatio || 1;
|
|
1748
|
+
canvas.height = canvas.width = size * pixelRatio;
|
|
1749
|
+
const scale = size / numCells * pixelRatio;
|
|
1750
|
+
ctx.scale(scale, scale);
|
|
1751
|
+
ctx.fillStyle = bgColor;
|
|
1752
|
+
ctx.fillRect(0, 0, numCells, numCells);
|
|
1753
|
+
ctx.fillStyle = fgColor;
|
|
1754
|
+
if (SUPPORTS_PATH2D) {
|
|
1755
|
+
ctx.fill(new Path2D(generatePath(cellsToDraw, margin)));
|
|
1756
|
+
} else {
|
|
1757
|
+
cells.forEach(function(row, rdx) {
|
|
1758
|
+
row.forEach(function(cell, cdx) {
|
|
1759
|
+
if (cell) {
|
|
1760
|
+
ctx.fillRect(cdx + margin, rdx + margin, 1, 1);
|
|
1761
|
+
}
|
|
1762
|
+
});
|
|
1541
1763
|
});
|
|
1542
|
-
}
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1764
|
+
}
|
|
1765
|
+
if (calculatedImageSettings) {
|
|
1766
|
+
ctx.globalAlpha = calculatedImageSettings.opacity;
|
|
1767
|
+
}
|
|
1768
|
+
if (haveImageToRender) {
|
|
1769
|
+
ctx.drawImage(
|
|
1770
|
+
image,
|
|
1771
|
+
calculatedImageSettings.x + margin,
|
|
1772
|
+
calculatedImageSettings.y + margin,
|
|
1773
|
+
calculatedImageSettings.w,
|
|
1774
|
+
calculatedImageSettings.h
|
|
1775
|
+
);
|
|
1776
|
+
}
|
|
1546
1777
|
}
|
|
1547
|
-
}
|
|
1548
|
-
});
|
|
1549
|
-
React.useEffect(() => {
|
|
1550
|
-
setIsImageLoaded(false);
|
|
1551
|
-
}, [imgSrc]);
|
|
1552
|
-
const canvasStyle = __spreadValues({ height: size, width: size }, style);
|
|
1553
|
-
let img = null;
|
|
1554
|
-
if (imgSrc != null) {
|
|
1555
|
-
img = /* @__PURE__ */ React.createElement("img", {
|
|
1556
|
-
src: imgSrc,
|
|
1557
|
-
key: imgSrc,
|
|
1558
|
-
style: { display: "none" },
|
|
1559
|
-
onLoad: () => {
|
|
1560
|
-
setIsImageLoaded(true);
|
|
1561
|
-
},
|
|
1562
|
-
ref: _image
|
|
1563
1778
|
});
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
height: size,
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
"size",
|
|
1584
|
-
"level",
|
|
1585
|
-
"bgColor",
|
|
1586
|
-
"fgColor",
|
|
1587
|
-
"includeMargin",
|
|
1588
|
-
"imageSettings"
|
|
1589
|
-
]);
|
|
1590
|
-
let cells = qrcodegen_default.QrCode.encodeText(value, ERROR_LEVEL_MAP[level]).getModules();
|
|
1591
|
-
const margin = includeMargin ? MARGIN_SIZE : 0;
|
|
1592
|
-
const numCells = cells.length + margin * 2;
|
|
1593
|
-
const calculatedImageSettings = getImageSettings(cells, size, includeMargin, imageSettings);
|
|
1594
|
-
let image = null;
|
|
1595
|
-
if (imageSettings != null && calculatedImageSettings != null) {
|
|
1596
|
-
if (calculatedImageSettings.excavation != null) {
|
|
1597
|
-
cells = excavateModules(cells, calculatedImageSettings.excavation);
|
|
1779
|
+
React.useEffect(() => {
|
|
1780
|
+
setIsImageLoaded(false);
|
|
1781
|
+
}, [imgSrc]);
|
|
1782
|
+
const canvasStyle = __spreadValues({ height: size, width: size }, style);
|
|
1783
|
+
let img = null;
|
|
1784
|
+
if (imgSrc != null) {
|
|
1785
|
+
img = /* @__PURE__ */ React.createElement(
|
|
1786
|
+
"img",
|
|
1787
|
+
{
|
|
1788
|
+
src: imgSrc,
|
|
1789
|
+
key: imgSrc,
|
|
1790
|
+
style: { display: "none" },
|
|
1791
|
+
onLoad: () => {
|
|
1792
|
+
setIsImageLoaded(true);
|
|
1793
|
+
},
|
|
1794
|
+
ref: _image,
|
|
1795
|
+
crossOrigin: calculatedImageSettings == null ? void 0 : calculatedImageSettings.crossOrigin
|
|
1796
|
+
}
|
|
1797
|
+
);
|
|
1598
1798
|
}
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1799
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
1800
|
+
"canvas",
|
|
1801
|
+
__spreadValues({
|
|
1802
|
+
style: canvasStyle,
|
|
1803
|
+
height: size,
|
|
1804
|
+
width: size,
|
|
1805
|
+
ref: setCanvasRef,
|
|
1806
|
+
role: "img"
|
|
1807
|
+
}, otherProps)
|
|
1808
|
+
), img);
|
|
1607
1809
|
}
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1810
|
+
);
|
|
1811
|
+
QRCodeCanvas.displayName = "QRCodeCanvas";
|
|
1812
|
+
var QRCodeSVG = React.forwardRef(
|
|
1813
|
+
function QRCodeSVG2(props, forwardedRef) {
|
|
1814
|
+
const _a = props, {
|
|
1815
|
+
value,
|
|
1816
|
+
size = DEFAULT_SIZE,
|
|
1817
|
+
level = DEFAULT_LEVEL,
|
|
1818
|
+
bgColor = DEFAULT_BGCOLOR,
|
|
1819
|
+
fgColor = DEFAULT_FGCOLOR,
|
|
1820
|
+
includeMargin = DEFAULT_INCLUDEMARGIN,
|
|
1821
|
+
minVersion = DEFAULT_MINVERSION,
|
|
1822
|
+
boostLevel,
|
|
1823
|
+
title,
|
|
1824
|
+
marginSize,
|
|
1825
|
+
imageSettings
|
|
1826
|
+
} = _a, otherProps = __objRest(_a, [
|
|
1827
|
+
"value",
|
|
1828
|
+
"size",
|
|
1829
|
+
"level",
|
|
1830
|
+
"bgColor",
|
|
1831
|
+
"fgColor",
|
|
1832
|
+
"includeMargin",
|
|
1833
|
+
"minVersion",
|
|
1834
|
+
"boostLevel",
|
|
1835
|
+
"title",
|
|
1836
|
+
"marginSize",
|
|
1837
|
+
"imageSettings"
|
|
1838
|
+
]);
|
|
1839
|
+
const { margin, cells, numCells, calculatedImageSettings } = useQRCode({
|
|
1840
|
+
value,
|
|
1841
|
+
level,
|
|
1842
|
+
minVersion,
|
|
1843
|
+
boostLevel,
|
|
1844
|
+
includeMargin,
|
|
1845
|
+
marginSize,
|
|
1846
|
+
imageSettings,
|
|
1847
|
+
size
|
|
1848
|
+
});
|
|
1849
|
+
let cellsToDraw = cells;
|
|
1850
|
+
let image = null;
|
|
1851
|
+
if (imageSettings != null && calculatedImageSettings != null) {
|
|
1852
|
+
if (calculatedImageSettings.excavation != null) {
|
|
1853
|
+
cellsToDraw = excavateModules(
|
|
1854
|
+
cells,
|
|
1855
|
+
calculatedImageSettings.excavation
|
|
1856
|
+
);
|
|
1857
|
+
}
|
|
1858
|
+
image = /* @__PURE__ */ React.createElement(
|
|
1859
|
+
"image",
|
|
1860
|
+
{
|
|
1861
|
+
href: imageSettings.src,
|
|
1862
|
+
height: calculatedImageSettings.h,
|
|
1863
|
+
width: calculatedImageSettings.w,
|
|
1864
|
+
x: calculatedImageSettings.x + margin,
|
|
1865
|
+
y: calculatedImageSettings.y + margin,
|
|
1866
|
+
preserveAspectRatio: "none",
|
|
1867
|
+
opacity: calculatedImageSettings.opacity,
|
|
1868
|
+
crossOrigin: calculatedImageSettings.crossOrigin
|
|
1869
|
+
}
|
|
1870
|
+
);
|
|
1871
|
+
}
|
|
1872
|
+
const fgPath = generatePath(cellsToDraw, margin);
|
|
1873
|
+
return /* @__PURE__ */ React.createElement(
|
|
1874
|
+
"svg",
|
|
1875
|
+
__spreadValues({
|
|
1876
|
+
height: size,
|
|
1877
|
+
width: size,
|
|
1878
|
+
viewBox: `0 0 ${numCells} ${numCells}`,
|
|
1879
|
+
ref: forwardedRef,
|
|
1880
|
+
role: "img"
|
|
1881
|
+
}, otherProps),
|
|
1882
|
+
!!title && /* @__PURE__ */ React.createElement("title", null, title),
|
|
1883
|
+
/* @__PURE__ */ React.createElement(
|
|
1884
|
+
"path",
|
|
1885
|
+
{
|
|
1886
|
+
fill: bgColor,
|
|
1887
|
+
d: `M0,0 h${numCells}v${numCells}H0z`,
|
|
1888
|
+
shapeRendering: "crispEdges"
|
|
1889
|
+
}
|
|
1890
|
+
),
|
|
1891
|
+
/* @__PURE__ */ React.createElement("path", { fill: fgColor, d: fgPath, shapeRendering: "crispEdges" }),
|
|
1892
|
+
image
|
|
1893
|
+
);
|
|
1627
1894
|
}
|
|
1628
|
-
|
|
1629
|
-
|
|
1895
|
+
);
|
|
1896
|
+
QRCodeSVG.displayName = "QRCodeSVG";
|
|
1630
1897
|
|
|
1631
1898
|
var QRCode = function QRCode(_ref) {
|
|
1632
1899
|
var entity = _ref.entity,
|
|
@@ -1682,7 +1949,7 @@ var QRCode = function QRCode(_ref) {
|
|
|
1682
1949
|
onClick: handleCopyQRCode
|
|
1683
1950
|
})]
|
|
1684
1951
|
}),
|
|
1685
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
1952
|
+
children: /*#__PURE__*/jsxRuntime.jsx(QRCodeCanvas, {
|
|
1686
1953
|
className: "mt-6 cursor-pointer",
|
|
1687
1954
|
"data-testid": "qr-code-image",
|
|
1688
1955
|
id: canvasId,
|