fastqr 1.0.8 โ†’ 1.0.9

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: ebdc094c4b99f58f52cb8e96663c42b155a036f419b2fa80239a92bbfb512eb9
4
+ data.tar.gz: 6dbb33c8d3dd4c35e34db189d47f9ce18490f474fa8faebfa41d843b66ae833f
5
5
  SHA512:
6
- metadata.gz: 268ac8155f79b118f4ea4799542d13fcbd80c887681419a1c7052f5e9d13758a127a53cd7d6d047bed9133fab35704808298d98dd03050e971799e3ace12732d
7
- data.tar.gz: a143f9911fda2c20a62d8208d4a48e6a3f143a28360a9a9c659a8a7615b8a64826a44be9a2c4ef4a6f9982e3656c0a83dd7dcb32b9c803c4a6100cb40942ee44
6
+ metadata.gz: 69e544be8d0454fccb215e7af53cbf8b0f3b50f0491f8cb3802b5070adcdae6265f82e795176488b4105bd174d9e000f37d53446c7f577684488ba28bfa2285f
7
+ data.tar.gz: 7c2a36f574a7f61cb68d4d317e2e413a5241a86a37e7b2421f0bef36ac653fc1f52158752d41260471f9746eac276a75933e3d7473a8669e736f97929cd0f376
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.9 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.9
@@ -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();
17
-
18
- // Define C struct for options
19
- const QROptionsStruct = ref.types.void; // Use void* for simplicity, C function handles NULL
20
-
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
15
+ const cliPath = path.join(__dirname, 'prebuilt', platform.getPlatformString(), 'bin', 'fastqr');
16
+
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
+ }
23
+
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.9",
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.9"
5
5
  end
6
6
 
@@ -17,7 +17,7 @@ begin
17
17
  ffi_lib lib_path
18
18
 
19
19
  # Define C functions
20
- attach_function :fastqr_generate_c, :fastqr_generate, [:string, :string, :pointer], :bool
20
+ attach_function :fastqr_generate_c, :fastqr_generate, [:string, :string, :pointer], :int
21
21
  attach_function :fastqr_version, [], :string
22
22
  end
23
23
  end
@@ -80,7 +80,7 @@ module FastQR
80
80
  # TODO: Build C struct from options hash
81
81
  # For now, pass nil to use defaults
82
82
  result = Native.fastqr_generate_c(data, output_path, nil)
83
- raise Error, "Failed to generate QR code" unless result
83
+ raise Error, "Failed to generate QR code" unless result == 1
84
84
 
85
85
  true
86
86
  end
@@ -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.9"
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.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - FastQR Project
@@ -134,6 +134,7 @@ files:
134
134
  - scripts/test-gem-local.sh
135
135
  - scripts/test-gem-manual.rb
136
136
  - scripts/test-npm-local.sh
137
+ - scripts/test-npm-real.sh
137
138
  - scripts/update-version.sh
138
139
  - src/cli.cpp
139
140
  - src/fastqr.cpp