diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..5193036 --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +build-from-source=false +prefer-offline=true \ No newline at end of file diff --git a/package.json b/package.json index 1a009d2..a26c018 100644 --- a/package.json +++ b/package.json @@ -18,12 +18,13 @@ "lint:fix": "eslint src --ext .ts --fix", "format": "prettier --write \"src/**/*.{ts,js}\" \"test/**/*.js\"", "format:check": "prettier --check \"src/**/*.{ts,js}\" \"test/**/*.js\"", - "prepare": "husky" + "prepare": "husky", + "postinstall": "node scripts/postinstall.js || true" }, "dependencies": { "@modelcontextprotocol/sdk": "^1.11.2", "clipboardy": "^4.0.0", - "keysender": "^2.3.0", + "keysender": "^2.2.0", "sharp": "^0.34.1", "ulid": "^3.0.0", "uuid": "^11.1.0", diff --git a/prebuilt/keysender/key_sender.node b/prebuilt/keysender/key_sender.node new file mode 100644 index 0000000..7f25447 Binary files /dev/null and b/prebuilt/keysender/key_sender.node differ diff --git a/scripts/postinstall.js b/scripts/postinstall.js new file mode 100644 index 0000000..317cb3e --- /dev/null +++ b/scripts/postinstall.js @@ -0,0 +1,27 @@ +#!/usr/bin/env node + +import fs from 'fs'; +import path from 'path'; +import { fileURLToPath } from 'url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +console.log('[postinstall] Copying pre-built keysender binary...'); + +const sourceDir = path.join(__dirname, '..', 'prebuilt', 'keysender'); +const targetDir = path.join(__dirname, '..', 'node_modules', 'keysender', 'build', 'Release'); +const sourceFile = path.join(sourceDir, 'key_sender.node'); +const targetFile = path.join(targetDir, 'key_sender.node'); + +// Create target directory if it doesn't exist +fs.mkdirSync(targetDir, { recursive: true }); + +// Copy the pre-built binary +try { + fs.copyFileSync(sourceFile, targetFile); + console.log('[postinstall] Successfully copied key_sender.node'); +} catch (error) { + console.error('[postinstall] Error copying pre-built binary:', error.message); + // Don't exit with error - allow npm to continue +} \ No newline at end of file