librats 0.3.1 → 0.5.1

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.
Files changed (69) hide show
  1. package/README.md +405 -405
  2. package/binding.gyp +96 -95
  3. package/lib/index.d.ts +522 -522
  4. package/lib/index.js +82 -82
  5. package/native-src/3rdparty/android/ifaddrs-android.c +600 -0
  6. package/native-src/3rdparty/android/ifaddrs-android.h +54 -0
  7. package/native-src/CMakeLists.txt +360 -0
  8. package/native-src/LICENSE +21 -0
  9. package/native-src/src/bencode.cpp +485 -0
  10. package/native-src/src/bencode.h +145 -0
  11. package/native-src/src/bittorrent.cpp +3682 -0
  12. package/native-src/src/bittorrent.h +731 -0
  13. package/native-src/src/dht.cpp +2342 -0
  14. package/native-src/src/dht.h +501 -0
  15. package/native-src/src/encrypted_socket.cpp +817 -0
  16. package/native-src/src/encrypted_socket.h +239 -0
  17. package/native-src/src/file_transfer.cpp +1808 -0
  18. package/native-src/src/file_transfer.h +567 -0
  19. package/native-src/src/fs.cpp +639 -0
  20. package/native-src/src/fs.h +108 -0
  21. package/native-src/src/gossipsub.cpp +1137 -0
  22. package/native-src/src/gossipsub.h +403 -0
  23. package/native-src/src/ice.cpp +1386 -0
  24. package/native-src/src/ice.h +328 -0
  25. package/native-src/src/json.hpp +25526 -0
  26. package/native-src/src/krpc.cpp +558 -0
  27. package/native-src/src/krpc.h +145 -0
  28. package/native-src/src/librats.cpp +2715 -0
  29. package/native-src/src/librats.h +1729 -0
  30. package/native-src/src/librats_bittorrent.cpp +167 -0
  31. package/native-src/src/librats_c.cpp +1317 -0
  32. package/native-src/src/librats_c.h +237 -0
  33. package/native-src/src/librats_encryption.cpp +123 -0
  34. package/native-src/src/librats_file_transfer.cpp +226 -0
  35. package/native-src/src/librats_gossipsub.cpp +293 -0
  36. package/native-src/src/librats_ice.cpp +515 -0
  37. package/native-src/src/librats_logging.cpp +158 -0
  38. package/native-src/src/librats_mdns.cpp +171 -0
  39. package/native-src/src/librats_nat.cpp +571 -0
  40. package/native-src/src/librats_persistence.cpp +815 -0
  41. package/native-src/src/logger.h +412 -0
  42. package/native-src/src/mdns.cpp +1178 -0
  43. package/native-src/src/mdns.h +253 -0
  44. package/native-src/src/network_utils.cpp +598 -0
  45. package/native-src/src/network_utils.h +162 -0
  46. package/native-src/src/noise.cpp +981 -0
  47. package/native-src/src/noise.h +227 -0
  48. package/native-src/src/os.cpp +371 -0
  49. package/native-src/src/os.h +40 -0
  50. package/native-src/src/rats_export.h +17 -0
  51. package/native-src/src/sha1.cpp +163 -0
  52. package/native-src/src/sha1.h +42 -0
  53. package/native-src/src/socket.cpp +1376 -0
  54. package/native-src/src/socket.h +309 -0
  55. package/native-src/src/stun.cpp +484 -0
  56. package/native-src/src/stun.h +349 -0
  57. package/native-src/src/threadmanager.cpp +105 -0
  58. package/native-src/src/threadmanager.h +53 -0
  59. package/native-src/src/tracker.cpp +1110 -0
  60. package/native-src/src/tracker.h +268 -0
  61. package/native-src/src/version.cpp +24 -0
  62. package/native-src/src/version.h.in +45 -0
  63. package/native-src/version.rc.in +31 -0
  64. package/package.json +62 -68
  65. package/scripts/build-librats.js +241 -194
  66. package/scripts/postinstall.js +52 -52
  67. package/scripts/prepare-package.js +187 -91
  68. package/scripts/verify-installation.js +119 -119
  69. package/src/librats_node.cpp +1174 -1174
@@ -1,194 +1,241 @@
1
- #!/usr/bin/env node
2
-
3
- const { execSync } = require('child_process');
4
- const fs = require('fs');
5
- const path = require('path');
6
- const os = require('os');
7
-
8
- // Determine platform
9
- const isWindows = process.platform === 'win32';
10
- const isMac = process.platform === 'darwin';
11
- const isLinux = process.platform === 'linux';
12
-
13
- // Paths
14
- const nodejsRoot = path.resolve(__dirname, '..');
15
- const projectRoot = path.resolve(__dirname, '..', '..');
16
- const buildDir = path.resolve(nodejsRoot, 'build-native'); // Build dir inside nodejs/
17
- const srcDir = path.resolve(projectRoot, 'src');
18
- const cmakeLists = path.resolve(projectRoot, 'CMakeLists.txt');
19
-
20
- console.log('Building librats native library...');
21
- console.log(`Platform: ${process.platform}`);
22
- console.log(`Project root: ${projectRoot}`);
23
- console.log(`Build directory: ${buildDir}`);
24
-
25
- // Check if CMake is installed
26
- try {
27
- execSync('cmake --version', { stdio: 'pipe' });
28
- console.log('✓ CMake found');
29
- } catch (error) {
30
- console.error('\n❌ ERROR: CMake is not installed or not in PATH');
31
- console.error('\nCMake is required to build librats.');
32
- console.error('Please install CMake:');
33
- if (isWindows) {
34
- console.error(' - Download from: https://cmake.org/download/');
35
- console.error(' - Or use: winget install Kitware.CMake');
36
- console.error(' - Or use: choco install cmake');
37
- } else if (isMac) {
38
- console.error(' - Use Homebrew: brew install cmake');
39
- console.error(' - Or download from: https://cmake.org/download/');
40
- } else if (isLinux) {
41
- console.error(' - Use: sudo apt install cmake');
42
- console.error(' - Or: sudo yum install cmake');
43
- console.error(' - Or download from: https://cmake.org/download/');
44
- }
45
- console.error('\nAfter installing CMake, run: npm install\n');
46
- process.exit(1);
47
- }
48
-
49
- // Check if CMakeLists.txt exists
50
- if (!fs.existsSync(cmakeLists)) {
51
- console.error('ERROR: CMakeLists.txt not found in project root.');
52
- console.error('Make sure all source files are included in the npm package.');
53
- process.exit(1);
54
- }
55
-
56
- // Check if src directory exists
57
- if (!fs.existsSync(srcDir)) {
58
- console.error('ERROR: src directory not found.');
59
- console.error('Make sure all source files are included in the npm package.');
60
- process.exit(1);
61
- }
62
-
63
- // Create build directory if it doesn't exist
64
- if (!fs.existsSync(buildDir)) {
65
- console.log(`Creating build directory: ${buildDir}`);
66
- fs.mkdirSync(buildDir, { recursive: true });
67
- }
68
-
69
- // Helper function to execute commands
70
- function exec(command, options = {}) {
71
- console.log(`> ${command}`);
72
- try {
73
- execSync(command, {
74
- cwd: buildDir,
75
- stdio: 'inherit',
76
- ...options
77
- });
78
- } catch (error) {
79
- console.error(`Command failed: ${command}`);
80
- throw error;
81
- }
82
- }
83
-
84
- try {
85
- // Configure CMake with appropriate options
86
- console.log('\nConfiguring CMake...');
87
-
88
- let cmakeArgs = [
89
- '-DRATS_BUILD_TESTS=OFF',
90
- '-DRATS_BUILD_EXAMPLES=OFF',
91
- '-DRATS_STATIC_LIBRARY=ON',
92
- '-DRATS_BINDINGS=ON',
93
- '-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL'
94
- ];
95
-
96
- // Add platform-specific CMake arguments
97
- if (isWindows) {
98
- // Try to detect Visual Studio version
99
- const vsVersions = ['2022', '2019', '2017'];
100
- let generator = null;
101
-
102
- for (const version of vsVersions) {
103
- try {
104
- execSync(`where "C:\\Program Files\\Microsoft Visual Studio\\${version}"`, { stdio: 'ignore' });
105
- generator = `Visual Studio ${version === '2022' ? '17' : version === '2019' ? '16' : '15'} ${version}`;
106
- break;
107
- } catch (e) {
108
- // Try next version
109
- }
110
- }
111
-
112
- if (generator) {
113
- cmakeArgs.push(`-G "${generator}"`);
114
- cmakeArgs.push('-A x64');
115
- }
116
- } else if (isMac) {
117
- // Use Unix Makefiles on macOS
118
- cmakeArgs.push('-G "Unix Makefiles"');
119
- } else if (isLinux) {
120
- // Use Unix Makefiles on Linux
121
- cmakeArgs.push('-G "Unix Makefiles"');
122
- }
123
-
124
- const cmakeConfigCmd = `cmake ${cmakeArgs.join(' ')} ../..`;
125
- exec(cmakeConfigCmd);
126
-
127
- // Build the library
128
- console.log('\nBuilding librats library...');
129
-
130
- if (isWindows) {
131
- // Build both Debug and Release configurations on Windows
132
- exec('cmake --build . --config Debug --parallel');
133
- exec('cmake --build . --config Release --parallel');
134
- console.log('\nLibrats built successfully (Debug and Release)');
135
- } else {
136
- exec('cmake --build . -- -j4');
137
- console.log('\nLibrats built successfully');
138
- }
139
-
140
- // Verify the library was built
141
- const expectedLibPaths = isWindows
142
- ? [
143
- path.join(buildDir, 'lib', 'Debug', 'rats.lib'),
144
- path.join(buildDir, 'lib', 'Release', 'rats.lib')
145
- ]
146
- : [
147
- path.join(buildDir, 'lib', 'librats.a')
148
- ];
149
-
150
- console.log('\nBuild directory:', buildDir);
151
-
152
- let foundLib = false;
153
- for (const libPath of expectedLibPaths) {
154
- if (fs.existsSync(libPath)) {
155
- console.log(`✓ Found library: ${libPath}`);
156
- foundLib = true;
157
- }
158
- }
159
-
160
- if (!foundLib) {
161
- console.warn('WARNING: Could not find built library files.');
162
- console.warn('Expected paths:');
163
- expectedLibPaths.forEach(p => console.warn(` - ${p}`));
164
- console.warn('The build may have failed. Check the output above.');
165
- // Don't exit with error - let node-gyp try anyway
166
- }
167
-
168
- console.log('\n✓ Librats build completed successfully!\n');
169
-
170
- } catch (error) {
171
- console.error('\n✗ Failed to build librats library');
172
- console.error('Error:', error.message);
173
-
174
- // Provide helpful error messages
175
- console.error('\nTroubleshooting:');
176
-
177
- if (isWindows) {
178
- console.error('- Ensure Visual Studio Build Tools or Visual Studio is installed');
179
- console.error('- Download from: https://visualstudio.microsoft.com/downloads/');
180
- console.error('- Or run: npm install --global windows-build-tools');
181
- } else if (isMac) {
182
- console.error('- Ensure Xcode Command Line Tools are installed');
183
- console.error('- Run: xcode-select --install');
184
- } else if (isLinux) {
185
- console.error('- Ensure build-essential is installed');
186
- console.error('- Run: sudo apt install build-essential cmake');
187
- }
188
-
189
- console.error('- Ensure CMake is installed and available in PATH');
190
- console.error('- CMake download: https://cmake.org/download/');
191
-
192
- process.exit(1);
193
- }
194
-
1
+ #!/usr/bin/env node
2
+
3
+ const { execSync } = require('child_process');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const os = require('os');
7
+
8
+ // Determine platform
9
+ const isWindows = process.platform === 'win32';
10
+ const isMac = process.platform === 'darwin';
11
+ const isLinux = process.platform === 'linux';
12
+
13
+ // Paths
14
+ const nodejsRoot = path.resolve(__dirname, '..');
15
+ const buildDir = path.resolve(nodejsRoot, 'build-native');
16
+
17
+ // Determine source location:
18
+ // 1. When installed from npm: sources are in nodejs/native-src/
19
+ // 2. When developing locally: sources are in project root (../../ from scripts)
20
+ let projectRoot;
21
+ let srcDir;
22
+ let cmakeLists;
23
+
24
+ const nativeSrcDir = path.resolve(nodejsRoot, 'native-src');
25
+ const devProjectRoot = path.resolve(__dirname, '..', '..');
26
+
27
+ if (fs.existsSync(path.join(nativeSrcDir, 'CMakeLists.txt'))) {
28
+ // npm install scenario: use native-src directory
29
+ projectRoot = nativeSrcDir;
30
+ srcDir = path.resolve(nativeSrcDir, 'src');
31
+ cmakeLists = path.resolve(nativeSrcDir, 'CMakeLists.txt');
32
+ console.log('Using bundled source files from native-src/');
33
+ } else if (fs.existsSync(path.join(devProjectRoot, 'CMakeLists.txt'))) {
34
+ // Development scenario: use parent directory
35
+ projectRoot = devProjectRoot;
36
+ srcDir = path.resolve(devProjectRoot, 'src');
37
+ cmakeLists = path.resolve(devProjectRoot, 'CMakeLists.txt');
38
+ console.log('Using source files from project root (development mode)');
39
+ } else {
40
+ console.error('ERROR: Cannot find librats source files.');
41
+ console.error('');
42
+ console.error('Checked locations:');
43
+ console.error(` - ${nativeSrcDir} (npm install)`);
44
+ console.error(` - ${devProjectRoot} (development)`);
45
+ console.error('');
46
+ console.error('If you installed from npm, the package may be corrupted.');
47
+ console.error('Try: npm cache clean --force && npm install librats');
48
+ console.error('');
49
+ console.error('If you are developing locally, make sure you are in the librats repository.');
50
+ process.exit(1);
51
+ }
52
+
53
+ console.log('Building librats native library...');
54
+ console.log(`Platform: ${process.platform}`);
55
+ console.log(`Source root: ${projectRoot}`);
56
+ console.log(`Build directory: ${buildDir}`);
57
+
58
+ // Check if CMake is installed
59
+ try {
60
+ execSync('cmake --version', { stdio: 'pipe' });
61
+ console.log('✓ CMake found');
62
+ } catch (error) {
63
+ console.error('\n❌ ERROR: CMake is not installed or not in PATH');
64
+ console.error('\nCMake is required to build librats.');
65
+ console.error('Please install CMake:');
66
+ if (isWindows) {
67
+ console.error(' - Download from: https://cmake.org/download/');
68
+ console.error(' - Or use: winget install Kitware.CMake');
69
+ console.error(' - Or use: choco install cmake');
70
+ } else if (isMac) {
71
+ console.error(' - Use Homebrew: brew install cmake');
72
+ console.error(' - Or download from: https://cmake.org/download/');
73
+ } else if (isLinux) {
74
+ console.error(' - Use: sudo apt install cmake');
75
+ console.error(' - Or: sudo yum install cmake');
76
+ console.error(' - Or download from: https://cmake.org/download/');
77
+ }
78
+ console.error('\nAfter installing CMake, run: npm install\n');
79
+ process.exit(1);
80
+ }
81
+
82
+ // Verify CMakeLists.txt exists
83
+ if (!fs.existsSync(cmakeLists)) {
84
+ console.error('ERROR: CMakeLists.txt not found.');
85
+ console.error(`Expected at: ${cmakeLists}`);
86
+ process.exit(1);
87
+ }
88
+
89
+ // Verify src directory exists
90
+ if (!fs.existsSync(srcDir)) {
91
+ console.error('ERROR: src directory not found.');
92
+ console.error(`Expected at: ${srcDir}`);
93
+ process.exit(1);
94
+ }
95
+
96
+ // Create build directory if it doesn't exist
97
+ if (!fs.existsSync(buildDir)) {
98
+ console.log(`Creating build directory: ${buildDir}`);
99
+ fs.mkdirSync(buildDir, { recursive: true });
100
+ } else {
101
+ // Clear CMake cache if it exists to avoid source directory mismatch errors
102
+ const cmakeCache = path.join(buildDir, 'CMakeCache.txt');
103
+ if (fs.existsSync(cmakeCache)) {
104
+ console.log('Clearing existing CMake cache...');
105
+ fs.unlinkSync(cmakeCache);
106
+
107
+ // Also remove CMakeFiles directory for a clean reconfigure
108
+ const cmakeFiles = path.join(buildDir, 'CMakeFiles');
109
+ if (fs.existsSync(cmakeFiles)) {
110
+ fs.rmSync(cmakeFiles, { recursive: true, force: true });
111
+ }
112
+ }
113
+ }
114
+
115
+ // Helper function to execute commands
116
+ function exec(command, options = {}) {
117
+ console.log(`> ${command}`);
118
+ try {
119
+ execSync(command, {
120
+ cwd: buildDir,
121
+ stdio: 'inherit',
122
+ ...options
123
+ });
124
+ } catch (error) {
125
+ console.error(`Command failed: ${command}`);
126
+ throw error;
127
+ }
128
+ }
129
+
130
+ try {
131
+ // Configure CMake with appropriate options
132
+ console.log('\nConfiguring CMake...');
133
+
134
+ let cmakeArgs = [
135
+ '-DRATS_BUILD_TESTS=OFF',
136
+ '-DRATS_BUILD_EXAMPLES=OFF',
137
+ '-DRATS_STATIC_LIBRARY=ON',
138
+ '-DRATS_BINDINGS=ON',
139
+ '-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL'
140
+ ];
141
+
142
+ // Add platform-specific CMake arguments
143
+ if (isWindows) {
144
+ // Try to detect Visual Studio version
145
+ const vsVersions = ['2022', '2019', '2017'];
146
+ let generator = null;
147
+
148
+ for (const version of vsVersions) {
149
+ try {
150
+ execSync(`where "C:\\Program Files\\Microsoft Visual Studio\\${version}"`, { stdio: 'ignore' });
151
+ generator = `Visual Studio ${version === '2022' ? '17' : version === '2019' ? '16' : '15'} ${version}`;
152
+ break;
153
+ } catch (e) {
154
+ // Try next version
155
+ }
156
+ }
157
+
158
+ if (generator) {
159
+ cmakeArgs.push(`-G "${generator}"`);
160
+ cmakeArgs.push('-A x64');
161
+ }
162
+ } else if (isMac) {
163
+ // Use Unix Makefiles on macOS
164
+ cmakeArgs.push('-G "Unix Makefiles"');
165
+ } else if (isLinux) {
166
+ // Use Unix Makefiles on Linux
167
+ cmakeArgs.push('-G "Unix Makefiles"');
168
+ }
169
+
170
+ // Calculate the relative path from build directory to source root
171
+ const relativePath = path.relative(buildDir, projectRoot);
172
+ const cmakeConfigCmd = `cmake ${cmakeArgs.join(' ')} "${relativePath}"`;
173
+ exec(cmakeConfigCmd);
174
+
175
+ // Build the library
176
+ console.log('\nBuilding librats library...');
177
+
178
+ if (isWindows) {
179
+ // Build both Debug and Release configurations on Windows
180
+ exec('cmake --build . --config Debug --parallel');
181
+ exec('cmake --build . --config Release --parallel');
182
+ console.log('\nLibrats built successfully (Debug and Release)');
183
+ } else {
184
+ exec('cmake --build . -- -j4');
185
+ console.log('\nLibrats built successfully');
186
+ }
187
+
188
+ // Verify the library was built
189
+ const expectedLibPaths = isWindows
190
+ ? [
191
+ path.join(buildDir, 'lib', 'Debug', 'rats.lib'),
192
+ path.join(buildDir, 'lib', 'Release', 'rats.lib')
193
+ ]
194
+ : [
195
+ path.join(buildDir, 'lib', 'librats.a')
196
+ ];
197
+
198
+ console.log('\nBuild directory:', buildDir);
199
+
200
+ let foundLib = false;
201
+ for (const libPath of expectedLibPaths) {
202
+ if (fs.existsSync(libPath)) {
203
+ console.log(`✓ Found library: ${libPath}`);
204
+ foundLib = true;
205
+ }
206
+ }
207
+
208
+ if (!foundLib) {
209
+ console.warn('WARNING: Could not find built library files.');
210
+ console.warn('Expected paths:');
211
+ expectedLibPaths.forEach(p => console.warn(` - ${p}`));
212
+ console.warn('The build may have failed. Check the output above.');
213
+ // Don't exit with error - let node-gyp try anyway
214
+ }
215
+
216
+ console.log('\n✓ Librats build completed successfully!\n');
217
+
218
+ } catch (error) {
219
+ console.error('\n✗ Failed to build librats library');
220
+ console.error('Error:', error.message);
221
+
222
+ // Provide helpful error messages
223
+ console.error('\nTroubleshooting:');
224
+
225
+ if (isWindows) {
226
+ console.error('- Ensure Visual Studio Build Tools or Visual Studio is installed');
227
+ console.error('- Download from: https://visualstudio.microsoft.com/downloads/');
228
+ console.error('- Or run: npm install --global windows-build-tools');
229
+ } else if (isMac) {
230
+ console.error('- Ensure Xcode Command Line Tools are installed');
231
+ console.error('- Run: xcode-select --install');
232
+ } else if (isLinux) {
233
+ console.error('- Ensure build-essential is installed');
234
+ console.error('- Run: sudo apt install build-essential cmake');
235
+ }
236
+
237
+ console.error('- Ensure CMake is installed and available in PATH');
238
+ console.error('- CMake download: https://cmake.org/download/');
239
+
240
+ process.exit(1);
241
+ }
@@ -1,52 +1,52 @@
1
- #!/usr/bin/env node
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
-
6
- // Check if we're in a development install (node_modules doesn't contain librats)
7
- const isDev = !__dirname.includes('node_modules');
8
-
9
- if (isDev) {
10
- console.log('\n✨ Development installation detected');
11
- console.log(' Librats native addon has been built for local development\n');
12
- } else {
13
- console.log('\n✅ Librats installed successfully!');
14
- console.log(' Native addon is ready to use\n');
15
- }
16
-
17
- // Check if the addon was built successfully
18
- const possiblePaths = [
19
- path.join(__dirname, '..', 'build', 'Release', 'librats.node'),
20
- path.join(__dirname, '..', 'build', 'Debug', 'librats.node'),
21
- ];
22
-
23
- let addonFound = false;
24
- for (const addonPath of possiblePaths) {
25
- if (fs.existsSync(addonPath)) {
26
- addonFound = true;
27
- if (process.env.LIBRATS_DEBUG) {
28
- console.log(` Native addon: ${addonPath}`);
29
- }
30
- break;
31
- }
32
- }
33
-
34
- if (!addonFound) {
35
- console.warn('⚠️ Warning: Native addon not found');
36
- console.warn(' The build may have failed. Try running:');
37
- console.warn(' npm rebuild librats\n');
38
- }
39
-
40
- // Show quick start example
41
- if (!process.env.CI && !process.env.npm_config_global) {
42
- console.log('Verify installation:');
43
- console.log(' npm run verify\n');
44
- console.log('Quick start:');
45
- console.log('```javascript');
46
- console.log("const { RatsClient } = require('librats');");
47
- console.log('const client = new RatsClient(8080);');
48
- console.log('client.start();');
49
- console.log('```\n');
50
- console.log('Documentation: https://github.com/librats/librats/tree/main/nodejs\n');
51
- }
52
-
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ // Check if we're in a development install (node_modules doesn't contain librats)
7
+ const isDev = !__dirname.includes('node_modules');
8
+
9
+ if (isDev) {
10
+ console.log('\n✨ Development installation detected');
11
+ console.log(' Librats native addon has been built for local development\n');
12
+ } else {
13
+ console.log('\n✅ Librats installed successfully!');
14
+ console.log(' Native addon is ready to use\n');
15
+ }
16
+
17
+ // Check if the addon was built successfully
18
+ const possiblePaths = [
19
+ path.join(__dirname, '..', 'build', 'Release', 'librats.node'),
20
+ path.join(__dirname, '..', 'build', 'Debug', 'librats.node'),
21
+ ];
22
+
23
+ let addonFound = false;
24
+ for (const addonPath of possiblePaths) {
25
+ if (fs.existsSync(addonPath)) {
26
+ addonFound = true;
27
+ if (process.env.LIBRATS_DEBUG) {
28
+ console.log(` Native addon: ${addonPath}`);
29
+ }
30
+ break;
31
+ }
32
+ }
33
+
34
+ if (!addonFound) {
35
+ console.warn('⚠️ Warning: Native addon not found');
36
+ console.warn(' The build may have failed. Try running:');
37
+ console.warn(' npm rebuild librats\n');
38
+ }
39
+
40
+ // Show quick start example
41
+ if (!process.env.CI && !process.env.npm_config_global) {
42
+ console.log('Verify installation:');
43
+ console.log(' npm run verify\n');
44
+ console.log('Quick start:');
45
+ console.log('```javascript');
46
+ console.log("const { RatsClient } = require('librats');");
47
+ console.log('const client = new RatsClient(8080);');
48
+ console.log('client.start();');
49
+ console.log('```\n');
50
+ console.log('Documentation: https://github.com/librats/librats/tree/main/nodejs\n');
51
+ }
52
+