@nativewrappers/common 0.0.100 → 0.0.102

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 +36 -14
  2. package/package.json +1 -1
package/decors/Events.js CHANGED
@@ -9,27 +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, async (...args) => {
19
- try {
20
- return await 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
- throw err;
31
- }
32
- });
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);
33
55
  });
34
56
  }, "actualDecorator");
35
57
  }
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "license": "MIT",
10
10
  "type": "module",
11
- "version": "0.0.100",
11
+ "version": "0.0.102",
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "https://github.com/nativewrappers/nativewrappers.git"