thermalkit 0.1.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.
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Shared types for the public API.
3
+ */
4
+ export type FontFamily = string;
5
+ export type Align = 'left' | 'center' | 'right';
6
+ export interface TextOptions {
7
+ /** X coordinate, or shorthand for alignment relative to the content area. */
8
+ x?: number;
9
+ /** Override Y (default: current cursor). */
10
+ y?: number;
11
+ /** Text anchor — overrides the alignment derived from `x`. */
12
+ anchor?: 'start' | 'middle' | 'end';
13
+ /** Font family stack. Common shorthands: `'georgia'`, `'helvetica'`, `'mono'`. */
14
+ family?: FontFamily;
15
+ /** Font size in pixels. Default 14. */
16
+ size?: number;
17
+ /** Numeric font weight (100..900). Default 400. */
18
+ weight?: number;
19
+ /** `'italic'` or `'oblique'`. */
20
+ style?: 'normal' | 'italic' | 'oblique';
21
+ /** Letter-spacing in pixels. */
22
+ spacing?: number;
23
+ /** Fill colour. Defaults to black; usually no reason to change. */
24
+ fill?: string;
25
+ }
26
+ export interface IconOptions {
27
+ /** Override X coordinate (default: page padding). */
28
+ x?: number;
29
+ /** Y offset from the current cursor (default 0). Use negative values to align an icon with text. */
30
+ dy?: number;
31
+ /** Fill colour. Defaults to black. */
32
+ fill?: string;
33
+ }
34
+ export interface RuleOptions {
35
+ /** Override start X. */
36
+ x1?: number;
37
+ /** Override end X. */
38
+ x2?: number;
39
+ /** Stroke width in pixels. Default 1. */
40
+ stroke?: number;
41
+ /** Dash pattern (e.g. `'4,2'` for dashed). */
42
+ dasharray?: string;
43
+ }
44
+ export interface RowOptions {
45
+ /** Horizontal gap between row items (defaults to 0). */
46
+ gap?: number;
47
+ /** How much to advance the cursor after the row (default: nothing — caller advances). */
48
+ advance?: number;
49
+ }
50
+ export interface ImageOptions {
51
+ /** X coordinate (default: page padding). */
52
+ x?: number;
53
+ /** Y coordinate (default: current cursor). */
54
+ y?: number;
55
+ /** Width override. Defaults to the PNG's native width. */
56
+ width?: number;
57
+ /** Height override. Defaults to the PNG's native height. */
58
+ height?: number;
59
+ }
60
+ export interface PageOptions {
61
+ /** Output width in pixels. Default 504 (TM-T88VI printable area at 180 dpi). Must be a multiple of 8. */
62
+ width?: number;
63
+ /** Horizontal padding around the content area. Default 22. */
64
+ padding?: number;
65
+ /** Map of icon name → inner SVG string, OR a list of names to load from Phosphor. */
66
+ icons?: string[] | Record<string, string>;
67
+ /** Default font family stack used by `text()` when no family is given. */
68
+ defaultFontFamily?: FontFamily;
69
+ }
70
+ export interface RenderOptions {
71
+ /** Sharp rasterisation density (DPI). Default 240. */
72
+ density?: number;
73
+ /** Output width in pixels (default: page.width). */
74
+ width?: number;
75
+ /** Threshold for 1-bit conversion (0..255). Default 140. */
76
+ threshold?: number;
77
+ }
78
+ export type DitherAlgorithm = 'atkinson' | 'fs' | 'bayer' | 'none';
79
+ export interface PosterOptions {
80
+ /** Target display width in pixels (default 100). */
81
+ width?: number;
82
+ /** Dithering algorithm. Default `'atkinson'`. */
83
+ dither?: DitherAlgorithm;
84
+ /** Local-contrast boost. `'clahe'` works best for posters; `'normalize'` only stretches the global range. */
85
+ contrast?: 'clahe' | 'normalize' | 'none';
86
+ /** User-Agent header for the download request. */
87
+ userAgent?: string;
88
+ }
89
+ export interface PreparedImage {
90
+ /** PNG bytes (greyscale, exactly 0/255 pixels for dithered output). */
91
+ data: Buffer;
92
+ width: number;
93
+ height: number;
94
+ }
95
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAChC,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEhD,MAAM,WAAW,WAAW;IAC1B,6EAA6E;IAC7E,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,4CAA4C;IA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AW,WAAW;IAC1B,yGAAyG;IACzG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qFAAqF;IACrF,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,0EAA0E;IAC1E,iBAAiB,CAAC,EAAE,UAAU,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC5B,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,IAAI,GAAG,OAAO,GAAG,MAAM,CAAC;AAEnE,MAAM,WAAW,aAAa;IAC5B,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,6GAA6G;IAC7G,QAAQ,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,MAAM,CAAC;IAC1C,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB"}
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "thermalkit",
3
+ "version": "0.1.0",
4
+ "description": "Compose nicely-typeset images for thermal receipt printers (Epson TM-T88VI and friends).",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./printer": {
14
+ "types": "./dist/printer.d.ts",
15
+ "import": "./dist/printer.js"
16
+ },
17
+ "./icons": {
18
+ "types": "./dist/icons.d.ts",
19
+ "import": "./dist/icons.js"
20
+ },
21
+ "./dither": {
22
+ "types": "./dist/dither.d.ts",
23
+ "import": "./dist/dither.js"
24
+ }
25
+ },
26
+ "files": [
27
+ "dist/",
28
+ "README.md",
29
+ "LICENSE"
30
+ ],
31
+ "scripts": {
32
+ "build": "rolldown -c rolldown.config.ts && tsc --emitDeclarationOnly -p tsconfig.build.json",
33
+ "dev": "rolldown -c rolldown.config.ts --watch",
34
+ "typecheck": "tsc --noEmit",
35
+ "prepublishOnly": "npm run build"
36
+ },
37
+ "keywords": [
38
+ "thermal-printer",
39
+ "escpos",
40
+ "epson",
41
+ "receipt",
42
+ "image",
43
+ "halftone",
44
+ "dithering",
45
+ "atkinson",
46
+ "phosphor-icons"
47
+ ],
48
+ "author": "NTag",
49
+ "license": "MIT",
50
+ "homepage": "https://github.com/NTag/thermalkit#readme",
51
+ "bugs": {
52
+ "url": "https://github.com/NTag/thermalkit/issues"
53
+ },
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "git+https://github.com/NTag/thermalkit.git"
57
+ },
58
+ "engines": {
59
+ "node": ">=20"
60
+ },
61
+ "publishConfig": {
62
+ "access": "public"
63
+ },
64
+ "dependencies": {
65
+ "@phosphor-icons/core": "^2.1.1",
66
+ "node-thermal-printer": "^4.6.0",
67
+ "sharp": "^0.34.0"
68
+ },
69
+ "devDependencies": {
70
+ "@types/node": "^25.9.1",
71
+ "rolldown": "^1.0.0-beta.21",
72
+ "typescript": "^5.5.0"
73
+ }
74
+ }