All files / qr-code/src headless.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112                                                                                                                                                                                                                               
/**
 * `@usefy/qr-code/headless` — the framework-free surface.
 *
 * Zero React in this graph and, deliberately, **no `"use client"` banner**
 * (SPEC decision #2): a React Server Component can import from here and render
 * a QR code with no client JavaScript at all. `src/headless.test.ts` asserts
 * the built bundle keeps that promise.
 */
 
export { encodeQR } from "./encode/encodeQR";
export {
  EC_LEVELS,
  EC_RECOVERY_RATIO,
  MAX_VERSION,
  MIN_VERSION,
  alignmentPatternPositions,
  charCountBits,
  dataCapacityBits,
  dataCodewords,
  ecCodewordsPerBlock,
  numEcBlocks,
  totalCodewords,
  versionSize,
} from "./encode/capacity";
export { ALPHANUMERIC_CHARSET, segment, segmentsBitLength } from "./encode/segment";
export { maskAt, penaltyScore } from "./encode/mask";
export { codewordModuleOrder, functionPatternMap } from "./encode/matrix";
export { formatInfoBits, versionInfoBits } from "./encode/info";
 
/**
 * GF(256) arithmetic and Reed–Solomon encoding.
 *
 * Published because the field, the tables and the traversal above are the
 * halves a **decoder** needs too — `@usefy/qr-scanner` composes them rather
 * than restating ISO/IEC 18004 a second time, which is what keeps the
 * generator and the scanner from ever disagreeing about the specification.
 * They are load-bearing public API, not incidental exports: treat a change
 * here as a breaking change.
 *
 * Deliberately *not* published: `gfLog`, `polyMul`, `PRIMITIVE`,
 * `generatorPoly` and `EC_FORMAT_BITS`. The first draft of this surface
 * exported them too, on the theory that "a decoder needs the primitives" — but
 * nothing in the scanner references them, and an export carrying an explicit
 * breaking-change contract that no one imports is a permanent cost for no
 * benefit. `MODE_INDICATOR` is likewise absent: it covers only the three modes
 * this package *writes*, so a scanner (which must also read Kanji, ECI,
 * Structured Append and FNC1) cannot use it as its table anyway.
 */
export { gfDiv, gfExp, gfMul } from "./encode/galois";
/** Used by the scanner's tests to build error-correction fixtures. */
export { rsEncode } from "./encode/reedSolomon";
 
export {
  MAX_LOGO_SIZE,
  MAX_MODULE_GAP,
  MAX_SAFE_MODULE_GAP,
  MIN_QUIET_ZONE,
  MIN_SCANNABLE_CONTRAST,
  contrastRatio,
  drawToCanvas,
  eyeOrigins,
  gradientId,
  isEyeModule,
  isSafeCssColor,
  logoClipId,
  logoSafety,
  matrixToPaths,
  relativeLuminance,
  resolveStyle,
  styleContrast,
  toPNG,
  toSVG,
  toSVGProps,
  warnInvertedPolarity,
  warnLowContrast,
  warnModuleGap,
  warnQuietZone,
  warnScannability,
  warnUnsafeLogo,
  worstContrast,
} from "./render";
export type {
  CanvasRenderOptions,
  LogoClipIdentity,
  PNGExport,
  PNGExportOptions,
  RenderOptions,
  RenderedPaths,
  ResolvedStyle,
} from "./render";
 
export { QRCapacityError, QRExportError } from "./errors";
 
export type {
  EncodeOptions,
  ErrorCorrectionLevel,
  LogoSafety,
  QRGradient,
  QRGradientDef,
  QRGradientStop,
  QREyeShape,
  QRLogoOptions,
  QRMatrix,
  QRModuleShape,
  QROptions,
  QRPath,
  QRSVGProps,
  QRSegment,
  QRSegmentMode,
  QRStyleOptions,
} from "./types";