### Install Dependencies with pnpm Source: https://github.com/productdevbook/etiket/blob/main/README.md Use this command to install all project dependencies required for development and testing. ```bash pnpm install ``` -------------------------------- ### Install etiket Source: https://github.com/productdevbook/etiket/blob/main/README.md Install the package via npm. ```sh npm install etiket ``` -------------------------------- ### Run Development Server with pnpm Source: https://github.com/productdevbook/etiket/blob/main/README.md Execute this command to start the development server, which typically includes tests that run in watch mode. ```bash pnpm dev ``` -------------------------------- ### Install Etiket with Package Managers Source: https://github.com/productdevbook/etiket/blob/main/docs/getting-started/installation.md Use the command corresponding to your preferred package manager (npm, pnpm, yarn, or bun) to install the etiket package. ```sh # npm npm install etiket ``` ```sh # pnpm pnpm add etiket ``` ```sh # yarn yarn add etiket ``` ```sh # bun bun add etiket ``` -------------------------------- ### Generate Barcodes with Etiket Source: https://github.com/productdevbook/etiket/blob/main/README.md Examples of generating different barcode types including Code 128, EAN-13, ITF-14, GS1-128, and Code 39. ```ts import { barcode } from "etiket"; barcode("Hello World"); // Code 128 (default) barcode("4006381333931", { type: "ean13", showText: true }); barcode("00012345678905", { type: "itf14", bearerBars: true }); barcode("(01)12345678901234(17)260101", { type: "gs1-128" }); barcode("HELLO", { type: "code39", code39CheckDigit: true }); ``` -------------------------------- ### Generate Codabar Barcodes Source: https://github.com/productdevbook/etiket/blob/main/docs/barcodes/codabar.md Use the barcode function to generate barcodes with default or custom start and stop characters. ```ts import { barcode } from "etiket"; barcode("12345", { type: "codabar" }); // Custom start/stop characters (A, B, C, or D) barcode("12345", { type: "codabar", codabarStart: "A", codabarStop: "B" }); ``` -------------------------------- ### Vue QR Code and Barcode Integration Source: https://github.com/productdevbook/etiket/blob/main/docs/getting-started/frameworks.md Generate QR codes and barcodes within a Vue 3 ` ``` -------------------------------- ### Encode Code 93 Data Directly Source: https://github.com/productdevbook/etiket/blob/main/docs/barcodes/code93.md Utilize `encodeCode93` for standard encoding or `encodeCode93Extended` for full ASCII support to get the raw bar data. Import these specific encoder functions from 'etiket'. ```typescript import { encodeCode93, encodeCode93Extended } from "etiket"; const bars = encodeCode93("TEST"); const extBars = encodeCode93Extended("hello"); ``` -------------------------------- ### Build for Production with pnpm Source: https://github.com/productdevbook/etiket/blob/main/README.md Use this command to create a production-ready build of the library. ```bash pnpm build ``` -------------------------------- ### Build and Script Commands Source: https://github.com/productdevbook/etiket/blob/main/AGENTS.md These commands are used for building the project, running tests, linting, formatting, and managing releases. ```bash pnpm build # obuild (rolldown) ``` ```bash pnpm dev # vitest watch ``` ```bash pnpm lint # oxlint + oxfmt --check ``` ```bash pnpm lint:fix # oxlint --fix + oxfmt ``` ```bash pnpm fmt # oxfmt ``` ```bash pnpm test # pnpm lint && pnpm typecheck && vitest run ``` ```bash pnpm typecheck # tsgo --noEmit ``` ```bash pnpm release # pnpm test && pnpm build && changelogen --release && npm publish && git push --follow-tags ``` ```bash pnpm docs:dev # npx mdzilla ./docs ``` -------------------------------- ### Encode Code 11 Raw Data Source: https://github.com/productdevbook/etiket/blob/main/docs/barcodes/code11.md Utilize the `encodeCode11` function to get the raw bar data for a Code 11 barcode. This is useful for custom rendering or integration with other systems. ```typescript import { encodeCode11 } from "etiket"; const bars = encodeCode11("123-456"); ``` -------------------------------- ### Use etiket CLI Source: https://github.com/productdevbook/etiket/blob/main/README.md Generate various barcode formats directly from the command line. ```sh npx etiket qr "Hello World" -o qr.svg npx etiket qr "Hello" --terminal npx etiket qr "Hello" --size 300 --ec H --dot-type dots npx etiket barcode "4006381333931" --type ean13 --show-text -o barcode.svg npx etiket datamatrix "Hello" -o dm.svg npx etiket pdf417 "Hello" -o pdf.svg npx etiket aztec "Hello" -o aztec.svg npx etiket wifi "MyNetwork" "secret123" -o wifi.svg ``` -------------------------------- ### Testing Commands Source: https://github.com/productdevbook/etiket/blob/main/AGENTS.md Commands for running tests, including all tests or a single test file. ```bash pnpm test ``` ```bash pnpm vitest run test/.test.ts ``` -------------------------------- ### Run Lint, Typecheck, and Tests with pnpm Source: https://github.com/productdevbook/etiket/blob/main/README.md This command performs a full suite of checks including linting, type checking, and running all tests. ```bash pnpm test ``` -------------------------------- ### Configure Project for ESM Source: https://github.com/productdevbook/etiket/blob/main/docs/getting-started/installation.md Set the "type" field to "module" in your package.json file to enable ESM support, which is required by etiket. ```json { "type": "module" } ``` -------------------------------- ### Generate Barcodes via CLI Source: https://context7.com/productdevbook/etiket/llms.txt Execute barcode and QR code generation directly from the terminal using npx. ```bash # Generate QR code npx etiket qr "Hello World" -o qr.svg npx etiket qr "Hello" --terminal npx etiket qr "Hello" --size 300 --ec H --dot-type dots # Generate 1D barcode npx etiket barcode "4006381333931" --type ean13 --show-text -o barcode.svg npx etiket barcode "Hello" --type code128 --height 100 # Generate 2D codes npx etiket datamatrix "Hello" -o dm.svg npx etiket pdf417 "Hello" --ec-level 4 -o pdf.svg npx etiket aztec "Hello" --ec-percent 33 -o aztec.svg # Generate WiFi QR code npx etiket wifi "MyNetwork" "password123" -o wifi.svg ``` -------------------------------- ### Generate WiFi Connection QR Codes Source: https://context7.com/productdevbook/etiket/llms.txt Create QR codes that allow users to automatically connect to WiFi networks, supporting WPA, WEP, and open network configurations. ```typescript import { wifi } from "etiket"; // Basic WiFi QR code (WPA encryption default) const wifiQR = wifi("MyNetwork", "password123"); // WiFi with WEP encryption const wepWifi = wifi("OldNetwork", "wepkey", { encryption: "WEP", }); // Open network (no password) const openWifi = wifi("PublicNetwork", "", { encryption: "nopass", }); // Hidden network const hiddenWifi = wifi("HiddenNetwork", "secret", { hidden: true, size: 300, ecLevel: "H", }); ``` -------------------------------- ### Optimize Bundle Size with Tree Shaking Source: https://github.com/productdevbook/etiket/blob/main/docs/getting-started/quick-start.md Import specific modules directly to reduce the final bundle size when only specific barcode types are required. ```ts import { barcode } from "etiket/barcode"; // 1D barcodes only import { qrcode } from "etiket/qr"; // QR codes only import { datamatrix } from "etiket/datamatrix"; import { pdf417 } from "etiket/pdf417"; import { aztec } from "etiket/aztec"; ``` -------------------------------- ### qrcode(data, options) Source: https://github.com/productdevbook/etiket/blob/main/docs/qr-code/index.md Generates a QR code based on the provided data and configuration options. ```APIDOC ## qrcode(data, options) ### Description Generates a QR code from the provided string data. The library automatically detects the optimal encoding mode and version, but these can be overridden via options. ### Parameters #### Request Body - **data** (string) - Required - The content to encode into the QR code. - **options** (object) - Optional - Configuration object: - **size** (number) - Optional - Dimensions of the QR code. - **ecLevel** (string) - Optional - Error correction level: 'L' (7%), 'M' (15%), 'Q' (25%), 'H' (30%). - **mode** (string) - Optional - Encoding mode: 'numeric', 'alphanumeric', 'byte', or 'auto'. - **version** (number) - Optional - QR code version from 1 to 40. - **mask** (number) - Optional - Mask pattern from 0 to 7. ### Request Example qrcode("Hello World", { size: 300, ecLevel: "H", mode: "byte" }); ``` -------------------------------- ### Convenience Helpers Source: https://github.com/productdevbook/etiket/blob/main/README.md Helper functions for generating specialized QR codes for common use cases like WiFi, email, SMS, and calendar events. ```APIDOC ## Convenience Helpers ### Description Functions to generate QR codes for specific data types. ### Methods - **wifi(ssid, password)** - Generates a WiFi connection QR. - **email(address)** - Generates a mailto QR. - **sms(number, message)** - Generates an SMS QR. - **geo(lat, lon)** - Generates a location QR. - **vcard(data)** - Generates a vCard QR. - **event(data)** - Generates a calendar event QR. ``` -------------------------------- ### Generate Barcode and QR Code with etiket Source: https://github.com/productdevbook/etiket/blob/main/docs/index.md Import `barcode` and `qrcode` functions to generate a Code 128 barcode and a styled QR code. The QR code can be customized with size, error correction level, dot type, and color. ```typescript import { barcode, qrcode } from "etiket"; // Code 128 barcode const svg = barcode("Hello World"); // Styled QR code const qr = qrcode("https://example.com", { size: 300, ecLevel: "H", dotType: "dots", color: "#1a1a2e", }); ``` -------------------------------- ### Optimize Bundle Size with Tree-Shakeable Imports Source: https://context7.com/productdevbook/etiket/llms.txt Import specific sub-modules to reduce the final bundle size by including only necessary functionality. ```typescript // Import only barcode functionality (~8KB) import { barcode, barcodeDataURI, encodeCode128 } from "etiket/barcode"; // Import only QR code functionality (~12KB) import { qrcode, qrcodeDataURI, qrcodeTerminal } from "etiket/qr"; // Import only Data Matrix (~6KB) import { datamatrix, gs1datamatrix } from "etiket/datamatrix"; // Import only PDF417 (~4KB) import { pdf417 } from "etiket/pdf417"; // Import only Aztec (~4KB) import { aztec } from "etiket/aztec"; // Import only PNG output (~3KB) import { barcodePNG, qrcodePNG } from "etiket/png"; ``` -------------------------------- ### Utilize Different Output Formats Source: https://github.com/productdevbook/etiket/blob/main/docs/getting-started/quick-start.md Generate output as SVG strings, Data URIs, Base64 encoded strings, or terminal-friendly Unicode blocks. ```ts import { barcode, qrcode, barcodeDataURI, qrcodeDataURI, barcodeBase64, qrcodeBase64, qrcodeTerminal, } from "etiket"; // SVG string (default) const svg = qrcode("Hello"); // Data URI — use in const uri = qrcodeDataURI("Hello"); // Base64 encoded SVG const b64 = qrcodeBase64("Hello"); // Terminal output with Unicode blocks const terminal = qrcodeTerminal("Hello"); console.log(terminal); ``` -------------------------------- ### Generate Swiss QR-bill Source: https://context7.com/productdevbook/etiket/llms.txt Creates a Swiss QR-bill payment code with required creditor, debtor, and reference details. ```typescript import { swissQR } from "etiket"; // Swiss QR-bill payment code const swissPayment = swissQR({ iban: "CH4431999123000889012", creditor: { name: "Max Muster", street: "Musterstrasse", houseNumber: "1", postalCode: "8000", city: "Zürich", country: "CH", }, amount: 1949.75, currency: "CHF", reference: "210000000003139471430009017", referenceType: "QRR", debtor: { name: "Simon Sample", postalCode: "3000", city: "Bern", country: "CH", }, additionalInfo: "Invoice 12345", }); ``` -------------------------------- ### Generate Barcodes and QR Codes Programmatically Source: https://github.com/productdevbook/etiket/blob/main/README.md Basic usage for generating barcode and QR code strings. ```ts import { barcode, qrcode } from "etiket"; const svg = barcode("Hello World"); const qr = qrcode("https://example.com", { dotType: "dots", ecLevel: "H" }); ``` -------------------------------- ### Use Convenience Helpers for Specialized QR Codes Source: https://github.com/productdevbook/etiket/blob/main/README.md Generate QR codes for common use cases like WiFi, contact information, and calendar events. ```ts import { wifi, email, sms, geo, url, phone, vcard, mecard, event } from "etiket"; wifi("MyNetwork", "password123"); // WiFi QR email("test@example.com"); // mailto: QR sms("+1234567890", "Hello!"); // SMS QR geo(37.7749, -122.4194); // Location QR url("https://example.com"); // URL QR phone("+1234567890"); // tel: QR // vCard QR vcard({ firstName: "John", lastName: "Doe", phone: "+1234567890", email: "john@example.com", org: "Acme Inc", }); // MeCard QR (simpler, used by Android) mecard({ name: "John Doe", phone: "+1234567890", email: "john@example.com" }); // Calendar event QR event({ title: "Meeting", start: "2026-04-01T10:00:00", end: "2026-04-01T11:00:00", location: "Office", }); ``` -------------------------------- ### barcode() Source: https://github.com/productdevbook/etiket/blob/main/docs/barcodes/msi.md Generates an MSI Plessey barcode with configurable check digit algorithms. ```APIDOC ## barcode(data, options) ### Description Generates an MSI Plessey barcode string based on the provided input data and check digit configuration. ### Parameters #### Request Body - **data** (string) - Required - The numeric string to encode. - **options** (object) - Required - Configuration object. - **type** (string) - Required - Must be set to "msi". - **msiCheckDigit** (string) - Optional - The algorithm to use: "mod10" (default), "mod11", "mod1010", "mod1110", or "none". ### Request Example { "data": "12345", "options": { "type": "msi", "msiCheckDigit": "mod10" } } ``` -------------------------------- ### Tree-shakable Imports Source: https://github.com/productdevbook/etiket/blob/main/README.md Import specific modules to reduce bundle size. ```ts import { barcode, barcodeDataURI, barcodeBase64 } from "etiket/barcode"; import { qrcode, qrcodeDataURI, qrcodeBase64, qrcodeTerminal } from "etiket/qr"; import { datamatrix, gs1datamatrix } from "etiket/datamatrix"; import { pdf417 } from "etiket/pdf417"; import { aztec } from "etiket/aztec"; import { barcodePNG, qrcodePNG } from "etiket/png"; // PNG output ``` -------------------------------- ### Generate QR Codes Source: https://context7.com/productdevbook/etiket/llms.txt Create customizable QR codes with support for gradients, dot styling, and corner shapes. Includes helpers for terminal output and data URI formats. ```typescript import { qrcode, qrcodeTerminal, qrcodeDataURI, qrcodeBase64 } from "etiket"; // Basic QR code const qr = qrcode("https://example.com"); // Styled QR code with custom options const styledQR = qrcode("Hello World", { size: 300, ecLevel: "H", dotType: "rounded", color: "#000000", background: "#ffffff", margin: 4, }); // QR code with gradient const gradientQR = qrcode("Test", { color: { type: "linear", rotation: 45, stops: [ { offset: 0, color: "#ff0000" }, { offset: 1, color: "#0000ff" }, ], }, }); // QR code with corner styling const corneredQR = qrcode("Test", { dotType: "dots", corners: { topLeft: { outerShape: "rounded", innerShape: "dots", outerColor: "#ff0000" }, topRight: { outerShape: "extra-rounded" }, bottomLeft: { outerShape: "dots" }, }, }); // Terminal output for CLI const terminal = qrcodeTerminal("Hello"); // Data URI and Base64 formats const dataUri = qrcodeDataURI("Hello"); const base64 = qrcodeBase64("Hello"); ``` -------------------------------- ### Basic QR Code Generation Source: https://github.com/productdevbook/etiket/blob/main/docs/qr-code/index.md Generate QR codes using default settings or custom sizes. ```ts import { qrcode } from "etiket"; qrcode("https://example.com"); qrcode("Hello World", { size: 300 }); ``` -------------------------------- ### QR Code Transparent Background Source: https://github.com/productdevbook/etiket/blob/main/docs/qr-code/styling.md Sets the QR code background to be transparent. This is useful for overlaying QR codes on other content. ```typescript qrcode("Hello", { background: "transparent" }); ``` -------------------------------- ### Generate QR Codes with TypeScript Source: https://github.com/productdevbook/etiket/blob/main/README.md Create QR codes with custom styling, gradients, and corner configurations. ```ts import { qrcode } from "etiket"; qrcode("https://example.com"); qrcode("Hello", { size: 300, ecLevel: "H", dotType: "rounded" }); // With gradient qrcode("Test", { color: { type: "linear", rotation: 45, stops: [ { offset: 0, color: "#ff0000" }, { offset: 1, color: "#0000ff" }, ], }, }); // With corner styling qrcode("Test", { dotType: "dots", corners: { topLeft: { outerShape: "rounded", innerShape: "dots", outerColor: "#ff0000" }, topRight: { outerShape: "extra-rounded" }, bottomLeft: { outerShape: "dots" }, }, }); ``` -------------------------------- ### Generate GS1 Digital Link Source: https://context7.com/productdevbook/etiket/llms.txt Creates GS1 Digital Link QR codes for retail products, supporting basic, full, and custom domain configurations. ```typescript import { gs1DigitalLink } from "etiket"; // Basic GS1 Digital Link const gs1Link = gs1DigitalLink({ gtin: "09520123456788", }); // Full GS1 Digital Link with batch, serial, expiry const fullGs1Link = gs1DigitalLink({ gtin: "09520123456788", batch: "ABC123", serial: "12345", expiry: "260101", weight: "1000", }); // Custom domain const customGs1Link = gs1DigitalLink( { gtin: "09520123456788" }, { domain: "https://mycompany.com" } ); ``` -------------------------------- ### Use Low-Level Renderers Source: https://github.com/productdevbook/etiket/blob/main/docs/rendering/index.md Access granular rendering functions for custom pipelines, styling, and format conversion. ```ts import { renderBarcodeSVG, renderQRCodeSVG, renderMatrixSVG, renderText, svgToDataURI, svgToBase64, svgToBase64Raw, } from "etiket"; // Custom barcode SVG const svg = renderBarcodeSVG(bars, { height: 100, barWidth: 3, color: "#333", showText: true, text: "CUSTOM", }); // Custom QR SVG with styling const qrSvg = renderQRCodeSVG(matrix, { size: 400, dotType: "dots", color: { type: "linear", rotation: 45, stops: [...] }, }); // Generic 2D matrix SVG (Data Matrix, Aztec) const matrixSvg = renderMatrixSVG(booleanMatrix, { size: 200 }); // Terminal text const text = renderText(matrix, { compact: true, margin: 2 }); // Convert any SVG const uri = svgToDataURI(svg); const b64 = svgToBase64(svg); const raw = svgToBase64Raw(svg); // No data: prefix ``` -------------------------------- ### Render Terminal Output Source: https://github.com/productdevbook/etiket/blob/main/docs/rendering/index.md Display QR codes in the terminal using Unicode half-block characters. ```ts import { qrcodeTerminal } from "etiket"; console.log(qrcodeTerminal("Hello")); ``` -------------------------------- ### Generate Contact Information QR Codes Source: https://context7.com/productdevbook/etiket/llms.txt Create vCard or MeCard formatted QR codes for easy contact sharing. ```typescript import { vcard, mecard } from "etiket"; // vCard QR code (full format) const vcardQR = vcard({ firstName: "John", lastName: "Doe", phone: "+1234567890", email: "john@example.com", org: "Acme Inc", title: "Software Engineer", url: "https://johndoe.com", address: "123 Main St, City, Country", }); // MeCard QR code (simpler format, used by Android) const mecardQR = mecard({ name: "John Doe", phone: "+1234567890", email: "john@example.com", url: "https://johndoe.com", address: "123 Main St", }); ``` -------------------------------- ### Generate Basic Barcodes and QR Codes Source: https://github.com/productdevbook/etiket/blob/main/docs/getting-started/quick-start.md Use the primary barcode and qrcode functions to generate SVG strings for your data. ```ts import { barcode, qrcode } from "etiket"; // Generate a Code 128 barcode const barcodeSvg = barcode("Hello World"); // Generate a QR code const qrSvg = qrcode("https://example.com"); ``` -------------------------------- ### Server-Side SVG File Generation Source: https://github.com/productdevbook/etiket/blob/main/docs/getting-started/frameworks.md Generate QR code and barcode SVG files directly on the server using Node.js, Bun, or Deno. Requires `node:fs` for file writing. ```ts import { writeFileSync } from "node:fs"; import { qrcode, barcode } from "etiket"; // Write SVG files writeFileSync("qr.svg", qrcode("https://example.com")); writeFileSync("barcode.svg", barcode("Hello", { showText: true })); ``` -------------------------------- ### Generate Communication QR Codes Source: https://context7.com/productdevbook/etiket/llms.txt Create QR codes for common communication actions including email, SMS, phone calls, URLs, and geographic locations. ```typescript import { email, sms, phone, url, geo } from "etiket"; // Email QR code const emailQR = email("contact@example.com"); // SMS QR code with message const smsQR = sms("+1234567890", "Hello from QR code!"); // Phone call QR code const phoneQR = phone("+1234567890"); // URL QR code const urlQR = url("https://example.com"); // Geographic location QR code const geoQR = geo(37.7749, -122.4194); ``` -------------------------------- ### Version Selection Source: https://github.com/productdevbook/etiket/blob/main/docs/qr-code/index.md Control the QR code size by selecting a specific version or allowing auto-selection. ```ts // Auto (smallest version that fits) qrcode("data"); // Force specific version qrcode("data", { version: 10 }); // 57x57 modules ``` -------------------------------- ### barcode(data, options) Source: https://github.com/productdevbook/etiket/blob/main/README.md Generates a barcode based on the provided data string and configuration options. ```APIDOC ## barcode(data, options) ### Description Generates a barcode image or SVG based on the input data and specified configuration options. ### Parameters #### Request Body - **data** (string) - Required - The content to encode into the barcode. - **options** (object) - Optional - Configuration object for barcode styling and format. - **type** (BarcodeType) - Optional - Barcode format (default: 'code128'). - **height** (number) - Optional - Bar height in pixels (default: 80). - **barWidth** (number) - Optional - Width multiplier per module (default: 2). - **color** (string) - Optional - Bar color (default: '#000'). - **background** (string) - Optional - Background color (default: '#fff'). - **showText** (boolean) - Optional - Show human-readable text (default: false). - **textPosition** ('bottom' | 'top') - Optional - Text position (default: 'bottom'). - **fontSize** (number) - Optional - Text font size (default: 14). - **fontFamily** (string) - Optional - Text font family (default: 'monospace'). - **margin** (number) - Optional - Margin around barcode (default: 10). - **marginTop** (number) - Optional - Top margin. - **marginBottom** (number) - Optional - Bottom margin. - **marginLeft** (number) - Optional - Left margin. - **marginRight** (number) - Optional - Right margin. - **textAlign** ('center' | 'left' | 'right') - Optional - Text alignment (default: 'center'). - **rotation** (0 | 90 | 180 | 270) - Optional - Barcode rotation (default: 0). - **bearerBars** (boolean) - Optional - Bearer bars for ITF-14 (default: false). - **barGap** (number) - Optional - Extra spacing between bars (default: 0). - **unit** ('px' | 'mm' | 'in' | 'cm') - Optional - Measurement unit (default: 'px'). - **ariaLabel** (string) - Optional - SVG aria-label attribute. - **title** (string) - Optional - SVG element. - **desc** (string) - Optional - SVG <desc> element. ### Request Example barcode("4006381333931", { type: "ean13", showText: true }); ``` -------------------------------- ### Handle Generated SVG Output Source: https://github.com/productdevbook/etiket/blob/main/docs/getting-started/quick-start.md Demonstrates how to inject SVG strings into the DOM, write them to files in Node.js, or convert them to data URIs. ```ts // In the browser document.getElementById("barcode").innerHTML = barcodeSvg; // In Node.js — write to file import { writeFileSync } from "node:fs"; writeFileSync("barcode.svg", barcodeSvg); // As an img src const dataUri = `data:image/svg+xml,${encodeURIComponent(barcodeSvg)}`; ``` -------------------------------- ### Generate Swiss QR-bill Source: https://github.com/productdevbook/etiket/blob/main/README.md Creates a Swiss QR-bill payment code using the swissQR function. ```ts import { swissQR } from "etiket"; swissQR({ iban: "CH4431999123000889012", creditor: { name: "Max Muster", postalCode: "8000", city: "Zürich", country: "CH" }, amount: 1949.75, currency: "CHF", reference: "210000000003139471430009017", referenceType: "QRR", }); ``` -------------------------------- ### Generate Specialized QR Codes Source: https://github.com/productdevbook/etiket/blob/main/docs/getting-started/quick-start.md Use convenience helpers to format specific data types like Wi-Fi credentials, emails, SMS, geolocation, and URLs. ```ts import { wifi, email, sms, geo, url } from "etiket"; wifi("MyNetwork", "password123"); email("hello@example.com"); sms("+1234567890", "Hello!"); geo(37.7749, -122.4194); url("https://example.com"); ``` -------------------------------- ### Validate QR Input Source: https://github.com/productdevbook/etiket/blob/main/docs/getting-started/validation.md The `validateQRInput` function checks if the provided data is suitable for encoding in a QR code, considering data length and mode. ```APIDOC ## Validate QR Input ### Description Validates input data for QR code encoding, checking for length constraints and acceptable characters based on the specified mode. ### Method `validateQRInput(data: string, mode: string): { valid: boolean, error?: string }` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```ts import { validateQRInput } from "etiket"; validateQRInput("Hello World", "M"); // → { valid: true } validateQRInput("A".repeat(10000), "H"); // → { valid: false, error: "Data too long for QR code..." } ``` ### Response #### Success Response (200) `{ valid: true }` #### Error Response `{ valid: false, error: "Error message describing the validation failure" }` #### Response Example ```json { "valid": false, "error": "Data too long for QR code..." } ``` ``` -------------------------------- ### encodeQR(data, options) Source: https://github.com/productdevbook/etiket/blob/main/docs/qr-code/index.md Generates the raw boolean matrix for a QR code without rendering it. ```APIDOC ## encodeQR(data, options) ### Description Returns the raw boolean matrix representation of a QR code, where true represents a dark module. ### Parameters #### Request Body - **data** (string) - Required - The content to encode. - **options** (object) - Optional - Configuration object including ecLevel, mode, version, and mask. ### Response #### Success Response (200) - **matrix** (boolean[][]) - A 2D array representing the QR code grid. ``` -------------------------------- ### Validate Barcode and QR Input Source: https://github.com/productdevbook/etiket/blob/main/README.md Verify the validity of barcode strings and input data before generation. ```ts import { validateBarcode, isValidInput, validateQRInput } from "etiket"; validateBarcode("4006381333931", "ean13"); // { valid: true } validateBarcode("ABC", "ean13"); // { valid: false, error: '...' } isValidInput("HELLO", "code39"); // true ``` -------------------------------- ### Generate 2D Codes with TypeScript Source: https://github.com/productdevbook/etiket/blob/main/README.md Generate DataMatrix, PDF417, and Aztec codes using specific configuration options. ```ts import { datamatrix, pdf417, aztec } from "etiket"; datamatrix("Hello World"); pdf417("Hello World", { ecLevel: 4, columns: 5 }); aztec("Hello World", { ecPercent: 33 }); ``` -------------------------------- ### Generate PDF417 Barcodes with TypeScript Source: https://context7.com/productdevbook/etiket/llms.txt Create PDF417 2D barcodes with configurable error correction levels, column counts, and visual styling. ```typescript import { pdf417 } from "etiket"; // Basic PDF417 const pdf = pdf417("Hello World"); // PDF417 with custom settings const customPdf = pdf417("Product information with lots of data", { ecLevel: 4, columns: 5, width: 400, color: "#000", background: "#fff", }); // Compact PDF417 const compactPdf = pdf417("Short text", { compact: true, columns: 3, }); ``` -------------------------------- ### QR Code Generation Source: https://github.com/productdevbook/etiket/blob/main/README.md Generate QR codes with customizable options such as size, error correction, colors, and corner styling. ```APIDOC ## qrcode(data, options) ### Description Generates a QR code string. ### Parameters #### Request Body - **data** (string) - Required - The content to encode. - **options** (object) - Optional - Configuration object including size, ecLevel, color, background, dotType, and corners. ``` -------------------------------- ### Generate Base64 Strings Source: https://github.com/productdevbook/etiket/blob/main/docs/rendering/index.md Produce Base64 encoded strings for image representation. ```ts import { barcodeBase64, qrcodeBase64 } from "etiket"; const b64 = qrcodeBase64("Hello"); // 'data:image/svg+xml;base64,...' ``` -------------------------------- ### Export Barcode and QR Code Formats Source: https://github.com/productdevbook/etiket/blob/main/README.md Generate codes in various formats including SVG strings, data URIs, base64, terminal output, and PNG buffers. ```ts import { barcode, qrcode, barcodeDataURI, qrcodeDataURI, barcodeBase64, qrcodeBase64, qrcodeTerminal, barcodePNG, qrcodePNG, barcodePNGDataURI, qrcodePNGDataURI, } from "etiket"; // SVG const svg = qrcode("Hello"); // SVG string const uri = qrcodeDataURI("Hello"); // data:image/svg+xml,... const b64 = qrcodeBase64("Hello"); // data:image/svg+xml;base64,... const term = qrcodeTerminal("Hello"); // Terminal (UTF-8 blocks) // PNG (zero-dependency raster output) const png = qrcodePNG("Hello"); // Uint8Array const pngUri = qrcodePNGDataURI("Hello"); // data:image/png;base64,... const barPng = barcodePNG("12345", { type: "code128" }); // Uint8Array ``` -------------------------------- ### Svelte QR Code and Barcode Rendering Source: https://github.com/productdevbook/etiket/blob/main/docs/getting-started/frameworks.md Dynamically generate and render QR codes and barcodes in Svelte using reactive declarations (`$:`). SVG is displayed using the `{@html}` tag. ```svelte <script lang="ts"> import { qrcode, barcode } from "etiket"; let text = "https://example.com"; $: qr = qrcode(text, { size: 200, dotType: "dots" }); $: bc = barcode("Hello", { showText: true }); </script> {@html qr} {@html bc} ``` -------------------------------- ### encodeMSI() Source: https://github.com/productdevbook/etiket/blob/main/docs/barcodes/msi.md Low-level encoder for MSI Plessey barcodes. ```APIDOC ## encodeMSI(data, options) ### Description Encodes raw data into MSI Plessey barcode format using a specific check digit algorithm. ### Parameters #### Request Body - **data** (string) - Required - The numeric string to encode. - **options** (object) - Required - Configuration object. - **checkDigit** (string) - Required - The algorithm to use: "mod10", "mod11", "mod1010", "mod1110", or "none". ### Request Example { "data": "12345", "options": { "checkDigit": "mod1010" } } ``` -------------------------------- ### Configure SVG Accessibility and Styling Source: https://github.com/productdevbook/etiket/blob/main/README.md Add accessibility attributes and theme-aware styling to generated SVG barcodes. ```ts barcode("123456789", { type: "ean13", ariaLabel: "EAN-13 barcode for product 123456789", title: "Product Barcode", desc: "EAN-13 barcode encoding the GTIN 123456789", }); qrcode("https://example.com", { ariaLabel: "QR code linking to example.com", title: "Website QR Code", }); // CSS currentColor support for theme-aware barcodes barcode("HELLO", { color: "currentColor", background: "transparent" }); ``` -------------------------------- ### Render SVG Strings Source: https://github.com/productdevbook/etiket/blob/main/docs/rendering/index.md High-level functions return SVG strings by default for barcode and QR code generation. ```ts import { barcode, qrcode, datamatrix, pdf417, aztec } from "etiket"; const svg = barcode("Hello"); // '<svg xmlns="http://www.w3.org/2000/svg" ...>...</svg>' ``` -------------------------------- ### SolidJS QR Code Component Source: https://github.com/productdevbook/etiket/blob/main/docs/getting-started/frameworks.md A SolidJS component for rendering QR codes. It generates the SVG dynamically and renders it using `innerHTML`. ```tsx import { qrcode, barcode } from "etiket"; function QRCode(props) { const svg = () => qrcode(props.text, props); return <div innerHTML={svg()} />; } ``` -------------------------------- ### React QR Code and Barcode Components Source: https://github.com/productdevbook/etiket/blob/main/docs/getting-started/frameworks.md Create reusable React components for generating QR codes and barcodes. Ensure proper import of `qrcode` and `barcode` from 'etiket'. Renders SVG directly into the DOM using `dangerouslySetInnerHTML`. ```tsx import { qrcode, barcode } from "etiket"; function QRCode({ text, ...options }) { const svg = qrcode(text, options); return <div dangerouslySetInnerHTML={{ __html: svg }} />; } function Barcode({ text, type = "code128", ...options }) { const svg = barcode(text, { type, ...options }); return <div dangerouslySetInnerHTML={{ __html: svg }} />; } // Usage export default function App() { return ( <> <QRCode text="https://example.com" size={200} dotType="dots" /> <Barcode text="Hello" showText /> </> ); } ``` -------------------------------- ### QR Code Dot Types Source: https://github.com/productdevbook/etiket/blob/main/docs/qr-code/styling.md Demonstrates various dot shapes for QR code modules. Use 'square' for default, 'rounded' for rounded corners, 'dots' for circular, 'diamond' for rotated, 'classy' and 'classy-rounded' for specific corner styles, 'extra-rounded' for fully rounded, 'vertical-line' and 'horizontal-line' for line shapes, and 'small-square'/'tiny-square' for modules with gaps. ```typescript import { qrcode } from "etiket"; qrcode("Hello", { dotType: "square" }); // Default qrcode("Hello", { dotType: "rounded" }); // Rounded corners qrcode("Hello", { dotType: "dots" }); // Circular qrcode("Hello", { dotType: "diamond" }); // 45° rotated qrcode("Hello", { dotType: "classy" }); // One rounded corner qrcode("Hello", { dotType: "classy-rounded" }); qrcode("Hello", { dotType: "extra-rounded" }); // Fully rounded qrcode("Hello", { dotType: "vertical-line" }); qrcode("Hello", { dotType: "horizontal-line" }); qrcode("Hello", { dotType: "small-square" }); // With gap qrcode("Hello", { dotType: "tiny-square" }); // Smaller with gap ``` -------------------------------- ### Generate EAN-5 Addon Barcode Source: https://github.com/productdevbook/etiket/blob/main/docs/barcodes/ean.md Use the `barcode` function with type 'ean5' for supplemental pricing information, commonly used for books. ```typescript // Price $24.95 barcode("52495", { type: "ean5" }); ``` -------------------------------- ### Generate Calendar Event QR Codes Source: https://context7.com/productdevbook/etiket/llms.txt Create QR codes containing iCalendar event data, supporting both string-based and Date object inputs. ```typescript import { event } from "etiket"; // Calendar event QR code const eventQR = event({ title: "Team Meeting", start: "2026-04-01T10:00:00", end: "2026-04-01T11:00:00", location: "Conference Room A", description: "Weekly team sync meeting", }); // Event with Date objects const eventWithDates = event({ title: "Conference", start: new Date("2026-06-15T09:00:00"), end: new Date("2026-06-15T17:00:00"), }); ``` -------------------------------- ### QR Code Background Gradient Source: https://github.com/productdevbook/etiket/blob/main/docs/qr-code/styling.md Applies a radial gradient to the QR code background. Specify the color stops for the gradient, defining the transition from the center outwards. ```typescript qrcode("Hello", { background: { type: "radial", stops: [ { offset: 0, color: "#ffffff" }, { offset: 1, color: "#f0f0f0" }, ], }, }); ``` -------------------------------- ### QR Code Module Size Source: https://github.com/productdevbook/etiket/blob/main/docs/qr-code/styling.md Adjusts the size of individual QR code modules. The `dotSize` property accepts values between 0.1 and 1, where 1 represents the full module size. ```typescript qrcode("Hello", { dotType: "dots", dotSize: 0.8 }); ``` -------------------------------- ### QR Code Corner Styling Source: https://github.com/productdevbook/etiket/blob/main/docs/qr-code/styling.md Customizes the three finder patterns (corners) of the QR code independently. Each corner can have its outer and inner shapes and colors defined, including linear gradients for outer colors. ```typescript qrcode("Hello", { corners: { topLeft: { outerShape: "rounded", // 'square' | 'rounded' | 'dots' | 'extra-rounded' | 'classy' innerShape: "dots", // 'square' | 'dots' | 'rounded' outerColor: "#ff0000", innerColor: "#0000ff", }, topRight: { outerShape: "extra-rounded", outerColor: { type: "linear", stops: [ { offset: 0, color: "#ff0000" }, { offset: 1, color: "#ff8800" }, ], }, }, bottomLeft: { outerShape: "dots", }, }, }); ``` -------------------------------- ### Generate Standard and Extended Code 93 Barcodes Source: https://github.com/productdevbook/etiket/blob/main/docs/barcodes/code93.md Use the `barcode` function with the `type` option set to 'code93' for standard encoding or 'code93ext' for full ASCII support. Ensure 'etiket' is imported. ```typescript import { barcode } from "etiket"; // Standard Code 93 barcode("TEST-123", { type: "code93" }); // Extended Code 93 (full ASCII) barcode("hello world", { type: "code93ext" }); ``` -------------------------------- ### Raw Matrix Encoding Source: https://github.com/productdevbook/etiket/blob/main/docs/qr-code/index.md Retrieve the raw boolean matrix representation of the QR code. ```ts import { encodeQR } from "etiket"; const matrix = encodeQR("Hello", { ecLevel: "H" }); // boolean[][] — true = dark module ``` -------------------------------- ### QR Code Module Gradient Source: https://github.com/productdevbook/etiket/blob/main/docs/qr-code/styling.md Applies a linear gradient to the QR code modules. Define the gradient's rotation and color stops, where each stop includes an offset and a color value. ```typescript qrcode("Hello", { color: { type: "linear", rotation: 45, stops: [ { offset: 0, color: "#ff6b6b" }, { offset: 1, color: "#4ecdc4" }, ], }, }); ``` -------------------------------- ### Generate MSI Plessey Barcodes Source: https://github.com/productdevbook/etiket/blob/main/docs/barcodes/msi.md Use the barcode function to generate MSI barcodes with various check digit algorithms. ```ts import { barcode } from "etiket"; // Default: Mod 10 check digit barcode("12345", { type: "msi" }); // Different check digit algorithms barcode("12345", { type: "msi", msiCheckDigit: "mod10" }); barcode("12345", { type: "msi", msiCheckDigit: "mod11" }); barcode("12345", { type: "msi", msiCheckDigit: "mod1010" }); barcode("12345", { type: "msi", msiCheckDigit: "mod1110" }); barcode("12345", { type: "msi", msiCheckDigit: "none" }); ``` -------------------------------- ### QR Code XML Declaration Source: https://github.com/productdevbook/etiket/blob/main/docs/qr-code/styling.md Includes the XML declaration `<?xml version="1.0"?>` at the beginning of the generated SVG output. This is useful for creating standalone SVG files. ```typescript qrcode("Hello", { xmlDeclaration: true }); ``` -------------------------------- ### Generate PNG Raster Images for Barcodes Source: https://context7.com/productdevbook/etiket/llms.txt Export various barcode and 2D code types as PNG images, returning either a Uint8Array or a data URI string. ```typescript import { barcodePNG, barcodePNGDataURI, qrcodePNG, qrcodePNGDataURI, datamatrixPNG, pdf417PNG, aztecPNG, } from "etiket/png"; // Barcode as PNG Uint8Array const barcodePngData = barcodePNG("12345", { type: "code128", height: 100, scale: 2, }); // Barcode as PNG data URI const barcodeDataUri = barcodePNGDataURI("12345", { type: "ean13" }); // QR code as PNG const qrPng = qrcodePNG("https://example.com", { moduleSize: 10, margin: 4, }); // QR code as PNG data URI const qrDataUri = qrcodePNGDataURI("Hello", { moduleSize: 8 }); // Data Matrix as PNG const dmPng = datamatrixPNG("Hello World", { moduleSize: 5 }); // PDF417 as PNG const pdfPng = pdf417PNG("Document data", { ecLevel: 3 }); // Aztec as PNG const azPng = aztecPNG("Aztec data", { ecPercent: 25 }); ``` -------------------------------- ### Access Raw Encoders and Renderers Source: https://github.com/productdevbook/etiket/blob/main/README.md Directly access encoding functions for custom rendering to SVG or PNG formats. ```ts import { encodeCode128, encodeEAN13, encodeQR, encodeDataMatrix, encodePDF417, encodeAztec, renderBarcodeSVG, renderQRCodeSVG, renderMatrixSVG, renderBarcodePNG, renderMatrixPNG, } from "etiket"; const bars = encodeCode128("data"); // number[] (bar/space widths) const matrix = encodeQR("data"); // boolean[][] (QR matrix) const dm = encodeDataMatrix("data"); // boolean[][] (Data Matrix) // SVG rendering const svg = renderBarcodeSVG(bars, { height: 100 }); const qrSvg = renderQRCodeSVG(matrix, { size: 400, dotType: "dots" }); // PNG rendering const png = renderBarcodePNG(bars, { height: 100, scale: 2 }); const qrPng = renderMatrixPNG(matrix, { moduleSize: 10, margin: 4 }); ``` -------------------------------- ### Generate USPS Intelligent Mail Barcode Source: https://context7.com/productdevbook/etiket/llms.txt Creates USPS Intelligent Mail barcodes (IMb) for tracking US postal mail. ```typescript import { encodeIMb } from "etiket"; // USPS Intelligent Mail barcode const imb = encodeIMb({ barcodeId: "00", serviceType: "040", mailerId: "123456789", serialNumber: "000000001", routingCode: "12345678901", }); ```