qrdx 0.0.61 → 0.0.62

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 (76) hide show
  1. package/README.md +2 -1
  2. package/dist/angular.js +7 -2
  3. package/dist/angular.js.map +1 -1
  4. package/dist/angular.mjs +7 -2
  5. package/dist/angular.mjs.map +1 -1
  6. package/dist/core.js +7 -7
  7. package/dist/core.js.map +1 -1
  8. package/dist/core.mjs +7 -7
  9. package/dist/core.mjs.map +1 -1
  10. package/dist/element.browser.mjs +6 -6
  11. package/dist/element.browser.mjs.map +1 -1
  12. package/dist/element.js +1 -1
  13. package/dist/element.js.map +1 -1
  14. package/dist/element.mjs +1 -1
  15. package/dist/element.mjs.map +1 -1
  16. package/dist/index.js +7 -7
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +7 -7
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/qr-code-canvas.js +1 -1
  21. package/dist/qr-code-canvas.js.map +1 -1
  22. package/dist/qr-code-canvas.mjs +1 -1
  23. package/dist/qr-code-canvas.mjs.map +1 -1
  24. package/dist/schemas.js +1 -1
  25. package/dist/schemas.js.map +1 -1
  26. package/dist/schemas.mjs +1 -1
  27. package/dist/schemas.mjs.map +1 -1
  28. package/dist/src/angular.d.ts +2 -1
  29. package/dist/src/element.d.ts +2 -0
  30. package/dist/src/element.d.ts.map +1 -1
  31. package/dist/src/helpers.d.ts +2 -2
  32. package/dist/src/helpers.d.ts.map +1 -1
  33. package/dist/src/logo-budget.d.ts +3 -1
  34. package/dist/src/logo-budget.d.ts.map +1 -1
  35. package/dist/src/looks.d.ts +2 -2
  36. package/dist/src/looks.d.ts.map +1 -1
  37. package/dist/src/plain.d.ts.map +1 -1
  38. package/dist/src/print.d.ts.map +1 -1
  39. package/dist/src/qr-code-canvas.d.ts.map +1 -1
  40. package/dist/src/qr-code-props.d.ts +1 -1
  41. package/dist/src/qr-code-props.d.ts.map +1 -1
  42. package/dist/src/scan-score.d.ts.map +1 -1
  43. package/dist/src/symbol.d.ts +13 -0
  44. package/dist/src/symbol.d.ts.map +1 -0
  45. package/dist/src/utils/print-shared.d.ts.map +1 -1
  46. package/dist/src/utils.d.ts +1 -0
  47. package/dist/src/utils.d.ts.map +1 -1
  48. package/dist/src/vue.d.ts.map +1 -1
  49. package/dist/types/index.js +1 -1
  50. package/dist/types/index.js.map +1 -1
  51. package/dist/types/index.mjs +1 -1
  52. package/dist/types/index.mjs.map +1 -1
  53. package/dist/types/qr.d.ts +2 -0
  54. package/dist/types/qr.d.ts.map +1 -1
  55. package/dist/vanilla.browser.mjs +16 -16
  56. package/dist/vanilla.browser.mjs.map +1 -1
  57. package/dist/vue.js +1 -1
  58. package/dist/vue.js.map +1 -1
  59. package/dist/vue.mjs +1 -1
  60. package/dist/vue.mjs.map +1 -1
  61. package/package.json +1 -1
  62. package/src/angular.ts +2 -0
  63. package/src/element.ts +3 -0
  64. package/src/helpers.ts +27 -10
  65. package/src/logo-budget.ts +9 -8
  66. package/src/looks.ts +17 -14
  67. package/src/plain.tsx +5 -7
  68. package/src/print.ts +3 -6
  69. package/src/qr-code-canvas.tsx +5 -7
  70. package/src/qr-code-props.ts +4 -0
  71. package/src/scan-score.ts +5 -4
  72. package/src/symbol.ts +27 -0
  73. package/src/utils/print-shared.ts +5 -9
  74. package/src/utils.tsx +9 -9
  75. package/src/vue.ts +1 -0
  76. package/types/qr.ts +6 -0
package/src/utils.tsx CHANGED
@@ -34,7 +34,6 @@ import {
34
34
  isShapedBodyPattern,
35
35
  renderShapedBody,
36
36
  } from "./body-patterns";
37
- import qrcodegen from "./codegen";
38
37
  import {
39
38
  DEFAULT_BGCOLOR,
40
39
  DEFAULT_FGCOLOR,
@@ -42,7 +41,6 @@ import {
42
41
  DEFAULT_LEVEL,
43
42
  DEFAULT_MARGIN,
44
43
  DEFAULT_SIZE,
45
- ERROR_LEVEL_MAP,
46
44
  } from "./constants";
47
45
  import { generateCornerDotPath } from "./corner-dot";
48
46
  import { generateCornerSquarePath } from "./corner-eye";
@@ -54,6 +52,7 @@ import { clampBgRadius, eyeShapeOf, resolveHalo, resolveShadow } from "./looks";
54
52
  import { partMarker, type QRPart, type QRPartEye } from "./part-markers";
55
53
  import { getLayoutMargin, shapeBackground, shapeDecoration } from "./qr-shape";
56
54
  import { hashString } from "./shapes";
55
+ import { encodeSymbol } from "./symbol";
57
56
  import { getTemplate } from "./templates";
58
57
  import { getSolidColor } from "./utils/color";
59
58
  import { compact, fmt, SCALE_DECIMALS } from "./utils/fmt";
@@ -888,6 +887,7 @@ export function resolveErrorLevel(props: {
888
887
  imageSettings?: ImageSettings;
889
888
  isOGContext?: boolean;
890
889
  autoLevel?: boolean;
890
+ exactLevel?: boolean;
891
891
  shape?: QRCodeShape;
892
892
  }): ErrorLevel {
893
893
  const level = props.level ?? DEFAULT_LEVEL;
@@ -899,9 +899,10 @@ export function resolveErrorLevel(props: {
899
899
  ? "Q"
900
900
  : level;
901
901
  if (props.autoLevel && imageSettings && effective !== "H") {
902
- const cells = qrcodegen.QrCode.encodeText(
902
+ const cells = encodeSymbol(
903
903
  props.value,
904
- ERROR_LEVEL_MAP[effective]
904
+ effective,
905
+ props.exactLevel
905
906
  ).getModules();
906
907
  const settings = getImageSettings(
907
908
  cells,
@@ -974,6 +975,7 @@ export function createQRCodeTree(props: QRSVGOptions): QRNode {
974
975
  eyeColors,
975
976
  moduleScale,
976
977
  autoLevel,
978
+ exactLevel,
977
979
  shape,
978
980
  eyeShapes,
979
981
  eyeGradient,
@@ -997,7 +999,7 @@ export function createQRCodeTree(props: QRSVGOptions): QRNode {
997
999
  );
998
1000
  // A logo no bigger than the code can repair (logo-budget.ts)
999
1001
  const imageSettings = capImageSettings(
1000
- { value, size, margin, level, shape, autoLevel, isOGContext },
1002
+ { value, size, margin, level, shape, autoLevel, exactLevel, isOGContext },
1001
1003
  requestedImageSettings
1002
1004
  );
1003
1005
 
@@ -1025,13 +1027,11 @@ export function createQRCodeTree(props: QRSVGOptions): QRNode {
1025
1027
  imageSettings,
1026
1028
  isOGContext,
1027
1029
  autoLevel,
1030
+ exactLevel,
1028
1031
  shape,
1029
1032
  });
1030
1033
 
1031
- const qrCode = qrcodegen.QrCode.encodeText(
1032
- value,
1033
- ERROR_LEVEL_MAP[effectiveLevel]
1034
- );
1034
+ const qrCode = encodeSymbol(value, effectiveLevel, exactLevel);
1035
1035
  let cells = qrCode.getModules();
1036
1036
  // A shaped code draws the symbol further in, inside its disc, heart or
1037
1037
  // silhouette (a silhouette that can't hold the code draws square)
package/src/vue.ts CHANGED
@@ -80,6 +80,7 @@ const svgProps = {
80
80
  eyeColors: null,
81
81
  moduleScale: Number,
82
82
  autoLevel: flag,
83
+ exactLevel: flag,
83
84
  shape: null,
84
85
  eyeShapes: null,
85
86
  eyeGradient: null,
package/types/qr.ts CHANGED
@@ -236,6 +236,7 @@ export const qrPropsSchema = z.object({
236
236
  .max(MODULE_SCALE_MAX)
237
237
  .optional(),
238
238
  autoLevel: z.boolean().optional(),
239
+ exactLevel: z.boolean().optional(),
239
240
  shape: qrCodeShapeSchema.optional(),
240
241
  eyeShapes: eyeShapesSchema.optional(),
241
242
  eyeGradient: eyeGradientSpanSchema.optional(),
@@ -290,6 +291,11 @@ export interface QRProps {
290
291
  // Raise error correction to H when the logo covers more than 7% of the
291
292
  // code (off by default, so existing output never changes)
292
293
  autoLevel?: boolean;
294
+ // Encode at exactly the level the code is drawn at. By default the encoder
295
+ // raises it to Q or H when the data still fits the same version (more
296
+ // error correction for free); a Swiss QR-bill must be M, so it sets this.
297
+ // Off by default, so existing output never changes.
298
+ exactLevel?: boolean;
293
299
  // Outline: "circle" or "heart" puts the symbol in a disc or a heart of
294
300
  // decorative modules (see QR_SHAPES); a QRSilhouette fills an outline of
295
301
  // your own. Ignored with a template.