fastqr 1.0.1 → 1.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3cfb16eee23a1070b11b2013601477652c38b61eb11e202fd14de3864de6dc16
4
- data.tar.gz: 4b9b60fb37a427f9921a4bb80bf32cddb7167fd7ea6e07f1938080885305f8a8
3
+ metadata.gz: 1ec4ef1b7b236292fd890d42f0793b9d86d899b48eb9fd006cb7b3cb8a9d10b2
4
+ data.tar.gz: a29d272dcd7338eec7a104cd9dccb36a798faf11c878b766ae7665abc6dddcc3
5
5
  SHA512:
6
- metadata.gz: 2a032ae6df4927909e110905199b26fd970abd8e59dd7d34eb3e718152f096da724fd153db2c570f8e31bea34769c98a696b982e00552ce1dec395ebf5fc0d3a
7
- data.tar.gz: 96a2b4db93bef4d77105b6439143bd52570a64fa4d3db13a7760284d126d46c8b534d068a32f0109c17a9b0daf159a4c55c8d1b2db31e3d26015db9ddede7d7f
6
+ metadata.gz: 93870ff403f744c28c7002f4475672ad97be71f5b82c596b8adf024f8275926146cdff00df86ec56c588063e66933bc6959e98048e744d6c3dfe5ae3a718f56c
7
+ data.tar.gz: 555944b886e5ceeaf444ce0f5c16b3f5672164fe153ce71109d5f5dfe1498ee1cdab36b00f194903cfd9b33506eb1ff96d70a6cbfa6cf9f851f1a95f6958487a
data/CMakeLists.txt CHANGED
@@ -1,5 +1,5 @@
1
1
  cmake_minimum_required(VERSION 3.15)
2
- project(fastqr VERSION 1.0.0 LANGUAGES CXX C)
2
+ project(fastqr VERSION 1.0.4 LANGUAGES CXX C)
3
3
 
4
4
  set(CMAKE_CXX_STANDARD 14)
5
5
  set(CMAKE_CXX_STANDARD_REQUIRED ON)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.4
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "fastqr",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
4
  "description": "Fast QR code generator with UTF-8 support, custom colors, logo embedding, and precise size control",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "scripts": {
8
- "install": "node-gyp rebuild",
9
8
  "test": "node test/test.js"
10
9
  },
11
10
  "keywords": [
@@ -31,13 +30,15 @@
31
30
  "url": "https://github.com/tranhuucanh/fastqr/issues"
32
31
  },
33
32
  "homepage": "https://github.com/tranhuucanh/fastqr#readme",
34
- "dependencies": {
35
- "node-gyp": "^9.0.0",
36
- "ffi-napi": "^4.0.3",
37
- "ref-napi": "^3.0.3"
38
- },
33
+ "files": [
34
+ "index.js",
35
+ "index.d.ts",
36
+ "lib/",
37
+ "prebuilt/",
38
+ "README.md"
39
+ ],
40
+ "dependencies": {},
39
41
  "devDependencies": {},
40
- "gypfile": true,
41
42
  "engines": {
42
43
  "node": ">=14.0.0"
43
44
  }
@@ -1,4 +1,61 @@
1
1
  require 'mkmf'
2
+ require 'rbconfig'
3
+
4
+ # Check if pre-built binary exists
5
+ def check_prebuilt_binary
6
+ os = RbConfig::CONFIG['host_os']
7
+ arch = RbConfig::CONFIG['host_cpu']
8
+
9
+ platform = case os
10
+ when /darwin/
11
+ case arch
12
+ when /arm64|aarch64/
13
+ 'macos-arm64'
14
+ when /x86_64|x64/
15
+ 'macos-x86_64'
16
+ else
17
+ nil
18
+ end
19
+ when /linux/
20
+ case arch
21
+ when /x86_64|x64/
22
+ 'linux-x86_64'
23
+ when /arm64|aarch64/
24
+ 'linux-arm64'
25
+ else
26
+ nil
27
+ end
28
+ else
29
+ nil
30
+ end
31
+
32
+ return false unless platform
33
+
34
+ prebuilt_dir = File.expand_path("../../prebuilt/#{platform}", __FILE__)
35
+ binary_path = File.join(prebuilt_dir, 'fastqr')
36
+
37
+ if File.exist?(binary_path)
38
+ puts "✅ Found pre-built binary at #{binary_path}"
39
+ puts "⏭️ Skipping compilation"
40
+
41
+ # Create a dummy Makefile that does nothing
42
+ File.open('Makefile', 'w') do |f|
43
+ f.puts "all:\n\t@echo 'Using pre-built binary'\n"
44
+ f.puts "install:\n\t@echo 'Using pre-built binary'\n"
45
+ f.puts "clean:\n\t@echo 'Nothing to clean'\n"
46
+ end
47
+
48
+ return true
49
+ end
50
+
51
+ false
52
+ end
53
+
54
+ # Try to use pre-built binary first
55
+ exit 0 if check_prebuilt_binary
56
+
57
+ # If no pre-built binary, compile from source
58
+ puts "⚠️ No pre-built binary found, compiling from source..."
2
59
 
3
60
  # Check for required libraries
4
61
  unless have_library('qrencode')
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FastQR
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.4"
5
5
  end
6
6
 
@@ -0,0 +1,97 @@
1
+ /*
2
+ * FastQR - Fast QR Code Generator Library
3
+ * Copyright (C) 2025 FastQR Project
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ */
15
+
16
+ #ifndef FASTQR_H
17
+ #define FASTQR_H
18
+
19
+ #include <string>
20
+ #include <cstdint>
21
+
22
+ namespace fastqr {
23
+
24
+ /**
25
+ * QR Code error correction level
26
+ */
27
+ enum class ErrorCorrectionLevel {
28
+ LOW, // Level L - ~7% correction
29
+ MEDIUM, // Level M - ~15% correction
30
+ QUARTILE, // Level Q - ~25% correction
31
+ HIGH // Level H - ~30% correction
32
+ };
33
+
34
+ /**
35
+ * Options for QR code generation
36
+ */
37
+ struct QROptions {
38
+ // Output image size (QR codes are square)
39
+ int size = 300;
40
+
41
+ // Optimize size - round up to nearest integer multiple for best performance
42
+ bool optimize_size = false;
43
+
44
+ // QR code colors (RGB)
45
+ struct Color {
46
+ uint8_t r = 0;
47
+ uint8_t g = 0;
48
+ uint8_t b = 0;
49
+ };
50
+
51
+ Color foreground = {0, 0, 0}; // QR code color (default: black)
52
+ Color background = {255, 255, 255}; // Background color (default: white)
53
+
54
+ // Error correction level
55
+ ErrorCorrectionLevel ec_level = ErrorCorrectionLevel::MEDIUM;
56
+
57
+ // Logo options
58
+ std::string logo_path = ""; // Path to logo image
59
+ int logo_size_percent = 20; // Logo size as percentage of QR code (default: 20%)
60
+
61
+ // Output format
62
+ std::string format = "png"; // png, jpg, webp, etc.
63
+ int quality = 95; // For lossy formats (1-100)
64
+ };
65
+
66
+ /**
67
+ * Generate QR code and save to file
68
+ *
69
+ * @param data The data to encode (supports UTF-8)
70
+ * @param output_path Path to save the generated QR code image
71
+ * @param options QR code generation options
72
+ * @return true if successful, false otherwise
73
+ */
74
+ bool generate(const std::string& data, const std::string& output_path, const QROptions& options = QROptions());
75
+
76
+ /**
77
+ * Generate QR code and return image data as buffer
78
+ *
79
+ * @param data The data to encode (supports UTF-8)
80
+ * @param buffer Output buffer for image data
81
+ * @param buffer_size Size of the output buffer
82
+ * @param options QR code generation options
83
+ * @return Size of image data written to buffer, or -1 on error
84
+ */
85
+ int generate_to_buffer(const std::string& data, void* buffer, size_t buffer_size, const QROptions& options = QROptions());
86
+
87
+ /**
88
+ * Get library version
89
+ *
90
+ * @return Version string (e.g., "1.0.0")
91
+ */
92
+ const char* version();
93
+
94
+ } // namespace fastqr
95
+
96
+ #endif // FASTQR_H
97
+