@nativewrappers/fivem 0.0.123 → 0.0.125

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.
@@ -5,4 +5,4 @@ export declare function OnResourceStart(resource?: string): (originalMethod: any
5
5
  /**
6
6
  * Called whenever the specified resource is stopped.
7
7
  */
8
- export declare function OnResoureStop(resource?: string): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
8
+ export declare function OnResourceStop(resource?: string): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
@@ -52,32 +52,43 @@ if (!globalThis.RESOURCE_WRAPPER) {
52
52
  globalThis.RESOURCE_WRAPPER = new ResourceWrapper();
53
53
  }
54
54
  const RESOURCE_WRAPPER = globalThis.RESOURCE_WRAPPER;
55
+ const onResourceStart = /* @__PURE__ */ __name((resource, originalMethod) => {
56
+ if (GetResourceState(resource) === "started") {
57
+ setImmediate(() => originalMethod.call());
58
+ }
59
+ RESOURCE_WRAPPER.add_to_resource_start(resource, originalMethod);
60
+ }, "onResourceStart");
55
61
  function OnResourceStart(resource = GetCurrentResourceName()) {
56
62
  return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
57
63
  if (context.private) {
58
64
  throw new Error("OnResourceStart does not work on private types, please mark the field as public");
59
65
  }
60
- context.addInitializer(() => {
61
- if (GetResourceState(resource) === "started") {
62
- setImmediate(() => originalMethod.call());
63
- }
64
- RESOURCE_WRAPPER.add_to_resource_start(resource, originalMethod);
65
- });
66
+ if (context.static) {
67
+ onResourceStart(resource, originalMethod);
68
+ } else {
69
+ context.addInitializer(function() {
70
+ onResourceStart(resource, originalMethod.bind(this));
71
+ });
72
+ }
66
73
  }, "actualDecorator");
67
74
  }
68
75
  __name(OnResourceStart, "OnResourceStart");
69
- function OnResoureStop(resource = GetCurrentResourceName()) {
76
+ function OnResourceStop(resource = GetCurrentResourceName()) {
70
77
  return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
71
78
  if (context.private) {
72
79
  throw new Error("OnResourceStop does not work on private types, please mark the field as public");
73
80
  }
74
- context.addInitializer(() => {
81
+ if (context.static) {
75
82
  RESOURCE_WRAPPER.add_to_resource_stop(resource, originalMethod);
76
- });
83
+ } else {
84
+ context.addInitializer(function() {
85
+ RESOURCE_WRAPPER.add_to_resource_stop(resource, originalMethod.bind(this));
86
+ });
87
+ }
77
88
  }, "actualDecorator");
78
89
  }
79
- __name(OnResoureStop, "OnResoureStop");
90
+ __name(OnResourceStop, "OnResourceStop");
80
91
  export {
81
92
  OnResourceStart,
82
- OnResoureStop
93
+ OnResourceStop
83
94
  };
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "license": "MIT",
10
10
  "type": "module",
11
- "version": "0.0.123",
11
+ "version": "0.0.125",
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "https://github.com/nativewrappers/nativewrappers.git"