Archived
Compare commits
2
Commits
master
...
napi-module
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52d611cf4e | ||
|
|
3e5e529924 |
@@ -1,3 +1,3 @@
|
|||||||
import { fw } from '@entityseven/rage-fw-client'
|
import { fw } from '@entityseven/rage-fw-client'
|
||||||
|
|
||||||
fw.player.browser = mp.browsers.new('https://localhost:8080')
|
fw.player.browser = mp.browsers.new('https://localhost:5173')
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"license": "CC BY-ND",
|
"license": "CC BY-ND",
|
||||||
"description": "Server side of rage-fw example",
|
"description": "Server side of rage-fw example",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "esbuild src/index.ts --bundle --platform=node --target=node10.4 --outfile=../../server/packages/server/index.js"
|
"build": "esbuild src/index.ts --bundle --platform=node --target=node14.10 --external:*.node --format=cjs --outfile=../../server/packages/server/index.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@entityseven/rage-fw-server": "latest"
|
"@entityseven/rage-fw-server": "latest"
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
mp.events.addCommand('veh', async (player, fullText) => {
|
|
||||||
const vehicleID = mp.joaat(fullText)
|
|
||||||
const vehicle = mp.vehicles.new(vehicleID, player.position, {
|
|
||||||
numberPlate: 'admin',
|
|
||||||
})
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
player.putIntoVehicle(vehicle, 0)
|
|
||||||
}, 250)
|
|
||||||
})
|
|
||||||
@@ -1,9 +1,3 @@
|
|||||||
import { fw } from '@entityseven/rage-fw-server'
|
import { checkLicense, doSensitiveOperation } from './x86_64-pc-windows-msvc'
|
||||||
|
|
||||||
import './commands'
|
console.log(doSensitiveOperation('test'))
|
||||||
|
|
||||||
fw.event.register('playerJoin', async player => {
|
|
||||||
fw.system.log.info(`Connected: ${player.socialClub}`)
|
|
||||||
|
|
||||||
fw.system.log.info(`Response from client: here respionse}`)
|
|
||||||
})
|
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,31 @@
|
|||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
|
||||||
|
/* auto-generated by NAPI-RS */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # checkLicense
|
||||||
|
* Accepts a 16-character license key string.
|
||||||
|
* Gets the server's local IPv4 address, prints it to the console,
|
||||||
|
* and validates the key. If valid, unlocks other functions.
|
||||||
|
*
|
||||||
|
* Returns `true` if the license key is valid, `false` otherwise.
|
||||||
|
*/
|
||||||
|
export declare function checkLicense(licenseKey: string): boolean
|
||||||
|
/**
|
||||||
|
* # doSensitiveOperation
|
||||||
|
* An example function that should only run if the license is validated.
|
||||||
|
* Takes a name as input and returns a greeting string.
|
||||||
|
*/
|
||||||
|
export declare function doSensitiveOperation(name: string): string
|
||||||
|
/**
|
||||||
|
* # getSecretData
|
||||||
|
* Another example function that should only run if the license is validated.
|
||||||
|
* Returns a dummy secret number.
|
||||||
|
*/
|
||||||
|
export declare function getSecretData(): number
|
||||||
|
/**
|
||||||
|
* # isLicensed (Optional utility)
|
||||||
|
* Allows JavaScript to check the current license status without triggering exit.
|
||||||
|
*/
|
||||||
|
export declare function isLicensed(): boolean
|
||||||
@@ -0,0 +1,318 @@
|
|||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
/* prettier-ignore */
|
||||||
|
|
||||||
|
/* auto-generated by NAPI-RS */
|
||||||
|
|
||||||
|
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 'android':
|
||||||
|
switch (arch) {
|
||||||
|
case 'arm64':
|
||||||
|
localFileExisted = existsSync(join(__dirname, 'gta5.android-arm64.node'))
|
||||||
|
try {
|
||||||
|
if (localFileExisted) {
|
||||||
|
nativeBinding = require('./gta5.android-arm64.node')
|
||||||
|
} else {
|
||||||
|
nativeBinding = require('gta5-android-arm64')
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
loadError = e
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 'arm':
|
||||||
|
localFileExisted = existsSync(join(__dirname, 'gta5.android-arm-eabi.node'))
|
||||||
|
try {
|
||||||
|
if (localFileExisted) {
|
||||||
|
nativeBinding = require('./gta5.android-arm-eabi.node')
|
||||||
|
} else {
|
||||||
|
nativeBinding = require('gta5-android-arm-eabi')
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
loadError = e
|
||||||
|
}
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
throw new Error(`Unsupported architecture on Android ${arch}`)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 'win32':
|
||||||
|
switch (arch) {
|
||||||
|
case 'x64':
|
||||||
|
localFileExisted = existsSync(
|
||||||
|
join(__dirname, 'gta5.win32-x64-msvc.node')
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
if (localFileExisted) {
|
||||||
|
nativeBinding = require('./gta5.win32-x64-msvc.node')
|
||||||
|
} else {
|
||||||
|
nativeBinding = require('gta5-win32-x64-msvc')
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
loadError = e
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 'ia32':
|
||||||
|
localFileExisted = existsSync(
|
||||||
|
join(__dirname, 'gta5.win32-ia32-msvc.node')
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
if (localFileExisted) {
|
||||||
|
nativeBinding = require('./gta5.win32-ia32-msvc.node')
|
||||||
|
} else {
|
||||||
|
nativeBinding = require('gta5-win32-ia32-msvc')
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
loadError = e
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 'arm64':
|
||||||
|
localFileExisted = existsSync(
|
||||||
|
join(__dirname, 'gta5.win32-arm64-msvc.node')
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
if (localFileExisted) {
|
||||||
|
nativeBinding = require('./gta5.win32-arm64-msvc.node')
|
||||||
|
} else {
|
||||||
|
nativeBinding = require('gta5-win32-arm64-msvc')
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
loadError = e
|
||||||
|
}
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 'darwin':
|
||||||
|
localFileExisted = existsSync(join(__dirname, 'gta5.darwin-universal.node'))
|
||||||
|
try {
|
||||||
|
if (localFileExisted) {
|
||||||
|
nativeBinding = require('./gta5.darwin-universal.node')
|
||||||
|
} else {
|
||||||
|
nativeBinding = require('gta5-darwin-universal')
|
||||||
|
}
|
||||||
|
break
|
||||||
|
} catch {}
|
||||||
|
switch (arch) {
|
||||||
|
case 'x64':
|
||||||
|
localFileExisted = existsSync(join(__dirname, 'gta5.darwin-x64.node'))
|
||||||
|
try {
|
||||||
|
if (localFileExisted) {
|
||||||
|
nativeBinding = require('./gta5.darwin-x64.node')
|
||||||
|
} else {
|
||||||
|
nativeBinding = require('gta5-darwin-x64')
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
loadError = e
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 'arm64':
|
||||||
|
localFileExisted = existsSync(
|
||||||
|
join(__dirname, 'gta5.darwin-arm64.node')
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
if (localFileExisted) {
|
||||||
|
nativeBinding = require('./gta5.darwin-arm64.node')
|
||||||
|
} else {
|
||||||
|
nativeBinding = require('gta5-darwin-arm64')
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
loadError = e
|
||||||
|
}
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
throw new Error(`Unsupported architecture on macOS: ${arch}`)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 'freebsd':
|
||||||
|
if (arch !== 'x64') {
|
||||||
|
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
|
||||||
|
}
|
||||||
|
localFileExisted = existsSync(join(__dirname, 'gta5.freebsd-x64.node'))
|
||||||
|
try {
|
||||||
|
if (localFileExisted) {
|
||||||
|
nativeBinding = require('./gta5.freebsd-x64.node')
|
||||||
|
} else {
|
||||||
|
nativeBinding = require('gta5-freebsd-x64')
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
loadError = e
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 'linux':
|
||||||
|
switch (arch) {
|
||||||
|
case 'x64':
|
||||||
|
if (isMusl()) {
|
||||||
|
localFileExisted = existsSync(
|
||||||
|
join(__dirname, 'gta5.linux-x64-musl.node')
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
if (localFileExisted) {
|
||||||
|
nativeBinding = require('./gta5.linux-x64-musl.node')
|
||||||
|
} else {
|
||||||
|
nativeBinding = require('gta5-linux-x64-musl')
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
loadError = e
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
localFileExisted = existsSync(
|
||||||
|
join(__dirname, 'gta5.linux-x64-gnu.node')
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
if (localFileExisted) {
|
||||||
|
nativeBinding = require('./gta5.linux-x64-gnu.node')
|
||||||
|
} else {
|
||||||
|
nativeBinding = require('gta5-linux-x64-gnu')
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
loadError = e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 'arm64':
|
||||||
|
if (isMusl()) {
|
||||||
|
localFileExisted = existsSync(
|
||||||
|
join(__dirname, 'gta5.linux-arm64-musl.node')
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
if (localFileExisted) {
|
||||||
|
nativeBinding = require('./gta5.linux-arm64-musl.node')
|
||||||
|
} else {
|
||||||
|
nativeBinding = require('gta5-linux-arm64-musl')
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
loadError = e
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
localFileExisted = existsSync(
|
||||||
|
join(__dirname, 'gta5.linux-arm64-gnu.node')
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
if (localFileExisted) {
|
||||||
|
nativeBinding = require('./gta5.linux-arm64-gnu.node')
|
||||||
|
} else {
|
||||||
|
nativeBinding = require('gta5-linux-arm64-gnu')
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
loadError = e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 'arm':
|
||||||
|
if (isMusl()) {
|
||||||
|
localFileExisted = existsSync(
|
||||||
|
join(__dirname, 'gta5.linux-arm-musleabihf.node')
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
if (localFileExisted) {
|
||||||
|
nativeBinding = require('./gta5.linux-arm-musleabihf.node')
|
||||||
|
} else {
|
||||||
|
nativeBinding = require('gta5-linux-arm-musleabihf')
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
loadError = e
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
localFileExisted = existsSync(
|
||||||
|
join(__dirname, 'gta5.linux-arm-gnueabihf.node')
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
if (localFileExisted) {
|
||||||
|
nativeBinding = require('./gta5.linux-arm-gnueabihf.node')
|
||||||
|
} else {
|
||||||
|
nativeBinding = require('gta5-linux-arm-gnueabihf')
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
loadError = e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 'riscv64':
|
||||||
|
if (isMusl()) {
|
||||||
|
localFileExisted = existsSync(
|
||||||
|
join(__dirname, 'gta5.linux-riscv64-musl.node')
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
if (localFileExisted) {
|
||||||
|
nativeBinding = require('./gta5.linux-riscv64-musl.node')
|
||||||
|
} else {
|
||||||
|
nativeBinding = require('gta5-linux-riscv64-musl')
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
loadError = e
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
localFileExisted = existsSync(
|
||||||
|
join(__dirname, 'gta5.linux-riscv64-gnu.node')
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
if (localFileExisted) {
|
||||||
|
nativeBinding = require('./gta5.linux-riscv64-gnu.node')
|
||||||
|
} else {
|
||||||
|
nativeBinding = require('gta5-linux-riscv64-gnu')
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
loadError = e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 's390x':
|
||||||
|
localFileExisted = existsSync(
|
||||||
|
join(__dirname, 'gta5.linux-s390x-gnu.node')
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
if (localFileExisted) {
|
||||||
|
nativeBinding = require('./gta5.linux-s390x-gnu.node')
|
||||||
|
} else {
|
||||||
|
nativeBinding = require('gta5-linux-s390x-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 { checkLicense, doSensitiveOperation, getSecretData, isLicensed } = nativeBinding
|
||||||
|
|
||||||
|
module.exports.checkLicense = checkLicense
|
||||||
|
module.exports.doSensitiveOperation = doSensitiveOperation
|
||||||
|
module.exports.getSecretData = getSecretData
|
||||||
|
module.exports.isLicensed = isLicensed
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"baseUrl": "./src",
|
"baseUrl": "./src",
|
||||||
"types": [
|
"types": [
|
||||||
|
"node",
|
||||||
"../../node_modules/@ragempcommunity/types-server/",
|
"../../node_modules/@ragempcommunity/types-server/",
|
||||||
"../shared/declarations/rage-fw-shared-types/"
|
"../shared/declarations/rage-fw-shared-types/"
|
||||||
]
|
]
|
||||||
|
|||||||
Binary file not shown.
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ESNext",
|
"target": "ESNext",
|
||||||
"lib": ["ESNext", "ES2019", "DOM"],
|
"lib": ["ESNext", "DOM"],
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user