fastqr 1.0.8 โ†’ 1.0.10

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: f26fd3c0bc6d11317f8660a7b89a69986d5619d4b78800f1a735370488f6fc73
4
- data.tar.gz: a179b19e3f7f02ecec67c150ab33515795d4e9badb3dd50b704d3b76dd4cfd5d
3
+ metadata.gz: 8c8da6700425b86beecd6243cae158af79644a0dcda10be631ee7edfbe7b4e82
4
+ data.tar.gz: c1d1e682923888db3ebe3486afb88e2f1b5e1b98531d5f85024a5faa63a565a4
5
5
  SHA512:
6
- metadata.gz: 268ac8155f79b118f4ea4799542d13fcbd80c887681419a1c7052f5e9d13758a127a53cd7d6d047bed9133fab35704808298d98dd03050e971799e3ace12732d
7
- data.tar.gz: a143f9911fda2c20a62d8208d4a48e6a3f143a28360a9a9c659a8a7615b8a64826a44be9a2c4ef4a6f9982e3656c0a83dd7dcb32b9c803c4a6100cb40942ee44
6
+ metadata.gz: 25a814734cc21e75ffa16c883d82d5800eb0bc0e43267b35bd19da2121b5a8e0cf82fdeb3db0219355765a6e5476529f98b884b481b75a0e9a176ff6421d9b9e
7
+ data.tar.gz: 7c68d84521eff5ee6eb234a9d29153924978935a53b8bf27f3fe2adc50cc6140870c1de46e788797cbdc2d9ec8dad3bd690b7dd8db5c43b5e8c3c1e57129406b
data/CMakeLists.txt CHANGED
@@ -1,5 +1,5 @@
1
1
  cmake_minimum_required(VERSION 3.15)
2
- project(fastqr VERSION 1.0.8 LANGUAGES CXX C)
2
+ project(fastqr VERSION 1.0.10 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.8
1
+ 1.0.10
@@ -4,45 +4,63 @@
4
4
  */
5
5
 
6
6
  const platform = require('./lib/platform');
7
- const ffi = require('ffi-napi');
8
- const ref = require('ref-napi');
7
+ const { execFileSync } = require('child_process');
8
+ const fs = require('fs');
9
9
  const path = require('path');
10
10
 
11
11
  let fastqr;
12
12
 
13
- // Try to load pre-built binary first, fall back to compiled addon
13
+ // Use pre-built CLI binary (no FFI needed!)
14
14
  if (platform.isPrebuiltAvailable()) {
15
- // Load via FFI
16
- const libPath = platform.getPrebuiltPath();
15
+ const cliPath = path.join(__dirname, 'prebuilt', platform.getPlatformString(), 'bin', 'fastqr');
17
16
 
18
- // Define C struct for options
19
- const QROptionsStruct = ref.types.void; // Use void* for simplicity, C function handles NULL
17
+ if (!fs.existsSync(cliPath)) {
18
+ throw new Error(
19
+ 'FastQR CLI binary not found. Expected at: ' + cliPath + '\n' +
20
+ 'Please reinstall the package: npm install fastqr-pro'
21
+ );
22
+ }
20
23
 
21
- const lib = ffi.Library(libPath, {
22
- 'fastqr_generate': ['int', ['string', 'string', 'pointer']],
23
- 'fastqr_version': ['string', []]
24
- });
25
-
26
- // Wrap FFI functions to match Node addon interface
24
+ // Wrap CLI to match API interface
27
25
  fastqr = {
28
26
  generate: function(data, outputPath, options = {}) {
29
- // For now, pass NULL - C function uses defaults
30
- // TODO: Build C struct for full options support
31
- const result = lib.fastqr_generate(data, outputPath, ref.NULL);
32
- return result === 1; // C returns 1 for success, 0 for failure
27
+ const args = [data, outputPath];
28
+
29
+ // Support both new 'size' and legacy 'width'/'height'
30
+ const size = options.size || options.width || options.height || 300;
31
+ args.push('-s', size.toString());
32
+
33
+ if (options.optimizeSize) args.push('-o');
34
+ if (options.foreground) args.push('-f', options.foreground.join(','));
35
+ if (options.background) args.push('-b', options.background.join(','));
36
+ if (options.errorLevel) args.push('-e', options.errorLevel);
37
+ if (options.logo) args.push('-l', options.logo);
38
+ if (options.logoSize) args.push('-p', options.logoSize.toString());
39
+ if (options.quality) args.push('-q', options.quality.toString());
40
+
41
+ try {
42
+ execFileSync(cliPath, args, { stdio: 'pipe' });
43
+ return true;
44
+ } catch (error) {
45
+ return false;
46
+ }
33
47
  },
34
48
  version: function() {
35
- return lib.fastqr_version();
49
+ try {
50
+ const output = execFileSync(cliPath, ['-v'], { encoding: 'utf8' });
51
+ return output.trim().replace('FastQR v', '');
52
+ } catch (error) {
53
+ return 'unknown';
54
+ }
36
55
  },
37
- VERSION: lib.fastqr_version()
56
+ VERSION: null // Will be set below
38
57
  };
39
- } else if (platform.isAddonAvailable()) {
40
- // Load compiled addon
41
- fastqr = require(platform.getAddonPath());
58
+
59
+ fastqr.VERSION = fastqr.version();
42
60
  } else {
43
61
  throw new Error(
44
62
  'FastQR native binding not found. ' +
45
- 'Please run: npm install --build-from-source'
63
+ 'No pre-built binary available for your platform: ' + process.platform + '-' + process.arch
46
64
  );
47
65
  }
48
66
 
@@ -157,8 +175,7 @@ function generateBatch(dataArray, outputDir, options = {}) {
157
175
  fs.writeFileSync(tempFile, dataArray.join('\n'), 'utf8');
158
176
 
159
177
  // Get CLI path
160
- const cliPath = platform.getPrebuiltPath().replace('.dylib', '').replace('.so', '');
161
- const actualCliPath = cliPath.endsWith('fastqr') ? cliPath : path.join(path.dirname(cliPath), 'fastqr');
178
+ const cliPath = path.join(__dirname, 'prebuilt', platform.getPlatformString(), 'bin', 'fastqr');
162
179
 
163
180
  // Build command arguments
164
181
  const args = ['-F', tempFile, outputDir];
@@ -171,7 +188,7 @@ function generateBatch(dataArray, outputDir, options = {}) {
171
188
  if (options.logoSize) args.push('-p', options.logoSize.toString());
172
189
  if (options.quality) args.push('-q', options.quality.toString());
173
190
 
174
- execFileSync(actualCliPath, args, { stdio: 'pipe' });
191
+ execFileSync(cliPath, args, { stdio: 'pipe' });
175
192
 
176
193
  return { success: dataArray.length, failed: 0 };
177
194
  } catch (error) {
@@ -65,8 +65,33 @@ function findFastQRBinary() {
65
65
  throw new Error(`Pre-built binary not found for ${platform}`);
66
66
  }
67
67
 
68
+ /**
69
+ * Checks if pre-built binary is available
70
+ * @returns {boolean}
71
+ */
72
+ function isPrebuiltAvailable() {
73
+ try {
74
+ const platform = detectPlatform();
75
+ const prebuiltDir = path.join(__dirname, '..', 'prebuilt', platform, 'bin');
76
+ const binaryPath = path.join(prebuiltDir, 'fastqr');
77
+ return fs.existsSync(binaryPath);
78
+ } catch (error) {
79
+ return false;
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Gets platform string
85
+ * @returns {string}
86
+ */
87
+ function getPlatformString() {
88
+ return detectPlatform();
89
+ }
90
+
68
91
  module.exports = {
69
92
  detectPlatform,
70
93
  extractBinary,
71
- findFastQRBinary
94
+ findFastQRBinary,
95
+ isPrebuiltAvailable,
96
+ getPlatformString
72
97
  };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastqr-pro",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
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",
@@ -37,10 +37,7 @@
37
37
  "prebuilt/",
38
38
  "README.md"
39
39
  ],
40
- "dependencies": {
41
- "ffi-napi": "^4.0.3",
42
- "ref-napi": "^3.0.3"
43
- },
40
+ "dependencies": {},
44
41
  "devDependencies": {},
45
42
  "engines": {
46
43
  "node": ">=14.0.0"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FastQR
4
- VERSION = "1.0.8"
4
+ VERSION = "1.0.10"
5
5
  end
6
6
 
@@ -3,33 +3,6 @@
3
3
  require_relative "fastqr/version"
4
4
  require_relative "fastqr/platform"
5
5
 
6
- # Load pre-built binary if available, otherwise try to load compiled extension
7
- begin
8
- if FastQR::Platform.prebuilt_available?
9
- # Load from pre-built binary
10
- require 'ffi'
11
-
12
- module FastQR
13
- module Native
14
- extend FFI::Library
15
-
16
- lib_path = Platform.lib_path
17
- ffi_lib lib_path
18
-
19
- # Define C functions
20
- attach_function :fastqr_generate_c, :fastqr_generate, [:string, :string, :pointer], :bool
21
- attach_function :fastqr_version, [], :string
22
- end
23
- end
24
- else
25
- # Fall back to compiled extension
26
- require_relative "fastqr/fastqr"
27
- end
28
- rescue LoadError => e
29
- warn "Warning: Could not load FastQR native extension: #{e.message}"
30
- warn "Please run: gem install fastqr -- --with-system-libraries"
31
- end
32
-
33
6
  module FastQR
34
7
  class Error < StandardError; end
35
8
 
@@ -37,7 +10,11 @@ module FastQR
37
10
  #
38
11
  # @return [String] Version string
39
12
  def self.version
40
- Native.fastqr_version
13
+ cli_path = Platform.find_binary
14
+ output = `#{cli_path} -v 2>&1`.strip
15
+ output.sub('FastQR v', '')
16
+ rescue => e
17
+ VERSION
41
18
  end
42
19
 
43
20
  # Generate QR code with options
@@ -77,9 +54,21 @@ module FastQR
77
54
  raise Error, "Data cannot be empty" if data.nil? || data.empty?
78
55
  raise Error, "Output path cannot be empty" if output_path.nil? || output_path.empty?
79
56
 
80
- # TODO: Build C struct from options hash
81
- # For now, pass nil to use defaults
82
- result = Native.fastqr_generate_c(data, output_path, nil)
57
+ cli_path = Platform.find_binary
58
+ args = [data, output_path]
59
+
60
+ # Build command arguments from options
61
+ args += ['-s', options[:size].to_s] if options[:size]
62
+ args += ['-o'] if options[:optimize_size]
63
+ args += ['-f', options[:foreground].join(',')] if options[:foreground]
64
+ args += ['-b', options[:background].join(',')] if options[:background]
65
+ args += ['-e', options[:error_level]] if options[:error_level]
66
+ args += ['-l', options[:logo]] if options[:logo]
67
+ args += ['-p', options[:logo_size].to_s] if options[:logo_size]
68
+ args += ['-q', options[:quality].to_s] if options[:quality]
69
+
70
+ # Execute CLI binary
71
+ result = system(cli_path, *args, out: File::NULL, err: File::NULL)
83
72
  raise Error, "Failed to generate QR code" unless result
84
73
 
85
74
  true
@@ -37,10 +37,11 @@ rm -rf build
37
37
  mkdir build
38
38
  cd build
39
39
 
40
- # Configure with static linking
40
+ echo "๐Ÿ”ง Building standalone CLI with static linking..."
41
+ # Configure for standalone CLI (all dependencies static)
41
42
  cmake .. \
42
43
  -DCMAKE_BUILD_TYPE=Release \
43
- -DBUILD_SHARED_LIBS=ON \
44
+ -DBUILD_SHARED_LIBS=OFF \
44
45
  -DCMAKE_INSTALL_PREFIX="$PWD/install" \
45
46
  -DFASTQR_BUILD_EXAMPLES=OFF
46
47
 
@@ -51,34 +52,14 @@ else
51
52
  make -j$(nproc)
52
53
  fi
53
54
 
54
- # Install to temporary location
55
- make install DESTDIR="$PWD/staging"
56
-
57
55
  cd ..
58
56
 
59
- # Copy binaries
60
- if [[ "$OS" == "macos" ]]; then
61
- cp build/staging/usr/local/lib/libfastqr.*.dylib "$OUTPUT_DIR/lib/libfastqr.dylib" 2>/dev/null || \
62
- cp build/libfastqr.*.dylib "$OUTPUT_DIR/lib/libfastqr.dylib" 2>/dev/null || \
63
- cp build/libfastqr.dylib "$OUTPUT_DIR/lib/libfastqr.dylib"
57
+ # Copy standalone CLI binary (no dylib needed!)
58
+ cp build/fastqr "$OUTPUT_DIR/bin/fastqr"
59
+ echo "โœ… Built standalone CLI (all static - no dependencies!)"
64
60
 
65
- cp build/staging/usr/local/bin/fastqr "$OUTPUT_DIR/bin/fastqr" 2>/dev/null || \
66
- cp build/fastqr "$OUTPUT_DIR/bin/fastqr"
67
- else
68
- # Copy all .so files to lib directory
69
- if [ -f build/staging/usr/local/lib/libfastqr.so ]; then
70
- cp build/staging/usr/local/lib/libfastqr.so* "$OUTPUT_DIR/lib/"
71
- else
72
- cp build/libfastqr.so* "$OUTPUT_DIR/lib/"
73
- fi
74
-
75
- # Copy binary
76
- if [ -f build/staging/usr/local/bin/fastqr ]; then
77
- cp build/staging/usr/local/bin/fastqr "$OUTPUT_DIR/bin/fastqr"
78
- else
79
- cp build/fastqr "$OUTPUT_DIR/bin/fastqr"
80
- fi
81
- fi
61
+ # No shared library needed - CLI is standalone!
62
+ # (Ruby and Node.js use CLI binary directly)
82
63
 
83
64
  # Copy headers
84
65
  cp -r include "$OUTPUT_DIR/"
@@ -0,0 +1,80 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ echo "๐Ÿงช Testing Node.js Package with REAL CODE..."
5
+ echo ""
6
+
7
+ # Get version
8
+ VERSION=$(cat VERSION)
9
+ echo "๐Ÿ“ฆ Version: $VERSION"
10
+ echo ""
11
+
12
+ # Step 1: Build project (need shared library + CLI)
13
+ echo "๐Ÿ”จ Step 1: Building C++ library..."
14
+ rm -rf build
15
+ mkdir -p build
16
+ cd build
17
+ cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release ..
18
+ cmake --build .
19
+ cd ..
20
+ echo "โœ… Build complete!"
21
+ echo ""
22
+
23
+ # Step 2: Copy binaries to Node.js prebuilt directory
24
+ echo "๐Ÿ“‹ Step 2: Copying binaries to Node.js prebuilt..."
25
+ PLATFORM="macos-arm64" # Adjust for your platform
26
+ PREBUILT_DIR="bindings/nodejs/prebuilt/$PLATFORM"
27
+
28
+ mkdir -p "$PREBUILT_DIR/lib"
29
+ mkdir -p "$PREBUILT_DIR/bin"
30
+
31
+ # Copy library and CLI
32
+ cp build/libfastqr.dylib "$PREBUILT_DIR/lib/"
33
+ cp build/fastqr "$PREBUILT_DIR/bin/"
34
+
35
+ echo "โœ… Copied to $PREBUILT_DIR/"
36
+ echo ""
37
+
38
+ # Step 3: Test with real Node.js code
39
+ echo "๐Ÿงช Step 3: Testing with real Node.js code..."
40
+ node -e "
41
+ const fastqr = require('./bindings/nodejs/index.js');
42
+
43
+ console.log('FastQR version:', fastqr.version());
44
+ console.log('');
45
+
46
+ // Test 1: Basic generation
47
+ console.log('Test 1: Basic QR code...');
48
+ const result1 = fastqr.generate('Hello World', 'test_node_basic.png');
49
+ console.log('โœ… Result:', result1);
50
+
51
+ // Test 2: With size option
52
+ console.log('');
53
+ console.log('Test 2: QR with size 500...');
54
+ const result2 = fastqr.generate('Test Size', 'test_node_500.png', { size: 500 });
55
+ console.log('โœ… Result:', result2);
56
+
57
+ // Test 3: With options
58
+ console.log('');
59
+ console.log('Test 3: QR with optimize...');
60
+ const result3 = fastqr.generate('Test Optimize', 'test_node_opt.png', {
61
+ size: 500,
62
+ optimizeSize: true
63
+ });
64
+ console.log('โœ… Result:', result3);
65
+
66
+ // Test 4: Batch mode
67
+ console.log('');
68
+ console.log('Test 4: Batch generation...');
69
+ const data = ['QR 1', 'QR 2', 'QR 3'];
70
+ const result4 = fastqr.generateBatch(data, 'test_node_batch/', { size: 300 });
71
+ console.log('โœ… Result:', JSON.stringify(result4));
72
+
73
+ console.log('');
74
+ console.log('โœ… All tests passed!');
75
+ "
76
+
77
+ echo ""
78
+ echo "โœ… REAL NODE.JS TEST PASSED!"
79
+ echo ""
80
+
data/src/fastqr.cpp CHANGED
@@ -25,7 +25,7 @@
25
25
  // Enable benchmarking
26
26
  // #define FASTQR_BENCHMARK
27
27
 
28
- #define FASTQR_VERSION "1.0.8"
28
+ #define FASTQR_VERSION "1.0.10"
29
29
 
30
30
  namespace fastqr {
31
31
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastqr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - FastQR Project
@@ -10,20 +10,6 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2025-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: ffi
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.15'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.15'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -104,13 +90,11 @@ files:
104
90
  - bindings/ruby/prebuilt/macos-arm64/include/fastqr.h
105
91
  - bindings/ruby/prebuilt/macos-arm64/include/stb_image.h
106
92
  - bindings/ruby/prebuilt/macos-arm64/include/stb_image_write.h
107
- - bindings/ruby/prebuilt/macos-arm64/lib/libfastqr.dylib
108
93
  - bindings/ruby/prebuilt/macos-x86_64.tar.gz
109
94
  - bindings/ruby/prebuilt/macos-x86_64/bin/fastqr
110
95
  - bindings/ruby/prebuilt/macos-x86_64/include/fastqr.h
111
96
  - bindings/ruby/prebuilt/macos-x86_64/include/stb_image.h
112
97
  - bindings/ruby/prebuilt/macos-x86_64/include/stb_image_write.h
113
- - bindings/ruby/prebuilt/macos-x86_64/lib/libfastqr.dylib
114
98
  - build.sh
115
99
  - cmake/fastqrConfig.cmake.in
116
100
  - composer.json
@@ -134,6 +118,7 @@ files:
134
118
  - scripts/test-gem-local.sh
135
119
  - scripts/test-gem-manual.rb
136
120
  - scripts/test-npm-local.sh
121
+ - scripts/test-npm-real.sh
137
122
  - scripts/update-version.sh
138
123
  - src/cli.cpp
139
124
  - src/fastqr.cpp