Skip to content

Commit

Permalink
chore: attempt to fix build issue
Browse files Browse the repository at this point in the history
  • Loading branch information
cyperdark committed Jul 10, 2024
1 parent 41e4f85 commit a3acd8b
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 68 deletions.
13 changes: 4 additions & 9 deletions packages/tsprocess-rust/.gitignore
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion packages/tsprocess-rust/globals.d.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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 };
2 changes: 1 addition & 1 deletion packages/tsprocess-rust/native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
43 changes: 21 additions & 22 deletions packages/tsprocess-rust/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
37 changes: 25 additions & 12 deletions packages/tsprocess-rust/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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": [
"**/*"
],
}

0 comments on commit a3acd8b

Please sign in to comment.