From 4333de78259c3450b6c4f242d203944968ca680e Mon Sep 17 00:00:00 2001 From: fan xia Date: Mon, 16 Oct 2023 23:29:29 +0800 Subject: [PATCH] 0.0.10 --- addon/.gitignore | 2 + addon/index.d.ts | 54 ------------- addon/index.js | 203 ----------------------------------------------- 3 files changed, 2 insertions(+), 257 deletions(-) delete mode 100644 addon/index.d.ts delete mode 100644 addon/index.js diff --git a/addon/.gitignore b/addon/.gitignore index 835453d..6cbb841 100644 --- a/addon/.gitignore +++ b/addon/.gitignore @@ -1,5 +1,7 @@ # Created by https://www.toptal.com/developers/gitignore/api/node # Edit at https://www.toptal.com/developers/gitignore?templates=node +index.d.ts +index.js ### Node ### # Logs diff --git a/addon/index.d.ts b/addon/index.d.ts deleted file mode 100644 index 740e437..0000000 --- a/addon/index.d.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ - -/* auto-generated by NAPI-RS */ - -export interface ClipBoardContentJson { - type: 'file' | 'text' - content: Array -} -export function getClipboardContent(): ClipBoardContentJson | null -export function onInputEvent(callback: (event: string) => void): void -export function grabInputEvent(callback: (event: string) => boolean): void -export function exeLookBase64(fileName: string): string | null -export function parseLnk(path: string): string | null -export function parseLnkFallback(path: string): LnkData -export function sendKeyboardSimulation(cmd: string): void -export const enum MouseBtn { - Left = 0, - Middle = 1, - Right = 2, - Back = 3, - Forward = 4 -} -export const enum MouseAction { - Locaion = 0, - MoveRelative = 1, - MoveTo = 2, - ScrollX = 3, - ScrollY = 4, - Up = 5, - Down = 6, - Click = 7 -} -export interface MouseActionInput { - action: MouseAction - data?: Position - button?: MouseBtn -} -export interface Position { - x: number - y: number -} -export function sendMouseSimulation(input: MouseActionInput): Position | null -export class ShorCutImg { - data: Array - width: number - height: number -} -export class LnkData { - nameString?: string - relativePath?: string - workingDir?: string - iconLocation?: string -} diff --git a/addon/index.js b/addon/index.js deleted file mode 100644 index c0257a8..0000000 --- a/addon/index.js +++ /dev/null @@ -1,203 +0,0 @@ -const { existsSync, readFileSync } = require('fs') -const { join } = require('path') - -const { platform, arch } = process - -let nativeBinding = null -let localFileExisted = false -let loadError = null - -function isMusl() { - // For Node 10 - if (!process.report || typeof process.report.getReport !== 'function') { - try { - const lddPath = require('child_process').execSync('which ldd').toString().trim() - return readFileSync(lddPath, 'utf8').includes('musl') - } catch (e) { - return true - } - } else { - const { glibcVersionRuntime } = process.report.getReport().header - return !glibcVersionRuntime - } -} - -switch (platform) { - case 'win32': - switch (arch) { - case 'x64': - localFileExisted = existsSync( - join(__dirname, 'rubick-native-addon.win32-x64-msvc.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./rubick-native-addon.win32-x64-msvc.node') - } else { - nativeBinding = require('rubick-native-addon-win32-x64-msvc') - } - } catch (e) { - loadError = e - } - break - case 'ia32': - localFileExisted = existsSync( - join(__dirname, 'rubick-native-addon.win32-ia32-msvc.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./rubick-native-addon.win32-ia32-msvc.node') - } else { - nativeBinding = require('rubick-native-addon-win32-ia32-msvc') - } - } catch (e) { - loadError = e - } - break - case 'arm64': - localFileExisted = existsSync( - join(__dirname, 'rubick-native-addon.win32-arm64-msvc.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./rubick-native-addon.win32-arm64-msvc.node') - } else { - nativeBinding = require('rubick-native-addon-win32-arm64-msvc') - } - } catch (e) { - loadError = e - } - break - default: - throw new Error(`Unsupported architecture on Windows: ${arch}`) - } - break - case 'darwin': - localFileExisted = existsSync(join(__dirname, 'rubick-native-addon.darwin-universal.node')) - try { - if (localFileExisted) { - nativeBinding = require('./rubick-native-addon.darwin-universal.node') - } else { - nativeBinding = require('rubick-native-addon-darwin-universal') - } - break - } catch { } - switch (arch) { - case 'x64': - localFileExisted = existsSync(join(__dirname, 'rubick-native-addon.darwin-x64.node')) - try { - if (localFileExisted) { - nativeBinding = require('./rubick-native-addon.darwin-x64.node') - } else { - nativeBinding = require('rubick-native-addon-darwin-x64') - } - } catch (e) { - loadError = e - } - break - case 'arm64': - localFileExisted = existsSync( - join(__dirname, 'rubick-native-addon.darwin-arm64.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./rubick-native-addon.darwin-arm64.node') - } else { - nativeBinding = require('rubick-native-addon-darwin-arm64') - } - } catch (e) { - loadError = e - } - break - default: - throw new Error(`Unsupported architecture on macOS: ${arch}`) - } - break - case 'linux': - switch (arch) { - case 'x64': - if (isMusl()) { - localFileExisted = existsSync( - join(__dirname, 'rubick-native-addon.linux-x64-musl.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./rubick-native-addon.linux-x64-musl.node') - } else { - nativeBinding = require('rubick-native-addon-linux-x64-musl') - } - } catch (e) { - loadError = e - } - } else { - localFileExisted = existsSync( - join(__dirname, 'rubick-native-addon.linux-x64-gnu.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./rubick-native-addon.linux-x64-gnu.node') - } else { - nativeBinding = require('rubick-native-addon-linux-x64-gnu') - } - } catch (e) { - loadError = e - } - } - break - case 'arm64': - if (isMusl()) { - localFileExisted = existsSync( - join(__dirname, 'rubick-native-addon.linux-arm64-musl.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./rubick-native-addon.linux-arm64-musl.node') - } else { - nativeBinding = require('rubick-native-addon-linux-arm64-musl') - } - } catch (e) { - loadError = e - } - } else { - localFileExisted = existsSync( - join(__dirname, 'rubick-native-addon.linux-arm64-gnu.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./rubick-native-addon.linux-arm64-gnu.node') - } else { - nativeBinding = require('rubick-native-addon-linux-arm64-gnu') - } - } catch (e) { - loadError = e - } - } - break - default: - throw new Error(`Unsupported architecture on Linux: ${arch}`) - } - break - default: - throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`) -} - -if (!nativeBinding) { - if (loadError) { - throw loadError - } - throw new Error(`Failed to load native binding`) -} - -const { getClipboardContent, onInputEvent, grabInputEvent, ShorCutImg, exeLookBase64, parseLnk, LnkData, parseLnkFallback, sendKeyboardSimulation, MouseBtn, MouseAction, sendMouseSimulation } = nativeBinding - -module.exports.getClipboardContent = getClipboardContent -module.exports.onInputEvent = onInputEvent -module.exports.grabInputEvent = grabInputEvent -module.exports.ShorCutImg = ShorCutImg -module.exports.exeLookBase64 = exeLookBase64 -module.exports.parseLnk = parseLnk -module.exports.LnkData = LnkData -module.exports.parseLnkFallback = parseLnkFallback -module.exports.sendKeyboardSimulation = sendKeyboardSimulation -module.exports.MouseBtn = MouseBtn -module.exports.MouseAction = MouseAction -module.exports.sendMouseSimulation = sendMouseSimulation