qreator 9.5.2 → 9.6.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.
Files changed (55) hide show
  1. package/README.md +2 -0
  2. package/lib/bitMatrix.d.ts +3 -0
  3. package/lib/bitMatrix.js +38 -0
  4. package/lib/bitMatrix.js.map +1 -0
  5. package/lib/browser/bitMatrix.d.ts +3 -0
  6. package/lib/browser/matrix.d.ts +0 -2
  7. package/lib/browser/pdf.umd.js +40 -37
  8. package/lib/browser/pdf.umd.js.map +1 -1
  9. package/lib/browser/png.umd.js +40 -37
  10. package/lib/browser/png.umd.js.map +1 -1
  11. package/lib/browser/react.d.ts +4 -0
  12. package/lib/browser/react.umd.js +5813 -0
  13. package/lib/browser/react.umd.js.map +1 -0
  14. package/lib/browser/svg.d.ts +2 -2
  15. package/lib/browser/svg.umd.js +238 -235
  16. package/lib/browser/svg.umd.js.map +1 -1
  17. package/lib/browser/tests/react.test.d.ts +1 -0
  18. package/lib/browser/typing/types.d.ts +1 -0
  19. package/lib/browser/utils.d.ts +1 -0
  20. package/lib/matrix.d.ts +0 -2
  21. package/lib/matrix.js +0 -35
  22. package/lib/matrix.js.map +1 -1
  23. package/lib/pdf.js +3 -3
  24. package/lib/pdf.js.map +1 -1
  25. package/lib/png.js +4 -4
  26. package/lib/png.js.map +1 -1
  27. package/lib/png_browser.js +3 -3
  28. package/lib/png_browser.js.map +1 -1
  29. package/lib/react.d.ts +4 -0
  30. package/lib/react.js +9 -0
  31. package/lib/react.js.map +1 -0
  32. package/lib/svg.d.ts +2 -2
  33. package/lib/svg.js +5 -5
  34. package/lib/svg.js.map +1 -1
  35. package/lib/tests/browser.test.js +1 -0
  36. package/lib/tests/browser.test.js.map +1 -1
  37. package/lib/tests/react.test.d.ts +1 -0
  38. package/lib/tests/react.test.js +9 -0
  39. package/lib/tests/react.test.js.map +1 -0
  40. package/lib/tests/test.js +29 -4
  41. package/lib/tests/test.js.map +1 -1
  42. package/lib/typing/types.d.ts +1 -0
  43. package/lib/utils.d.ts +1 -0
  44. package/package.json +9 -1
  45. package/src/bitMatrix.ts +53 -0
  46. package/src/matrix.ts +1 -51
  47. package/src/pdf.ts +3 -3
  48. package/src/png.ts +4 -4
  49. package/src/png_browser.ts +3 -3
  50. package/src/react.tsx +8 -0
  51. package/src/svg.ts +6 -6
  52. package/src/tests/browser.test.ts +1 -0
  53. package/src/tests/react.test.ts +9 -0
  54. package/src/tests/test.ts +31 -4
  55. package/src/typing/types.ts +4 -0
package/README.md CHANGED
@@ -75,6 +75,8 @@ const pngBuffer = await getPNG("I love QR", {
75
75
  | `color` | module color in rgba or hex format | number | `#000000` - `#000000` | `#000000`<br />(black with 100% opacity) |
76
76
  | `bgColor` | background color in rgba or hex format | number | `#000000` - `#FFFFFF` | `#FFFFFF`<br />(white with 100% opacity) |
77
77
  | `borderRadius` | border-radius (in pixels) | number | 0 - `size / 2` | `0` |
78
+ | `noExcavate` | don't remove partially covered modules | boolean | `true`, `false` | `false` |
79
+
78
80
 
79
81
  ## Benchmarks
80
82
 
@@ -0,0 +1,3 @@
1
+ import { BitMatrix } from "./typing/types";
2
+ export declare function zeroFillFinders(matrix: BitMatrix): BitMatrix;
3
+ export declare function clearMatrixCenter(matrix: BitMatrix, widthPct: number, heightPct: number): BitMatrix;
@@ -0,0 +1,38 @@
1
+ export function zeroFillFinders(matrix) {
2
+ matrix = structuredClone(matrix);
3
+ const N = matrix.length;
4
+ const zeroPixel = 0;
5
+ for (let i = -3; i <= 3; i++) {
6
+ for (let j = -3; j <= 3; j++) {
7
+ matrix[3 + i][3 + j] = zeroPixel;
8
+ matrix[3 + i][N - 4 + j] = zeroPixel;
9
+ matrix[N - 4 + i][3 + j] = zeroPixel;
10
+ }
11
+ }
12
+ for (let i = 0; i < 8; i++) {
13
+ matrix[7][i] =
14
+ matrix[i][7] =
15
+ matrix[7][N - i - 1] =
16
+ matrix[i][N - 8] =
17
+ matrix[N - 8][i] =
18
+ matrix[N - 1 - i][7] =
19
+ zeroPixel;
20
+ }
21
+ return matrix;
22
+ }
23
+ export function clearMatrixCenter(matrix, widthPct, heightPct) {
24
+ matrix = structuredClone(matrix);
25
+ const mW = matrix.length;
26
+ const cW = Math.ceil(((mW * widthPct) / 100 + (mW % 2)) / 2) * 2 - (mW % 2);
27
+ const mH = matrix[0]?.length ?? 0;
28
+ const cH = Math.ceil(((mH * heightPct) / 100 + (mH % 2)) / 2) * 2 - (mH % 2);
29
+ const clearStartX = Math.round((mW - cW) / 2);
30
+ const clearStartY = Math.round((mH - cH) / 2);
31
+ for (let x = clearStartX; x < clearStartX + cW; x += 1) {
32
+ for (let y = clearStartY; y < clearStartY + cH; y += 1) {
33
+ matrix[x][y] = 0;
34
+ }
35
+ }
36
+ return matrix;
37
+ }
38
+ //# sourceMappingURL=bitMatrix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitMatrix.js","sourceRoot":"","sources":["../src/bitMatrix.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,eAAe,CAAC,MAAiB;IAC7C,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IACxB,MAAM,SAAS,GAAG,CAAC,CAAC;IAEpB,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3B,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC;YACjC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC;YACrC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,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CAAC,CAAC;IAG7E,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9C,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAE9C,KAAK,IAAI,CAAC,GAAG,WAAW,EAAE,CAAC,GAAG,WAAW,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACrD,KAAK,IAAI,CAAC,GAAG,WAAW,EAAE,CAAC,GAAG,WAAW,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YACrD,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { BitMatrix } from "./typing/types";
2
+ export declare function zeroFillFinders(matrix: BitMatrix): BitMatrix;
3
+ export declare function clearMatrixCenter(matrix: BitMatrix, widthPct: number, heightPct: number): BitMatrix;
@@ -1,11 +1,9 @@
1
1
  import { BitMatrix, Data, EcLevel, Matrix } from "./typing/types";
2
2
  export declare function init(version: number): Matrix;
3
3
  export declare function fillFinders(matrix: Matrix): void;
4
- export declare function zeroFillFinders(matrix: BitMatrix): void;
5
4
  export declare function fillAlignAndTiming(matrix: Matrix): void;
6
5
  export declare function fillStub(matrix: Matrix): void;
7
6
  export declare const fillReserved: (matrix: Matrix, ec_level: EcLevel, mask: number) => void;
8
7
  export declare const fillData: (matrix: Matrix, data: Data, mask: number) => void;
9
8
  export declare function calculatePenalty(matrix: Matrix): number;
10
9
  export declare function getMatrix(data: Data): BitMatrix;
11
- export declare function clearMatrixCenter(matrix: BitMatrix, widthPct: number, heightPct: number): BitMatrix;
@@ -25934,26 +25934,6 @@
25934
25934
  128;
25935
25935
  }
25936
25936
  }
25937
- function zeroFillFinders(matrix) {
25938
- const N = matrix.length;
25939
- const zeroPixel = 0;
25940
- for (let i = -3; i <= 3; i++) {
25941
- for (let j = -3; j <= 3; j++) {
25942
- matrix[3 + i][3 + j] = zeroPixel;
25943
- matrix[3 + i][N - 4 + j] = zeroPixel;
25944
- matrix[N - 4 + i][3 + j] = zeroPixel;
25945
- }
25946
- }
25947
- for (let i = 0; i < 8; i++) {
25948
- matrix[7][i] =
25949
- matrix[i][7] =
25950
- matrix[7][N - i - 1] =
25951
- matrix[i][N - 8] =
25952
- matrix[N - 8][i] =
25953
- matrix[N - 1 - i][7] =
25954
- zeroPixel;
25955
- }
25956
- }
25957
25937
  function fillAlignAndTiming(matrix) {
25958
25938
  const N = matrix.length;
25959
25939
  if (N > 21) {
@@ -26267,21 +26247,6 @@
26267
26247
  fillReserved(matrix, data.ec_level, bestMask);
26268
26248
  return matrix.map((row) => row.map((cell) => (cell & 1)));
26269
26249
  }
26270
- function clearMatrixCenter(matrix, widthPct, heightPct) {
26271
- matrix = matrix.map((x) => x.slice());
26272
- const mW = matrix.length;
26273
- const cW = Math.ceil(((mW * widthPct) / 100 + (mW % 2)) / 2) * 2 - (mW % 2);
26274
- const mH = matrix[0]?.length ?? 0;
26275
- const cH = Math.ceil(((mH * heightPct) / 100 + (mH % 2)) / 2) * 2 - (mH % 2);
26276
- const clearStartX = Math.round((mW - cW) / 2);
26277
- const clearStartY = Math.round((mH - cH) / 2);
26278
- for (let x = clearStartX; x < clearStartX + cW; x += 1) {
26279
- for (let y = clearStartY; y < clearStartY + cH; y += 1) {
26280
- matrix[x][y] = 0;
26281
- }
26282
- }
26283
- return matrix;
26284
- }
26285
26250
 
26286
26251
  const EC_LEVELS = ["L", "M", "Q", "H"];
26287
26252
  function getTemplate(message, ec_level) {
@@ -26989,12 +26954,50 @@
26989
26954
  size: 0,
26990
26955
  };
26991
26956
 
26957
+ function zeroFillFinders(matrix) {
26958
+ matrix = structuredClone(matrix);
26959
+ const N = matrix.length;
26960
+ const zeroPixel = 0;
26961
+ for (let i = -3; i <= 3; i++) {
26962
+ for (let j = -3; j <= 3; j++) {
26963
+ matrix[3 + i][3 + j] = zeroPixel;
26964
+ matrix[3 + i][N - 4 + j] = zeroPixel;
26965
+ matrix[N - 4 + i][3 + j] = zeroPixel;
26966
+ }
26967
+ }
26968
+ for (let i = 0; i < 8; i++) {
26969
+ matrix[7][i] =
26970
+ matrix[i][7] =
26971
+ matrix[7][N - i - 1] =
26972
+ matrix[i][N - 8] =
26973
+ matrix[N - 8][i] =
26974
+ matrix[N - 1 - i][7] =
26975
+ zeroPixel;
26976
+ }
26977
+ return matrix;
26978
+ }
26979
+ function clearMatrixCenter(matrix, widthPct, heightPct) {
26980
+ matrix = structuredClone(matrix);
26981
+ const mW = matrix.length;
26982
+ const cW = Math.ceil(((mW * widthPct) / 100 + (mW % 2)) / 2) * 2 - (mW % 2);
26983
+ const mH = matrix[0]?.length ?? 0;
26984
+ const cH = Math.ceil(((mH * heightPct) / 100 + (mH % 2)) / 2) * 2 - (mH % 2);
26985
+ const clearStartX = Math.round((mW - cW) / 2);
26986
+ const clearStartY = Math.round((mH - cH) / 2);
26987
+ for (let x = clearStartX; x < clearStartX + cW; x += 1) {
26988
+ for (let y = clearStartY; y < clearStartY + cH; y += 1) {
26989
+ matrix[x][y] = 0;
26990
+ }
26991
+ }
26992
+ return matrix;
26993
+ }
26994
+
26992
26995
  const textDec = new TextDecoder();
26993
26996
  async function getPDF(text, inOptions) {
26994
26997
  const options = getOptions(inOptions);
26995
26998
  let matrix = QR(text, options.ec_level, options.parse_url);
26996
- zeroFillFinders(matrix);
26997
- if (options.logo && options.logoWidth && options.logoHeight) {
26999
+ matrix = zeroFillFinders(matrix);
27000
+ if (options.logo && options.logoWidth && options.logoHeight && !options.noExcavate) {
26998
27001
  matrix = clearMatrixCenter(matrix, options.logoWidth, options.logoHeight);
26999
27002
  }
27000
27003
  return PDF({ matrix, ...options });