qrdx 0.0.1
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/README.md +414 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +11 -0
- package/dist/index.mjs.map +1 -0
- package/dist/src/api.d.ts +3 -0
- package/dist/src/api.d.ts.map +1 -0
- package/dist/src/codegen.d.ts +101 -0
- package/dist/src/codegen.d.ts.map +1 -0
- package/dist/src/constants.d.ts +15 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/corner-dot.d.ts +4 -0
- package/dist/src/corner-dot.d.ts.map +1 -0
- package/dist/src/corner-eye.d.ts +3 -0
- package/dist/src/corner-eye.d.ts.map +1 -0
- package/dist/src/detection.d.ts +13 -0
- package/dist/src/detection.d.ts.map +1 -0
- package/dist/src/download.d.ts +36 -0
- package/dist/src/download.d.ts.map +1 -0
- package/dist/src/helpers.d.ts +36 -0
- package/dist/src/helpers.d.ts.map +1 -0
- package/dist/src/index.d.ts +25 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/qr-code.d.ts +20 -0
- package/dist/src/qr-code.d.ts.map +1 -0
- package/dist/src/template/arrow.d.ts +3 -0
- package/dist/src/template/arrow.d.ts.map +1 -0
- package/dist/src/template/default.d.ts +3 -0
- package/dist/src/template/default.d.ts.map +1 -0
- package/dist/src/template/halloween.d.ts +3 -0
- package/dist/src/template/halloween.d.ts.map +1 -0
- package/dist/src/template/index.d.ts +7 -0
- package/dist/src/template/index.d.ts.map +1 -0
- package/dist/src/template/square-border.d.ts +3 -0
- package/dist/src/template/square-border.d.ts.map +1 -0
- package/dist/src/template/standard-box.d.ts +3 -0
- package/dist/src/template/standard-box.d.ts.map +1 -0
- package/dist/src/template/striked-box.d.ts +3 -0
- package/dist/src/template/striked-box.d.ts.map +1 -0
- package/dist/src/templates.d.ts +8 -0
- package/dist/src/templates.d.ts.map +1 -0
- package/dist/src/utils.d.ts +38 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/types/common.d.ts +9 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/corner-dot.d.ts +3 -0
- package/dist/types/corner-dot.d.ts.map +1 -0
- package/dist/types/corner-eye.d.ts +3 -0
- package/dist/types/corner-eye.d.ts.map +1 -0
- package/dist/types/image-pattern.d.ts +3 -0
- package/dist/types/image-pattern.d.ts.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/qr.d.ts +35 -0
- package/dist/types/qr.d.ts.map +1 -0
- package/dist/types/template.d.ts +34 -0
- package/dist/types/template.d.ts.map +1 -0
- package/package.json +51 -0
- package/src/api.tsx +85 -0
- package/src/codegen.ts +1043 -0
- package/src/constants.ts +26 -0
- package/src/corner-dot.tsx +101 -0
- package/src/corner-eye.ts +165 -0
- package/src/detection.ts +266 -0
- package/src/download.tsx +235 -0
- package/src/helpers.ts +59 -0
- package/src/index.tsx +306 -0
- package/src/qr-code.tsx +116 -0
- package/src/template/arrow.tsx +39 -0
- package/src/template/default.tsx +26 -0
- package/src/template/halloween.tsx +146 -0
- package/src/template/index.ts +6 -0
- package/src/template/square-border.tsx +42 -0
- package/src/template/standard-box.tsx +42 -0
- package/src/template/striked-box.tsx +41 -0
- package/src/templates.tsx +32 -0
- package/src/utils.tsx +750 -0
- package/types/common.ts +4 -0
- package/types/corner-dot.ts +13 -0
- package/types/corner-eye.ts +13 -0
- package/types/image-pattern.ts +12 -0
- package/types/index.ts +16 -0
- package/types/qr.ts +41 -0
- package/types/template.ts +41 -0
package/types/common.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const CORNER_EYE_DOT_PATTERNS = [
|
|
2
|
+
"square",
|
|
3
|
+
"rounded-square",
|
|
4
|
+
"circle",
|
|
5
|
+
"rounded-inward",
|
|
6
|
+
"rounded-inward-flipped",
|
|
7
|
+
"semi-round",
|
|
8
|
+
"leaf",
|
|
9
|
+
"diamond",
|
|
10
|
+
"diamond-rounded",
|
|
11
|
+
] as const;
|
|
12
|
+
|
|
13
|
+
export type CornerEyeDotPattern = (typeof CORNER_EYE_DOT_PATTERNS)[number];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const CORNER_EYE_PATTERNS = [
|
|
2
|
+
"square",
|
|
3
|
+
"rounded",
|
|
4
|
+
"rounded-inward",
|
|
5
|
+
"rounded-inward-flipped",
|
|
6
|
+
"gear",
|
|
7
|
+
"semi-round",
|
|
8
|
+
"rounded-extra",
|
|
9
|
+
"rounded-square",
|
|
10
|
+
"circle",
|
|
11
|
+
] as const;
|
|
12
|
+
|
|
13
|
+
export type CornerEyePattern = (typeof CORNER_EYE_PATTERNS)[number];
|
package/types/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Re-export all types from domain files
|
|
2
|
+
|
|
3
|
+
export type { Excavation, Modules } from "./common";
|
|
4
|
+
export type { CornerEyeDotPattern } from "./corner-dot";
|
|
5
|
+
export { CORNER_EYE_DOT_PATTERNS } from "./corner-dot";
|
|
6
|
+
export type { CornerEyePattern } from "./corner-eye";
|
|
7
|
+
export { CORNER_EYE_PATTERNS } from "./corner-eye";
|
|
8
|
+
export type { BodyPattern } from "./image-pattern";
|
|
9
|
+
export { BODY_PATTERN } from "./image-pattern";
|
|
10
|
+
export type {
|
|
11
|
+
ImageSettings,
|
|
12
|
+
QRProps,
|
|
13
|
+
QRPropsCanvas,
|
|
14
|
+
QRPropsSVG,
|
|
15
|
+
} from "./qr";
|
|
16
|
+
export type { BaseTemplateProps, TemplateConfig, TemplateDefinition } from "./template";
|
package/types/qr.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
import type { CornerEyeDotPattern } from "./corner-dot";
|
|
3
|
+
import type { CornerEyePattern } from "./corner-eye";
|
|
4
|
+
import type { BodyPattern } from "./image-pattern";
|
|
5
|
+
import type { TemplateDefinition } from "./template";
|
|
6
|
+
|
|
7
|
+
export type ImageSettings = {
|
|
8
|
+
src: string;
|
|
9
|
+
height: number;
|
|
10
|
+
width: number;
|
|
11
|
+
excavate: boolean;
|
|
12
|
+
x?: number;
|
|
13
|
+
y?: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type QRProps = {
|
|
17
|
+
value: string;
|
|
18
|
+
size?: number;
|
|
19
|
+
level?: string;
|
|
20
|
+
bgColor?: string;
|
|
21
|
+
fgColor?: string;
|
|
22
|
+
eyeColor?: string;
|
|
23
|
+
dotColor?: string;
|
|
24
|
+
bodyPattern?: BodyPattern;
|
|
25
|
+
cornerEyePattern?: CornerEyePattern;
|
|
26
|
+
cornerEyeDotPattern?: CornerEyeDotPattern;
|
|
27
|
+
margin?: number;
|
|
28
|
+
style?: CSSProperties;
|
|
29
|
+
imageSettings?: ImageSettings;
|
|
30
|
+
isOGContext?: boolean;
|
|
31
|
+
templateId?: string;
|
|
32
|
+
// Custom template definition - if provided, this will be used instead of looking up by templateId
|
|
33
|
+
customTemplate?: TemplateDefinition<any>;
|
|
34
|
+
// Generic custom props that can be used by any template
|
|
35
|
+
// Each template can define its own custom props type (e.g., FlamQRProps)
|
|
36
|
+
customProps?: Record<string, any>;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type QRPropsCanvas = QRProps &
|
|
40
|
+
React.CanvasHTMLAttributes<HTMLCanvasElement>;
|
|
41
|
+
export type QRPropsSVG = QRProps & React.SVGProps<SVGSVGElement>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Base props that all templates support
|
|
2
|
+
export type BaseTemplateProps = {
|
|
3
|
+
fgColor?: string;
|
|
4
|
+
bgColor?: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Configuration object passed to template wrappers containing all QR code metadata.
|
|
9
|
+
* All dimension values are in the template coordinate space (typically 300x300).
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* wrapper: (children, config, props) => {
|
|
14
|
+
* // Use pixelSize to calculate decorative element sizes
|
|
15
|
+
* const decorativeRadius = config.pixelSize * 0.5;
|
|
16
|
+
*
|
|
17
|
+
* // Use qrSize to determine QR complexity
|
|
18
|
+
* if (config.qrSize > 40) {
|
|
19
|
+
* // Adjust template for high-density QR codes
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* return <svg>...</svg>;
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export type TemplateConfig = {
|
|
27
|
+
pixelSize: number; // Calculated pixel size per QR module
|
|
28
|
+
url: string; // The URL/value used to generate the QR code
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// Generic template definition that allows custom props
|
|
32
|
+
export type TemplateDefinition<TCustomProps = Record<string, never>> = {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
wrapper: (
|
|
37
|
+
children: React.ReactNode,
|
|
38
|
+
props?: BaseTemplateProps & TCustomProps,
|
|
39
|
+
templateConfig?: TemplateConfig
|
|
40
|
+
) => React.ReactNode;
|
|
41
|
+
};
|