@nativewrappers/redm 0.0.159 → 0.0.160
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/common/BaseScript.d.ts +18 -0
- package/common/BaseScript.js +36 -0
- package/common/decors/Proto.d.ts +2 -2
- package/common/decors/Proto.js +2 -2
- package/common/net/Net.js +3 -3
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare enum State {
|
|
2
|
+
Uninitialized = 0,
|
|
3
|
+
Initialized = 1,
|
|
4
|
+
Enabled = 2
|
|
5
|
+
}
|
|
6
|
+
export declare class BaseScript {
|
|
7
|
+
private state;
|
|
8
|
+
private events;
|
|
9
|
+
private exports;
|
|
10
|
+
private ticks;
|
|
11
|
+
private statebags;
|
|
12
|
+
private convars;
|
|
13
|
+
get IsEnabled(): boolean;
|
|
14
|
+
start(): void;
|
|
15
|
+
stop(): void;
|
|
16
|
+
startTick(name: string): void;
|
|
17
|
+
stopTick(name: string): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
var State = /* @__PURE__ */ ((State2) => {
|
|
4
|
+
State2[State2["Uninitialized"] = 0] = "Uninitialized";
|
|
5
|
+
State2[State2["Initialized"] = 1] = "Initialized";
|
|
6
|
+
State2[State2["Enabled"] = 2] = "Enabled";
|
|
7
|
+
return State2;
|
|
8
|
+
})(State || {});
|
|
9
|
+
class BaseScript {
|
|
10
|
+
static {
|
|
11
|
+
__name(this, "BaseScript");
|
|
12
|
+
}
|
|
13
|
+
state = 0 /* Uninitialized */;
|
|
14
|
+
events = /* @__PURE__ */ new Map();
|
|
15
|
+
exports = /* @__PURE__ */ new Map();
|
|
16
|
+
ticks = /* @__PURE__ */ new Map();
|
|
17
|
+
statebags = /* @__PURE__ */ new Map();
|
|
18
|
+
convars = /* @__PURE__ */ new Map();
|
|
19
|
+
// TODO:
|
|
20
|
+
// Commands?
|
|
21
|
+
get IsEnabled() {
|
|
22
|
+
return (this.state & 2 /* Enabled */) !== 0;
|
|
23
|
+
}
|
|
24
|
+
start() {
|
|
25
|
+
}
|
|
26
|
+
stop() {
|
|
27
|
+
}
|
|
28
|
+
startTick(name) {
|
|
29
|
+
}
|
|
30
|
+
stopTick(name) {
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
BaseScript,
|
|
35
|
+
State
|
|
36
|
+
};
|
package/common/decors/Proto.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export type MessageTypeDecoder<T> = {
|
|
2
2
|
decode: (input: Uint8Array) => T;
|
|
3
|
-
|
|
3
|
+
__proto_name__: string;
|
|
4
4
|
};
|
|
5
5
|
export type MessageTypeEncoder<T> = {
|
|
6
6
|
encode: (message: T) => any;
|
|
7
|
-
|
|
7
|
+
__proto_name__: string;
|
|
8
8
|
};
|
|
9
9
|
type ProtoCallback<Message> = (message: Message) => Promise<void> | void;
|
|
10
10
|
type NetProtoCallback<Message> = (message: Message, source: number) => Promise<void> | void;
|
package/common/decors/Proto.js
CHANGED
|
@@ -7,7 +7,7 @@ function parseSource(source) {
|
|
|
7
7
|
}
|
|
8
8
|
__name(parseSource, "parseSource");
|
|
9
9
|
function OnProto(messageType, eventName) {
|
|
10
|
-
const event = eventName ?? `${messageType.
|
|
10
|
+
const event = eventName ?? `${messageType.__proto_name__}`;
|
|
11
11
|
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
12
12
|
if (context.private) {
|
|
13
13
|
throw new Error("OnProto does not work on private methods");
|
|
@@ -26,7 +26,7 @@ function OnProto(messageType, eventName) {
|
|
|
26
26
|
}
|
|
27
27
|
__name(OnProto, "OnProto");
|
|
28
28
|
function OnProtoNet(messageType, eventName) {
|
|
29
|
-
const event = eventName ?? `${messageType.
|
|
29
|
+
const event = eventName ?? `${messageType.__proto_name__}`;
|
|
30
30
|
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
31
31
|
if (context.private) {
|
|
32
32
|
throw new Error("OnProto does not work on private methods");
|
package/common/net/Net.js
CHANGED
|
@@ -31,11 +31,11 @@ class NetServer extends Net {
|
|
|
31
31
|
}
|
|
32
32
|
static emitProto(source, message) {
|
|
33
33
|
const encoded = message.encode(message);
|
|
34
|
-
NetServer.emitRawNet(message.
|
|
34
|
+
NetServer.emitRawNet(message.__proto_name__, source, encoded);
|
|
35
35
|
}
|
|
36
36
|
static broadcastProto(sources, message) {
|
|
37
37
|
const encoded = message.encode(message);
|
|
38
|
-
NetServer.broadcastRaw(sources, message.
|
|
38
|
+
NetServer.broadcastRaw(sources, message.__proto_name__, encoded);
|
|
39
39
|
}
|
|
40
40
|
static broadcast(sources, eventName, ...args) {
|
|
41
41
|
const packed = msgpack_pack(...args);
|
|
@@ -61,7 +61,7 @@ class NetClient extends Net {
|
|
|
61
61
|
}
|
|
62
62
|
static emitProto(message) {
|
|
63
63
|
const encoded = message.encode(message);
|
|
64
|
-
NetClient.emitRawNet(message.
|
|
64
|
+
NetClient.emitRawNet(message.__proto_name__, encoded);
|
|
65
65
|
}
|
|
66
66
|
static emitRawNet(eventName, data) {
|
|
67
67
|
TriggerServerEventInternal(eventName, data, data.byteLength);
|
package/index.d.ts
CHANGED
|
@@ -75,6 +75,7 @@ export * from "./common-game/definitions/index.d";
|
|
|
75
75
|
export * from "./common-game/definitions/redm.d";
|
|
76
76
|
export * from "./common-game/cfx/StateBagChangeHandler";
|
|
77
77
|
export * from "./common-game/cfx/cfx";
|
|
78
|
+
export * from "./common/BaseScript";
|
|
78
79
|
export * from "./common/Command";
|
|
79
80
|
export * from "./common/Convar";
|
|
80
81
|
export * from "./common/GlobalData";
|
package/index.js
CHANGED
|
@@ -75,6 +75,7 @@ export * from "./common-game/definitions/index.d";
|
|
|
75
75
|
export * from "./common-game/definitions/redm.d";
|
|
76
76
|
export * from "./common-game/cfx/StateBagChangeHandler";
|
|
77
77
|
export * from "./common-game/cfx/cfx";
|
|
78
|
+
export * from "./common/BaseScript";
|
|
78
79
|
export * from "./common/Command";
|
|
79
80
|
export * from "./common/Convar";
|
|
80
81
|
export * from "./common/GlobalData";
|