@gamecrafters/base-ui 0.0.5 → 0.0.7
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/build/components/blockquote/Blockquote.d.ts +10 -0
- package/build/components/blockquote/Blockquote.types.d.ts +9 -0
- package/build/components/blockquote/index.d.ts +2 -0
- package/build/components/code/Code.d.ts +7 -0
- package/build/components/code/Code.types.d.ts +5 -0
- package/build/components/code/index.d.ts +2 -0
- package/build/components/code-block/CodeBlock.d.ts +12 -0
- package/build/components/code-block/CodeBlock.types.d.ts +40 -0
- package/build/components/code-block/CodeBlockCode.d.ts +7 -0
- package/build/components/code-block/CodeBlockContent.d.ts +7 -0
- package/build/components/code-block/CodeBlockContext.d.ts +2 -0
- package/build/components/code-block/CodeBlockHeader.d.ts +7 -0
- package/build/components/code-block/CodeBlockTitle.d.ts +7 -0
- package/build/components/code-block/highlightCode.d.ts +12 -0
- package/build/components/code-block/index.d.ts +38 -0
- package/build/components/em/Em.d.ts +10 -0
- package/build/components/em/Em.types.d.ts +9 -0
- package/build/components/em/index.d.ts +2 -0
- package/build/components/highlight/Highlight.d.ts +11 -0
- package/build/components/highlight/Highlight.types.d.ts +15 -0
- package/build/components/highlight/highlightMatches.d.ts +2 -0
- package/build/components/highlight/index.d.ts +3 -0
- package/build/components/image/Image.d.ts +11 -0
- package/build/components/image/Image.types.d.ts +10 -0
- package/build/components/image/index.d.ts +2 -0
- package/build/components/index.d.ts +12 -0
- package/build/components/mark/Mark.d.ts +11 -0
- package/build/components/mark/Mark.types.d.ts +11 -0
- package/build/components/mark/index.d.ts +2 -0
- package/build/components/markdown/Markdown.d.ts +10 -0
- package/build/components/markdown/Markdown.types.d.ts +17 -0
- package/build/components/markdown/MarkdownProse.d.ts +8 -0
- package/build/components/markdown/index.d.ts +3 -0
- package/build/components/markdown/markdownTheme.d.ts +6 -0
- package/build/components/progress-circle/ProgressCircle.d.ts +11 -0
- package/build/components/progress-circle/ProgressCircle.types.d.ts +10 -0
- package/build/components/progress-circle/index.d.ts +2 -0
- package/build/components/rating/Rating.d.ts +18 -0
- package/build/components/rating/Rating.types.d.ts +16 -0
- package/build/components/rating/index.d.ts +2 -0
- package/build/components/rich-text-editor/RichTextEditor.d.ts +15 -0
- package/build/components/rich-text-editor/RichTextEditor.types.d.ts +36 -0
- package/build/components/rich-text-editor/RichTextEditorContent.d.ts +5 -0
- package/build/components/rich-text-editor/RichTextEditorContext.d.ts +2 -0
- package/build/components/rich-text-editor/RichTextEditorToolbar.d.ts +8 -0
- package/build/components/rich-text-editor/index.d.ts +23 -0
- package/build/components/rich-text-editor/richTextEditorTheme.d.ts +4 -0
- package/build/components/status/Status.d.ts +11 -0
- package/build/components/status/Status.types.d.ts +19 -0
- package/build/components/status/StatusContext.d.ts +2 -0
- package/build/components/status/StatusIndicator.d.ts +8 -0
- package/build/components/status/index.d.ts +17 -0
- package/build/hooks/useSlots.d.ts +1 -4
- package/build/lib/qr-code/core/data.d.ts +13 -0
- package/build/lib/qr-code/core/errors.d.ts +12 -0
- package/build/lib/qr-code/core/format.d.ts +12 -0
- package/build/lib/qr-code/core/index.d.ts +16 -0
- package/build/lib/qr-code/core/mask.d.ts +19 -0
- package/build/lib/qr-code/core/matrix.d.ts +17 -0
- package/build/lib/qr-code/core/micro.d.ts +16 -0
- package/build/lib/qr-code/core/mode.d.ts +31 -0
- package/build/lib/qr-code/core/reed-solomon.d.ts +13 -0
- package/build/lib/qr-code/core/segment.d.ts +8 -0
- package/build/lib/qr-code/core/tables.d.ts +49 -0
- package/build/lib/qr-code/core/types.d.ts +36 -0
- package/build/lib/qr-code/core/version.d.ts +18 -0
- package/build/lib/qr-code/index.d.ts +17 -0
- package/build/lib/qr-code/types/index.d.ts +65 -0
- package/build/lib/qr-code/utilities/adler32.d.ts +4 -0
- package/build/lib/qr-code/utilities/common.d.ts +2 -0
- package/build/lib/qr-code/utilities/crc32.d.ts +4 -0
- package/build/lib/qr-code/utilities/data-uri.d.ts +6 -0
- package/build/lib/qr-code/utilities/deflate.d.ts +6 -0
- package/build/lib/qr-code/utilities/gradient.d.ts +10 -0
- package/build/lib/qr-code/utilities/ico.d.ts +4 -0
- package/build/lib/qr-code/utilities/logo.d.ts +9 -0
- package/build/lib/qr-code/utilities/png-encoder.d.ts +5 -0
- package/build/lib/qr-code/utilities/shapes.d.ts +7 -0
- package/build/lib/qr-code/utilities/svg.d.ts +5 -0
- package/build/lib/qr-code/utilities/text.d.ts +11 -0
- package/build/main.cjs.js +2 -2
- package/build/main.esm.js +2 -2
- package/build/styles/main.css +1 -1
- package/package.json +11 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import type { PolymorphicProps } from "../../utilities/polymorphic";
|
|
3
|
+
export type StatusVariant = "accent" | "success" | "attention" | "severe" | "danger" | "done" | "neutral";
|
|
4
|
+
export type StatusSize = "small" | "medium" | "large";
|
|
5
|
+
export type StatusProps<As extends React.ElementType = "span"> = PolymorphicProps<As, "span", {
|
|
6
|
+
variant?: StatusVariant;
|
|
7
|
+
size?: StatusSize;
|
|
8
|
+
srText?: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
}>;
|
|
11
|
+
export type StatusIndicatorProps = React.ComponentPropsWithoutRef<"span"> & {
|
|
12
|
+
variant?: StatusVariant;
|
|
13
|
+
size?: StatusSize;
|
|
14
|
+
className?: string;
|
|
15
|
+
};
|
|
16
|
+
export type StatusContextValue = {
|
|
17
|
+
variant?: StatusVariant;
|
|
18
|
+
size?: StatusSize;
|
|
19
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { StatusSize, StatusVariant } from "./Status.types";
|
|
3
|
+
declare const _default: (props: Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
4
|
+
variant?: StatusVariant;
|
|
5
|
+
size?: StatusSize;
|
|
6
|
+
className?: string;
|
|
7
|
+
} & React.RefAttributes<any>) => React.ReactNode;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import StatusIndicator from "./StatusIndicator";
|
|
2
|
+
export declare const Status: (<As extends React.ElementType = "span">(props: import("../../utilities/polymorphic").DistributiveOmit<import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "span" : As> & {
|
|
3
|
+
variant?: import("./Status.types").StatusVariant;
|
|
4
|
+
size?: import("./Status.types").StatusSize;
|
|
5
|
+
srText?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
}, "as"> & {
|
|
8
|
+
as?: As | undefined;
|
|
9
|
+
} & import("react").RefAttributes<any>) => React.ReactNode) & {
|
|
10
|
+
Indicator: (props: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
11
|
+
variant?: import("./Status.types").StatusVariant;
|
|
12
|
+
size?: import("./Status.types").StatusSize;
|
|
13
|
+
className?: string;
|
|
14
|
+
} & import("react").RefAttributes<any>) => React.ReactNode;
|
|
15
|
+
};
|
|
16
|
+
export { StatusIndicator };
|
|
17
|
+
export * from "./Status.types";
|
|
@@ -6,9 +6,6 @@ export type SlotConfig = Record<string, ComponentMatcher | ComponentAndPropsMatc
|
|
|
6
6
|
type SlotElements<Config extends SlotConfig> = {
|
|
7
7
|
[Property in keyof Config]: SlotValue<Config, Property>;
|
|
8
8
|
};
|
|
9
|
-
type SlotValue<Config, Property extends keyof Config> = Config[Property] extends React.ElementType ? React.ReactElement<React.ComponentPropsWithoutRef<Config[Property]>, Config[Property]> : Config[Property] extends readonly [
|
|
10
|
-
infer ElementType extends React.ElementType,
|
|
11
|
-
infer _testFn
|
|
12
|
-
] ? React.ReactElement<React.ComponentPropsWithoutRef<ElementType>, ElementType> : never;
|
|
9
|
+
type SlotValue<Config, Property extends keyof Config> = Config[Property] extends React.ElementType ? React.ReactElement<React.ComponentPropsWithoutRef<Config[Property]>, Config[Property]> : Config[Property] extends readonly [infer ElementType extends React.ElementType, infer _testFn] ? React.ReactElement<React.ComponentPropsWithoutRef<ElementType>, ElementType> : never;
|
|
13
10
|
export declare const useSlots: <Config extends SlotConfig>(children: React.ReactNode, config: Config) => [Partial<SlotElements<Config>>, React.ReactNode[]];
|
|
14
11
|
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QR Code data encoding and bitstream construction
|
|
3
|
+
*/
|
|
4
|
+
import type { ErrorCorrectionLevel, QRCodeOptions } from "./types";
|
|
5
|
+
export interface EncodedData {
|
|
6
|
+
version: number;
|
|
7
|
+
ecLevel: ErrorCorrectionLevel;
|
|
8
|
+
bits: number[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Encode text into QR code data bits with error correction
|
|
12
|
+
*/
|
|
13
|
+
export declare function encodeData(text: string, options?: QRCodeOptions): EncodedData;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error classes for qr-code
|
|
3
|
+
*/
|
|
4
|
+
export declare class QRCodeError extends Error {
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class InvalidInputError extends QRCodeError {
|
|
8
|
+
name: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class CapacityError extends QRCodeError {
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QR Code format and version info encoding
|
|
3
|
+
* BCH encoding for format info, Golay encoding for version info
|
|
4
|
+
*/
|
|
5
|
+
import type { Module } from "./matrix";
|
|
6
|
+
import type { ErrorCorrectionLevel } from "./types";
|
|
7
|
+
/** Generate 15-bit format info for given EC level and mask */
|
|
8
|
+
export declare function generateFormatInfo(ecLevel: ErrorCorrectionLevel, mask: number): number;
|
|
9
|
+
/** Write format info to the matrix at the reserved positions */
|
|
10
|
+
export declare function writeFormatInfo(matrix: Module[][], ecLevel: ErrorCorrectionLevel, mask: number): void;
|
|
11
|
+
/** Write version info for version 7+ */
|
|
12
|
+
export declare function writeVersionInfo(matrix: Module[][], version: number): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QR Code core encoder — main entry point
|
|
3
|
+
*/
|
|
4
|
+
export type { ErrorCorrectionLevel, EncodingMode, QRCodeOptions, QRSegment } from "./types";
|
|
5
|
+
export { encodeData } from "./data";
|
|
6
|
+
export { createMatrix, placeFunctionPatterns, placeData } from "./matrix";
|
|
7
|
+
export { selectBestMask, applyMask } from "./mask";
|
|
8
|
+
export { writeFormatInfo, writeVersionInfo } from "./format";
|
|
9
|
+
export { encodeMicroQR } from "./micro";
|
|
10
|
+
export type { MicroQROptions } from "./micro";
|
|
11
|
+
import type { QRCodeOptions } from "./types";
|
|
12
|
+
/**
|
|
13
|
+
* Encode text into a QR code matrix.
|
|
14
|
+
* Returns a 2D boolean array — true = dark module.
|
|
15
|
+
*/
|
|
16
|
+
export declare function encodeQR(text: string, options?: QRCodeOptions): boolean[][];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QR Code mask patterns and penalty evaluation
|
|
3
|
+
* 8 mask patterns, 4 penalty rules
|
|
4
|
+
*/
|
|
5
|
+
import type { Module } from "./matrix";
|
|
6
|
+
/** Get mask function for a given mask pattern (0-7) */
|
|
7
|
+
export declare function getMaskFn(mask: number): (r: number, c: number) => boolean;
|
|
8
|
+
/** Apply a mask pattern to the matrix (only data modules) */
|
|
9
|
+
export declare function applyMask(matrix: Module[][], mask: number, size: number, version: number): void;
|
|
10
|
+
/**
|
|
11
|
+
* Select the best mask pattern by evaluating all 8 masks
|
|
12
|
+
* Returns the mask number with the lowest penalty score
|
|
13
|
+
*/
|
|
14
|
+
export declare function selectBestMask(matrix: Module[][], size: number, version: number, requestedMask?: number): number;
|
|
15
|
+
/**
|
|
16
|
+
* Evaluate penalty score for a masked matrix
|
|
17
|
+
* Implements all 4 penalty rules from the QR code spec
|
|
18
|
+
*/
|
|
19
|
+
export declare function evaluatePenalty(matrix: Module[][], size: number): number;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QR Code matrix construction
|
|
3
|
+
* Function patterns, data placement, alignment patterns
|
|
4
|
+
*/
|
|
5
|
+
export type Module = boolean | null;
|
|
6
|
+
/** Create an empty matrix of the given size */
|
|
7
|
+
export declare function createMatrix(size: number): Module[][];
|
|
8
|
+
/** Place all function patterns on the matrix */
|
|
9
|
+
export declare function placeFunctionPatterns(matrix: Module[][], version: number): void;
|
|
10
|
+
/**
|
|
11
|
+
* Place data bits in the matrix using the zigzag pattern
|
|
12
|
+
*/
|
|
13
|
+
export declare function placeData(matrix: Module[][], bits: number[], _version: number): void;
|
|
14
|
+
/**
|
|
15
|
+
* Check if a module is a data module (not a function pattern)
|
|
16
|
+
*/
|
|
17
|
+
export declare function isDataModule(r: number, c: number, size: number, version: number): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Micro QR Code encoder (M1-M4)
|
|
3
|
+
* ISO/IEC 18004 — single finder pattern, reduced quiet zone
|
|
4
|
+
*
|
|
5
|
+
* M1: 11x11, numeric only, error detection only
|
|
6
|
+
* M2: 13x13, numeric/alphanumeric, EC L/M
|
|
7
|
+
* M3: 15x15, numeric/alphanumeric/byte, EC L/M
|
|
8
|
+
* M4: 17x17, numeric/alphanumeric/byte/kanji, EC L/M/Q
|
|
9
|
+
*/
|
|
10
|
+
export interface MicroQROptions {
|
|
11
|
+
version?: 1 | 2 | 3 | 4;
|
|
12
|
+
ecLevel?: "L" | "M" | "Q";
|
|
13
|
+
mask?: 0 | 1 | 2 | 3;
|
|
14
|
+
}
|
|
15
|
+
export declare const MICRO_QR_SIZES: readonly [11, 13, 15, 17];
|
|
16
|
+
export declare function encodeMicroQR(text: string, options?: MicroQROptions): boolean[][];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QR Code encoding modes - detection and encoding
|
|
3
|
+
*/
|
|
4
|
+
/** Check if a string can be encoded in numeric mode */
|
|
5
|
+
export declare function isNumeric(text: string): boolean;
|
|
6
|
+
/** Check if a string can be encoded in alphanumeric mode */
|
|
7
|
+
export declare function isAlphanumeric(text: string): boolean;
|
|
8
|
+
/** Check if a string can be encoded in Kanji mode (Shift JIS double-byte) */
|
|
9
|
+
export declare function isKanji(_text: string): boolean;
|
|
10
|
+
/** Auto-detect the best encoding mode for the given text */
|
|
11
|
+
export declare function detectMode(text: string): "numeric" | "alphanumeric" | "byte" | "kanji";
|
|
12
|
+
/** Get alphanumeric character value (0-44) */
|
|
13
|
+
export declare function getAlphanumericValue(char: string): number;
|
|
14
|
+
/** Encode numeric data to bits */
|
|
15
|
+
export declare function encodeNumericData(text: string): number[];
|
|
16
|
+
/** Encode alphanumeric data to bits */
|
|
17
|
+
export declare function encodeAlphanumericData(text: string): number[];
|
|
18
|
+
/** Encode byte data to bits */
|
|
19
|
+
export declare function encodeByteData(data: Uint8Array): number[];
|
|
20
|
+
/**
|
|
21
|
+
* Encode Kanji data to bits (13 bits per character)
|
|
22
|
+
* Input must be pre-converted to Shift JIS double-byte values
|
|
23
|
+
*/
|
|
24
|
+
export declare function encodeKanjiData(sjisValues: number[]): number[];
|
|
25
|
+
/**
|
|
26
|
+
* Convert a Unicode string to Shift JIS double-byte values for Kanji encoding.
|
|
27
|
+
* This is a simplified mapping — covers common CJK characters.
|
|
28
|
+
*/
|
|
29
|
+
export declare function unicodeToShiftJIS(text: string): number[];
|
|
30
|
+
/** Push a value as the specified number of bits (MSB first) */
|
|
31
|
+
export declare function pushBits(arr: number[], value: number, count: number): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reed-Solomon error correction for QR codes
|
|
3
|
+
* GF(256) arithmetic with primitive polynomial 0x11D
|
|
4
|
+
*/
|
|
5
|
+
/** Multiply two GF(256) elements */
|
|
6
|
+
export declare function gfMultiply(a: number, b: number): number;
|
|
7
|
+
/** Generate error correction codewords for a data block */
|
|
8
|
+
export declare function generateECCodewords(data: number[], ecCount: number): number[];
|
|
9
|
+
/**
|
|
10
|
+
* Add error correction to data bytes
|
|
11
|
+
* Handles block splitting, EC generation, and interleaving
|
|
12
|
+
*/
|
|
13
|
+
export declare function addErrorCorrection(dataBytes: number[], ecCodewordsPerBlock: number, group1Blocks: number, group1DataCW: number, group2Blocks: number, group2DataCW: number): number[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optimal segment mode switching for QR codes
|
|
3
|
+
*/
|
|
4
|
+
import type { QRSegment } from "./types";
|
|
5
|
+
/**
|
|
6
|
+
* Split text into optimized segments that minimize total encoded bit length.
|
|
7
|
+
*/
|
|
8
|
+
export declare function optimizeSegments(text: string, version: number): QRSegment[];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QR Code lookup tables for versions 1-40, all EC levels
|
|
3
|
+
* Based on ISO/IEC 18004:2015
|
|
4
|
+
*/
|
|
5
|
+
import type { ErrorCorrectionLevel } from "./types";
|
|
6
|
+
/**
|
|
7
|
+
* Character count indicator bit lengths by version group and mode
|
|
8
|
+
* [V1-9, V10-26, V27-40]
|
|
9
|
+
*/
|
|
10
|
+
export declare const CHAR_COUNT_BITS: Record<string, [number, number, number]>;
|
|
11
|
+
/** Get character count bits for a version and mode */
|
|
12
|
+
export declare function getCharCountBits(version: number, mode: string): number;
|
|
13
|
+
/**
|
|
14
|
+
* Alphanumeric character values
|
|
15
|
+
*/
|
|
16
|
+
export declare const ALPHANUMERIC_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
|
17
|
+
/**
|
|
18
|
+
* Error correction block information for each version and EC level
|
|
19
|
+
* Format: [totalCodewords, ecCodewordsPerBlock, group1Blocks,
|
|
20
|
+
* group1DataCW, group2Blocks, group2DataCW]
|
|
21
|
+
*/
|
|
22
|
+
interface ECBlockInfo {
|
|
23
|
+
totalDataCodewords: number;
|
|
24
|
+
ecCodewordsPerBlock: number;
|
|
25
|
+
group1Blocks: number;
|
|
26
|
+
group1DataCW: number;
|
|
27
|
+
group2Blocks: number;
|
|
28
|
+
group2DataCW: number;
|
|
29
|
+
}
|
|
30
|
+
export declare function getECInfo(version: number, ecLevel: ErrorCorrectionLevel): ECBlockInfo;
|
|
31
|
+
/**
|
|
32
|
+
* Alignment pattern positions for each version (2-40)
|
|
33
|
+
* Version 1 has no alignment patterns
|
|
34
|
+
*/
|
|
35
|
+
export declare const ALIGNMENT_POSITIONS: number[][];
|
|
36
|
+
/**
|
|
37
|
+
* Remainder bits after data placement for each version
|
|
38
|
+
*/
|
|
39
|
+
export declare const REMAINDER_BITS: number[];
|
|
40
|
+
/**
|
|
41
|
+
* Total codewords (data + EC) for each version
|
|
42
|
+
*/
|
|
43
|
+
export declare function getTotalCodewords(version: number): number;
|
|
44
|
+
/**
|
|
45
|
+
* Version info bit strings for versions 7-40
|
|
46
|
+
* 18-bit BCH code
|
|
47
|
+
*/
|
|
48
|
+
export declare const VERSION_INFO: number[];
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QR Code types and interfaces
|
|
3
|
+
*/
|
|
4
|
+
export type ErrorCorrectionLevel = "L" | "M" | "Q" | "H";
|
|
5
|
+
export type EncodingMode = "numeric" | "alphanumeric" | "byte" | "kanji" | "auto";
|
|
6
|
+
export interface QRCodeOptions {
|
|
7
|
+
ecLevel?: ErrorCorrectionLevel;
|
|
8
|
+
version?: number;
|
|
9
|
+
mode?: EncodingMode;
|
|
10
|
+
mask?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
11
|
+
micro?: boolean;
|
|
12
|
+
structuredAppend?: {
|
|
13
|
+
index: number;
|
|
14
|
+
total: number;
|
|
15
|
+
parity: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface QRSegment {
|
|
19
|
+
mode: "numeric" | "alphanumeric" | "byte" | "kanji" | "eci";
|
|
20
|
+
data: Uint8Array | string;
|
|
21
|
+
charCount: number;
|
|
22
|
+
}
|
|
23
|
+
/** EC level indicators: L=01, M=00, Q=11, H=10 */
|
|
24
|
+
export declare const EC_LEVEL_BITS: Record<ErrorCorrectionLevel, number>;
|
|
25
|
+
/** Mode indicators (4 bits) */
|
|
26
|
+
export declare const MODE_INDICATOR: {
|
|
27
|
+
readonly numeric: 1;
|
|
28
|
+
readonly alphanumeric: 2;
|
|
29
|
+
readonly byte: 4;
|
|
30
|
+
readonly kanji: 8;
|
|
31
|
+
readonly eci: 7;
|
|
32
|
+
readonly structuredAppend: 3;
|
|
33
|
+
readonly fnc1First: 5;
|
|
34
|
+
readonly fnc1Second: 9;
|
|
35
|
+
readonly terminator: 0;
|
|
36
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QR Code version selection
|
|
3
|
+
* Versions 1-40, size = 4*V + 17 modules per side
|
|
4
|
+
*/
|
|
5
|
+
import type { ErrorCorrectionLevel } from "./types";
|
|
6
|
+
/** Calculate data capacity in bits for a given version and EC level */
|
|
7
|
+
export declare function getDataCapacityBits(version: number, ecLevel: ErrorCorrectionLevel): number;
|
|
8
|
+
/**
|
|
9
|
+
* Select the smallest QR version that can encode the given data
|
|
10
|
+
* Returns version number (1-40)
|
|
11
|
+
*/
|
|
12
|
+
export declare function selectVersion(text: string, ecLevel: ErrorCorrectionLevel, mode?: string, requestedVersion?: number): number;
|
|
13
|
+
/** Get the module count (size) for a version */
|
|
14
|
+
export declare function getModuleCount(version: number): number;
|
|
15
|
+
/**
|
|
16
|
+
* Determine the optimal encoding mode based on data content
|
|
17
|
+
*/
|
|
18
|
+
export declare function selectMode(text: string, requestedMode?: string): "numeric" | "alphanumeric" | "byte" | "kanji";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QR Code library
|
|
3
|
+
*/
|
|
4
|
+
import type { QRCodeSVGOptions } from "./types";
|
|
5
|
+
import type { QRCodeOptions } from "./core/types";
|
|
6
|
+
export declare function qrcode(text: string, options?: QRCodeSVGOptions & QRCodeOptions): string;
|
|
7
|
+
export declare function qrcodeTerminal(text: string, options?: QRCodeOptions): string;
|
|
8
|
+
export declare function qrcodeDataURI(text: string, options?: QRCodeSVGOptions & QRCodeOptions): string;
|
|
9
|
+
export declare function qrcodeBase64(text: string, options?: QRCodeSVGOptions & QRCodeOptions): string;
|
|
10
|
+
export { encodeQR } from "./core/index";
|
|
11
|
+
export { encodeMicroQR } from "./core/micro";
|
|
12
|
+
export { renderQRCodeSVG } from "./utilities/svg";
|
|
13
|
+
export { renderText } from "./utilities/text";
|
|
14
|
+
export { svgToDataURI, svgToBase64, svgToBase64Raw } from "./utilities/data-uri";
|
|
15
|
+
export type { QRCodeSVGOptions, DotType, GradientOptions, CornerOptions, LogoOptions, TextRenderOptions, MeasurementUnit, } from "./types";
|
|
16
|
+
export type { QRCodeOptions, ErrorCorrectionLevel, EncodingMode, QRSegment } from "./core/types";
|
|
17
|
+
export type { MicroQROptions } from "./core/micro";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export type DotType = "square" | "rounded" | "dots" | "diamond" | "classy" | "classy-rounded" | "extra-rounded" | "vertical-line" | "horizontal-line" | "small-square" | "tiny-square";
|
|
2
|
+
export interface LinearGradientOptions {
|
|
3
|
+
type: "linear";
|
|
4
|
+
rotation?: number;
|
|
5
|
+
stops: Array<{
|
|
6
|
+
offset: number;
|
|
7
|
+
color: string;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
export interface RadialGradientOptions {
|
|
11
|
+
type: "radial";
|
|
12
|
+
stops: Array<{
|
|
13
|
+
offset: number;
|
|
14
|
+
color: string;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
export type GradientOptions = LinearGradientOptions | RadialGradientOptions;
|
|
18
|
+
export interface CornerOptions {
|
|
19
|
+
outerShape?: "square" | "rounded" | "dots" | "extra-rounded" | "classy";
|
|
20
|
+
innerShape?: "square" | "dots" | "rounded";
|
|
21
|
+
outerColor?: string | GradientOptions;
|
|
22
|
+
innerColor?: string | GradientOptions;
|
|
23
|
+
}
|
|
24
|
+
export interface LogoOptions {
|
|
25
|
+
svg?: string;
|
|
26
|
+
path?: string;
|
|
27
|
+
imageUrl?: string;
|
|
28
|
+
imageWidth?: number;
|
|
29
|
+
imageHeight?: number;
|
|
30
|
+
size?: number;
|
|
31
|
+
margin?: number;
|
|
32
|
+
hideBackgroundDots?: boolean;
|
|
33
|
+
backgroundColor?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface SVGAccessibilityOptions {
|
|
36
|
+
ariaLabel?: string;
|
|
37
|
+
role?: string;
|
|
38
|
+
title?: string;
|
|
39
|
+
desc?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface QRCodeSVGOptions extends SVGAccessibilityOptions {
|
|
42
|
+
size?: number;
|
|
43
|
+
margin?: number;
|
|
44
|
+
unit?: MeasurementUnit;
|
|
45
|
+
color?: string | GradientOptions;
|
|
46
|
+
background?: string | GradientOptions | "transparent";
|
|
47
|
+
dotType?: DotType;
|
|
48
|
+
dotSize?: number;
|
|
49
|
+
shape?: "square" | "circle";
|
|
50
|
+
corners?: {
|
|
51
|
+
topLeft?: CornerOptions;
|
|
52
|
+
topRight?: CornerOptions;
|
|
53
|
+
bottomLeft?: CornerOptions;
|
|
54
|
+
};
|
|
55
|
+
logo?: LogoOptions;
|
|
56
|
+
xmlDeclaration?: boolean;
|
|
57
|
+
}
|
|
58
|
+
export type MeasurementUnit = "px" | "mm" | "in" | "pt" | "cm";
|
|
59
|
+
export interface TextRenderOptions {
|
|
60
|
+
dark?: string;
|
|
61
|
+
light?: string;
|
|
62
|
+
compact?: boolean;
|
|
63
|
+
margin?: number;
|
|
64
|
+
invert?: boolean;
|
|
65
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SVG gradient generation
|
|
3
|
+
*/
|
|
4
|
+
import type { GradientOptions } from "../types";
|
|
5
|
+
export declare function resetGradientCounter(): void;
|
|
6
|
+
export declare function isGradient(color: string | GradientOptions | undefined): color is GradientOptions;
|
|
7
|
+
export declare function generateGradientDef(options: GradientOptions): {
|
|
8
|
+
id: string;
|
|
9
|
+
svg: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logo embedding in QR codes
|
|
3
|
+
*/
|
|
4
|
+
import type { LogoOptions } from "../types";
|
|
5
|
+
export interface LogoPlacement {
|
|
6
|
+
svg: string;
|
|
7
|
+
hiddenModules: Set<string>;
|
|
8
|
+
}
|
|
9
|
+
export declare function calculateLogoPlacement(options: LogoOptions, moduleCount: number, moduleSize: number, margin: number): LogoPlacement;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PNG encoder — assembles valid PNG files from pixel data
|
|
3
|
+
*/
|
|
4
|
+
export declare function encodePNG(width: number, height: number, rows: Uint8Array[], fg: [number, number, number], bg: [number, number, number], useUpFilter?: boolean): Uint8Array;
|
|
5
|
+
export declare function encodeTrueColorPNG(width: number, height: number, rgba: Uint8Array): Uint8Array;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module shape generators for QR code SVG rendering
|
|
3
|
+
*/
|
|
4
|
+
import type { DotType } from "../types";
|
|
5
|
+
export declare function getModulePath(x: number, y: number, size: number, dotType: DotType, dotSize?: number): string;
|
|
6
|
+
export declare function getFinderOuterPath(x: number, y: number, moduleSize: number, shape?: string): string;
|
|
7
|
+
export declare function getFinderInnerPath(x: number, y: number, moduleSize: number, shape?: string): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal/text output for QR codes
|
|
3
|
+
*/
|
|
4
|
+
export interface TextRenderOptions {
|
|
5
|
+
dark?: string;
|
|
6
|
+
light?: string;
|
|
7
|
+
compact?: boolean;
|
|
8
|
+
margin?: number;
|
|
9
|
+
invert?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function renderText(matrix: boolean[][], options?: TextRenderOptions): string;
|