@nativewrappers/common 0.0.99 → 0.0.101

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.
Files changed (2) hide show
  1. package/decors/Events.js +40 -17
  2. package/package.json +1 -1
package/decors/Events.js CHANGED
@@ -9,26 +9,49 @@ var ConVarType = /* @__PURE__ */ ((ConVarType2) => {
9
9
  return ConVarType2;
10
10
  })(ConVarType || {});
11
11
  const DisablePrettyPrint = /* @__PURE__ */ __name(() => GlobalData.EnablePrettyPrint = false, "DisablePrettyPrint");
12
+ const AsyncFunction = (async () => {
13
+ }).constructor;
12
14
  function Exports(exportName) {
13
15
  return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
14
16
  if (context.private) {
15
17
  throw new Error("Exports does not work on private methods, please mark the method as public");
16
18
  }
17
19
  context.addInitializer(function() {
18
- exports(exportName, (...args) => {
19
- try {
20
- return originalMethod.call(this, ...args);
21
- } catch (err) {
22
- REMOVE_EVENT_LOG: {
23
- if (!GlobalData.EnablePrettyPrint) return;
24
- console.error("------- EXPORT ERROR --------");
25
- console.error(`Call to ${exportName} errored`);
26
- console.error(`Data: ${JSON.stringify(args)}`);
27
- console.error(`Error: ${err}`);
28
- console.error("------- END EXPORT ERROR --------");
20
+ let exportCb;
21
+ if (originalMethod instanceof AsyncFunction) {
22
+ exportCb = /* @__PURE__ */ __name(async (...args) => {
23
+ try {
24
+ return await originalMethod.call(this, ...args);
25
+ } catch (err) {
26
+ REMOVE_EVENT_LOG: {
27
+ if (!GlobalData.EnablePrettyPrint) return;
28
+ console.error("------- EXPORT ERROR --------");
29
+ console.error(`Call to ${exportName} errored`);
30
+ console.error(`Data: ${JSON.stringify(args)}`);
31
+ console.error(`Error: ${err}`);
32
+ console.error("------- END EXPORT ERROR --------");
33
+ }
34
+ throw err;
29
35
  }
30
- }
31
- });
36
+ }, "exportCb");
37
+ } else {
38
+ exportCb = /* @__PURE__ */ __name((...args) => {
39
+ try {
40
+ return originalMethod.call(this, ...args);
41
+ } catch (err) {
42
+ REMOVE_EVENT_LOG: {
43
+ if (!GlobalData.EnablePrettyPrint) return;
44
+ console.error("------- EXPORT ERROR --------");
45
+ console.error(`Call to ${exportName} errored`);
46
+ console.error(`Data: ${JSON.stringify(args)}`);
47
+ console.error(`Error: ${err}`);
48
+ console.error("------- END EXPORT ERROR --------");
49
+ }
50
+ throw err;
51
+ }
52
+ }, "exportCb");
53
+ }
54
+ exports(exportName, exportCb);
32
55
  });
33
56
  }, "actualDecorator");
34
57
  }
@@ -39,9 +62,9 @@ function Event(eventName) {
39
62
  throw new Error("Event does not work on private methods, please mark the method as public");
40
63
  }
41
64
  context.addInitializer(function() {
42
- on(eventName, (...args) => {
65
+ on(eventName, async (...args) => {
43
66
  try {
44
- return originalMethod.call(this, ...args);
67
+ return await originalMethod.call(this, ...args);
45
68
  } catch (e) {
46
69
  REMOVE_EVENT_LOG: {
47
70
  if (!GlobalData.EnablePrettyPrint) return;
@@ -63,7 +86,7 @@ function NetEvent(eventName, remoteOnly = true) {
63
86
  throw new Error("NetEvent does not work on private methods, please mark the method as public");
64
87
  }
65
88
  context.addInitializer(function() {
66
- onNet(eventName, (...args) => {
89
+ onNet(eventName, async (...args) => {
67
90
  const src = source;
68
91
  try {
69
92
  $CLIENT: {
@@ -71,7 +94,7 @@ function NetEvent(eventName, remoteOnly = true) {
71
94
  return;
72
95
  }
73
96
  }
74
- return originalMethod.call(this, ...args);
97
+ return await originalMethod.call(this, ...args);
75
98
  } catch (e) {
76
99
  REMOVE_NET_EVENT_LOG: {
77
100
  if (!GlobalData.EnablePrettyPrint) return;
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "license": "MIT",
10
10
  "type": "module",
11
- "version": "0.0.99",
11
+ "version": "0.0.101",
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "https://github.com/nativewrappers/nativewrappers.git"