axhub-mcp-bridge 1.0.30
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/dist/README.md +25 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +158 -0
- package/dist/cli.js.map +1 -0
- package/dist/constant/index.d.ts +38 -0
- package/dist/constant/index.js +47 -0
- package/dist/constant/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/mcp-server-stdio.d.ts +50 -0
- package/dist/mcp/mcp-server-stdio.js +135 -0
- package/dist/mcp/mcp-server-stdio.js.map +1 -0
- package/dist/mcp/mcp-server.d.ts +25 -0
- package/dist/mcp/mcp-server.js +23 -0
- package/dist/mcp/mcp-server.js.map +1 -0
- package/dist/mcp/register-tools.d.ts +2 -0
- package/dist/mcp/register-tools.js +51 -0
- package/dist/mcp/register-tools.js.map +1 -0
- package/dist/mcp/stdio-config.json +3 -0
- package/dist/native-messaging-host.d.ts +38 -0
- package/dist/native-messaging-host.js +241 -0
- package/dist/native-messaging-host.js.map +1 -0
- package/dist/run_host.bat +95 -0
- package/dist/run_host.sh +141 -0
- package/dist/scripts/build.d.ts +1 -0
- package/dist/scripts/build.js +119 -0
- package/dist/scripts/build.js.map +1 -0
- package/dist/scripts/constant.d.ts +11 -0
- package/dist/scripts/constant.js +45 -0
- package/dist/scripts/constant.js.map +1 -0
- package/dist/scripts/postinstall.d.ts +2 -0
- package/dist/scripts/postinstall.js +231 -0
- package/dist/scripts/postinstall.js.map +1 -0
- package/dist/scripts/register-dev.d.ts +1 -0
- package/dist/scripts/register-dev.js +5 -0
- package/dist/scripts/register-dev.js.map +1 -0
- package/dist/scripts/register.d.ts +2 -0
- package/dist/scripts/register.js +22 -0
- package/dist/scripts/register.js.map +1 -0
- package/dist/scripts/utils.d.ts +36 -0
- package/dist/scripts/utils.js +353 -0
- package/dist/scripts/utils.js.map +1 -0
- package/dist/server/index.d.ts +24 -0
- package/dist/server/index.js +266 -0
- package/dist/server/index.js.map +1 -0
- package/dist/shared.d.ts +62 -0
- package/dist/shared.js +209 -0
- package/dist/shared.js.map +1 -0
- package/dist/util/logger.d.ts +1 -0
- package/dist/util/logger.js +43 -0
- package/dist/util/logger.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Environment-specific configuration for extension IDs
|
|
3
|
+
// Automatically detects dev vs build mode and uses appropriate extension ID
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.EXTENSION_CONFIG = exports.DESCRIPTION = exports.HOST_NAME = exports.EXTENSION_ID = exports.COMMAND_NAME = void 0;
|
|
6
|
+
exports.getExtensionConfig = getExtensionConfig;
|
|
7
|
+
// Development environment configuration (for npm run dev)
|
|
8
|
+
const DEV_CONFIG = {
|
|
9
|
+
extensionId: 'fhjdnggclemkomiakghnjefmcljbcddp', // Current production ID
|
|
10
|
+
hostName: 'com.axhubdev.nativehost', // Development host name
|
|
11
|
+
description: 'Node.js Host for Browser Bridge Extension (Dev)',
|
|
12
|
+
};
|
|
13
|
+
// Production environment configuration (for npm run build)
|
|
14
|
+
const PROD_CONFIG = {
|
|
15
|
+
extensionId: 'cndglokmgjecikflojjieeeajbljgfae', // Current production ID
|
|
16
|
+
hostName: 'com.axhub.nativehost', // Production host name
|
|
17
|
+
description: 'Node.js Host for Browser Bridge Extension',
|
|
18
|
+
};
|
|
19
|
+
// Detect if we're in development or build mode
|
|
20
|
+
function isDevelopmentMode() {
|
|
21
|
+
// Check if we're running in dev mode
|
|
22
|
+
if (typeof process !== 'undefined' && process.env) {
|
|
23
|
+
// Nodemon sets NODE_ENV to 'development' in dev mode
|
|
24
|
+
if (process.env.NODE_ENV === 'development')
|
|
25
|
+
return true;
|
|
26
|
+
// Check for explicit dev flag
|
|
27
|
+
if (process.env.NODEMON === 'true')
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
// Default to production mode (build)
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
// Get configuration based on mode
|
|
34
|
+
function getExtensionConfig() {
|
|
35
|
+
return isDevelopmentMode() ? DEV_CONFIG : PROD_CONFIG;
|
|
36
|
+
}
|
|
37
|
+
// Export individual values for backward compatibility
|
|
38
|
+
exports.COMMAND_NAME = 'axhub-mcp-bridge';
|
|
39
|
+
// Dynamic values based on mode
|
|
40
|
+
exports.EXTENSION_ID = getExtensionConfig().extensionId;
|
|
41
|
+
exports.HOST_NAME = getExtensionConfig().hostName;
|
|
42
|
+
exports.DESCRIPTION = getExtensionConfig().description;
|
|
43
|
+
// Export the full config for advanced usage
|
|
44
|
+
exports.EXTENSION_CONFIG = getExtensionConfig();
|
|
45
|
+
//# sourceMappingURL=constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../src/scripts/constant.ts"],"names":[],"mappings":";AAAA,uDAAuD;AACvD,4EAA4E;;;AAqC5E,gDAEC;AA/BD,0DAA0D;AAC1D,MAAM,UAAU,GAAoB;IAClC,WAAW,EAAE,kCAAkC,EAAE,wBAAwB;IACzE,QAAQ,EAAE,yBAAyB,EAAE,wBAAwB;IAC7D,WAAW,EAAE,iDAAiD;CAC/D,CAAC;AAEF,2DAA2D;AAC3D,MAAM,WAAW,GAAoB;IACnC,WAAW,EAAE,kCAAkC,EAAE,wBAAwB;IACzE,QAAQ,EAAE,sBAAsB,EAAE,uBAAuB;IACzD,WAAW,EAAE,2CAA2C;CACzD,CAAC;AAEF,+CAA+C;AAC/C,SAAS,iBAAiB;IACxB,qCAAqC;IACrC,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAClD,qDAAqD;QACrD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa;YAAE,OAAO,IAAI,CAAC;QACxD,8BAA8B;QAC9B,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,MAAM;YAAE,OAAO,IAAI,CAAC;IAClD,CAAC;IAED,qCAAqC;IACrC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,kCAAkC;AAClC,SAAgB,kBAAkB;IAChC,OAAO,iBAAiB,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC;AACxD,CAAC;AAED,sDAAsD;AACzC,QAAA,YAAY,GAAG,kBAAkB,CAAC;AAE/C,+BAA+B;AAClB,QAAA,YAAY,GAAG,kBAAkB,EAAE,CAAC,WAAW,CAAC;AAChD,QAAA,SAAS,GAAG,kBAAkB,EAAE,CAAC,QAAQ,CAAC;AAC1C,QAAA,WAAW,GAAG,kBAAkB,EAAE,CAAC,WAAW,CAAC;AAE5D,4CAA4C;AAC/B,QAAA,gBAAgB,GAAG,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const constant_1 = require("./constant");
|
|
11
|
+
const utils_1 = require("./utils");
|
|
12
|
+
// Check if this script is run directly
|
|
13
|
+
const isDirectRun = require.main === module;
|
|
14
|
+
// Detect global installation for both npm and pnpm
|
|
15
|
+
function detectGlobalInstall() {
|
|
16
|
+
// npm uses npm_config_global
|
|
17
|
+
if (process.env.npm_config_global === 'true') {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
// pnpm detection methods
|
|
21
|
+
// Method 1: Check if PNPM_HOME is set and current path contains it
|
|
22
|
+
if (process.env.PNPM_HOME && __dirname.includes(process.env.PNPM_HOME)) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
// Method 2: Check if we're in a global pnpm directory structure
|
|
26
|
+
// pnpm global packages are typically installed in ~/.local/share/pnpm/global/5/node_modules
|
|
27
|
+
// Windows: %APPDATA%\pnpm\global\5\node_modules
|
|
28
|
+
const globalPnpmPatterns = process.platform === 'win32'
|
|
29
|
+
? ['\\pnpm\\global\\', '\\pnpm-global\\', '\\AppData\\Roaming\\pnpm\\']
|
|
30
|
+
: ['/pnpm/global/', '/.local/share/pnpm/', '/pnpm-global/'];
|
|
31
|
+
if (globalPnpmPatterns.some((pattern) => __dirname.includes(pattern))) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
// Method 3: Check npm_config_prefix for pnpm
|
|
35
|
+
if (process.env.npm_config_prefix && __dirname.includes(process.env.npm_config_prefix)) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
// Method 4: Windows-specific global installation paths
|
|
39
|
+
if (process.platform === 'win32') {
|
|
40
|
+
const windowsGlobalPatterns = [
|
|
41
|
+
'\\npm\\node_modules\\',
|
|
42
|
+
'\\AppData\\Roaming\\npm\\node_modules\\',
|
|
43
|
+
'\\Program Files\\nodejs\\node_modules\\',
|
|
44
|
+
'\\nodejs\\node_modules\\',
|
|
45
|
+
];
|
|
46
|
+
if (windowsGlobalPatterns.some((pattern) => __dirname.includes(pattern))) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
const isGlobalInstall = detectGlobalInstall();
|
|
53
|
+
/**
|
|
54
|
+
* Write Node.js path for run_host scripts to avoid fragile relative paths
|
|
55
|
+
*/
|
|
56
|
+
async function writeNodePath() {
|
|
57
|
+
try {
|
|
58
|
+
const nodePath = process.execPath;
|
|
59
|
+
const nodePathFile = path_1.default.join(__dirname, '..', 'node_path.txt');
|
|
60
|
+
console.log((0, utils_1.colorText)(`Writing Node.js path: ${nodePath}`, 'blue'));
|
|
61
|
+
fs_1.default.writeFileSync(nodePathFile, nodePath, 'utf8');
|
|
62
|
+
console.log((0, utils_1.colorText)('✓ Node.js path written for run_host scripts', 'green'));
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
console.warn((0, utils_1.colorText)(`⚠️ Failed to write Node.js path: ${error.message}`, 'yellow'));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 确保执行权限(无论是否为全局安装)
|
|
70
|
+
*/
|
|
71
|
+
async function ensureExecutionPermissions() {
|
|
72
|
+
if (process.platform === 'win32') {
|
|
73
|
+
// Windows 平台处理
|
|
74
|
+
await ensureWindowsFilePermissions();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
// Unix/Linux 平台处理
|
|
78
|
+
const filesToCheck = [
|
|
79
|
+
path_1.default.join(__dirname, '..', 'index.js'),
|
|
80
|
+
path_1.default.join(__dirname, '..', 'run_host.sh'),
|
|
81
|
+
path_1.default.join(__dirname, '..', 'cli.js'),
|
|
82
|
+
];
|
|
83
|
+
for (const filePath of filesToCheck) {
|
|
84
|
+
if (fs_1.default.existsSync(filePath)) {
|
|
85
|
+
try {
|
|
86
|
+
fs_1.default.chmodSync(filePath, '755');
|
|
87
|
+
console.log((0, utils_1.colorText)(`✓ Set execution permissions for ${path_1.default.basename(filePath)}`, 'green'));
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
console.warn((0, utils_1.colorText)(`⚠️ Unable to set execution permissions for ${path_1.default.basename(filePath)}: ${err.message}`, 'yellow'));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
console.warn((0, utils_1.colorText)(`⚠️ File not found: ${filePath}`, 'yellow'));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Windows 平台文件权限处理
|
|
100
|
+
*/
|
|
101
|
+
async function ensureWindowsFilePermissions() {
|
|
102
|
+
const filesToCheck = [
|
|
103
|
+
path_1.default.join(__dirname, '..', 'index.js'),
|
|
104
|
+
path_1.default.join(__dirname, '..', 'run_host.bat'),
|
|
105
|
+
path_1.default.join(__dirname, '..', 'cli.js'),
|
|
106
|
+
];
|
|
107
|
+
for (const filePath of filesToCheck) {
|
|
108
|
+
if (fs_1.default.existsSync(filePath)) {
|
|
109
|
+
try {
|
|
110
|
+
// 检查文件是否为只读,如果是则移除只读属性
|
|
111
|
+
const stats = fs_1.default.statSync(filePath);
|
|
112
|
+
if (!(stats.mode & parseInt('200', 8))) {
|
|
113
|
+
// 检查写权限
|
|
114
|
+
// 尝试移除只读属性
|
|
115
|
+
fs_1.default.chmodSync(filePath, stats.mode | parseInt('200', 8));
|
|
116
|
+
console.log((0, utils_1.colorText)(`✓ Removed read-only attribute from ${path_1.default.basename(filePath)}`, 'green'));
|
|
117
|
+
}
|
|
118
|
+
// 验证文件可读性
|
|
119
|
+
fs_1.default.accessSync(filePath, fs_1.default.constants.R_OK);
|
|
120
|
+
console.log((0, utils_1.colorText)(`✓ Verified file accessibility for ${path_1.default.basename(filePath)}`, 'green'));
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
console.warn((0, utils_1.colorText)(`⚠️ Unable to verify file permissions for ${path_1.default.basename(filePath)}: ${err.message}`, 'yellow'));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
console.warn((0, utils_1.colorText)(`⚠️ File not found: ${filePath}`, 'yellow'));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async function tryRegisterNativeHost() {
|
|
132
|
+
try {
|
|
133
|
+
console.log((0, utils_1.colorText)('Attempting to register Chrome Native Messaging host...', 'blue'));
|
|
134
|
+
// Always ensure execution permissions, regardless of installation type
|
|
135
|
+
await ensureExecutionPermissions();
|
|
136
|
+
if (isGlobalInstall) {
|
|
137
|
+
// First try user-level installation (no elevated permissions required)
|
|
138
|
+
const userLevelSuccess = await (0, utils_1.tryRegisterUserLevelHost)();
|
|
139
|
+
if (!userLevelSuccess) {
|
|
140
|
+
// User-level installation failed, suggest using register command
|
|
141
|
+
console.log((0, utils_1.colorText)('User-level installation failed, system-level installation may be needed', 'yellow'));
|
|
142
|
+
console.log((0, utils_1.colorText)('Please run the following command for system-level installation:', 'blue'));
|
|
143
|
+
console.log(` ${constant_1.COMMAND_NAME} register --system`);
|
|
144
|
+
printManualInstructions();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
// Local installation mode, don't attempt automatic registration
|
|
149
|
+
console.log((0, utils_1.colorText)('Local installation detected, skipping automatic registration', 'yellow'));
|
|
150
|
+
printManualInstructions();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
console.log((0, utils_1.colorText)(`注册过程中出现错误: ${error instanceof Error ? error.message : String(error)}`, 'red'));
|
|
155
|
+
printManualInstructions();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* 打印手动安装指南
|
|
160
|
+
*/
|
|
161
|
+
function printManualInstructions() {
|
|
162
|
+
console.log('\n' + (0, utils_1.colorText)('===== Manual Registration Guide =====', 'blue'));
|
|
163
|
+
console.log((0, utils_1.colorText)('1. Try user-level installation (recommended):', 'yellow'));
|
|
164
|
+
if (isGlobalInstall) {
|
|
165
|
+
console.log(` ${constant_1.COMMAND_NAME} register`);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
console.log(` npx ${constant_1.COMMAND_NAME} register`);
|
|
169
|
+
}
|
|
170
|
+
console.log((0, utils_1.colorText)('\n2. If user-level installation fails, try system-level installation:', 'yellow'));
|
|
171
|
+
console.log((0, utils_1.colorText)(' Use --system parameter (auto-elevate permissions):', 'yellow'));
|
|
172
|
+
if (isGlobalInstall) {
|
|
173
|
+
console.log(` ${constant_1.COMMAND_NAME} register --system`);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
console.log(` npx ${constant_1.COMMAND_NAME} register --system`);
|
|
177
|
+
}
|
|
178
|
+
console.log((0, utils_1.colorText)('\n Or use administrator privileges directly:', 'yellow'));
|
|
179
|
+
if (os_1.default.platform() === 'win32') {
|
|
180
|
+
console.log((0, utils_1.colorText)(' Please run Command Prompt or PowerShell as administrator and execute:', 'yellow'));
|
|
181
|
+
if (isGlobalInstall) {
|
|
182
|
+
console.log(` ${constant_1.COMMAND_NAME} register`);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
console.log(` npx ${constant_1.COMMAND_NAME} register`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
console.log((0, utils_1.colorText)(' Please run the following command in terminal:', 'yellow'));
|
|
190
|
+
if (isGlobalInstall) {
|
|
191
|
+
console.log(` sudo ${constant_1.COMMAND_NAME} register`);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
console.log(` sudo npx ${constant_1.COMMAND_NAME} register`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
console.log('\n' +
|
|
198
|
+
(0, utils_1.colorText)('Ensure Chrome extension is installed and refresh the extension to connect to local service.', 'blue'));
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* 主函数
|
|
202
|
+
*/
|
|
203
|
+
async function main() {
|
|
204
|
+
console.log((0, utils_1.colorText)(`Installing ${constant_1.COMMAND_NAME}...`, 'green'));
|
|
205
|
+
// Debug information
|
|
206
|
+
console.log((0, utils_1.colorText)('Installation environment debug info:', 'blue'));
|
|
207
|
+
console.log(` __dirname: ${__dirname}`);
|
|
208
|
+
console.log(` npm_config_global: ${process.env.npm_config_global}`);
|
|
209
|
+
console.log(` PNPM_HOME: ${process.env.PNPM_HOME}`);
|
|
210
|
+
console.log(` npm_config_prefix: ${process.env.npm_config_prefix}`);
|
|
211
|
+
console.log(` isGlobalInstall: ${isGlobalInstall}`);
|
|
212
|
+
// Always ensure execution permissions first
|
|
213
|
+
await ensureExecutionPermissions();
|
|
214
|
+
// Write Node.js path for run_host scripts to use
|
|
215
|
+
await writeNodePath();
|
|
216
|
+
// If global installation, try automatic registration
|
|
217
|
+
if (isGlobalInstall) {
|
|
218
|
+
await tryRegisterNativeHost();
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
console.log((0, utils_1.colorText)('Local installation detected', 'yellow'));
|
|
222
|
+
printManualInstructions();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
// Only execute main function when running this script directly
|
|
226
|
+
if (isDirectRun) {
|
|
227
|
+
main().catch((error) => {
|
|
228
|
+
console.error((0, utils_1.colorText)(`Installation script error: ${error instanceof Error ? error.message : String(error)}`, 'red'));
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
//# sourceMappingURL=postinstall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postinstall.js","sourceRoot":"","sources":["../../src/scripts/postinstall.ts"],"names":[],"mappings":";;;;;;AAEA,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AACxB,yCAA0C;AAC1C,mCAA8D;AAE9D,uCAAuC;AACvC,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC;AAE5C,mDAAmD;AACnD,SAAS,mBAAmB;IAC1B,6BAA6B;IAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,MAAM,EAAE,CAAC;QAC7C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,yBAAyB;IACzB,mEAAmE;IACnE,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;QACvE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gEAAgE;IAChE,4FAA4F;IAC5F,gDAAgD;IAChD,MAAM,kBAAkB,GACtB,OAA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AAC,sBAAsB,eAAe,EAAE,CAAC,CAAC;IAErD,4CAA4C;IAC5C,MAAM,0BAA0B,EAAE,CAAC;IAEnC,iDAAiD;IACjD,MAAM,aAAa,EAAE,CAAC;IAEtB,qDAAqD;IACrD,IAAI,eAAe,EAAE,CAAC;QACpB,MAAM,qBAAqB,EAAE,CAAC;IAChC,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,IAAA,iBAAS,EAAC,6BAA6B,EAAE,QAAQ,CAAC,CAAC,CAAC;QAChE,uBAAuB,EAAE,CAAC;IAC5B,CAAC;AACH,CAAC;AAED,+DAA+D;AAC/D,IAAI,WAAW,EAAE,CAAC;IAChB,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACrB,OAAO,CAAC,KAAK,CACX,IAAA,iBAAS,EACP,8BAA8B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EACtF,KAAK,CACN,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-dev.js","sourceRoot":"","sources":["../../src/scripts/register-dev.ts"],"names":[],"mappings":";;AAAA,mCAAmD;AAEnD,IAAA,gCAAwB,GAAE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const constant_1 = require("./constant");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
/**
|
|
7
|
+
* 主函数
|
|
8
|
+
*/
|
|
9
|
+
async function main() {
|
|
10
|
+
console.log((0, utils_1.colorText)(`正在注册 ${constant_1.COMMAND_NAME} Native Messaging主机...`, 'blue'));
|
|
11
|
+
try {
|
|
12
|
+
await (0, utils_1.registerWithElevatedPermissions)();
|
|
13
|
+
console.log((0, utils_1.colorText)('注册成功!现在Chrome扩展可以通过Native Messaging与本地服务通信。', 'green'));
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
console.error((0, utils_1.colorText)(`注册失败: ${error.message}`, 'red'));
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
// 执行主函数
|
|
21
|
+
main();
|
|
22
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/scripts/register.ts"],"names":[],"mappings":";;;AACA,yCAA0C;AAC1C,mCAAqE;AAErE;;GAEG;AACH,KAAK,UAAU,IAAI;IACjB,OAAO,CAAC,GAAG,CAAC,IAAA,iBAAS,EAAC,QAAQ,uBAAY,wBAAwB,EAAE,MAAM,CAAC,CAAC,CAAC;IAE7E,IAAI,CAAC;QACH,MAAM,IAAA,uCAA+B,GAAE,CAAC;QACxC,OAAO,CAAC,GAAG,CACT,IAAA,iBAAS,EAAC,6CAA6C,EAAE,OAAO,CAAC,CAClE,CAAC;IACJ,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,IAAA,iBAAS,EAAC,SAAS,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;QAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,QAAQ;AACR,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
export declare const access: typeof fs.access.__promisify__;
|
|
3
|
+
export declare const mkdir: typeof fs.mkdir.__promisify__;
|
|
4
|
+
export declare const writeFile: typeof fs.writeFile.__promisify__;
|
|
5
|
+
/**
|
|
6
|
+
* 打印彩色文本
|
|
7
|
+
*/
|
|
8
|
+
export declare function colorText(text: string, color: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Get user-level manifest file path
|
|
11
|
+
*/
|
|
12
|
+
export declare function getUserManifestPath(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Get system-level manifest file path
|
|
15
|
+
*/
|
|
16
|
+
export declare function getSystemManifestPath(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Get native host startup script file path
|
|
19
|
+
*/
|
|
20
|
+
export declare function getMainPath(): Promise<string>;
|
|
21
|
+
/**
|
|
22
|
+
* 确保关键文件具有执行权限
|
|
23
|
+
*/
|
|
24
|
+
export declare function ensureExecutionPermissions(): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Create Native Messaging host manifest content
|
|
27
|
+
*/
|
|
28
|
+
export declare function createManifestContent(): Promise<any>;
|
|
29
|
+
/**
|
|
30
|
+
* 尝试注册用户级别的Native Messaging主机
|
|
31
|
+
*/
|
|
32
|
+
export declare function tryRegisterUserLevelHost(): Promise<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* 使用提升权限注册系统级清单
|
|
35
|
+
*/
|
|
36
|
+
export declare function registerWithElevatedPermissions(): Promise<void>;
|