mirror of
https://github.com/rilaxik/fivem-rpc.git
synced 2026-09-28 01:29:13 +00:00
chore(repo): migrate biome to oxfmt + oxlint
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"$schema": "./node_modules/oxfmt/configuration_schema.json",
|
||||||
|
"useTabs": true,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"printWidth": 80,
|
||||||
|
"endOfLine": "crlf",
|
||||||
|
"singleQuote": true,
|
||||||
|
"semi": false,
|
||||||
|
"trailingComma": "all",
|
||||||
|
"arrowParens": "avoid",
|
||||||
|
"bracketSpacing": true,
|
||||||
|
"sortImports": true,
|
||||||
|
"ignorePatterns": ["**/dist", "bun.lock"],
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": ["*.md"],
|
||||||
|
"options": { "embeddedLanguageFormatting": "off" }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
||||||
|
"plugins": ["eslint", "typescript", "unicorn", "oxc", "import"],
|
||||||
|
"categories": {
|
||||||
|
"correctness": "error",
|
||||||
|
"suspicious": "warn"
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"typescript/no-explicit-any": "warn",
|
||||||
|
"typescript/no-unsafe-function-type": "warn",
|
||||||
|
"eslint/no-underscore-dangle": "off"
|
||||||
|
},
|
||||||
|
"ignorePatterns": ["**/dist"]
|
||||||
|
}
|
||||||
-47
@@ -1,47 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
|
|
||||||
"vcs": {
|
|
||||||
"enabled": false,
|
|
||||||
"clientKind": "git",
|
|
||||||
"useIgnoreFile": false
|
|
||||||
},
|
|
||||||
"files": {
|
|
||||||
"ignoreUnknown": false,
|
|
||||||
"includes": ["**", "!dist/*"]
|
|
||||||
},
|
|
||||||
"formatter": {
|
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
"linter": {
|
|
||||||
"enabled": true,
|
|
||||||
"rules": {
|
|
||||||
"recommended": true,
|
|
||||||
"complexity": {
|
|
||||||
"noBannedTypes": "info"
|
|
||||||
},
|
|
||||||
"suspicious": {
|
|
||||||
"noExplicitAny": "info"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"javascript": {
|
|
||||||
"formatter": {
|
|
||||||
"arrowParentheses": "asNeeded",
|
|
||||||
"bracketSpacing": true,
|
|
||||||
"indentWidth": 2,
|
|
||||||
"lineEnding": "crlf",
|
|
||||||
"lineWidth": 80,
|
|
||||||
"quoteStyle": "single",
|
|
||||||
"semicolons": "asNeeded",
|
|
||||||
"trailingCommas": "all"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"assist": {
|
|
||||||
"enabled": true,
|
|
||||||
"actions": {
|
|
||||||
"source": {
|
|
||||||
"organizeImports": "on"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,8 +4,9 @@
|
|||||||
"workspaces": {
|
"workspaces": {
|
||||||
"": {
|
"": {
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "^2.1.1",
|
|
||||||
"@types/bun": "^1.2.18",
|
"@types/bun": "^1.2.18",
|
||||||
|
"oxfmt": "^0.70.0",
|
||||||
|
"oxlint": "^1.85.0",
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": "^5",
|
"typescript": "^5",
|
||||||
@@ -33,24 +34,6 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
"packages": {
|
"packages": {
|
||||||
"@biomejs/biome": ["@biomejs/[email protected]", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.5.14", "@biomejs/cli-darwin-x64": "2.5.14", "@biomejs/cli-linux-arm64": "2.5.14", "@biomejs/cli-linux-arm64-musl": "2.5.14", "@biomejs/cli-linux-x64": "2.5.14", "@biomejs/cli-linux-x64-musl": "2.5.14", "@biomejs/cli-win32-arm64": "2.5.14", "@biomejs/cli-win32-x64": "2.5.14" }, "bin": { "biome": "bin/biome" } }, "sha512-0FabLIjd4M/dm8VFI86RMaLLdgepzbdfiAL2R8cr7V81OYYrP1w7Z73KfAwPK5h9SrEBXTzNG2y+mBwPo9xRnw=="],
|
|
||||||
|
|
||||||
"@biomejs/cli-darwin-arm64": ["@biomejs/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-UnzaXO65L4tsZimFITFP2M121GyhDcWFrT3pL5ZJ5U4XcS/0L5VHYytVohdCf/gnDUFHgl2I9xnt5bV/J1kxHQ=="],
|
|
||||||
|
|
||||||
"@biomejs/cli-darwin-x64": ["@biomejs/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-kiy8qA16K93J7uvFfWi4LgjqDpnRKyePAna6A0Y4jxyUga35SYpIZ2cNWlhy0lsfgqRenCpfymnJWEZ6mgpRgA=="],
|
|
||||||
|
|
||||||
"@biomejs/cli-linux-arm64": ["@biomejs/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-vO/9BaU1n30CiFNLx49gMTMtbCAAqlo/EqFoG0BU3deQInTbJrmXSmTQ9e3FoDZIKQnvSLDVNL4lx1ci7y1T1Q=="],
|
|
||||||
|
|
||||||
"@biomejs/cli-linux-arm64-musl": ["@biomejs/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-SJ9PrZkBnnH9dHJDnxk34vKs0GB2dbsioaft6/hPhWJ7AHpwYH83Isnhj0FSRpFkGgpVfJ1lds23ApB2czUDLQ=="],
|
|
||||||
|
|
||||||
"@biomejs/cli-linux-x64": ["@biomejs/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-VHZRa7CCQBUWKxNwUvHJeuW03WFRgN5NWO//SDGOitc9QIeNyfA42V9zlKm+x82xFSG9Bzi5fi+hbhm9anO8yA=="],
|
|
||||||
|
|
||||||
"@biomejs/cli-linux-x64-musl": ["@biomejs/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-2kI5PrMgW5dcEZYrstLPmUmCwkUwZY39rP4BN93Vxbwcs2O57LDQOktUZZYPvvspN5i0mhGr3TJtF5sU26NUWg=="],
|
|
||||||
|
|
||||||
"@biomejs/cli-win32-arm64": ["@biomejs/[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-pHgAFffmZtaYoxavEsWEYNvcA7NwOIjLyqw2HXyLbt16xYryX0L4fMV2u0G9ag6LNYPIoqWaWqzUcnc6rLGGXg=="],
|
|
||||||
|
|
||||||
"@biomejs/cli-win32-x64": ["@biomejs/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-oJWmBhoHsnhUKIke+0gXDX0mltJrWHA1UyHsrTlXwX0TL64ilVZAo+TYZm97baecV0esBdpzy3k96q+09JaZUQ=="],
|
|
||||||
|
|
||||||
"@citizenfx/client": ["@citizenfx/[email protected]", "", {}, "sha512-gm0/fWM0/Wn5Hny+cnSRsBc73Opz1PPKS4LKCraIE477tQ0uGNVACoeTQqxRJz54Lu09KeA4cCfocVmefVAqUA=="],
|
"@citizenfx/client": ["@citizenfx/[email protected]", "", {}, "sha512-gm0/fWM0/Wn5Hny+cnSRsBc73Opz1PPKS4LKCraIE477tQ0uGNVACoeTQqxRJz54Lu09KeA4cCfocVmefVAqUA=="],
|
||||||
|
|
||||||
"@citizenfx/server": ["@citizenfx/[email protected]", "", {}, "sha512-I6XnxIGBhskPe9S+q1OQLDqs6TYw1RhX06K6jUg+n0hGITYools6VBIIhdPe2uUlHA+76qJajQlV9ONeR3mDig=="],
|
"@citizenfx/server": ["@citizenfx/[email protected]", "", {}, "sha512-I6XnxIGBhskPe9S+q1OQLDqs6TYw1RhX06K6jUg+n0hGITYools6VBIIhdPe2uUlHA+76qJajQlV9ONeR3mDig=="],
|
||||||
@@ -129,6 +112,82 @@
|
|||||||
|
|
||||||
"@napi-rs/lzma-linux-x64-gnu": ["@napi-rs/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ=="],
|
"@napi-rs/lzma-linux-x64-gnu": ["@napi-rs/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ=="],
|
||||||
|
|
||||||
|
"@oxfmt/binding-android-arm-eabi": ["@oxfmt/[email protected]", "", { "os": "android", "cpu": "arm" }, "sha512-Xd7YO4/T2axEj6FTLcj4Why3mTBqFMg+x24xtorT4Lb2+1g82090GH0a/4U1m0pABGYiix2bq1pqkYrmV3f0Sw=="],
|
||||||
|
|
||||||
|
"@oxfmt/binding-android-arm64": ["@oxfmt/[email protected]", "", { "os": "android", "cpu": "arm64" }, "sha512-x9rlMYyKXdgKdYyUJzGsK1ZV8P4di/J32ipzcS6Jet6p9r9UAh28neXIMtdlSaJJycdi61Z4YkcLKLpk8ueFjg=="],
|
||||||
|
|
||||||
|
"@oxfmt/binding-darwin-arm64": ["@oxfmt/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-IUTUPvrBVYy7POh4stXzRdz4IVC/1QSaviCWoyenSlOhGu0X9j5K07vCTM9biLjAA2Zs31l0Rj5vvRpj9n95wA=="],
|
||||||
|
|
||||||
|
"@oxfmt/binding-darwin-x64": ["@oxfmt/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-vw745q870oTd6J517O24asoX4/E+eK0nxYIFoedSLqgJ+nI5En7+ZS82iZSHZ69zevQrnOXiyHP01dA+t8xD8w=="],
|
||||||
|
|
||||||
|
"@oxfmt/binding-freebsd-x64": ["@oxfmt/[email protected]", "", { "os": "freebsd", "cpu": "x64" }, "sha512-NO14EgSM9dFkcg+MfGPxvsKqXYs9LKaxPrOKXpv1R0rLokGGFDcCq6dBMq18dE4wlpFOovX0UZY2uh1P30O7QA=="],
|
||||||
|
|
||||||
|
"@oxfmt/binding-linux-arm-gnueabihf": ["@oxfmt/[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-139OEhHarj9CYoJ/i9gXlPv4KLBGtLj2toseOWYFf09QwlhklaZk+wW3aOvlqoeZtuayvkoSNVWra7WJ21s3VQ=="],
|
||||||
|
|
||||||
|
"@oxfmt/binding-linux-arm-musleabihf": ["@oxfmt/[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-GEh2PY3IWTE0M24eNhTduountANSbWyDmMnzFSQE/nGg/bjPugbUgiGuFu+xdqcQSd/HKSwH80/F2yVVD48yhA=="],
|
||||||
|
|
||||||
|
"@oxfmt/binding-linux-arm64-gnu": ["@oxfmt/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-En5i+UJmZSPxuSf47F2Hl5YOzKB0bicQLnGQkeTCMQ35cWLtbrSwACJKfiLqRZrk05DwSnsJkhBRaM3OURtIaA=="],
|
||||||
|
|
||||||
|
"@oxfmt/binding-linux-arm64-musl": ["@oxfmt/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-WWOoV5W9Im3flVwOVrWn/2DUlOF8v5vcCip+kcNuaMpulRCh6nzzt1Su2vcL2F908YJIXNV3HvegbBHuyLwKHg=="],
|
||||||
|
|
||||||
|
"@oxfmt/binding-linux-ppc64-gnu": ["@oxfmt/[email protected]", "", { "os": "linux", "cpu": "ppc64" }, "sha512-YUouneIqW+5n7aE8xx/zeZ6/utr/KH7oykcGoFyd8Uz8uh591T1oKlnoWA3BsRq/ZR42oY1w4MUYvS/0e/MQOA=="],
|
||||||
|
|
||||||
|
"@oxfmt/binding-linux-riscv64-gnu": ["@oxfmt/[email protected]", "", { "os": "linux", "cpu": "none" }, "sha512-iEnMf21S5aGVa4hViDGY8sAQ/AHyCu2JPyrQF8P06wtHhSkD1YJBeT4m/KiGewgf7+a5XCYSCRIPcRQa1xwEoQ=="],
|
||||||
|
|
||||||
|
"@oxfmt/binding-linux-riscv64-musl": ["@oxfmt/[email protected]", "", { "os": "linux", "cpu": "none" }, "sha512-91Sdniaj20fQzyMeCxMDzTP4c9s4RB8dGQ308xHhDR0n6U7+1Xq7N9klE7mfXq8iV3lRmIGSXi5X23Hn/0XX/g=="],
|
||||||
|
|
||||||
|
"@oxfmt/binding-linux-s390x-gnu": ["@oxfmt/[email protected]", "", { "os": "linux", "cpu": "s390x" }, "sha512-uUV30M6E+2TKKGMaKiwfeL4RZrviHXlUxsrYJ/jFBb+1EZy+pnFT+hF73eeWdzh5NqPOAnw0iiMAIqjqiLZPFg=="],
|
||||||
|
|
||||||
|
"@oxfmt/binding-linux-x64-gnu": ["@oxfmt/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-ivMcX6kNDPhqtbOaBt/ItFlLlTlXNHLgRuNmxP6Na6UuYXRT10llpJcAPbGeRgjjb3Qzv4jwPp3fB0hui50WNQ=="],
|
||||||
|
|
||||||
|
"@oxfmt/binding-linux-x64-musl": ["@oxfmt/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-w+S+fERxYmlZSyZlJK/U292FjyBoH8cCEj21/tYJX6atX5kNSn+HDkhlFQKT2zcMwUW0uAtUL/bOrlwJZwqRdA=="],
|
||||||
|
|
||||||
|
"@oxfmt/binding-openharmony-arm64": ["@oxfmt/[email protected]", "", { "os": "none", "cpu": "arm64" }, "sha512-Zlom1Xkx257R8bk4ZI4zJsrGno2opknz1+5v5baka3nn4FPyvNSdh8JUL4CdN1S1OWRMvJ9UJQ+RfIqGGCUEfA=="],
|
||||||
|
|
||||||
|
"@oxfmt/binding-win32-arm64-msvc": ["@oxfmt/[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-FQgPW5R17vzt7cgrJ8eG/dqX00o2xHsqFeLfw4xzA9FRHpN/DjFo9YDonvIIXGxiEuS9F/jZPnGO+KHNKuCo4Q=="],
|
||||||
|
|
||||||
|
"@oxfmt/binding-win32-ia32-msvc": ["@oxfmt/[email protected]", "", { "os": "win32", "cpu": "ia32" }, "sha512-ZfZublNhZ+XBndMiXhkiLlPE+XyGRDa0CweeTL6t1fZypfCh1LTg7e5CvnOeTBunq15MskOcRempumSPGAaCQA=="],
|
||||||
|
|
||||||
|
"@oxfmt/binding-win32-x64-msvc": ["@oxfmt/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-HlIZEn+WzLQL0DszNzldiRl/DPRCX5R0Vkt6qeUPR1YHwy52hZZo4x6HoTOVmKRP2wUiwPGtKsihNY/f8KRaBg=="],
|
||||||
|
|
||||||
|
"@oxlint/binding-android-arm-eabi": ["@oxlint/[email protected]", "", { "os": "android", "cpu": "arm" }, "sha512-q2KO/Zso9UT+OMn0NF9ywn4E4t0MI3yxiDhNyhsQ7DyQJrC4FhFE4TXOi4bktFnOWXTMds8qZSbpv2XwRaNOBg=="],
|
||||||
|
|
||||||
|
"@oxlint/binding-android-arm64": ["@oxlint/[email protected]", "", { "os": "android", "cpu": "arm64" }, "sha512-SxLN3ALjoT9NNdvpjEevGeHvfzTAFrF0NBYB5tzK7/GtCKMze3j1e/m/X2ozqGj2U9hfGG/dg/OG8vpVK4PiDA=="],
|
||||||
|
|
||||||
|
"@oxlint/binding-darwin-arm64": ["@oxlint/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-Y/Sup/J4f0f9UGsSd/xyCNTeWL+gepO63GBdEDAfue9nBsnk9zMmnIXx1O6b1V8C90vB5nucYNZ0pbMXAp8zJA=="],
|
||||||
|
|
||||||
|
"@oxlint/binding-darwin-x64": ["@oxlint/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-ApOSNC04ynpDTwvBD+//0wyfODRSbEzvRoKpX8teffmc27z8AockwSNeMXGJXn5KP85eahDgR/2llICWLkzcnw=="],
|
||||||
|
|
||||||
|
"@oxlint/binding-freebsd-x64": ["@oxlint/[email protected]", "", { "os": "freebsd", "cpu": "x64" }, "sha512-bNrVrCOA/kHky3Tu79IXWXe5bhIgLXfUuUEDHlAGOHUk96MkvDZ1ecaQF19rwstrnaqfP1o9nBTqzIr9+ZHkUg=="],
|
||||||
|
|
||||||
|
"@oxlint/binding-linux-arm-gnueabihf": ["@oxlint/[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-NUrzOJ1s/EqsVvfn2L/1D8Wro2LPIZUbihL8kOJLh5fEdGEN3rdOGUYq3HwnUIL8sjpoP+4N6RaGrgmMJnaMPw=="],
|
||||||
|
|
||||||
|
"@oxlint/binding-linux-arm-musleabihf": ["@oxlint/[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-UJXrAT3E/RWkEqXLIs2ehETja1qfgkPb+5gwLIIS+o/6cf+grHvoOXTa5997a/YNQfcJS0DRBTOfZt95cvOI1g=="],
|
||||||
|
|
||||||
|
"@oxlint/binding-linux-arm64-gnu": ["@oxlint/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-lK40QLjI0HxigO7CjDDshEtfYIeiYS0020v5BHFPqN4uuQBQxd2K9LNom2dW15o9F1937quSCRVp4ZsVhdbYdg=="],
|
||||||
|
|
||||||
|
"@oxlint/binding-linux-arm64-musl": ["@oxlint/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-c2zbdBwGKreHXwRx3gWBuFGJxLhxgsg6YlZ+3H+RgRusU/UEV9jNwJ3HGYK+nRo0LvBa7mt6Kj86xoVotUo8cw=="],
|
||||||
|
|
||||||
|
"@oxlint/binding-linux-ppc64-gnu": ["@oxlint/[email protected]", "", { "os": "linux", "cpu": "ppc64" }, "sha512-tlt/Hy8lZ97/lCPmCgw/B3k/mwh+BzaIPbPkldZEly7TwLmx0xe2CQcaW2g/rR0dOgS9JNGCZsMEqLhUNMGvaw=="],
|
||||||
|
|
||||||
|
"@oxlint/binding-linux-riscv64-gnu": ["@oxlint/[email protected]", "", { "os": "linux", "cpu": "none" }, "sha512-3tNR9Xey82X0zKuY1d8hJ6Rc9gwRDurmqGLnQZa5xqOXy8/YyiqFXjAtugkKLY82obOlpK1eSiDRlgcNPuxtIg=="],
|
||||||
|
|
||||||
|
"@oxlint/binding-linux-riscv64-musl": ["@oxlint/[email protected]", "", { "os": "linux", "cpu": "none" }, "sha512-wbGRd5PqCcjkJFHhZuZ2OBSUQY9czlQsoA/cQQB9JK/L9mC5MQgGoKAh+xd8QjA5V+0D3j+Qd1lAWn1I8zlelA=="],
|
||||||
|
|
||||||
|
"@oxlint/binding-linux-s390x-gnu": ["@oxlint/[email protected]", "", { "os": "linux", "cpu": "s390x" }, "sha512-3Sn0kSrE4DPZCWV/8o+n4x3aFZxI9ulMnkYlwCbJ8eUVkwRK2IerohE/A/z3SNbCwoPFOCJmGE5Avrq0rrvdvQ=="],
|
||||||
|
|
||||||
|
"@oxlint/binding-linux-x64-gnu": ["@oxlint/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-JY2pxxYfB62bAGfejljVCqc44etItehPuAyaeSAdMuEMtwNA00ggMnS66lC1oIhos6oOXUkuU6mZ9bpFh3BqWg=="],
|
||||||
|
|
||||||
|
"@oxlint/binding-linux-x64-musl": ["@oxlint/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-5k74vZ6qJBjBHEOlBk9B/iv68Yu0F1Afw/vvT2ar6OGCqEeXLaSjXz2n/IPCbhLG22UoKoYEJTzpYraRdcp6PA=="],
|
||||||
|
|
||||||
|
"@oxlint/binding-openharmony-arm64": ["@oxlint/[email protected]", "", { "os": "none", "cpu": "arm64" }, "sha512-GbAl5qt5TCkPLXTaIISZJnugrcBhra6rodcXc9jYt620UtdsTt71NlNmJmm0frxzFpd54x/G+MkitEJA8I/BoA=="],
|
||||||
|
|
||||||
|
"@oxlint/binding-win32-arm64-msvc": ["@oxlint/[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-kjmws5MK0et2swk4ND85D7NVQyDHw162i6whtZDLUA/lo6FQyBZDcmMRCMcVZcNrAhIaftVb00x9ChGDOjjNJA=="],
|
||||||
|
|
||||||
|
"@oxlint/binding-win32-ia32-msvc": ["@oxlint/[email protected]", "", { "os": "win32", "cpu": "ia32" }, "sha512-eSsIJx9n4yxvOqYTZyPEMyEXRmE60XH7xGAU7i0Qbsn1lf6Za3CWJ9aRd82oSFKXaxhp+sA6/yMJVRIpLpna6A=="],
|
||||||
|
|
||||||
|
"@oxlint/binding-win32-x64-msvc": ["@oxlint/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-pBebIPUpKKhWrhSMWhy8TdAZBewiXnfxmaAGxhzxM1068GagqFaTwgKlU6e+UyJ2sPR+VoHouhXuGJkQjsrDvA=="],
|
||||||
|
|
||||||
"@rollup/rollup-android-arm-eabi": ["@rollup/[email protected]", "", { "os": "android", "cpu": "arm" }, "sha512-J25QJU+B78T4FhhBsNpLJyVWOi31mwtpcMwywHmOKH65Q9IWGA81gPj+dnwlhU8wktVriYE+tFAaQgrnJRzAZg=="],
|
"@rollup/rollup-android-arm-eabi": ["@rollup/[email protected]", "", { "os": "android", "cpu": "arm" }, "sha512-J25QJU+B78T4FhhBsNpLJyVWOi31mwtpcMwywHmOKH65Q9IWGA81gPj+dnwlhU8wktVriYE+tFAaQgrnJRzAZg=="],
|
||||||
|
|
||||||
"@rollup/rollup-android-arm64": ["@rollup/[email protected]", "", { "os": "android", "cpu": "arm64" }, "sha512-LDopB3zuZM5Ux9TT2luNEBJW/tYbGU2g1d+VpKk6I+gSKDb+/7sYE6M225gRQt4RbMX6MSwMsVR/phdjVUgRLg=="],
|
"@rollup/rollup-android-arm64": ["@rollup/[email protected]", "", { "os": "android", "cpu": "arm64" }, "sha512-LDopB3zuZM5Ux9TT2luNEBJW/tYbGU2g1d+VpKk6I+gSKDb+/7sYE6M225gRQt4RbMX6MSwMsVR/phdjVUgRLg=="],
|
||||||
@@ -285,6 +344,10 @@
|
|||||||
|
|
||||||
"object-assign": ["[email protected]", "", {}, "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg=="],
|
"object-assign": ["[email protected]", "", {}, "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg=="],
|
||||||
|
|
||||||
|
"oxfmt": ["[email protected]", "", { "dependencies": { "tinypool": "2.1.2" }, "optionalDependencies": { "@oxfmt/binding-android-arm-eabi": "0.70.0", "@oxfmt/binding-android-arm64": "0.70.0", "@oxfmt/binding-darwin-arm64": "0.70.0", "@oxfmt/binding-darwin-x64": "0.70.0", "@oxfmt/binding-freebsd-x64": "0.70.0", "@oxfmt/binding-linux-arm-gnueabihf": "0.70.0", "@oxfmt/binding-linux-arm-musleabihf": "0.70.0", "@oxfmt/binding-linux-arm64-gnu": "0.70.0", "@oxfmt/binding-linux-arm64-musl": "0.70.0", "@oxfmt/binding-linux-ppc64-gnu": "0.70.0", "@oxfmt/binding-linux-riscv64-gnu": "0.70.0", "@oxfmt/binding-linux-riscv64-musl": "0.70.0", "@oxfmt/binding-linux-s390x-gnu": "0.70.0", "@oxfmt/binding-linux-x64-gnu": "0.70.0", "@oxfmt/binding-linux-x64-musl": "0.70.0", "@oxfmt/binding-openharmony-arm64": "0.70.0", "@oxfmt/binding-win32-arm64-msvc": "0.70.0", "@oxfmt/binding-win32-ia32-msvc": "0.70.0", "@oxfmt/binding-win32-x64-msvc": "0.70.0" }, "peerDependencies": { "svelte": "^5.0.0", "vite-plus": "*" }, "optionalPeers": ["svelte", "vite-plus"], "bin": { "oxfmt": "bin/oxfmt" } }, "sha512-IsHxZ4y0wQLLMhnrJblBJgZsLDzfULrJnAw5j/QqsTlMa/m3AqsbToi+W71uhBGaqlqq/PbbjvHc09TJwdv3Tw=="],
|
||||||
|
|
||||||
|
"oxlint": ["[email protected]", "", { "optionalDependencies": { "@oxlint/binding-android-arm-eabi": "1.85.0", "@oxlint/binding-android-arm64": "1.85.0", "@oxlint/binding-darwin-arm64": "1.85.0", "@oxlint/binding-darwin-x64": "1.85.0", "@oxlint/binding-freebsd-x64": "1.85.0", "@oxlint/binding-linux-arm-gnueabihf": "1.85.0", "@oxlint/binding-linux-arm-musleabihf": "1.85.0", "@oxlint/binding-linux-arm64-gnu": "1.85.0", "@oxlint/binding-linux-arm64-musl": "1.85.0", "@oxlint/binding-linux-ppc64-gnu": "1.85.0", "@oxlint/binding-linux-riscv64-gnu": "1.85.0", "@oxlint/binding-linux-riscv64-musl": "1.85.0", "@oxlint/binding-linux-s390x-gnu": "1.85.0", "@oxlint/binding-linux-x64-gnu": "1.85.0", "@oxlint/binding-linux-x64-musl": "1.85.0", "@oxlint/binding-openharmony-arm64": "1.85.0", "@oxlint/binding-win32-arm64-msvc": "1.85.0", "@oxlint/binding-win32-ia32-msvc": "1.85.0", "@oxlint/binding-win32-x64-msvc": "1.85.0" }, "peerDependencies": { "oxlint-tsgolint": ">=7.0.2001", "vite-plus": "*" }, "optionalPeers": ["oxlint-tsgolint", "vite-plus"], "bin": { "oxlint": "bin/oxlint" } }, "sha512-bc26s97nuvPj1ViyPsqmKecVkUWFMEdtayO8MaQ6oiLfs1pj94cQlZZhrh4BPNlr9HQosjhIlwgZKsfcwmcNgg=="],
|
||||||
|
|
||||||
"path-parse": ["[email protected]", "", {}, "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw=="],
|
"path-parse": ["[email protected]", "", {}, "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw=="],
|
||||||
|
|
||||||
"pathe": ["[email protected]", "", {}, "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w=="],
|
"pathe": ["[email protected]", "", {}, "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w=="],
|
||||||
@@ -331,6 +394,8 @@
|
|||||||
|
|
||||||
"tinyglobby": ["[email protected]", "", { "dependencies": { "fdir": "^6.5.0", "picomatch": "^4.0.4" } }, "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g=="],
|
"tinyglobby": ["[email protected]", "", { "dependencies": { "fdir": "^6.5.0", "picomatch": "^4.0.4" } }, "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g=="],
|
||||||
|
|
||||||
|
"tinypool": ["[email protected]", "", {}, "sha512-9YodfrxS9g9IbFr/KOjE5bAeJ0p61n3bW6mqvy0jtoeKd1kTW1Cxm0oulm6KX2lyM9Gl6WIe8nEbY7LWv5ZJww=="],
|
||||||
|
|
||||||
"tree-kill": ["[email protected]", "", { "bin": { "tree-kill": "cli.js" } }, "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A=="],
|
"tree-kill": ["[email protected]", "", { "bin": { "tree-kill": "cli.js" } }, "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A=="],
|
||||||
|
|
||||||
"ts-interface-checker": ["[email protected]", "", {}, "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA=="],
|
"ts-interface-checker": ["[email protected]", "", {}, "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA=="],
|
||||||
|
|||||||
+19
-16
@@ -1,21 +1,5 @@
|
|||||||
{
|
{
|
||||||
"workspaces": [
|
|
||||||
"rpc",
|
|
||||||
"shared-types"
|
|
||||||
],
|
|
||||||
"devDependencies": {
|
|
||||||
"@biomejs/biome": "^2.1.1",
|
|
||||||
"@types/bun": "^1.2.18"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"typescript": "^5"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"check": "bunx biome check",
|
|
||||||
"format": "bunx biome format --write"
|
|
||||||
},
|
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
|
||||||
"license": "CC0-1.0",
|
"license": "CC0-1.0",
|
||||||
"author": "Entity Seven Group",
|
"author": "Entity Seven Group",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
@@ -33,5 +17,24 @@
|
|||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/rilaxik/fivem-rpc.git"
|
"url": "https://github.com/rilaxik/fivem-rpc.git"
|
||||||
|
},
|
||||||
|
"workspaces": [
|
||||||
|
"rpc",
|
||||||
|
"shared-types"
|
||||||
|
],
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"check": "oxfmt --check && oxlint",
|
||||||
|
"format": "oxfmt",
|
||||||
|
"format:check": "oxfmt --check",
|
||||||
|
"lint": "oxlint"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/bun": "^1.2.18",
|
||||||
|
"oxfmt": "^0.70.0",
|
||||||
|
"oxlint": "^1.85.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"typescript": "^5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,41 +1,54 @@
|
|||||||
# FiveM RPC
|
# FiveM RPC
|
||||||
|
|
||||||
is an all-in-one package with asynchronous RPC implementation for FiveM servers in JS/TS
|
is an all-in-one package with asynchronous RPC implementation for FiveM servers in JS/TS
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm i @entityseven/fivem-rpc
|
pnpm i @entityseven/fivem-rpc
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn add @entityseven/fivem-rpc
|
yarn add @entityseven/fivem-rpc
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bun add @entityseven/fivem-rpc
|
bun add @entityseven/fivem-rpc
|
||||||
```
|
```
|
||||||
|
|
||||||
It is highly recommended to also install additional package for enhanced typing
|
It is highly recommended to also install additional package for enhanced typing
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm i @entityseven/fivem-rpc-shared-types -D
|
pnpm i @entityseven/fivem-rpc-shared-types -D
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn add @entityseven/fivem-rpc-shared-types --dev
|
yarn add @entityseven/fivem-rpc-shared-types --dev
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bun add @entityseven/fivem-rpc-shared-types -d
|
bun add @entityseven/fivem-rpc-shared-types -d
|
||||||
```
|
```
|
||||||
|
|
||||||
## Docs
|
## Docs
|
||||||
|
|
||||||
Can be found in [/rpc/readme.md](https://github.com/rilaxik/fivem-rpc/blob/master/rpc/readme.md)
|
Can be found in [/rpc/readme.md](https://github.com/rilaxik/fivem-rpc/blob/master/rpc/readme.md)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Type-Safe Development: Eliminate runtime errors and enhance code reliability with comprehensive type safety
|
- Type-Safe Development: Eliminate runtime errors and enhance code reliability with comprehensive type safety
|
||||||
- All-in-one package: Communicate effortlessly between server, client and webview
|
- All-in-one package: Communicate effortlessly between server, client and webview
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Issues and pull requests are very welcome
|
Issues and pull requests are very welcome
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Licensed under Custom Attribution-NoDerivs Software License
|
Licensed under Custom Attribution-NoDerivs Software License
|
||||||
|
|
||||||
## WIP
|
## WIP
|
||||||
|
|
||||||
- client observers to catch events between server and webview (subscribe-like behaviour)
|
- client observers to catch events between server and webview (subscribe-like behaviour)
|
||||||
- client observers to prevent events (middleware-like behaviour)
|
- client observers to prevent events (middleware-like behaviour)
|
||||||
- player manager (transform player id to desired data straight from a listener)
|
- player manager (transform player id to desired data straight from a listener)
|
||||||
+11
-11
@@ -1,20 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "@entityseven/fivem-rpc",
|
"name": "@entityseven/fivem-rpc",
|
||||||
"description": "FiveM RPC is an all-in-one package with asynchronous RPC implementation for FiveM servers in JS/TS",
|
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"main": "dist/index.js",
|
"description": "FiveM RPC is an all-in-one package with asynchronous RPC implementation for FiveM servers in JS/TS",
|
||||||
"types": "dist/index.d.ts",
|
|
||||||
"files": [
|
|
||||||
"dist/**/*",
|
|
||||||
"readme.md",
|
|
||||||
"license.md"
|
|
||||||
],
|
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
"fivem",
|
||||||
"fivem-rpc",
|
"fivem-rpc",
|
||||||
"fivem-rpc-shared-types",
|
"fivem-rpc-shared-types",
|
||||||
"fivem",
|
|
||||||
"gta"
|
"gta"
|
||||||
],
|
],
|
||||||
|
"license": "Custom-Attribution-NoDerivs",
|
||||||
"author": "Entity Seven Group",
|
"author": "Entity Seven Group",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
{
|
{
|
||||||
@@ -23,18 +17,24 @@
|
|||||||
"url": "https://github.com/rilaxik/"
|
"url": "https://github.com/rilaxik/"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"license": "Custom-Attribution-NoDerivs",
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/rilaxik/fivem-rpc.git"
|
"url": "https://github.com/rilaxik/fivem-rpc.git"
|
||||||
},
|
},
|
||||||
|
"files": [
|
||||||
|
"dist/**/*",
|
||||||
|
"readme.md",
|
||||||
|
"license.md"
|
||||||
|
],
|
||||||
|
"main": "dist/index.js",
|
||||||
|
"types": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsup"
|
"build": "tsup"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@microsoft/api-extractor": "^7.47.9",
|
|
||||||
"@citizenfx/client": "^2.0.15015-1",
|
"@citizenfx/client": "^2.0.15015-1",
|
||||||
"@citizenfx/server": "^2.0.14862-1",
|
"@citizenfx/server": "^2.0.14862-1",
|
||||||
|
"@microsoft/api-extractor": "^7.47.9",
|
||||||
"tsup": "^8.3.0"
|
"tsup": "^8.3.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|||||||
+121
-1
@@ -1,32 +1,43 @@
|
|||||||
# FiveM RPC
|
# FiveM RPC
|
||||||
|
|
||||||
is an all-in package with asynchronous RPC implementation for RageMP servers in JS/TS. [Extra info](https://github.com/rilaxik/fivem-rpc/blob/master/readme.md)
|
is an all-in package with asynchronous RPC implementation for RageMP servers in JS/TS. [Extra info](https://github.com/rilaxik/fivem-rpc/blob/master/readme.md)
|
||||||
|
|
||||||
# Motivation
|
# Motivation
|
||||||
|
|
||||||
The idea was to create an extensible package, with various features to simplify the development process and provide as much comfort as possible. Inspired by usage of [altv-xrpc](https://github.com/xxshady/altv-xrpc)
|
The idea was to create an extensible package, with various features to simplify the development process and provide as much comfort as possible. Inspired by usage of [altv-xrpc](https://github.com/xxshady/altv-xrpc)
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm i @entityseven/fivem-rpc
|
pnpm i @entityseven/fivem-rpc
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn add @entityseven/fivem-rpc
|
yarn add @entityseven/fivem-rpc
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bun add @entityseven/fivem-rpc
|
bun add @entityseven/fivem-rpc
|
||||||
```
|
```
|
||||||
|
|
||||||
It is highly recommended to also install additional package for enhanced typing
|
It is highly recommended to also install additional package for enhanced typing
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm i @entityseven/fivem-rpc-shared-types -D
|
pnpm i @entityseven/fivem-rpc-shared-types -D
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn add @entityseven/fivem-rpc-shared-types --dev
|
yarn add @entityseven/fivem-rpc-shared-types --dev
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bun add @entityseven/fivem-rpc-shared-types -d
|
bun add @entityseven/fivem-rpc-shared-types -d
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
FiveM RPC is meant to be a singletone per environment. This means you _must create only one_ `RPCFactory` per your server/client/web. This also enables modifying `const rpc` to your needs, adding new methods or variables by forcing you to import it from file instead of library reference
|
FiveM RPC is meant to be a singletone per environment. This means you _must create only one_ `RPCFactory` per your server/client/web. This also enables modifying `const rpc` to your needs, adding new methods or variables by forcing you to import it from file instead of library reference
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
// lib/rpc.ts
|
// lib/rpc.ts
|
||||||
import { RPCFactory } from '@entityseven/fivem-rpc'
|
import { RPCFactory } from '@entityseven/fivem-rpc'
|
||||||
@@ -36,21 +47,25 @@ export const rpc = new RPCFactory(/* options */).get()
|
|||||||
# Docs
|
# Docs
|
||||||
|
|
||||||
## Extras
|
## Extras
|
||||||
|
|
||||||
Along with `RPCFactory` you can also import all the types used internally, types for native client/server events and lists of native client/server events. All of that is documented in JSDoc, so no need to duplicate it here
|
Along with `RPCFactory` you can also import all the types used internally, types for native client/server events and lists of native client/server events. All of that is documented in JSDoc, so no need to duplicate it here
|
||||||
|
|
||||||
## RPCConfig
|
## RPCConfig
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
type RPCConfig<T extends RPCEnvironment | unknown> = {
|
type RPCConfig<T extends RPCEnvironment | unknown> = {
|
||||||
env: T
|
env: T
|
||||||
debug?: boolean
|
debug?: boolean
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Failing to set `env` to provided type will result in `RPCErrors.UNKNOWN_ENVIRONMENT`
|
Failing to set `env` to provided type will result in `RPCErrors.UNKNOWN_ENVIRONMENT`
|
||||||
`debug` adds additional console logs to events
|
`debug` adds additional console logs to events
|
||||||
|
|
||||||
|
|
||||||
## Errors
|
## Errors
|
||||||
|
|
||||||
Known errors could be one of following or an error throw by a callback specifically
|
Known errors could be one of following or an error throw by a callback specifically
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
enum RPCErrors {
|
enum RPCErrors {
|
||||||
EVENT_NOT_REGISTERED = 'Event not registered',
|
EVENT_NOT_REGISTERED = 'Event not registered',
|
||||||
@@ -62,7 +77,9 @@ enum RPCErrors {
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Example error
|
### Example error
|
||||||
|
|
||||||
Values wrapped in `<>` always exist, just not relevant for an example. Keep in mind that some errors are thrown in their destination(`To`) point: this example will throw on server
|
Values wrapped in `<>` always exist, just not relevant for an example. Keep in mind that some errors are thrown in their destination(`To`) point: this example will throw on server
|
||||||
|
|
||||||
```
|
```
|
||||||
Error: No player (failed to resolve from local index)
|
Error: No player (failed to resolve from local index)
|
||||||
Event: 'clientServerEvent'
|
Event: 'clientServerEvent'
|
||||||
@@ -75,77 +92,113 @@ Data: [<data>]
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Server ([source](https://github.com/rilaxik/fivem-rpc/blob/master/rpc/src/core/server.ts))
|
## Server ([source](https://github.com/rilaxik/fivem-rpc/blob/master/rpc/src/core/server.ts))
|
||||||
|
|
||||||
### onClient
|
### onClient
|
||||||
|
|
||||||
Listens to client event
|
Listens to client event
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.onClient('clientServerEvent', (player, arg1, arg2, ...rest) => {
|
rpc.onClient('clientServerEvent', (player, arg1, arg2, ...rest) => {
|
||||||
// logic
|
// logic
|
||||||
return someData // this will be forwarded back to caller
|
return someData // this will be forwarded back to caller
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### offClient
|
### offClient
|
||||||
|
|
||||||
Stops listening to client event
|
Stops listening to client event
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.offClient('clientServerEvent')
|
rpc.offClient('clientServerEvent')
|
||||||
```
|
```
|
||||||
|
|
||||||
### emitClient
|
### emitClient
|
||||||
|
|
||||||
Sends event to specified client
|
Sends event to specified client
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const response = await rpc.emitClient(playerServerId, 'serverClientEvent', someData)
|
const response = await rpc.emitClient(playerServerId, 'serverClientEvent', someData)
|
||||||
// response will come from client listener with returned data
|
// response will come from client listener with returned data
|
||||||
```
|
```
|
||||||
|
|
||||||
### emitClientEveryone
|
### emitClientEveryone
|
||||||
|
|
||||||
Sends event to all clients
|
Sends event to all clients
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.emitClientEveryone('serverClientEvent', someData)
|
rpc.emitClientEveryone('serverClientEvent', someData)
|
||||||
```
|
```
|
||||||
|
|
||||||
### onWebview
|
### onWebview
|
||||||
|
|
||||||
Listens to webview event
|
Listens to webview event
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.onWebview('webviewServerEvent', (player, arg1, arg2, ...rest) => {
|
rpc.onWebview('webviewServerEvent', (player, arg1, arg2, ...rest) => {
|
||||||
// logic
|
// logic
|
||||||
return someData // this will be forwarded back to caller
|
return someData // this will be forwarded back to caller
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### offWebview
|
### offWebview
|
||||||
|
|
||||||
Stops listening to webview event
|
Stops listening to webview event
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.offWebview('webviewServerEvent')
|
rpc.offWebview('webviewServerEvent')
|
||||||
```
|
```
|
||||||
|
|
||||||
### emitWebview
|
### emitWebview
|
||||||
|
|
||||||
Sends event to specified webview
|
Sends event to specified webview
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const response = await rpc.emitWebview(playerServerId, 'serverWebviewEvent', someData)
|
const response = await rpc.emitWebview(playerServerId, 'serverWebviewEvent', someData)
|
||||||
// response will come from webview listener with returned data
|
// response will come from webview listener with returned data
|
||||||
```
|
```
|
||||||
|
|
||||||
### onSelf
|
### onSelf
|
||||||
|
|
||||||
Listens to server event
|
Listens to server event
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.onSelf('serverEvent', (arg1, arg2, ...rest) => {
|
rpc.onSelf('serverEvent', (arg1, arg2, ...rest) => {
|
||||||
// logic
|
// logic
|
||||||
return someData // this will be forwarded back to caller
|
return someData // this will be forwarded back to caller
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### offSelf
|
### offSelf
|
||||||
|
|
||||||
Stops listening to server event
|
Stops listening to server event
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.offSelf('serverEvent')
|
rpc.offSelf('serverEvent')
|
||||||
```
|
```
|
||||||
|
|
||||||
### emitSelf
|
### emitSelf
|
||||||
|
|
||||||
Sends event to server
|
Sends event to server
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const response = await rpc.emitSelf('serverEvent', someData)
|
const response = await rpc.emitSelf('serverEvent', someData)
|
||||||
// response will come from server listener with returned data
|
// response will come from server listener with returned data
|
||||||
```
|
```
|
||||||
|
|
||||||
### onCommand
|
### onCommand
|
||||||
|
|
||||||
Registers chat command. Since arguments are untyped you must validate them yourself
|
Registers chat command. Since arguments are untyped you must validate them yourself
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.onCommand('serverCommand', (player, args, commandRaw) => {
|
rpc.onCommand('serverCommand', (player, args, commandRaw) => {
|
||||||
// logic
|
// logic
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### onNativeEvent
|
### onNativeEvent
|
||||||
|
|
||||||
Listens to native server event ([reference](https://docs.fivem.net/docs/scripting-reference/events/server-events/))
|
Listens to native server event ([reference](https://docs.fivem.net/docs/scripting-reference/events/server-events/))
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.onNativeEvent('playerJoining', (source, oldId) => {
|
rpc.onNativeEvent('playerJoining', (source, oldId) => {
|
||||||
// logic
|
// logic
|
||||||
@@ -153,148 +206,215 @@ rpc.onNativeEvent('playerJoining', (source, oldId) => {
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Client ([source](https://github.com/rilaxik/fivem-rpc/blob/master/rpc/src/core/client.ts))
|
## Client ([source](https://github.com/rilaxik/fivem-rpc/blob/master/rpc/src/core/client.ts))
|
||||||
|
|
||||||
### onServer
|
### onServer
|
||||||
|
|
||||||
Listens to server event
|
Listens to server event
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.onServer('serverClientEvent', (arg1, arg2, ...rest) => {
|
rpc.onServer('serverClientEvent', (arg1, arg2, ...rest) => {
|
||||||
// logic
|
// logic
|
||||||
return someData // this will be forwarded back to caller
|
return someData // this will be forwarded back to caller
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### offServer
|
### offServer
|
||||||
|
|
||||||
Stops listening to server event
|
Stops listening to server event
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.offServer('serverClientEvent')
|
rpc.offServer('serverClientEvent')
|
||||||
```
|
```
|
||||||
|
|
||||||
### emitServer
|
### emitServer
|
||||||
|
|
||||||
Sends event to server
|
Sends event to server
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const response = await rpc.emitServer('clientServerEvent', someData)
|
const response = await rpc.emitServer('clientServerEvent', someData)
|
||||||
// response will come from webview listener with returned data
|
// response will come from webview listener with returned data
|
||||||
```
|
```
|
||||||
|
|
||||||
### onWebview
|
### onWebview
|
||||||
|
|
||||||
Listens to webview event
|
Listens to webview event
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.onWebview('webviewClientEvent', (arg1, arg2, ...rest) => {
|
rpc.onWebview('webviewClientEvent', (arg1, arg2, ...rest) => {
|
||||||
// logic
|
// logic
|
||||||
return someData // this will be forwarded back to caller
|
return someData // this will be forwarded back to caller
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### offWebview
|
### offWebview
|
||||||
|
|
||||||
Stops listening to webview event
|
Stops listening to webview event
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.offWebview('webviewClientEvent')
|
rpc.offWebview('webviewClientEvent')
|
||||||
```
|
```
|
||||||
|
|
||||||
### emitWebview
|
### emitWebview
|
||||||
|
|
||||||
Sends event to specified webview
|
Sends event to specified webview
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const response = await rpc.emitWebview('clientWebviewEvent', someData)
|
const response = await rpc.emitWebview('clientWebviewEvent', someData)
|
||||||
// response will come from webview listener with returned data
|
// response will come from webview listener with returned data
|
||||||
```
|
```
|
||||||
|
|
||||||
### onSelf
|
### onSelf
|
||||||
|
|
||||||
Listens to client event
|
Listens to client event
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.onSelf('clientEvent', (arg1, arg2, ...rest) => {
|
rpc.onSelf('clientEvent', (arg1, arg2, ...rest) => {
|
||||||
// logic
|
// logic
|
||||||
return someData // this will be forwarded back to caller
|
return someData // this will be forwarded back to caller
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### offSelf
|
### offSelf
|
||||||
|
|
||||||
Stops listening to client event
|
Stops listening to client event
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.offSelf('clientEvent')
|
rpc.offSelf('clientEvent')
|
||||||
```
|
```
|
||||||
|
|
||||||
### emitSelf
|
### emitSelf
|
||||||
|
|
||||||
Sends event to client
|
Sends event to client
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const response = await rpc.emitSelf('clientEvent', someData)
|
const response = await rpc.emitSelf('clientEvent', someData)
|
||||||
// response will come from client listener with returned data
|
// response will come from client listener with returned data
|
||||||
```
|
```
|
||||||
|
|
||||||
### onCommand
|
### onCommand
|
||||||
|
|
||||||
Registers chat command. Since arguments are untyped you must validate them yourself
|
Registers chat command. Since arguments are untyped you must validate them yourself
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.onCommand('clientCommand', (player, args, commandRaw) => {
|
rpc.onCommand('clientCommand', (player, args, commandRaw) => {
|
||||||
// logic
|
// logic
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### onNativeEvent
|
### onNativeEvent
|
||||||
|
|
||||||
Listens to native client event ([reference](https://docs.fivem.net/docs/scripting-reference/events/client-events/))
|
Listens to native client event ([reference](https://docs.fivem.net/docs/scripting-reference/events/client-events/))
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.onNativeEvent('entityDamaged', (victim, culprit, weapon, baseDamage) => {
|
rpc.onNativeEvent('entityDamaged', (victim, culprit, weapon, baseDamage) => {
|
||||||
// logic
|
// logic
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### onNativeNetworkEvent
|
### onNativeNetworkEvent
|
||||||
|
|
||||||
Listens to native client network event ([reference](https://docs.fivem.net/docs/game-references/game-events/))
|
Listens to native client network event ([reference](https://docs.fivem.net/docs/game-references/game-events/))
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.onNativeNetworkEvent('CEventShockingCarCrash', (entities, eventEntity, data) => {
|
rpc.onNativeNetworkEvent('CEventShockingCarCrash', (entities, eventEntity, data) => {
|
||||||
// logic
|
// logic
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### setWebviewFocus
|
### setWebviewFocus
|
||||||
|
|
||||||
Sets or removes focus and cursor from own webview
|
Sets or removes focus and cursor from own webview
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.setWebviewFocus(true /* focus */, true /* show cursor */)
|
rpc.setWebviewFocus(true /* focus */, true /* show cursor */)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Webview ([source](https://github.com/rilaxik/fivem-rpc/blob/master/rpc/src/core/webview.ts))
|
## Webview ([source](https://github.com/rilaxik/fivem-rpc/blob/master/rpc/src/core/webview.ts))
|
||||||
|
|
||||||
### onClient
|
### onClient
|
||||||
|
|
||||||
Listens to client event
|
Listens to client event
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.onClient('clientWebviewEvent', (arg1, arg2, ...rest) => {
|
rpc.onClient('clientWebviewEvent', (arg1, arg2, ...rest) => {
|
||||||
// logic
|
// logic
|
||||||
return someData // this will be forwarded back to caller
|
return someData // this will be forwarded back to caller
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### offClient
|
### offClient
|
||||||
|
|
||||||
Stops listening to client event
|
Stops listening to client event
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.offClient('clientWebviewEvent')
|
rpc.offClient('clientWebviewEvent')
|
||||||
```
|
```
|
||||||
|
|
||||||
### emitClient
|
### emitClient
|
||||||
|
|
||||||
Sends event to own client
|
Sends event to own client
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const response = await rpc.emitClient('webviewClientEvent', someData)
|
const response = await rpc.emitClient('webviewClientEvent', someData)
|
||||||
// response will come from client listener with returned data
|
// response will come from client listener with returned data
|
||||||
```
|
```
|
||||||
|
|
||||||
### onServer
|
### onServer
|
||||||
|
|
||||||
Listens to server event
|
Listens to server event
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.onServer('serverWebviewEvent', (arg1, arg2, ...rest) => {
|
rpc.onServer('serverWebviewEvent', (arg1, arg2, ...rest) => {
|
||||||
// logic
|
// logic
|
||||||
return someData // this will be forwarded back to caller
|
return someData // this will be forwarded back to caller
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### offServer
|
### offServer
|
||||||
|
|
||||||
Stops listening to server event
|
Stops listening to server event
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.offServer('serverWebviewEvent')
|
rpc.offServer('serverWebviewEvent')
|
||||||
```
|
```
|
||||||
|
|
||||||
### emitServer
|
### emitServer
|
||||||
|
|
||||||
Sends event to server
|
Sends event to server
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const response = await rpc.emitServer('webviewServerEvent', someData)
|
const response = await rpc.emitServer('webviewServerEvent', someData)
|
||||||
// response will come from webview listener with returned data
|
// response will come from webview listener with returned data
|
||||||
```
|
```
|
||||||
|
|
||||||
### onSelf
|
### onSelf
|
||||||
|
|
||||||
Listens to webview event
|
Listens to webview event
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.onSelf('webviewEvent', (arg1, arg2, ...rest) => {
|
rpc.onSelf('webviewEvent', (arg1, arg2, ...rest) => {
|
||||||
// logic
|
// logic
|
||||||
return someData // this will be forwarded back to caller
|
return someData // this will be forwarded back to caller
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### offSelf
|
### offSelf
|
||||||
|
|
||||||
Stops listening to webview event
|
Stops listening to webview event
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
rpc.offSelf('webviewEvent')
|
rpc.offSelf('webviewEvent')
|
||||||
```
|
```
|
||||||
|
|
||||||
### emitSelf
|
### emitSelf
|
||||||
|
|
||||||
Sends event to webview
|
Sends event to webview
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const response = await rpc.emitSelf('webviewEvent', someData)
|
const response = await rpc.emitSelf('webviewEvent', someData)
|
||||||
// response will come from webview listener with returned data
|
// response will come from webview listener with returned data
|
||||||
```
|
```
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
Licensed under Custom Attribution-NoDerivs Software License
|
Licensed under Custom Attribution-NoDerivs Software License
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type * as s from '@entityseven/fivem-rpc-shared-types'
|
import type * as s from '@entityseven/fivem-rpc-shared-types'
|
||||||
|
|
||||||
import { Emitter } from '../utils/emitter'
|
import { Emitter } from '../utils/emitter'
|
||||||
import { generateUUID, parse, stringify, stringifyWeb } from '../utils/funcs'
|
import { generateUUID, parse, stringify, stringifyWeb } from '../utils/funcs'
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type * as s from '@entityseven/fivem-rpc-shared-types'
|
import type * as s from '@entityseven/fivem-rpc-shared-types'
|
||||||
|
|
||||||
import { Emitter } from '../utils/emitter'
|
import { Emitter } from '../utils/emitter'
|
||||||
import { generateUUID, parse, stringify } from '../utils/funcs'
|
import { generateUUID, parse, stringify } from '../utils/funcs'
|
||||||
import { NATIVE_SERVER_EVENTS } from '../utils/native'
|
import { NATIVE_SERVER_EVENTS } from '../utils/native'
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type * as s from '@entityseven/fivem-rpc-shared-types'
|
import type * as s from '@entityseven/fivem-rpc-shared-types'
|
||||||
|
|
||||||
import { Emitter } from '../utils/emitter'
|
import { Emitter } from '../utils/emitter'
|
||||||
import { generateUUID, stringify } from '../utils/funcs'
|
import { generateUUID, stringify } from '../utils/funcs'
|
||||||
import {
|
import {
|
||||||
|
|||||||
+11
-11
@@ -1,20 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "@entityseven/fivem-rpc-shared-types",
|
"name": "@entityseven/fivem-rpc-shared-types",
|
||||||
"description": "Shared (enhanced) types for @entityseven/fivem-rpc. Highly recommended to install together",
|
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"types": "types/types/index.d.ts",
|
"description": "Shared (enhanced) types for @entityseven/fivem-rpc. Highly recommended to install together",
|
||||||
"files": [
|
|
||||||
"types/**/*",
|
|
||||||
"readme.md",
|
|
||||||
"license.md"
|
|
||||||
],
|
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"fivem-rpc-shared-types",
|
|
||||||
"fivem-rpc",
|
|
||||||
"fivem",
|
"fivem",
|
||||||
|
"fivem-rpc",
|
||||||
|
"fivem-rpc-shared-types",
|
||||||
"gta"
|
"gta"
|
||||||
],
|
],
|
||||||
"type": "module",
|
"license": "Custom-Attribution-NoDerivs",
|
||||||
"author": "Entity Seven Group",
|
"author": "Entity Seven Group",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
{
|
{
|
||||||
@@ -23,11 +17,17 @@
|
|||||||
"url": "https://github.com/rilaxik/"
|
"url": "https://github.com/rilaxik/"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"license": "Custom-Attribution-NoDerivs",
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/rilaxik/fivem-rpc.git"
|
"url": "https://github.com/rilaxik/fivem-rpc.git"
|
||||||
},
|
},
|
||||||
|
"files": [
|
||||||
|
"types/**/*",
|
||||||
|
"readme.md",
|
||||||
|
"license.md"
|
||||||
|
],
|
||||||
|
"type": "module",
|
||||||
|
"types": "types/types/index.d.ts",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": "^5"
|
"typescript": "^5"
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-1
@@ -1,22 +1,29 @@
|
|||||||
# FiveM RPC Shared Types
|
# FiveM RPC Shared Types
|
||||||
|
|
||||||
### [Docs & Info](https://github.com/rilaxik/fivem-rpc/blob/master/readme.md)
|
### [Docs & Info](https://github.com/rilaxik/fivem-rpc/blob/master/readme.md)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm i @entityseven/fivem-rpc-shared-types -D
|
pnpm i @entityseven/fivem-rpc-shared-types -D
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn add @entityseven/fivem-rpc-shared-types --dev
|
yarn add @entityseven/fivem-rpc-shared-types --dev
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bun add @entityseven/fivem-rpc-shared-types -d
|
bun add @entityseven/fivem-rpc-shared-types -d
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
This package is an enhanced type support for `@entityseven/fivem-rpc`. It provides ability to strictly type your events for better dx.
|
This package is an enhanced type support for `@entityseven/fivem-rpc`. It provides ability to strictly type your events for better dx.
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
This example is neat way to follow up but you can change it as you wish. It will use bun workspaces, pnpm workspaces work in a similar manner. Referring the following folder structure:
|
This example is neat way to follow up but you can change it as you wish. It will use bun workspaces, pnpm workspaces work in a similar manner. Referring the following folder structure:
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
apps/
|
apps/
|
||||||
- server/
|
- server/
|
||||||
@@ -38,6 +45,7 @@ apps/
|
|||||||
- Environment folder: folder with server, client or webview code in it
|
- Environment folder: folder with server, client or webview code in it
|
||||||
|
|
||||||
1. Install this package as dev dependency in your root package or in each environment folder separately
|
1. Install this package as dev dependency in your root package or in each environment folder separately
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
apps/
|
apps/
|
||||||
- server/ <- (if not installed root)
|
- server/ <- (if not installed root)
|
||||||
@@ -49,6 +57,7 @@ apps/
|
|||||||
```
|
```
|
||||||
|
|
||||||
2. In `shared/` create folder `fivem-rpc` (or similar), inside it create `index.d.ts`
|
2. In `shared/` create folder `fivem-rpc` (or similar), inside it create `index.d.ts`
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
apps/
|
apps/
|
||||||
- server/
|
- server/
|
||||||
@@ -62,6 +71,7 @@ apps/
|
|||||||
```
|
```
|
||||||
|
|
||||||
3. In `index.d.ts` add following:
|
3. In `index.d.ts` add following:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
declare module '@entityseven/fivem-rpc-shared-types' {
|
declare module '@entityseven/fivem-rpc-shared-types' {
|
||||||
// Client commands names
|
// Client commands names
|
||||||
@@ -110,12 +120,14 @@ apps/
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
5. We also need to populate interfaces we created in step 3.
|
5. We also need to populate interfaces we created in step 3.
|
||||||
|
|
||||||
- `RPCCommands_Client` and `RPCCommands_Server` will include your commands names an union strings:
|
- `RPCCommands_Client` and `RPCCommands_Server` will include your commands names an union strings:
|
||||||
```ts
|
```ts
|
||||||
export type RPCCommands_Client = 'afk' | 'vanish' | '...' // example names
|
export type RPCCommands_Client = 'afk' | 'vanish' | '...' // example names
|
||||||
export type RPCCommands_Server = 'report' | 'ban' | '...' // example names
|
export type RPCCommands_Server = 'report' | 'ban' | '...' // example names
|
||||||
```
|
```
|
||||||
- Other interfaces will include your events types. The example will show one but all of the work same way
|
- Other interfaces will include your events types. The example will show one but all of the work same way
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
export interface RPCEvents_ClientServer {
|
export interface RPCEvents_ClientServer {
|
||||||
clientToServerEventName(data: string, moreData: boolean): number
|
clientToServerEventName(data: string, moreData: boolean): number
|
||||||
@@ -127,6 +139,7 @@ apps/
|
|||||||
- `number` is a return type that will be forwarded back to caller
|
- `number` is a return type that will be forwarded back to caller
|
||||||
|
|
||||||
Doing this will create type hints for you:
|
Doing this will create type hints for you:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
// assuming this is in client
|
// assuming this is in client
|
||||||
const response /* number */ = await rpc.emitServer(
|
const response /* number */ = await rpc.emitServer(
|
||||||
@@ -137,9 +150,11 @@ apps/
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Example (alternative)
|
## Example (alternative)
|
||||||
|
|
||||||
If previous example does not work or you do not like you can also try it this way. Steps that are not mentioned are the same as previous
|
If previous example does not work or you do not like you can also try it this way. Steps that are not mentioned are the same as previous
|
||||||
|
|
||||||
2. In `shared/` create folders `declarations/fivem-rpc`, inside it create `index.d.ts`
|
2. In `shared/` create folders `declarations/fivem-rpc`, inside it create `index.d.ts`
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
apps/
|
apps/
|
||||||
- server/
|
- server/
|
||||||
@@ -153,7 +168,7 @@ If previous example does not work or you do not like you can also try it this wa
|
|||||||
- package.json
|
- package.json
|
||||||
```
|
```
|
||||||
|
|
||||||
4. We just created a declaration which will overwrite types from the package. Now we need our packages to refer to these types when linting `rpc` functions. To do this in each environment folder of your project in `tsconfig.json` do these:
|
3. We just created a declaration which will overwrite types from the package. Now we need our packages to refer to these types when linting `rpc` functions. To do this in each environment folder of your project in `tsconfig.json` do these:
|
||||||
```json5
|
```json5
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
|||||||
Reference in New Issue
Block a user