From a3acd8be8fe58429110879e37181b5ce3143c065 Mon Sep 17 00:00:00 2001 From: ck <21735205+cyperdark@users.noreply.github.com> Date: Wed, 10 Jul 2024 11:38:00 +0300 Subject: [PATCH] chore: attempt to fix build issue --- packages/tsprocess-rust/.gitignore | 13 ++--- packages/tsprocess-rust/globals.d.ts | 1 - .../tsprocess-rust/{index.ts => index.js} | 49 ++++++++++--------- packages/tsprocess-rust/native/Cargo.toml | 2 +- packages/tsprocess-rust/package.json | 43 ++++++++-------- packages/tsprocess-rust/tsconfig.json | 37 +++++++++----- 6 files changed, 77 insertions(+), 68 deletions(-) delete mode 100644 packages/tsprocess-rust/globals.d.ts rename packages/tsprocess-rust/{index.ts => index.js} (51%) diff --git a/packages/tsprocess-rust/.gitignore b/packages/tsprocess-rust/.gitignore index 5bd193a7..ab6c3043 100644 --- a/packages/tsprocess-rust/.gitignore +++ b/packages/tsprocess-rust/.gitignore @@ -1,13 +1,8 @@ .idea/ -native/.idea/ -native/target/ -native/cargo.log -native/cross.log -native/main.rs +native/ +dist -**/*.node -*.js +NativeMemoryReader.node **/node_modules **/.DS_Store -npm-debug.log - +npm-debug.log \ No newline at end of file diff --git a/packages/tsprocess-rust/globals.d.ts b/packages/tsprocess-rust/globals.d.ts deleted file mode 100644 index e8d1a79b..00000000 --- a/packages/tsprocess-rust/globals.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module '*.node'; diff --git a/packages/tsprocess-rust/index.ts b/packages/tsprocess-rust/index.js similarity index 51% rename from packages/tsprocess-rust/index.ts rename to packages/tsprocess-rust/index.js index daea8978..fa3f4f09 100644 --- a/packages/tsprocess-rust/index.ts +++ b/packages/tsprocess-rust/index.js @@ -1,82 +1,85 @@ -// @ts-ignore -import { MemoryReader as NativeMemoryReader } from './native/index.node'; +const { + MemoryReader: NativeMemoryReader +} = require('./NativeMemoryReader.node'); -export class MemoryReader { - private nativeReader: NativeMemoryReader; +class MemoryReader { + #nativeReader; - constructor(processId: number) { + constructor(processId) { this.nativeReader = new NativeMemoryReader(processId); } - public static isProcessExists(processId: number): boolean { + static isProcessExists(processId) { return NativeMemoryReader.isProcessExists(processId); } - public static findProcesses(processName: string): number[] { + static findProcesses(processName) { return NativeMemoryReader.findProcesses(processName); } - public static getProcessPath(processId: number): string { + static getProcessPath(processId) { return NativeMemoryReader.getProcessPath(processId); } - public static getProcessCommandLine(processId: number): string { + static getProcessCommandLine(processId) { return NativeMemoryReader.getProcessCommandLine(processId); } - public findSignature(signature: string): number { + findSignature(signature) { return this.nativeReader.findSignature(signature); } - public readRaw(address: number, length: number): number[] { + readRaw(address, length) { return this.nativeReader.readRaw(address, length); } - public readPointer(address: number): number { + readPointer(address) { return this.nativeReader.readPointer(address); } - public readString(address: number): string { + readString(address) { return this.nativeReader.readString(address); } - public readI8(address: number): number { + readI8(address) { return this.nativeReader.read_i8(address); } - public readI16(address: number): number { + readI16(address) { return this.nativeReader.read_i16(address); } - public readI32(address: number): number { + readI32(address) { return this.nativeReader.read_i32(address); } - public readI64(address: number): number { + readI64(address) { return this.nativeReader.read_i64(address); } - public readU8(address: number): number { + readU8(address) { return this.nativeReader.read_u8(address); } - public readU16(address: number): number { + readU16(address) { return this.nativeReader.read_u16(address); } - public readU32(address: number): number { + readU32(address) { return this.nativeReader.read_u32(address); } - public readU64(address: number): number { + readU64(address) { return this.nativeReader.read_u64(address); } - public readF32(address: number): number { + readF32(address) { return this.nativeReader.read_f32(address); } - public readF64(address: number): number { + readF64(address) { return this.nativeReader.read_f64(address); } } + +module.exports = { MemoryReader }; diff --git a/packages/tsprocess-rust/native/Cargo.toml b/packages/tsprocess-rust/native/Cargo.toml index 48f6a2a0..7464cc06 100644 --- a/packages/tsprocess-rust/native/Cargo.toml +++ b/packages/tsprocess-rust/native/Cargo.toml @@ -3,7 +3,7 @@ name = "tsprocess-rust" version = "0.1.0" license = "ISC" edition = "2021" -exclude = ["index.node"] +exclude = ["NativeMemoryReader.node"] [lib] crate-type = ["cdylib"] diff --git a/packages/tsprocess-rust/package.json b/packages/tsprocess-rust/package.json index a1efdb08..57d2a9e9 100644 --- a/packages/tsprocess-rust/package.json +++ b/packages/tsprocess-rust/package.json @@ -1,23 +1,22 @@ { - "name": "tsprocess-rust", - "version": "0.1.0", - "main": "dist/index.js", - "types": "dist/index.d.ts", - "scripts": { - "test": "cargo test", - "cargo-build": "cargo build --manifest-path ./native/Cargo.toml --message-format=json > ./native/cargo.log", - "cross-build": "cross build --manifest-path ./native/Cargo.toml --message-format=json > ./native/cross.log", - "postcargo-build": "neon dist < ./native/cargo.log --out ./dist/native/index.node", - "postcross-build": "neon dist -m ./native/target < cross.log --out ./dist/native/index.node", - "prepare": "npm run build", - "debug": "npm run build", - "build": "npm run cargo-build -- --release && tsc", - "cross": "npm run cross-build -- --release && tsc", - "help": "@neon-rs/cli" - }, - "author": "", - "license": "ISC", - "devDependencies": { - "@neon-rs/cli": "0.1.73" - } -} + "name": "tsprocess-rust", + "version": "0.1.0", + "main": "index.js", + "scripts": { + "test": "cargo test", + "cargo-build": "cargo build --manifest-path ./native/Cargo.toml --message-format=json > ./native/cargo.log", + "cross-build": "cross build --manifest-path ./native/Cargo.toml --message-format=json > ./native/cross.log", + "postcargo-build": "neon dist < ./native/cargo.log --out ./dist/NativeMemoryReader.node", + "postcross-build": "neon dist -m ./native/target < cross.log --out ./dist/NativeMemoryReader.node", + "prepare": "npm run cargo-build -- --release", + "debug": "npm run build", + "build": "tsc", + "cross": "npm run cross-build -- --release && tsc", + "help": "@neon-rs/cli" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "@neon-rs/cli": "0.1.73" + } +} \ No newline at end of file diff --git a/packages/tsprocess-rust/tsconfig.json b/packages/tsprocess-rust/tsconfig.json index f41732ae..7c8dee29 100644 --- a/packages/tsprocess-rust/tsconfig.json +++ b/packages/tsprocess-rust/tsconfig.json @@ -1,14 +1,27 @@ { - "compilerOptions": { - "target": "ES2020", - "module":"CommonJS", - "sourceMap": true, - "declaration": true, - "allowSyntheticDefaultImports": true, - "declarationDir": "dist", - "outDir": "dist" - }, - "include": [ - "./globals.d.ts" - ], + "compilerOptions": { + "lib": [ + "ES2020" + ], + "module": "commonjs", + "moduleResolution": "Node", + "allowJs": true, + "esModuleInterop": true, + "outDir": "dist", + "rootDir": "./", + "sourceMap": false, + "declaration": false, + "strict": true, + "noImplicitAny": false, + "target": "ES2020", + "strictPropertyInitialization": false, + "baseUrl": ".", + }, + "exclude": [ + "node_modules", + "dist", + ], + "include": [ + "**/*" + ], } \ No newline at end of file