qr-code-styling-node 1.11.0 → 1.13.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.
- package/README.md +54 -1
- package/lib/core/QRCanvas.d.ts +1 -0
- package/lib/core/QRSVG.d.ts +3 -0
- package/lib/figures/shapes.d.ts +19 -0
- package/lib/qr-code-styling.common.js +1 -1
- package/lib/qr-code-styling.common.js.map +1 -1
- package/lib/qr-code-styling.js +1 -1
- package/lib/qr-code-styling.js.map +1 -1
- package/lib/qr-code-styling.mjs +399 -104
- package/lib/qr-code-styling.mjs.map +4 -4
- package/lib/tools/cornerTypes.d.ts +0 -1
- package/lib/tools/pathRecorder.d.ts +15 -0
- package/lib/tools/plugins.d.ts +7 -0
- package/lib/types/index.d.ts +42 -1
- package/package.json +3 -2
|
@@ -2,7 +2,6 @@ import { RequiredOptions } from "../core/QROptions";
|
|
|
2
2
|
import { CornerDotType, CornerSquareType, DotType } from "../types";
|
|
3
3
|
/** Dot types with a round look; blend art matches its corners and correction dots to them. */
|
|
4
4
|
export declare const ROUND_DOT_TYPES: DotType[];
|
|
5
|
-
/** True when alignment patterns must be drawn as plain squares for this dot type to scan. */
|
|
6
5
|
export declare const needsSolidAlignment: (type: DotType) => boolean;
|
|
7
6
|
export default function getCornerTypes(options: RequiredOptions): {
|
|
8
7
|
square?: CornerSquareType;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default class PathRecorder {
|
|
2
|
+
private _m;
|
|
3
|
+
private _parts;
|
|
4
|
+
private _open;
|
|
5
|
+
get d(): string;
|
|
6
|
+
beginPath(): void;
|
|
7
|
+
translate(x: number, y: number): void;
|
|
8
|
+
rotate(angle: number): void;
|
|
9
|
+
private _point;
|
|
10
|
+
moveTo(x: number, y: number): void;
|
|
11
|
+
lineTo(x: number, y: number): void;
|
|
12
|
+
closePath(): void;
|
|
13
|
+
rect(x: number, y: number, width: number, height: number): void;
|
|
14
|
+
arc(cx: number, cy: number, r: number, start: number, end: number, anticlockwise?: boolean): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RequiredOptions } from "../core/QROptions";
|
|
2
|
+
import { PluginArea, PluginDrawContext } from "../types";
|
|
3
|
+
/** Lets each plugin's configure() adjust the options, in order. */
|
|
4
|
+
export declare function configurePlugins(options: RequiredOptions): RequiredOptions;
|
|
5
|
+
/** Where the code is drawn in the output, frames included. */
|
|
6
|
+
export declare function getPluginArea(options: RequiredOptions, count: number): PluginArea;
|
|
7
|
+
export declare function runAfterDraw(options: RequiredOptions, draw: Omit<PluginDrawContext, "options">): Promise<void>;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface UnknownObject {
|
|
2
2
|
[key: string]: any;
|
|
3
3
|
}
|
|
4
|
-
export type DotType = "dots" | "rounded" | "classy" | "classy-rounded" | "square" | "extra-rounded" | "diamond" | "small-square" | "vertical-lines" | "horizontal-lines" | "fluid";
|
|
4
|
+
export type DotType = "dots" | "rounded" | "classy" | "classy-rounded" | "square" | "extra-rounded" | "diamond" | "small-square" | "vertical-lines" | "horizontal-lines" | "fluid" | "wave" | "blob" | "circuit";
|
|
5
5
|
export type CornerDotType = "dot" | "square" | "rounded";
|
|
6
6
|
export type CornerSquareType = "dot" | "square" | "extra-rounded" | "rounded";
|
|
7
7
|
export type Extension = "svg" | "png" | "jpeg" | "webp";
|
|
@@ -161,6 +161,13 @@ export type Options = {
|
|
|
161
161
|
* filled with decorative dots in the same style; the background becomes a circle. Default "square".
|
|
162
162
|
*/
|
|
163
163
|
shape?: ShapeType;
|
|
164
|
+
/** SVG output only. */
|
|
165
|
+
/** Plugins that adjust options and draw on top of the code. See QRPlugin. */
|
|
166
|
+
plugins?: QRPlugin[];
|
|
167
|
+
svgOptions?: {
|
|
168
|
+
/** Draw all dots as one path instead of one element per module: smaller files, faster rendering. Default false. */
|
|
169
|
+
mergePaths?: boolean;
|
|
170
|
+
};
|
|
164
171
|
width?: number;
|
|
165
172
|
height?: number;
|
|
166
173
|
margin?: number;
|
|
@@ -255,4 +262,38 @@ export type RotateFigureArgsCanvas = RotateFigureArgs & {
|
|
|
255
262
|
context: CanvasRenderingContext2D;
|
|
256
263
|
};
|
|
257
264
|
export type GetNeighbor = (x: number, y: number) => boolean;
|
|
265
|
+
/** Where the code (without margin and frame) is drawn in the output, in pixels. */
|
|
266
|
+
export interface PluginArea {
|
|
267
|
+
x: number;
|
|
268
|
+
y: number;
|
|
269
|
+
/** Width and height of the code. */
|
|
270
|
+
size: number;
|
|
271
|
+
/** Size of one module. */
|
|
272
|
+
dotSize: number;
|
|
273
|
+
/** Modules across. */
|
|
274
|
+
count: number;
|
|
275
|
+
}
|
|
276
|
+
export interface PluginDrawContext {
|
|
277
|
+
type: DrawType;
|
|
278
|
+
options: Options;
|
|
279
|
+
area: PluginArea;
|
|
280
|
+
width: number;
|
|
281
|
+
height: number;
|
|
282
|
+
/** Canvas output: the 2D context to draw on. */
|
|
283
|
+
context?: CanvasRenderingContext2D;
|
|
284
|
+
/** SVG output: the root <svg> element, and the document to create elements with. */
|
|
285
|
+
svg?: SVGElement;
|
|
286
|
+
document?: Document;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* A plugin. Both hooks are optional.
|
|
290
|
+
* - configure(options): return option changes to merge in before drawing (called again on every update, so
|
|
291
|
+
* return the same changes for the same options).
|
|
292
|
+
* - afterDraw(draw): draw extra things on top, on the canvas context or into the SVG.
|
|
293
|
+
*/
|
|
294
|
+
export interface QRPlugin {
|
|
295
|
+
name?: string;
|
|
296
|
+
configure?: (options: Options) => Partial<Options> | void;
|
|
297
|
+
afterDraw?: (draw: PluginDrawContext) => void | Promise<void>;
|
|
298
|
+
}
|
|
258
299
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qr-code-styling-node",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "Style your QR codes: dots, corners, gradients and a logo. Works in the browser and on Node.js.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"qr",
|
|
@@ -74,7 +74,8 @@
|
|
|
74
74
|
"art-examples": "npm run build && node scripts/art-examples.mjs",
|
|
75
75
|
"style-examples": "npm run build && node scripts/style-examples.mjs",
|
|
76
76
|
"blend-examples": "npm run build && node scripts/blend-examples.mjs",
|
|
77
|
-
"circle-examples": "npm run build && node scripts/circle-examples.mjs"
|
|
77
|
+
"circle-examples": "npm run build && node scripts/circle-examples.mjs",
|
|
78
|
+
"dot-examples": "npm run build && node scripts/dot-examples.mjs"
|
|
78
79
|
},
|
|
79
80
|
"dependencies": {
|
|
80
81
|
"qrcode-generator": "^1.4.3"
|