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 +4 -4
- data/CMakeLists.txt +1 -1
- data/VERSION +1 -1
- data/bindings/nodejs/index.js +45 -28
- data/bindings/nodejs/lib/platform.js +26 -1
- data/bindings/nodejs/package.json +2 -5
- data/bindings/nodejs/prebuilt/macos-arm64/bin/fastqr +0 -0
- data/bindings/ruby/lib/fastqr/version.rb +1 -1
- data/bindings/ruby/lib/fastqr.rb +2 -2
- data/bindings/ruby/prebuilt/macos-arm64/bin/fastqr +0 -0
- data/bindings/ruby/prebuilt/macos-arm64/lib/libfastqr.dylib +0 -0
- data/bindings/ruby/prebuilt/macos-arm64.tar.gz +0 -0
- data/bindings/ruby/prebuilt/macos-x86_64/bin/fastqr +0 -0
- data/bindings/ruby/prebuilt/macos-x86_64/lib/libfastqr.dylib +0 -0
- data/bindings/ruby/prebuilt/macos-x86_64.tar.gz +0 -0
- data/scripts/test-npm-real.sh +80 -0
- data/src/fastqr.cpp +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ebdc094c4b99f58f52cb8e96663c42b155a036f419b2fa80239a92bbfb512eb9
|
|
4
|
+
data.tar.gz: 6dbb33c8d3dd4c35e34db189d47f9ce18490f474fa8faebfa41d843b66ae833f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 69e544be8d0454fccb215e7af53cbf8b0f3b50f0491f8cb3802b5070adcdae6265f82e795176488b4105bd174d9e000f37d53446c7f577684488ba28bfa2285f
|
|
7
|
+
data.tar.gz: 7c2a36f574a7f61cb68d4d317e2e413a5241a86a37e7b2421f0bef36ac653fc1f52158752d41260471f9746eac276a75933e3d7473a8669e736f97929cd0f376
|
data/CMakeLists.txt
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.9
|
data/bindings/nodejs/index.js
CHANGED
|
@@ -4,45 +4,63 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const platform = require('./lib/platform');
|
|
7
|
-
const
|
|
8
|
-
const
|
|
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
|
-
//
|
|
13
|
+
// Use pre-built CLI binary (no FFI needed!)
|
|
14
14
|
if (platform.isPrebuiltAvailable()) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
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:
|
|
56
|
+
VERSION: null // Will be set below
|
|
38
57
|
};
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
'
|
|
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 =
|
|
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(
|
|
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.
|
|
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"
|
|
Binary file
|
data/bindings/ruby/lib/fastqr.rb
CHANGED
|
@@ -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], :
|
|
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
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -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
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.
|
|
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
|