@twin.org/qr 0.0.2-next.20 → 0.0.2-next.21

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.
@@ -59,9 +59,9 @@ const QRDataMode = {
59
59
  */
60
60
  class QRDataBase {
61
61
  /**
62
- * @internal
62
+ * Runtime name for the class.
63
63
  */
64
- _className;
64
+ static CLASS_NAME = "QRDataBase";
65
65
  /**
66
66
  * @internal
67
67
  */
@@ -72,12 +72,10 @@ class QRDataBase {
72
72
  _data;
73
73
  /**
74
74
  * Create a new instance of QRDataBase.
75
- * @param className The class name for the derived class.
76
75
  * @param mode The mode for the data.
77
76
  * @param data The data.
78
77
  */
79
- constructor(className, mode, data) {
80
- this._className = className;
78
+ constructor(mode, data) {
81
79
  this._mode = mode;
82
80
  this._data = data;
83
81
  }
@@ -111,7 +109,7 @@ class QRDataBase {
111
109
  case QRDataMode.Byte8:
112
110
  return 8;
113
111
  default:
114
- throw new core.GeneralError(this._className, "invalidMode", {
112
+ throw new core.GeneralError(QRDataBase.CLASS_NAME, "invalidMode", {
115
113
  typeNumber,
116
114
  mode: this._mode
117
115
  });
@@ -126,7 +124,7 @@ class QRDataBase {
126
124
  case QRDataMode.Byte8:
127
125
  return 16;
128
126
  default:
129
- throw new core.GeneralError(this._className, "invalidMode", {
127
+ throw new core.GeneralError(QRDataBase.CLASS_NAME, "invalidMode", {
130
128
  typeNumber,
131
129
  mode: this._mode
132
130
  });
@@ -141,14 +139,14 @@ class QRDataBase {
141
139
  case QRDataMode.Byte8:
142
140
  return 16;
143
141
  default:
144
- throw new core.GeneralError(this._className, "invalidMode", {
142
+ throw new core.GeneralError(QRDataBase.CLASS_NAME, "invalidMode", {
145
143
  typeNumber,
146
144
  mode: this._mode
147
145
  });
148
146
  }
149
147
  }
150
148
  else {
151
- throw new core.GeneralError(this._className, "invalidTypeNumber", { typeNumber });
149
+ throw new core.GeneralError(QRDataBase.CLASS_NAME, "invalidTypeNumber", { typeNumber });
152
150
  }
153
151
  }
154
152
  }
@@ -163,15 +161,14 @@ class QRDataBase {
163
161
  class QRAlphaNumeric extends QRDataBase {
164
162
  /**
165
163
  * Runtime name for the class.
166
- * @internal
167
164
  */
168
- static _CLASS_NAME = "QRAlphaNumeric";
165
+ static CLASS_NAME = "QRAlphaNumeric";
169
166
  /**
170
167
  * Create a new instance of QRAlphaNumeric.
171
168
  * @param data The data for the qr alpha numeric.
172
169
  */
173
170
  constructor(data) {
174
- super(QRAlphaNumeric._CLASS_NAME, QRDataMode.AlphaNumeric, data);
171
+ super(QRDataMode.AlphaNumeric, data);
175
172
  }
176
173
  /**
177
174
  * Get the length of the data.
@@ -225,27 +222,25 @@ class QRAlphaNumeric extends QRDataBase {
225
222
  case ":":
226
223
  return 44;
227
224
  default:
228
- throw new core.GeneralError(QRAlphaNumeric._CLASS_NAME, "illegalCharacter", { value: c });
225
+ throw new core.GeneralError(QRAlphaNumeric.CLASS_NAME, "illegalCharacter", { value: c });
229
226
  }
230
227
  }
231
228
  }
232
229
 
230
+ // Copyright 2024 IOTA Stiftung.
231
+ // SPDX-License-Identifier: Apache-2.0.
232
+ /* eslint-disable no-bitwise */
233
233
  /**
234
234
  * QR Data for representing a 8 bit data.
235
235
  * Based on https://github.com/kazuhikoarase/qrcode-generator/ .
236
236
  */
237
237
  class QRByte8 extends QRDataBase {
238
- /**
239
- * Runtime name for the class.
240
- * @internal
241
- */
242
- static _CLASS_NAME = "QRByte8";
243
238
  /**
244
239
  * Create a new instance of QRByte8.
245
240
  * @param data The data for the qr 8 bit data.
246
241
  */
247
242
  constructor(data) {
248
- super(QRByte8._CLASS_NAME, QRDataMode.Byte8, data);
243
+ super(QRDataMode.Byte8, data);
249
244
  }
250
245
  /**
251
246
  * Get the length of the data.
@@ -303,15 +298,14 @@ class QRByte8 extends QRDataBase {
303
298
  class QRNumber extends QRDataBase {
304
299
  /**
305
300
  * Runtime name for the class.
306
- * @internal
307
301
  */
308
- static _CLASS_NAME = "QRNumber";
302
+ static CLASS_NAME = "QRNumber";
309
303
  /**
310
304
  * Create a new instance of QRNumber.
311
305
  * @param data The data for the qr number.
312
306
  */
313
307
  constructor(data) {
314
- super(QRNumber._CLASS_NAME, QRDataMode.Number, data);
308
+ super(QRDataMode.Number, data);
315
309
  }
316
310
  /**
317
311
  * Get the length of the data.
@@ -360,7 +354,7 @@ class QRNumber extends QRDataBase {
360
354
  if (c >= "0" && c <= "9") {
361
355
  return c.charCodeAt(0) - "0".charCodeAt(0);
362
356
  }
363
- throw new core.GeneralError(QRNumber._CLASS_NAME, "illegalCharacter", { value: c });
357
+ throw new core.GeneralError(QRNumber.CLASS_NAME, "illegalCharacter", { value: c });
364
358
  }
365
359
  }
366
360
 
@@ -453,9 +447,8 @@ class BitBuffer {
453
447
  class MathHelper {
454
448
  /**
455
449
  * Runtime name for the class.
456
- * @internal
457
450
  */
458
- static _CLASS_NAME = "MathHelper";
451
+ static CLASS_NAME = "MathHelper";
459
452
  /**
460
453
  * @internal
461
454
  */
@@ -493,7 +486,7 @@ class MathHelper {
493
486
  */
494
487
  static gLog(value) {
495
488
  if (value < 1) {
496
- throw new core.GeneralError(MathHelper._CLASS_NAME, "lessThanOne", { value });
489
+ throw new core.GeneralError(MathHelper.CLASS_NAME, "lessThanOne", { value });
497
490
  }
498
491
  return MathHelper._LOG_TABLE[value];
499
492
  }
@@ -546,7 +539,7 @@ class Polynomial {
546
539
  }
547
540
  }
548
541
  /**
549
- * The the value of the polynomial at given index.
542
+ * The value of the polynomial at given index.
550
543
  * @param index The index.
551
544
  * @returns The value of the polynomial.
552
545
  */
@@ -682,9 +675,8 @@ const MaskPattern = {
682
675
  class QRHelper {
683
676
  /**
684
677
  * Runtime name for the class.
685
- * @internal
686
678
  */
687
- static _CLASS_NAME = "QRHelper";
679
+ static CLASS_NAME = "QRHelper";
688
680
  /**
689
681
  * @internal
690
682
  */
@@ -841,7 +833,7 @@ class QRHelper {
841
833
  e = 3;
842
834
  break;
843
835
  default:
844
- throw new core.GeneralError(QRHelper._CLASS_NAME, "correctionLevelRange", { errorCorrectLevel });
836
+ throw new core.GeneralError(QRHelper.CLASS_NAME, "correctionLevelRange", { errorCorrectLevel });
845
837
  }
846
838
  switch (mode) {
847
839
  case QRDataMode.Number:
@@ -854,7 +846,7 @@ class QRHelper {
854
846
  m = 2;
855
847
  break;
856
848
  default:
857
- throw new core.GeneralError(QRHelper._CLASS_NAME, "modeRange", { mode });
849
+ throw new core.GeneralError(QRHelper.CLASS_NAME, "modeRange", { mode });
858
850
  }
859
851
  return QRHelper._MAX_LENGTH[t][e][m];
860
852
  }
@@ -895,7 +887,7 @@ class QRHelper {
895
887
  case MaskPattern.PATTERN111:
896
888
  return (i, j) => (((i * j) % 3) + ((i + j) % 2)) % 2 === 0;
897
889
  default:
898
- throw new core.GeneralError(QRHelper._CLASS_NAME, "maskPatternRange", { maskPattern });
890
+ throw new core.GeneralError(QRHelper.CLASS_NAME, "maskPatternRange", { maskPattern });
899
891
  }
900
892
  }
901
893
  /**
@@ -946,9 +938,8 @@ class QRHelper {
946
938
  class RSBlock {
947
939
  /**
948
940
  * Runtime name for the class.
949
- * @internal
950
941
  */
951
- static _CLASS_NAME = "RSBlock";
942
+ static CLASS_NAME = "RSBlock";
952
943
  /**
953
944
  * @internal
954
945
  */
@@ -1209,7 +1200,7 @@ class RSBlock {
1209
1200
  case ErrorCorrectLevel.H:
1210
1201
  return RSBlock._RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
1211
1202
  }
1212
- throw new core.GeneralError(RSBlock._CLASS_NAME, "correctionLevelRange", { errorCorrectLevel });
1203
+ throw new core.GeneralError(RSBlock.CLASS_NAME, "correctionLevelRange", { errorCorrectLevel });
1213
1204
  }
1214
1205
  /**
1215
1206
  * Get the data count of the block.
@@ -1239,9 +1230,8 @@ class RSBlock {
1239
1230
  class QR {
1240
1231
  /**
1241
1232
  * Runtime name for the class.
1242
- * @internal
1243
1233
  */
1244
- static _CLASS_NAME = "QR";
1234
+ static CLASS_NAME = "QR";
1245
1235
  /**
1246
1236
  * @internal
1247
1237
  */
@@ -1278,7 +1268,7 @@ class QR {
1278
1268
  */
1279
1269
  constructor(typeNumber = 6, errorCorrectLevel = ErrorCorrectLevel.L) {
1280
1270
  if (!core.Is.integer(typeNumber) || typeNumber < 0 || typeNumber > 40) {
1281
- throw new core.GeneralError(QR._CLASS_NAME, "typeNumberRange", { typeNumber });
1271
+ throw new core.GeneralError(QR.CLASS_NAME, "typeNumberRange", { typeNumber });
1282
1272
  }
1283
1273
  this._typeNumber = typeNumber;
1284
1274
  this._errorCorrectLevel = errorCorrectLevel;
@@ -1640,7 +1630,7 @@ class QR {
1640
1630
  totalDataCount += rsBlocks[i].getDataCount();
1641
1631
  }
1642
1632
  if (buffer.getLengthInBits() > totalDataCount * 8) {
1643
- throw new core.GeneralError(QR._CLASS_NAME, "dataOverflow", {
1633
+ throw new core.GeneralError(QR.CLASS_NAME, "dataOverflow", {
1644
1634
  lengthInBits: buffer.getLengthInBits(),
1645
1635
  totalDataCount,
1646
1636
  typeNumber: this._typeNumber
@@ -1759,7 +1749,7 @@ class QR {
1759
1749
  break;
1760
1750
  }
1761
1751
  if (typeNumber === 40) {
1762
- throw new core.GeneralError(QR._CLASS_NAME, "typeNumberOverflow", {
1752
+ throw new core.GeneralError(QR.CLASS_NAME, "typeNumberOverflow", {
1763
1753
  lengthInBits: buffer.getLengthInBits(),
1764
1754
  totalDataCount
1765
1755
  });
@@ -1778,9 +1768,8 @@ class QR {
1778
1768
  class JpegRenderer {
1779
1769
  /**
1780
1770
  * Runtime name for the class.
1781
- * @internal
1782
1771
  */
1783
- static _CLASS_NAME = "JpegRenderer";
1772
+ static CLASS_NAME = "JpegRenderer";
1784
1773
  /**
1785
1774
  * Render the QR code data as a bitmap.
1786
1775
  * @param cellData The cell data for the QR code.
@@ -1788,7 +1777,7 @@ class JpegRenderer {
1788
1777
  * @returns The bitmap content.
1789
1778
  */
1790
1779
  static async render(cellData, options) {
1791
- core.Guards.array(JpegRenderer._CLASS_NAME, "cellData", cellData);
1780
+ core.Guards.array(JpegRenderer.CLASS_NAME, "cellData", cellData);
1792
1781
  options = options ?? {};
1793
1782
  options.cellSize = options.cellSize ?? 5;
1794
1783
  options.marginSize = options.marginSize ?? 10;
@@ -1857,9 +1846,8 @@ class JpegRenderer {
1857
1846
  class PngRenderer {
1858
1847
  /**
1859
1848
  * Runtime name for the class.
1860
- * @internal
1861
1849
  */
1862
- static _CLASS_NAME = "PngRenderer";
1850
+ static CLASS_NAME = "PngRenderer";
1863
1851
  /**
1864
1852
  * Render the QR code data as a bitmap.
1865
1853
  * @param cellData The cell data for the QR code.
@@ -1867,7 +1855,7 @@ class PngRenderer {
1867
1855
  * @returns The bitmap content.
1868
1856
  */
1869
1857
  static async render(cellData, options) {
1870
- core.Guards.array(PngRenderer._CLASS_NAME, "cellData", cellData);
1858
+ core.Guards.array(PngRenderer.CLASS_NAME, "cellData", cellData);
1871
1859
  options = options ?? {};
1872
1860
  options.cellSize = options.cellSize ?? 5;
1873
1861
  options.marginSize = options.marginSize ?? 10;
@@ -1935,9 +1923,8 @@ class PngRenderer {
1935
1923
  class TextRenderer {
1936
1924
  /**
1937
1925
  * Runtime name for the class.
1938
- * @internal
1939
1926
  */
1940
- static _CLASS_NAME = "TextRenderer";
1927
+ static CLASS_NAME = "TextRenderer";
1941
1928
  /**
1942
1929
  * Render the QR code data as text.
1943
1930
  * @param cellData The cell data for the QR code.
@@ -1945,7 +1932,7 @@ class TextRenderer {
1945
1932
  * @returns The text content.
1946
1933
  */
1947
1934
  static async render(cellData, options) {
1948
- core.Guards.array(TextRenderer._CLASS_NAME, "cellData", cellData);
1935
+ core.Guards.array(TextRenderer.CLASS_NAME, "cellData", cellData);
1949
1936
  options = options ?? {};
1950
1937
  options.cellSize = options.cellSize ?? 1;
1951
1938
  options.marginSize = options.marginSize ?? 2;
@@ -57,9 +57,9 @@ const QRDataMode = {
57
57
  */
58
58
  class QRDataBase {
59
59
  /**
60
- * @internal
60
+ * Runtime name for the class.
61
61
  */
62
- _className;
62
+ static CLASS_NAME = "QRDataBase";
63
63
  /**
64
64
  * @internal
65
65
  */
@@ -70,12 +70,10 @@ class QRDataBase {
70
70
  _data;
71
71
  /**
72
72
  * Create a new instance of QRDataBase.
73
- * @param className The class name for the derived class.
74
73
  * @param mode The mode for the data.
75
74
  * @param data The data.
76
75
  */
77
- constructor(className, mode, data) {
78
- this._className = className;
76
+ constructor(mode, data) {
79
77
  this._mode = mode;
80
78
  this._data = data;
81
79
  }
@@ -109,7 +107,7 @@ class QRDataBase {
109
107
  case QRDataMode.Byte8:
110
108
  return 8;
111
109
  default:
112
- throw new GeneralError(this._className, "invalidMode", {
110
+ throw new GeneralError(QRDataBase.CLASS_NAME, "invalidMode", {
113
111
  typeNumber,
114
112
  mode: this._mode
115
113
  });
@@ -124,7 +122,7 @@ class QRDataBase {
124
122
  case QRDataMode.Byte8:
125
123
  return 16;
126
124
  default:
127
- throw new GeneralError(this._className, "invalidMode", {
125
+ throw new GeneralError(QRDataBase.CLASS_NAME, "invalidMode", {
128
126
  typeNumber,
129
127
  mode: this._mode
130
128
  });
@@ -139,14 +137,14 @@ class QRDataBase {
139
137
  case QRDataMode.Byte8:
140
138
  return 16;
141
139
  default:
142
- throw new GeneralError(this._className, "invalidMode", {
140
+ throw new GeneralError(QRDataBase.CLASS_NAME, "invalidMode", {
143
141
  typeNumber,
144
142
  mode: this._mode
145
143
  });
146
144
  }
147
145
  }
148
146
  else {
149
- throw new GeneralError(this._className, "invalidTypeNumber", { typeNumber });
147
+ throw new GeneralError(QRDataBase.CLASS_NAME, "invalidTypeNumber", { typeNumber });
150
148
  }
151
149
  }
152
150
  }
@@ -161,15 +159,14 @@ class QRDataBase {
161
159
  class QRAlphaNumeric extends QRDataBase {
162
160
  /**
163
161
  * Runtime name for the class.
164
- * @internal
165
162
  */
166
- static _CLASS_NAME = "QRAlphaNumeric";
163
+ static CLASS_NAME = "QRAlphaNumeric";
167
164
  /**
168
165
  * Create a new instance of QRAlphaNumeric.
169
166
  * @param data The data for the qr alpha numeric.
170
167
  */
171
168
  constructor(data) {
172
- super(QRAlphaNumeric._CLASS_NAME, QRDataMode.AlphaNumeric, data);
169
+ super(QRDataMode.AlphaNumeric, data);
173
170
  }
174
171
  /**
175
172
  * Get the length of the data.
@@ -223,27 +220,25 @@ class QRAlphaNumeric extends QRDataBase {
223
220
  case ":":
224
221
  return 44;
225
222
  default:
226
- throw new GeneralError(QRAlphaNumeric._CLASS_NAME, "illegalCharacter", { value: c });
223
+ throw new GeneralError(QRAlphaNumeric.CLASS_NAME, "illegalCharacter", { value: c });
227
224
  }
228
225
  }
229
226
  }
230
227
 
228
+ // Copyright 2024 IOTA Stiftung.
229
+ // SPDX-License-Identifier: Apache-2.0.
230
+ /* eslint-disable no-bitwise */
231
231
  /**
232
232
  * QR Data for representing a 8 bit data.
233
233
  * Based on https://github.com/kazuhikoarase/qrcode-generator/ .
234
234
  */
235
235
  class QRByte8 extends QRDataBase {
236
- /**
237
- * Runtime name for the class.
238
- * @internal
239
- */
240
- static _CLASS_NAME = "QRByte8";
241
236
  /**
242
237
  * Create a new instance of QRByte8.
243
238
  * @param data The data for the qr 8 bit data.
244
239
  */
245
240
  constructor(data) {
246
- super(QRByte8._CLASS_NAME, QRDataMode.Byte8, data);
241
+ super(QRDataMode.Byte8, data);
247
242
  }
248
243
  /**
249
244
  * Get the length of the data.
@@ -301,15 +296,14 @@ class QRByte8 extends QRDataBase {
301
296
  class QRNumber extends QRDataBase {
302
297
  /**
303
298
  * Runtime name for the class.
304
- * @internal
305
299
  */
306
- static _CLASS_NAME = "QRNumber";
300
+ static CLASS_NAME = "QRNumber";
307
301
  /**
308
302
  * Create a new instance of QRNumber.
309
303
  * @param data The data for the qr number.
310
304
  */
311
305
  constructor(data) {
312
- super(QRNumber._CLASS_NAME, QRDataMode.Number, data);
306
+ super(QRDataMode.Number, data);
313
307
  }
314
308
  /**
315
309
  * Get the length of the data.
@@ -358,7 +352,7 @@ class QRNumber extends QRDataBase {
358
352
  if (c >= "0" && c <= "9") {
359
353
  return c.charCodeAt(0) - "0".charCodeAt(0);
360
354
  }
361
- throw new GeneralError(QRNumber._CLASS_NAME, "illegalCharacter", { value: c });
355
+ throw new GeneralError(QRNumber.CLASS_NAME, "illegalCharacter", { value: c });
362
356
  }
363
357
  }
364
358
 
@@ -451,9 +445,8 @@ class BitBuffer {
451
445
  class MathHelper {
452
446
  /**
453
447
  * Runtime name for the class.
454
- * @internal
455
448
  */
456
- static _CLASS_NAME = "MathHelper";
449
+ static CLASS_NAME = "MathHelper";
457
450
  /**
458
451
  * @internal
459
452
  */
@@ -491,7 +484,7 @@ class MathHelper {
491
484
  */
492
485
  static gLog(value) {
493
486
  if (value < 1) {
494
- throw new GeneralError(MathHelper._CLASS_NAME, "lessThanOne", { value });
487
+ throw new GeneralError(MathHelper.CLASS_NAME, "lessThanOne", { value });
495
488
  }
496
489
  return MathHelper._LOG_TABLE[value];
497
490
  }
@@ -544,7 +537,7 @@ class Polynomial {
544
537
  }
545
538
  }
546
539
  /**
547
- * The the value of the polynomial at given index.
540
+ * The value of the polynomial at given index.
548
541
  * @param index The index.
549
542
  * @returns The value of the polynomial.
550
543
  */
@@ -680,9 +673,8 @@ const MaskPattern = {
680
673
  class QRHelper {
681
674
  /**
682
675
  * Runtime name for the class.
683
- * @internal
684
676
  */
685
- static _CLASS_NAME = "QRHelper";
677
+ static CLASS_NAME = "QRHelper";
686
678
  /**
687
679
  * @internal
688
680
  */
@@ -839,7 +831,7 @@ class QRHelper {
839
831
  e = 3;
840
832
  break;
841
833
  default:
842
- throw new GeneralError(QRHelper._CLASS_NAME, "correctionLevelRange", { errorCorrectLevel });
834
+ throw new GeneralError(QRHelper.CLASS_NAME, "correctionLevelRange", { errorCorrectLevel });
843
835
  }
844
836
  switch (mode) {
845
837
  case QRDataMode.Number:
@@ -852,7 +844,7 @@ class QRHelper {
852
844
  m = 2;
853
845
  break;
854
846
  default:
855
- throw new GeneralError(QRHelper._CLASS_NAME, "modeRange", { mode });
847
+ throw new GeneralError(QRHelper.CLASS_NAME, "modeRange", { mode });
856
848
  }
857
849
  return QRHelper._MAX_LENGTH[t][e][m];
858
850
  }
@@ -893,7 +885,7 @@ class QRHelper {
893
885
  case MaskPattern.PATTERN111:
894
886
  return (i, j) => (((i * j) % 3) + ((i + j) % 2)) % 2 === 0;
895
887
  default:
896
- throw new GeneralError(QRHelper._CLASS_NAME, "maskPatternRange", { maskPattern });
888
+ throw new GeneralError(QRHelper.CLASS_NAME, "maskPatternRange", { maskPattern });
897
889
  }
898
890
  }
899
891
  /**
@@ -944,9 +936,8 @@ class QRHelper {
944
936
  class RSBlock {
945
937
  /**
946
938
  * Runtime name for the class.
947
- * @internal
948
939
  */
949
- static _CLASS_NAME = "RSBlock";
940
+ static CLASS_NAME = "RSBlock";
950
941
  /**
951
942
  * @internal
952
943
  */
@@ -1207,7 +1198,7 @@ class RSBlock {
1207
1198
  case ErrorCorrectLevel.H:
1208
1199
  return RSBlock._RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
1209
1200
  }
1210
- throw new GeneralError(RSBlock._CLASS_NAME, "correctionLevelRange", { errorCorrectLevel });
1201
+ throw new GeneralError(RSBlock.CLASS_NAME, "correctionLevelRange", { errorCorrectLevel });
1211
1202
  }
1212
1203
  /**
1213
1204
  * Get the data count of the block.
@@ -1237,9 +1228,8 @@ class RSBlock {
1237
1228
  class QR {
1238
1229
  /**
1239
1230
  * Runtime name for the class.
1240
- * @internal
1241
1231
  */
1242
- static _CLASS_NAME = "QR";
1232
+ static CLASS_NAME = "QR";
1243
1233
  /**
1244
1234
  * @internal
1245
1235
  */
@@ -1276,7 +1266,7 @@ class QR {
1276
1266
  */
1277
1267
  constructor(typeNumber = 6, errorCorrectLevel = ErrorCorrectLevel.L) {
1278
1268
  if (!Is.integer(typeNumber) || typeNumber < 0 || typeNumber > 40) {
1279
- throw new GeneralError(QR._CLASS_NAME, "typeNumberRange", { typeNumber });
1269
+ throw new GeneralError(QR.CLASS_NAME, "typeNumberRange", { typeNumber });
1280
1270
  }
1281
1271
  this._typeNumber = typeNumber;
1282
1272
  this._errorCorrectLevel = errorCorrectLevel;
@@ -1638,7 +1628,7 @@ class QR {
1638
1628
  totalDataCount += rsBlocks[i].getDataCount();
1639
1629
  }
1640
1630
  if (buffer.getLengthInBits() > totalDataCount * 8) {
1641
- throw new GeneralError(QR._CLASS_NAME, "dataOverflow", {
1631
+ throw new GeneralError(QR.CLASS_NAME, "dataOverflow", {
1642
1632
  lengthInBits: buffer.getLengthInBits(),
1643
1633
  totalDataCount,
1644
1634
  typeNumber: this._typeNumber
@@ -1757,7 +1747,7 @@ class QR {
1757
1747
  break;
1758
1748
  }
1759
1749
  if (typeNumber === 40) {
1760
- throw new GeneralError(QR._CLASS_NAME, "typeNumberOverflow", {
1750
+ throw new GeneralError(QR.CLASS_NAME, "typeNumberOverflow", {
1761
1751
  lengthInBits: buffer.getLengthInBits(),
1762
1752
  totalDataCount
1763
1753
  });
@@ -1776,9 +1766,8 @@ class QR {
1776
1766
  class JpegRenderer {
1777
1767
  /**
1778
1768
  * Runtime name for the class.
1779
- * @internal
1780
1769
  */
1781
- static _CLASS_NAME = "JpegRenderer";
1770
+ static CLASS_NAME = "JpegRenderer";
1782
1771
  /**
1783
1772
  * Render the QR code data as a bitmap.
1784
1773
  * @param cellData The cell data for the QR code.
@@ -1786,7 +1775,7 @@ class JpegRenderer {
1786
1775
  * @returns The bitmap content.
1787
1776
  */
1788
1777
  static async render(cellData, options) {
1789
- Guards.array(JpegRenderer._CLASS_NAME, "cellData", cellData);
1778
+ Guards.array(JpegRenderer.CLASS_NAME, "cellData", cellData);
1790
1779
  options = options ?? {};
1791
1780
  options.cellSize = options.cellSize ?? 5;
1792
1781
  options.marginSize = options.marginSize ?? 10;
@@ -1855,9 +1844,8 @@ class JpegRenderer {
1855
1844
  class PngRenderer {
1856
1845
  /**
1857
1846
  * Runtime name for the class.
1858
- * @internal
1859
1847
  */
1860
- static _CLASS_NAME = "PngRenderer";
1848
+ static CLASS_NAME = "PngRenderer";
1861
1849
  /**
1862
1850
  * Render the QR code data as a bitmap.
1863
1851
  * @param cellData The cell data for the QR code.
@@ -1865,7 +1853,7 @@ class PngRenderer {
1865
1853
  * @returns The bitmap content.
1866
1854
  */
1867
1855
  static async render(cellData, options) {
1868
- Guards.array(PngRenderer._CLASS_NAME, "cellData", cellData);
1856
+ Guards.array(PngRenderer.CLASS_NAME, "cellData", cellData);
1869
1857
  options = options ?? {};
1870
1858
  options.cellSize = options.cellSize ?? 5;
1871
1859
  options.marginSize = options.marginSize ?? 10;
@@ -1933,9 +1921,8 @@ class PngRenderer {
1933
1921
  class TextRenderer {
1934
1922
  /**
1935
1923
  * Runtime name for the class.
1936
- * @internal
1937
1924
  */
1938
- static _CLASS_NAME = "TextRenderer";
1925
+ static CLASS_NAME = "TextRenderer";
1939
1926
  /**
1940
1927
  * Render the QR code data as text.
1941
1928
  * @param cellData The cell data for the QR code.
@@ -1943,7 +1930,7 @@ class TextRenderer {
1943
1930
  * @returns The text content.
1944
1931
  */
1945
1932
  static async render(cellData, options) {
1946
- Guards.array(TextRenderer._CLASS_NAME, "cellData", cellData);
1933
+ Guards.array(TextRenderer.CLASS_NAME, "cellData", cellData);
1947
1934
  options = options ?? {};
1948
1935
  options.cellSize = options.cellSize ?? 1;
1949
1936
  options.marginSize = options.marginSize ?? 2;
@@ -1,10 +1,14 @@
1
+ import { QRDataBase } from "./qrDataBase";
1
2
  import type { BitBuffer } from "../helpers/bitBuffer";
2
- import { QRDataBase } from "../models/qrDataBase";
3
3
  /**
4
4
  * QR Data for representing a alpha numeric.
5
5
  * Based on https://github.com/kazuhikoarase/qrcode-generator/ .
6
6
  */
7
7
  export declare class QRAlphaNumeric extends QRDataBase {
8
+ /**
9
+ * Runtime name for the class.
10
+ */
11
+ static readonly CLASS_NAME: string;
8
12
  /**
9
13
  * Create a new instance of QRAlphaNumeric.
10
14
  * @param data The data for the qr alpha numeric.
@@ -1,5 +1,5 @@
1
+ import { QRDataBase } from "./qrDataBase";
1
2
  import type { BitBuffer } from "../helpers/bitBuffer";
2
- import { QRDataBase } from "../models/qrDataBase";
3
3
  /**
4
4
  * QR Data for representing a 8 bit data.
5
5
  * Based on https://github.com/kazuhikoarase/qrcode-generator/ .
@@ -1,17 +1,20 @@
1
- import { QRDataMode } from "./qrDataMode";
2
1
  import type { BitBuffer } from "../helpers/bitBuffer";
2
+ import { QRDataMode } from "../models/qrDataMode";
3
3
  /**
4
4
  * Base class for storing QR Data.
5
5
  * Based on https://github.com/kazuhikoarase/qrcode-generator/ .
6
6
  */
7
7
  export declare abstract class QRDataBase {
8
+ /**
9
+ * Runtime name for the class.
10
+ */
11
+ static readonly CLASS_NAME: string;
8
12
  /**
9
13
  * Create a new instance of QRDataBase.
10
- * @param className The class name for the derived class.
11
14
  * @param mode The mode for the data.
12
15
  * @param data The data.
13
16
  */
14
- constructor(className: string, mode: QRDataMode, data: string);
17
+ constructor(mode: QRDataMode, data: string);
15
18
  /**
16
19
  * Get the data mode.
17
20
  * @returns The data mode.
@@ -1,10 +1,14 @@
1
+ import { QRDataBase } from "./qrDataBase";
1
2
  import type { BitBuffer } from "../helpers/bitBuffer";
2
- import { QRDataBase } from "../models/qrDataBase";
3
3
  /**
4
4
  * QR Data for representing a number.
5
5
  * Based on https://github.com/kazuhikoarase/qrcode-generator/ .
6
6
  */
7
7
  export declare class QRNumber extends QRDataBase {
8
+ /**
9
+ * Runtime name for the class.
10
+ */
11
+ static readonly CLASS_NAME: string;
8
12
  /**
9
13
  * Create a new instance of QRNumber.
10
14
  * @param data The data for the qr number.
@@ -3,6 +3,10 @@
3
3
  * Based on https://github.com/kazuhikoarase/qrcode-generator/ .
4
4
  */
5
5
  export declare class MathHelper {
6
+ /**
7
+ * Runtime name for the class.
8
+ */
9
+ static readonly CLASS_NAME: string;
6
10
  /**
7
11
  * Initialize the math helper.
8
12
  */
@@ -10,7 +10,7 @@ export declare class Polynomial {
10
10
  */
11
11
  constructor(num: number[], shift?: number);
12
12
  /**
13
- * The the value of the polynomial at given index.
13
+ * The value of the polynomial at given index.
14
14
  * @param index The index.
15
15
  * @returns The value of the polynomial.
16
16
  */
@@ -6,6 +6,10 @@ import { QRDataMode } from "../models/qrDataMode";
6
6
  * Based on https://github.com/kazuhikoarase/qrcode-generator/ .
7
7
  */
8
8
  export declare class QRHelper {
9
+ /**
10
+ * Runtime name for the class.
11
+ */
12
+ static readonly CLASS_NAME: string;
9
13
  /**
10
14
  * Get the pattern position for the given type number.
11
15
  * @param typeNumber The type number to get the pattern for.
@@ -4,6 +4,10 @@ import { ErrorCorrectLevel } from "../models/errorCorrectLevel";
4
4
  * Based on https://github.com/kazuhikoarase/qrcode-generator/ .
5
5
  */
6
6
  export declare class RSBlock {
7
+ /**
8
+ * Runtime name for the class.
9
+ */
10
+ static readonly CLASS_NAME: string;
7
11
  /**
8
12
  * Create a new instance of RSBlock.
9
13
  * @param totalCount The total count for the block.
@@ -5,6 +5,10 @@ import type { QRCellData } from "./models/qrCellData";
5
5
  * Based on https://github.com/kazuhikoarase/qrcode-generator/ .
6
6
  */
7
7
  export declare class QR {
8
+ /**
9
+ * Runtime name for the class.
10
+ */
11
+ static readonly CLASS_NAME: string;
8
12
  /**
9
13
  * Create a new instance of QR.
10
14
  * @param typeNumber 0 to 40, 0 means autodetect.
@@ -4,6 +4,10 @@ import type { QRCellData } from "../models/qrCellData";
4
4
  * Class to render qr data as jpeg.
5
5
  */
6
6
  export declare class JpegRenderer {
7
+ /**
8
+ * Runtime name for the class.
9
+ */
10
+ static readonly CLASS_NAME: string;
7
11
  /**
8
12
  * Render the QR code data as a bitmap.
9
13
  * @param cellData The cell data for the QR code.
@@ -4,6 +4,10 @@ import type { QRCellData } from "../models/qrCellData";
4
4
  * Class to render qr data as png.
5
5
  */
6
6
  export declare class PngRenderer {
7
+ /**
8
+ * Runtime name for the class.
9
+ */
10
+ static readonly CLASS_NAME: string;
7
11
  /**
8
12
  * Render the QR code data as a bitmap.
9
13
  * @param cellData The cell data for the QR code.
@@ -4,6 +4,10 @@ import type { QRCellData } from "../models/qrCellData";
4
4
  * Class to render qr data as text.
5
5
  */
6
6
  export declare class TextRenderer {
7
+ /**
8
+ * Runtime name for the class.
9
+ */
10
+ static readonly CLASS_NAME: string;
7
11
  /**
8
12
  * Render the QR code data as text.
9
13
  * @param cellData The cell data for the QR code.
package/docs/changelog.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @twin.org/qr - Changelog
2
2
 
3
+ ## [0.0.2-next.21](https://github.com/twinfoundation/framework/compare/qr-v0.0.2-next.20...qr-v0.0.2-next.21) (2025-10-09)
4
+
5
+
6
+ ### Features
7
+
8
+ * locales validation ([#197](https://github.com/twinfoundation/framework/issues/197)) ([55fdadb](https://github.com/twinfoundation/framework/commit/55fdadb13595ce0047f787bd1d4135d429a99f12))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/core bumped from 0.0.2-next.20 to 0.0.2-next.21
16
+ * @twin.org/image bumped from 0.0.2-next.20 to 0.0.2-next.21
17
+ * @twin.org/nameof bumped from 0.0.2-next.20 to 0.0.2-next.21
18
+ * devDependencies
19
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.20 to 0.0.2-next.21
20
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.20 to 0.0.2-next.21
21
+ * @twin.org/validate-locales bumped from 0.0.2-next.20 to 0.0.2-next.21
22
+
3
23
  ## [0.0.2-next.20](https://github.com/twinfoundation/framework/compare/qr-v0.0.2-next.19...qr-v0.0.2-next.20) (2025-10-02)
4
24
 
5
25
 
@@ -12,6 +12,14 @@ Class to render qr data as jpeg.
12
12
 
13
13
  `JpegRenderer`
14
14
 
15
+ ## Properties
16
+
17
+ ### CLASS\_NAME
18
+
19
+ > `readonly` `static` **CLASS\_NAME**: `string`
20
+
21
+ Runtime name for the class.
22
+
15
23
  ## Methods
16
24
 
17
25
  ### render()
@@ -12,6 +12,14 @@ Class to render qr data as png.
12
12
 
13
13
  `PngRenderer`
14
14
 
15
+ ## Properties
16
+
17
+ ### CLASS\_NAME
18
+
19
+ > `readonly` `static` **CLASS\_NAME**: `string`
20
+
21
+ Runtime name for the class.
22
+
15
23
  ## Methods
16
24
 
17
25
  ### render()
@@ -33,6 +33,14 @@ Create a new instance of QR.
33
33
 
34
34
  Error if the typeNumber is invalid.
35
35
 
36
+ ## Properties
37
+
38
+ ### CLASS\_NAME
39
+
40
+ > `readonly` `static` **CLASS\_NAME**: `string`
41
+
42
+ Runtime name for the class.
43
+
36
44
  ## Methods
37
45
 
38
46
  ### addText()
@@ -12,6 +12,14 @@ Class to render qr data as text.
12
12
 
13
13
  `TextRenderer`
14
14
 
15
+ ## Properties
16
+
17
+ ### CLASS\_NAME
18
+
19
+ > `readonly` `static` **CLASS\_NAME**: `string`
20
+
21
+ Runtime name for the class.
22
+
15
23
  ## Methods
16
24
 
17
25
  ### render()
package/locales/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "error": {
3
- "qr": {
3
+ "qR": {
4
4
  "typeNumberRange": "The typeNumber parameter should be a number >= 0 and <= 40, it is {typeNumber}",
5
5
  "dataOverflow": "There is not enough space in the QR code to store the data, {lengthInBits} > {totalDataCount}, try increasing the typeNumber from {typeNumber}, or use 0 for auto detect",
6
6
  "typeNumberOverflow": "There is not enough space in the QR code to store the data, {lengthInBits} > {totalDataCount}, typeNumber cannot be greater than 40"
@@ -10,21 +10,21 @@
10
10
  "marginSizeZero": "The marginSize must be a number >= 0, it is \"{marginSize}\""
11
11
  },
12
12
  "qRAlphaNumeric": {
13
- "illegalCharacter ": "Illegal character in string \"{value}\""
13
+ "illegalCharacter": "Illegal character in string \"{value}\""
14
14
  },
15
15
  "qRNumber": {
16
- "illegalCharacter ": "Illegal character in string \"{value}\""
16
+ "illegalCharacter": "Illegal character in string \"{value}\""
17
17
  },
18
18
  "mathHelper": {
19
- "lessThanOne ": "The value can not be less than 1, it is \"{value}\""
19
+ "lessThanOne": "The value can not be less than 1, it is \"{value}\""
20
20
  },
21
- "qrHelper": {
22
- "correctionLevelRange ": "The errorCorrectLevel parameter should be one of the following: \"L\", \"M\", \"Q\", \"H\", it is \"{errorCorrectLevel}\"",
23
- "modeRange ": "The mode parameter should be one of the following: \"Byte\", \"Numeric\", \"Alphanumeric\", it is \"{mode}\"",
24
- "maskPatternRange ": "The maskPattern parameter should be a number >= 0 and <= 7, it is \"{maskPattern}\""
21
+ "qRHelper": {
22
+ "correctionLevelRange": "The errorCorrectLevel parameter should be one of the following: \"L\", \"M\", \"Q\", \"H\", it is \"{errorCorrectLevel}\"",
23
+ "modeRange": "The mode parameter should be one of the following: \"Byte\", \"Numeric\", \"Alphanumeric\", it is \"{mode}\"",
24
+ "maskPatternRange": "The maskPattern parameter should be a number >= 0 and <= 7, it is \"{maskPattern}\""
25
25
  },
26
26
  "rSBlock": {
27
- "correctionLevelRange ": "The errorCorrectLevel parameter should be one of the following: \"L\", \"M\", \"Q\", \"H\", it is \"{errorCorrectLevel}\""
27
+ "correctionLevelRange": "The errorCorrectLevel parameter should be one of the following: \"L\", \"M\", \"Q\", \"H\", it is \"{errorCorrectLevel}\""
28
28
  },
29
29
  "qRDataBase": {
30
30
  "invalidMode": "Invalid mode {mode} for typeNumber {typeNumber}",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/qr",
3
- "version": "0.0.2-next.20",
3
+ "version": "0.0.2-next.21",
4
4
  "description": "Package for creating QR codes",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,9 +14,9 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/core": "0.0.2-next.20",
18
- "@twin.org/image": "0.0.2-next.20",
19
- "@twin.org/nameof": "0.0.2-next.20"
17
+ "@twin.org/core": "0.0.2-next.21",
18
+ "@twin.org/image": "0.0.2-next.21",
19
+ "@twin.org/nameof": "0.0.2-next.21"
20
20
  },
21
21
  "main": "./dist/cjs/index.cjs",
22
22
  "module": "./dist/esm/index.mjs",
@@ -41,5 +41,9 @@
41
41
  "iota",
42
42
  "framework",
43
43
  "blockchain"
44
- ]
44
+ ],
45
+ "bugs": {
46
+ "url": "git+https://github.com/twinfoundation/framework/issues"
47
+ },
48
+ "homepage": "https://twindev.org"
45
49
  }