sdl-mcp-native 0.8.0 → 0.8.2
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.
- package/index.js +146 -146
- package/package.json +7 -7
package/index.js
CHANGED
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Platform-detection loader for sdl-mcp-native.
|
|
5
|
-
*
|
|
6
|
-
* Standard napi-rs pattern: detects process.platform/process.arch and loads
|
|
7
|
-
* the correct prebuilt binary from per-platform npm packages.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const { existsSync, readFileSync } = require("fs");
|
|
11
|
-
const { join } = require("path");
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Determine the platform package name based on current OS/arch/libc.
|
|
15
|
-
* @returns {string | null}
|
|
16
|
-
*/
|
|
17
|
-
function getPackageName() {
|
|
18
|
-
const platform = process.platform;
|
|
19
|
-
const arch = process.arch;
|
|
20
|
-
|
|
21
|
-
if (platform === "win32" && arch === "x64") {
|
|
22
|
-
return "sdl-mcp-native-win32-x64-msvc";
|
|
23
|
-
}
|
|
24
|
-
if (platform === "darwin" && arch === "x64") {
|
|
25
|
-
return "sdl-mcp-native-darwin-x64";
|
|
26
|
-
}
|
|
27
|
-
if (platform === "darwin" && arch === "arm64") {
|
|
28
|
-
return "sdl-mcp-native-darwin-arm64";
|
|
29
|
-
}
|
|
30
|
-
if (platform === "linux" && arch === "x64") {
|
|
31
|
-
// Detect musl vs glibc
|
|
32
|
-
if (isMusl()) {
|
|
33
|
-
return "sdl-mcp-native-linux-x64-musl";
|
|
34
|
-
}
|
|
35
|
-
return "sdl-mcp-native-linux-x64-gnu";
|
|
36
|
-
}
|
|
37
|
-
if (platform === "linux" && arch === "arm64") {
|
|
38
|
-
return "sdl-mcp-native-linux-arm64-gnu";
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Detect musl libc on Linux.
|
|
46
|
-
* @returns {boolean}
|
|
47
|
-
*/
|
|
48
|
-
function isMusl() {
|
|
49
|
-
// Check if we're running on Alpine or musl-based distro
|
|
50
|
-
try {
|
|
51
|
-
const output = readFileSync("/usr/bin/ldd", "utf8");
|
|
52
|
-
if (output.includes("musl")) return true;
|
|
53
|
-
} catch {
|
|
54
|
-
// ldd not readable
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
if (existsSync("/etc/alpine-release")) return true;
|
|
59
|
-
} catch {
|
|
60
|
-
// not alpine
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Check the dynamic linker
|
|
64
|
-
try {
|
|
65
|
-
const maps = readFileSync("/proc/self/maps", "utf8");
|
|
66
|
-
if (maps.includes("musl")) return true;
|
|
67
|
-
} catch {
|
|
68
|
-
// /proc not available
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Map platform package names to their .node file suffix.
|
|
76
|
-
*/
|
|
77
|
-
const PLATFORM_NODE_FILES = {
|
|
78
|
-
"sdl-mcp-native-win32-x64-msvc": "sdl-mcp-native.win32-x64-msvc.node",
|
|
79
|
-
"sdl-mcp-native-darwin-x64": "sdl-mcp-native.darwin-x64.node",
|
|
80
|
-
"sdl-mcp-native-darwin-arm64": "sdl-mcp-native.darwin-arm64.node",
|
|
81
|
-
"sdl-mcp-native-linux-x64-gnu": "sdl-mcp-native.linux-x64-gnu.node",
|
|
82
|
-
"sdl-mcp-native-linux-x64-musl": "sdl-mcp-native.linux-x64-musl.node",
|
|
83
|
-
"sdl-mcp-native-linux-arm64-gnu": "sdl-mcp-native.linux-arm64-gnu.node",
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
let nativeBinding = null;
|
|
87
|
-
let loadError = null;
|
|
88
|
-
|
|
89
|
-
const packageName = getPackageName();
|
|
90
|
-
|
|
91
|
-
if (packageName) {
|
|
92
|
-
const nodeFileName = PLATFORM_NODE_FILES[packageName];
|
|
93
|
-
|
|
94
|
-
// 1. Try local platform-suffixed .node file (dev builds via napi artifacts)
|
|
95
|
-
const localPlatformPath = join(__dirname, nodeFileName);
|
|
96
|
-
if (existsSync(localPlatformPath)) {
|
|
97
|
-
try {
|
|
98
|
-
nativeBinding = require(localPlatformPath);
|
|
99
|
-
} catch (e) {
|
|
100
|
-
loadError = e;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// 2. Try per-platform npm package
|
|
105
|
-
if (!nativeBinding) {
|
|
106
|
-
try {
|
|
107
|
-
nativeBinding = require(packageName);
|
|
108
|
-
} catch (e) {
|
|
109
|
-
loadError = e;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// 3. Try legacy local files (backward compat with dev builds)
|
|
114
|
-
if (!nativeBinding) {
|
|
115
|
-
const legacyPaths = [
|
|
116
|
-
join(__dirname, "sdl-mcp-native.node"),
|
|
117
|
-
join(__dirname, "index.node"),
|
|
118
|
-
];
|
|
119
|
-
for (const p of legacyPaths) {
|
|
120
|
-
if (existsSync(p)) {
|
|
121
|
-
try {
|
|
122
|
-
nativeBinding = require(p);
|
|
123
|
-
break;
|
|
124
|
-
} catch (e) {
|
|
125
|
-
loadError = e;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
} else {
|
|
131
|
-
loadError = new Error(
|
|
132
|
-
`Unsupported platform: ${process.platform}-${process.arch}. ` +
|
|
133
|
-
`sdl-mcp-native supports: win32-x64, darwin-x64, darwin-arm64, linux-x64, linux-arm64`
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (!nativeBinding) {
|
|
138
|
-
if (loadError) {
|
|
139
|
-
throw loadError;
|
|
140
|
-
}
|
|
141
|
-
throw new Error("Failed to load sdl-mcp-native native binding");
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
module.exports.parseFiles = nativeBinding.parseFiles;
|
|
145
|
-
module.exports.hashContentNative = nativeBinding.hashContentNative;
|
|
146
|
-
module.exports.generateSymbolIdNative = nativeBinding.generateSymbolIdNative;
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Platform-detection loader for sdl-mcp-native.
|
|
5
|
+
*
|
|
6
|
+
* Standard napi-rs pattern: detects process.platform/process.arch and loads
|
|
7
|
+
* the correct prebuilt binary from per-platform npm packages.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const { existsSync, readFileSync } = require("fs");
|
|
11
|
+
const { join } = require("path");
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Determine the platform package name based on current OS/arch/libc.
|
|
15
|
+
* @returns {string | null}
|
|
16
|
+
*/
|
|
17
|
+
function getPackageName() {
|
|
18
|
+
const platform = process.platform;
|
|
19
|
+
const arch = process.arch;
|
|
20
|
+
|
|
21
|
+
if (platform === "win32" && arch === "x64") {
|
|
22
|
+
return "sdl-mcp-native-win32-x64-msvc";
|
|
23
|
+
}
|
|
24
|
+
if (platform === "darwin" && arch === "x64") {
|
|
25
|
+
return "sdl-mcp-native-darwin-x64";
|
|
26
|
+
}
|
|
27
|
+
if (platform === "darwin" && arch === "arm64") {
|
|
28
|
+
return "sdl-mcp-native-darwin-arm64";
|
|
29
|
+
}
|
|
30
|
+
if (platform === "linux" && arch === "x64") {
|
|
31
|
+
// Detect musl vs glibc
|
|
32
|
+
if (isMusl()) {
|
|
33
|
+
return "sdl-mcp-native-linux-x64-musl";
|
|
34
|
+
}
|
|
35
|
+
return "sdl-mcp-native-linux-x64-gnu";
|
|
36
|
+
}
|
|
37
|
+
if (platform === "linux" && arch === "arm64") {
|
|
38
|
+
return "sdl-mcp-native-linux-arm64-gnu";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Detect musl libc on Linux.
|
|
46
|
+
* @returns {boolean}
|
|
47
|
+
*/
|
|
48
|
+
function isMusl() {
|
|
49
|
+
// Check if we're running on Alpine or musl-based distro
|
|
50
|
+
try {
|
|
51
|
+
const output = readFileSync("/usr/bin/ldd", "utf8");
|
|
52
|
+
if (output.includes("musl")) return true;
|
|
53
|
+
} catch {
|
|
54
|
+
// ldd not readable
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
if (existsSync("/etc/alpine-release")) return true;
|
|
59
|
+
} catch {
|
|
60
|
+
// not alpine
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Check the dynamic linker
|
|
64
|
+
try {
|
|
65
|
+
const maps = readFileSync("/proc/self/maps", "utf8");
|
|
66
|
+
if (maps.includes("musl")) return true;
|
|
67
|
+
} catch {
|
|
68
|
+
// /proc not available
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Map platform package names to their .node file suffix.
|
|
76
|
+
*/
|
|
77
|
+
const PLATFORM_NODE_FILES = {
|
|
78
|
+
"sdl-mcp-native-win32-x64-msvc": "sdl-mcp-native.win32-x64-msvc.node",
|
|
79
|
+
"sdl-mcp-native-darwin-x64": "sdl-mcp-native.darwin-x64.node",
|
|
80
|
+
"sdl-mcp-native-darwin-arm64": "sdl-mcp-native.darwin-arm64.node",
|
|
81
|
+
"sdl-mcp-native-linux-x64-gnu": "sdl-mcp-native.linux-x64-gnu.node",
|
|
82
|
+
"sdl-mcp-native-linux-x64-musl": "sdl-mcp-native.linux-x64-musl.node",
|
|
83
|
+
"sdl-mcp-native-linux-arm64-gnu": "sdl-mcp-native.linux-arm64-gnu.node",
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
let nativeBinding = null;
|
|
87
|
+
let loadError = null;
|
|
88
|
+
|
|
89
|
+
const packageName = getPackageName();
|
|
90
|
+
|
|
91
|
+
if (packageName) {
|
|
92
|
+
const nodeFileName = PLATFORM_NODE_FILES[packageName];
|
|
93
|
+
|
|
94
|
+
// 1. Try local platform-suffixed .node file (dev builds via napi artifacts)
|
|
95
|
+
const localPlatformPath = join(__dirname, nodeFileName);
|
|
96
|
+
if (existsSync(localPlatformPath)) {
|
|
97
|
+
try {
|
|
98
|
+
nativeBinding = require(localPlatformPath);
|
|
99
|
+
} catch (e) {
|
|
100
|
+
loadError = e;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// 2. Try per-platform npm package
|
|
105
|
+
if (!nativeBinding) {
|
|
106
|
+
try {
|
|
107
|
+
nativeBinding = require(packageName);
|
|
108
|
+
} catch (e) {
|
|
109
|
+
loadError = e;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 3. Try legacy local files (backward compat with dev builds)
|
|
114
|
+
if (!nativeBinding) {
|
|
115
|
+
const legacyPaths = [
|
|
116
|
+
join(__dirname, "sdl-mcp-native.node"),
|
|
117
|
+
join(__dirname, "index.node"),
|
|
118
|
+
];
|
|
119
|
+
for (const p of legacyPaths) {
|
|
120
|
+
if (existsSync(p)) {
|
|
121
|
+
try {
|
|
122
|
+
nativeBinding = require(p);
|
|
123
|
+
break;
|
|
124
|
+
} catch (e) {
|
|
125
|
+
loadError = e;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
loadError = new Error(
|
|
132
|
+
`Unsupported platform: ${process.platform}-${process.arch}. ` +
|
|
133
|
+
`sdl-mcp-native supports: win32-x64, darwin-x64, darwin-arm64, linux-x64, linux-arm64`
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (!nativeBinding) {
|
|
138
|
+
if (loadError) {
|
|
139
|
+
throw loadError;
|
|
140
|
+
}
|
|
141
|
+
throw new Error("Failed to load sdl-mcp-native native binding");
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
module.exports.parseFiles = nativeBinding.parseFiles;
|
|
145
|
+
module.exports.hashContentNative = nativeBinding.hashContentNative;
|
|
146
|
+
module.exports.generateSymbolIdNative = nativeBinding.generateSymbolIdNative;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sdl-mcp-native",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "Native Rust indexer for SDL-MCP with tree-sitter parsing and Rayon parallelism",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"main": "index.js",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"version": "napi version"
|
|
30
30
|
},
|
|
31
31
|
"optionalDependencies": {
|
|
32
|
-
"sdl-mcp-native-win32-x64-msvc": "0.8.
|
|
33
|
-
"sdl-mcp-native-darwin-x64": "0.8.
|
|
34
|
-
"sdl-mcp-native-darwin-arm64": "0.8.
|
|
35
|
-
"sdl-mcp-native-linux-x64-gnu": "0.8.
|
|
36
|
-
"sdl-mcp-native-linux-x64-musl": "0.8.
|
|
37
|
-
"sdl-mcp-native-linux-arm64-gnu": "0.8.
|
|
32
|
+
"sdl-mcp-native-win32-x64-msvc": "0.8.2",
|
|
33
|
+
"sdl-mcp-native-darwin-x64": "0.8.2",
|
|
34
|
+
"sdl-mcp-native-darwin-arm64": "0.8.2",
|
|
35
|
+
"sdl-mcp-native-linux-x64-gnu": "0.8.2",
|
|
36
|
+
"sdl-mcp-native-linux-x64-musl": "0.8.2",
|
|
37
|
+
"sdl-mcp-native-linux-arm64-gnu": "0.8.2"
|
|
38
38
|
},
|
|
39
39
|
"repository": {
|
|
40
40
|
"type": "git",
|