@rage.mp/rpc 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cef.d.ts +9 -0
- package/dist/cef.js +39 -0
- package/dist/client.d.ts +5 -0
- package/dist/client.js +35 -0
- package/dist/common-CMpLKDnd.d.ts +23 -0
- package/dist/server.d.ts +8 -0
- package/dist/server.js +46 -0
- package/package.json +39 -0
package/dist/cef.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { R as RpcEventMap, a as RpcSendClientEventMap, b as RpcInvokeClientEventMap, c as RpcSendServerEventMap } from './common-CMpLKDnd.js';
|
|
2
|
+
|
|
3
|
+
declare class Rpc<T extends RpcEventMap> {
|
|
4
|
+
sendClient<K extends keyof RpcSendClientEventMap<T>>(eventName: K, payload: RpcSendClientEventMap<T>[K]['request']): void;
|
|
5
|
+
callClient<K extends keyof RpcInvokeClientEventMap<T>>(eventName: K, payload: RpcInvokeClientEventMap<T>[K]['request']): Promise<RpcInvokeClientEventMap<T>[K]['response']>;
|
|
6
|
+
sendServer<K extends keyof RpcSendServerEventMap<T>>(eventName: K, payload?: RpcSendServerEventMap<T>[K]['request']): void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { Rpc };
|
package/dist/cef.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/cef.ts
|
|
20
|
+
var cef_exports = {};
|
|
21
|
+
__export(cef_exports, {
|
|
22
|
+
Rpc: () => Rpc
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(cef_exports);
|
|
25
|
+
var Rpc = class {
|
|
26
|
+
sendClient(eventName, payload) {
|
|
27
|
+
return mp.trigger(eventName, payload);
|
|
28
|
+
}
|
|
29
|
+
async callClient(eventName, payload) {
|
|
30
|
+
return mp.events.callProc(eventName, payload);
|
|
31
|
+
}
|
|
32
|
+
sendServer(eventName, payload) {
|
|
33
|
+
return mp.trigger("c__sbs", [eventName, payload]);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
Rpc
|
|
39
|
+
});
|
package/dist/client.d.ts
ADDED
package/dist/client.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/client.ts
|
|
20
|
+
var client_exports = {};
|
|
21
|
+
__export(client_exports, {
|
|
22
|
+
Rpc: () => Rpc
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(client_exports);
|
|
25
|
+
var Rpc = class {
|
|
26
|
+
constructor() {
|
|
27
|
+
mp.events.add("c__sbs", (payload) => {
|
|
28
|
+
mp.events.callRemote("s__sbs", payload);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
Rpc
|
|
35
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type RpcEventMap = Record<string, {
|
|
2
|
+
request: any;
|
|
3
|
+
response: any;
|
|
4
|
+
}>;
|
|
5
|
+
type ExtractSendEventMap<T extends RpcEventMap> = {
|
|
6
|
+
[K in keyof T as T[K]['response'] extends void ? K : never]: T[K];
|
|
7
|
+
};
|
|
8
|
+
type ExtractInvokeEventMap<T extends RpcEventMap> = {
|
|
9
|
+
[K in keyof T as T[K]['response'] extends void ? never : K]: T[K];
|
|
10
|
+
};
|
|
11
|
+
type ClientEventNames<T> = {
|
|
12
|
+
[K in keyof T]: K extends `client.${string}` ? K : never;
|
|
13
|
+
}[keyof T];
|
|
14
|
+
type ServerEventNames<T> = {
|
|
15
|
+
[K in keyof T]: K extends `srv.${string}` ? K : never;
|
|
16
|
+
}[keyof T];
|
|
17
|
+
type RpcClientEventMap<T extends RpcEventMap> = Pick<T, ClientEventNames<T>>;
|
|
18
|
+
type RpcSendClientEventMap<T extends RpcEventMap> = ExtractSendEventMap<RpcClientEventMap<T>>;
|
|
19
|
+
type RpcInvokeClientEventMap<T extends RpcEventMap> = ExtractInvokeEventMap<RpcClientEventMap<T>>;
|
|
20
|
+
type RpcServerEventMap<T extends RpcEventMap> = Pick<T, ServerEventNames<T>>;
|
|
21
|
+
type RpcSendServerEventMap<T extends RpcEventMap> = ExtractSendEventMap<RpcServerEventMap<T>>;
|
|
22
|
+
|
|
23
|
+
export type { RpcEventMap as R, RpcSendClientEventMap as a, RpcInvokeClientEventMap as b, RpcSendServerEventMap as c };
|
package/dist/server.d.ts
ADDED
package/dist/server.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/server.ts
|
|
20
|
+
var server_exports = {};
|
|
21
|
+
__export(server_exports, {
|
|
22
|
+
Rpc: () => Rpc
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(server_exports);
|
|
25
|
+
var Rpc = class {
|
|
26
|
+
listeners = {};
|
|
27
|
+
constructor() {
|
|
28
|
+
}
|
|
29
|
+
// on<K extends keyof RpcSendServerEventMap<T>>(
|
|
30
|
+
// eventName: K,
|
|
31
|
+
// listener: (player: PlayerMp, payload: RpcSendServerEventMap<T>[K]['request']) => void
|
|
32
|
+
// ) {
|
|
33
|
+
// if (!this.listeners[eventName]) this.listeners[eventName] = []
|
|
34
|
+
// // const transformedListener: ProcedureListener = (args, info) => {
|
|
35
|
+
// // return listener(info.player as PlayerMp, args)
|
|
36
|
+
// // }
|
|
37
|
+
// // const map = new Map<Function, Function>()
|
|
38
|
+
// // map.set(listener, transformedListener)
|
|
39
|
+
// // this.listeners[eventName].push(map)
|
|
40
|
+
// // return rageRpc.on(eventName, transformedListener)
|
|
41
|
+
// }
|
|
42
|
+
};
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
Rpc
|
|
46
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rage.mp/rpc",
|
|
3
|
+
"author": "storme-dev",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "An asynchronous, type-safe RPC implementation for RAGE Multiplayer",
|
|
6
|
+
"keywords": [],
|
|
7
|
+
"exports": {
|
|
8
|
+
"./client": {
|
|
9
|
+
"types": "./dist/client.d.ts",
|
|
10
|
+
"import": "./dist/client.js",
|
|
11
|
+
"require": "./dist/client.js"
|
|
12
|
+
},
|
|
13
|
+
"./server": {
|
|
14
|
+
"types": "./dist/server.d.ts",
|
|
15
|
+
"import": "./dist/server.js",
|
|
16
|
+
"require": "./dist/server.js"
|
|
17
|
+
},
|
|
18
|
+
"./cef": {
|
|
19
|
+
"types": "./dist/cef.d.ts",
|
|
20
|
+
"import": "./dist/cef.js",
|
|
21
|
+
"require": "./dist/cef.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"/dist"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsup"
|
|
29
|
+
},
|
|
30
|
+
"license": "ISC",
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@ragempcommunity/types-cef": "^2.1.9",
|
|
33
|
+
"@ragempcommunity/types-client": "^2.1.9",
|
|
34
|
+
"@ragempcommunity/types-server": "^2.1.9",
|
|
35
|
+
"@types/node": "^14.18.63",
|
|
36
|
+
"tsup": "^8.5.1",
|
|
37
|
+
"typescript": "^5.9.3"
|
|
38
|
+
}
|
|
39
|
+
}
|