@twin.org/modules 0.0.1-next.57 → 0.0.1-next.58

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.
@@ -92,42 +92,44 @@ class ModuleHelper {
92
92
  static async execModuleMethodThread(module, method, args) {
93
93
  return new Promise((resolve, reject) => {
94
94
  const worker = new node_worker_threads.Worker(`
95
- const { workerData, parentPort } = require('worker_threads');
95
+ (async () => {
96
+ const { workerData, parentPort } = await import('worker_threads');
96
97
 
97
- function rejectError(type, innerError) {
98
- parentPort.postMessage({ errorType: type, innerError });
99
- }
98
+ function rejectError(type, innerError) {
99
+ parentPort.postMessage({ errorType: type, innerError });
100
+ }
100
101
 
101
- function resolveResult(result) {
102
- Promise.resolve(result).then(res => parentPort.postMessage({ result: res }));
103
- }
102
+ function resolveResult(result) {
103
+ Promise.resolve(result).then(res => parentPort.postMessage({ result: res }));
104
+ }
104
105
 
105
- const { module, method, args } = workerData;
106
+ const { module, method, args } = workerData;
106
107
 
107
- import(module)
108
- .then(moduleInstance => {
109
- const methodParts = method.split(".");
110
- const moduleEntry = moduleInstance[methodParts[0]];
108
+ import(module)
109
+ .then(moduleInstance => {
110
+ const methodParts = method.split(".");
111
+ const moduleEntry = moduleInstance[methodParts[0]];
111
112
 
112
- if (moduleEntry === undefined) {
113
- rejectError("entryNotFound");
114
- } else if (methodParts.length === 2) {
115
- const moduleMethod = moduleEntry[methodParts[1]];
116
- if (typeof moduleMethod === "function") {
117
- resolveResult(moduleMethod(...(args ?? [])));
113
+ if (moduleEntry === undefined) {
114
+ rejectError("entryNotFound");
115
+ } else if (methodParts.length === 2) {
116
+ const moduleMethod = moduleEntry[methodParts[1]];
117
+ if (typeof moduleMethod === "function") {
118
+ resolveResult(moduleMethod(...(args ?? [])));
119
+ } else {
120
+ rejectError("notFunction");
121
+ }
122
+ } else if (typeof moduleEntry === "function") {
123
+ resolveResult(moduleEntry(...(args ?? [])));
118
124
  } else {
119
125
  rejectError("notFunction");
120
126
  }
121
- } else if (typeof moduleEntry === "function") {
122
- resolveResult(moduleEntry(...(args ?? [])));
123
- } else {
124
- rejectError("notFunction");
125
- }
126
- })
127
- .catch(err => {
128
- rejectError("moduleNotFound", err);
129
- });
130
- `, { eval: true, workerData: { module, method, args: args ?? [] } });
127
+ })
128
+ .catch(err => {
129
+ rejectError("moduleNotFound", err);
130
+ });
131
+ })();
132
+ `, { eval: true, workerData: { module, method, args: args ?? [] } });
131
133
  worker.on("message", msg => {
132
134
  if (core.Is.stringValue(msg.errorType)) {
133
135
  reject(new core.GeneralError(ModuleHelper.CLASS_NAME, msg.errorType, { module, entry: method }, msg.innerError));
@@ -90,42 +90,44 @@ class ModuleHelper {
90
90
  static async execModuleMethodThread(module, method, args) {
91
91
  return new Promise((resolve, reject) => {
92
92
  const worker = new Worker(`
93
- const { workerData, parentPort } = require('worker_threads');
93
+ (async () => {
94
+ const { workerData, parentPort } = await import('worker_threads');
94
95
 
95
- function rejectError(type, innerError) {
96
- parentPort.postMessage({ errorType: type, innerError });
97
- }
96
+ function rejectError(type, innerError) {
97
+ parentPort.postMessage({ errorType: type, innerError });
98
+ }
98
99
 
99
- function resolveResult(result) {
100
- Promise.resolve(result).then(res => parentPort.postMessage({ result: res }));
101
- }
100
+ function resolveResult(result) {
101
+ Promise.resolve(result).then(res => parentPort.postMessage({ result: res }));
102
+ }
102
103
 
103
- const { module, method, args } = workerData;
104
+ const { module, method, args } = workerData;
104
105
 
105
- import(module)
106
- .then(moduleInstance => {
107
- const methodParts = method.split(".");
108
- const moduleEntry = moduleInstance[methodParts[0]];
106
+ import(module)
107
+ .then(moduleInstance => {
108
+ const methodParts = method.split(".");
109
+ const moduleEntry = moduleInstance[methodParts[0]];
109
110
 
110
- if (moduleEntry === undefined) {
111
- rejectError("entryNotFound");
112
- } else if (methodParts.length === 2) {
113
- const moduleMethod = moduleEntry[methodParts[1]];
114
- if (typeof moduleMethod === "function") {
115
- resolveResult(moduleMethod(...(args ?? [])));
111
+ if (moduleEntry === undefined) {
112
+ rejectError("entryNotFound");
113
+ } else if (methodParts.length === 2) {
114
+ const moduleMethod = moduleEntry[methodParts[1]];
115
+ if (typeof moduleMethod === "function") {
116
+ resolveResult(moduleMethod(...(args ?? [])));
117
+ } else {
118
+ rejectError("notFunction");
119
+ }
120
+ } else if (typeof moduleEntry === "function") {
121
+ resolveResult(moduleEntry(...(args ?? [])));
116
122
  } else {
117
123
  rejectError("notFunction");
118
124
  }
119
- } else if (typeof moduleEntry === "function") {
120
- resolveResult(moduleEntry(...(args ?? [])));
121
- } else {
122
- rejectError("notFunction");
123
- }
124
- })
125
- .catch(err => {
126
- rejectError("moduleNotFound", err);
127
- });
128
- `, { eval: true, workerData: { module, method, args: args ?? [] } });
125
+ })
126
+ .catch(err => {
127
+ rejectError("moduleNotFound", err);
128
+ });
129
+ })();
130
+ `, { eval: true, workerData: { module, method, args: args ?? [] } });
129
131
  worker.on("message", msg => {
130
132
  if (Is.stringValue(msg.errorType)) {
131
133
  reject(new GeneralError(ModuleHelper.CLASS_NAME, msg.errorType, { module, entry: method }, msg.innerError));
package/docs/changelog.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @twin.org/modules - Changelog
2
2
 
3
+ ## [0.0.1-next.58](https://github.com/twinfoundation/framework/compare/modules-v0.0.1-next.57...modules-v0.0.1-next.58) (2025-06-13)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **modules:** Synchronize repo versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/core bumped from 0.0.1-next.57 to 0.0.1-next.58
16
+
3
17
  ## [0.0.1-next.57](https://github.com/twinfoundation/framework/compare/modules-v0.0.1-next.56...modules-v0.0.1-next.57) (2025-06-10)
4
18
 
5
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/modules",
3
- "version": "0.0.1-next.57",
3
+ "version": "0.0.1-next.58",
4
4
  "description": "Helper classes for loading and executing from modules",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,7 +14,7 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/core": "0.0.1-next.57",
17
+ "@twin.org/core": "0.0.1-next.58",
18
18
  "@twin.org/nameof": "next"
19
19
  },
20
20
  "main": "./dist/cjs/index.cjs",