@twin.org/modules 0.0.3-next.22 → 0.0.3-next.24
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/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# TWIN Framework Modules
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package is part of the framework workspace and provides helper classes for loading and executing from modules to support consistent development workflows across the ecosystem.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
package/docs/changelog.md
CHANGED
|
@@ -1,4 +1,44 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.0.3-next.24](https://github.com/twinfoundation/framework/compare/modules-v0.0.3-next.23...modules-v0.0.3-next.24) (2026-03-19)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* ensure __decorate is defined for decorators ([103a563](https://github.com/twinfoundation/framework/commit/103a563ce01ebdef6240d2e590e7b026e8692684))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/core bumped from 0.0.3-next.23 to 0.0.3-next.24
|
|
16
|
+
* @twin.org/context bumped from 0.0.3-next.23 to 0.0.3-next.24
|
|
17
|
+
* @twin.org/nameof bumped from 0.0.3-next.23 to 0.0.3-next.24
|
|
18
|
+
* devDependencies
|
|
19
|
+
* @twin.org/nameof-transformer bumped from 0.0.3-next.23 to 0.0.3-next.24
|
|
20
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.23 to 0.0.3-next.24
|
|
21
|
+
* @twin.org/validate-locales bumped from 0.0.3-next.23 to 0.0.3-next.24
|
|
22
|
+
|
|
23
|
+
## [0.0.3-next.23](https://github.com/twinfoundation/framework/compare/modules-v0.0.3-next.22...modules-v0.0.3-next.23) (2026-03-17)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Miscellaneous Chores
|
|
27
|
+
|
|
28
|
+
* **modules:** Synchronize repo versions
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Dependencies
|
|
32
|
+
|
|
33
|
+
* The following workspace dependencies were updated
|
|
34
|
+
* dependencies
|
|
35
|
+
* @twin.org/core bumped from 0.0.3-next.22 to 0.0.3-next.23
|
|
36
|
+
* @twin.org/context bumped from 0.0.3-next.22 to 0.0.3-next.23
|
|
37
|
+
* @twin.org/nameof bumped from 0.0.3-next.22 to 0.0.3-next.23
|
|
38
|
+
* devDependencies
|
|
39
|
+
* @twin.org/nameof-transformer bumped from 0.0.3-next.22 to 0.0.3-next.23
|
|
40
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.22 to 0.0.3-next.23
|
|
41
|
+
* @twin.org/validate-locales bumped from 0.0.3-next.22 to 0.0.3-next.23
|
|
2
42
|
|
|
3
43
|
## [0.0.3-next.22](https://github.com/twinfoundation/framework/compare/modules-v0.0.3-next.21...modules-v0.0.3-next.22) (2026-02-26)
|
|
4
44
|
|
package/docs/examples.md
CHANGED
|
@@ -1 +1,110 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Modules Examples
|
|
2
|
+
|
|
3
|
+
Use these snippets for dynamic module loading patterns at runtime extension points.
|
|
4
|
+
|
|
5
|
+
## ModuleHelper
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { ModuleHelper } from '@twin.org/modules';
|
|
9
|
+
|
|
10
|
+
console.log(ModuleHelper.isRelativeModule('./workers/sendEmail.js')); // true
|
|
11
|
+
console.log(ModuleHelper.isLocalModule('./workers/sendEmail.js')); // true
|
|
12
|
+
console.log(ModuleHelper.isLocalModule('@twin.org/core')); // false
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { ModuleHelper } from '@twin.org/modules';
|
|
17
|
+
|
|
18
|
+
const convertToFahrenheit = await ModuleHelper.getModuleMethod<(celsius: number) => number>(
|
|
19
|
+
'./workers/temperature.js',
|
|
20
|
+
'convertToFahrenheit'
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
console.log(convertToFahrenheit(18)); // 64.4
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { ModuleHelper } from '@twin.org/modules';
|
|
28
|
+
|
|
29
|
+
const sum = await ModuleHelper.getModuleEntry<(left: number, right: number) => number>(
|
|
30
|
+
'./workers/math.js',
|
|
31
|
+
'sum'
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
console.log(sum(7, 5)); // 12
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { ModuleHelper } from '@twin.org/modules';
|
|
39
|
+
|
|
40
|
+
const result = await ModuleHelper.execModuleMethod<number>(
|
|
41
|
+
'./workers/temperature.js',
|
|
42
|
+
'convertToFahrenheit',
|
|
43
|
+
[18]
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
console.log(result); // 64.4
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { ModuleHelper } from '@twin.org/modules';
|
|
51
|
+
|
|
52
|
+
ModuleHelper.overrideImport(async moduleName => {
|
|
53
|
+
if (moduleName === './workers/math.js') {
|
|
54
|
+
return {
|
|
55
|
+
module: {
|
|
56
|
+
sum: (left: number, right: number) => left + right
|
|
57
|
+
},
|
|
58
|
+
useDefault: false
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
useDefault: true
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const sum = await ModuleHelper.execModuleMethod<number>('./workers/math.js', 'sum', [3, 4]);
|
|
68
|
+
|
|
69
|
+
console.log(sum); // 7
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import { ModuleHelper } from '@twin.org/modules';
|
|
74
|
+
|
|
75
|
+
const threaded = await ModuleHelper.execModuleMethodThread<number>(
|
|
76
|
+
'./workers/temperature.js',
|
|
77
|
+
'convertToFahrenheit',
|
|
78
|
+
[18],
|
|
79
|
+
{
|
|
80
|
+
traceId: 'trc-01',
|
|
81
|
+
spanId: 'spn-02'
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
console.log(threaded); // 64.4
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { ModuleHelper } from '@twin.org/modules';
|
|
90
|
+
|
|
91
|
+
const worker = ModuleHelper.execModuleMethodThreadMessage(
|
|
92
|
+
'./workers/temperature.js',
|
|
93
|
+
(operation, result, err) => {
|
|
94
|
+
if (err) {
|
|
95
|
+
console.log(err.message); // resultError
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (operation === 'convertToFahrenheit') {
|
|
100
|
+
console.log(result); // 64.4
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
threadName: 'temperature-worker'
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
worker.executeMethod('convertToFahrenheit', [18]);
|
|
109
|
+
await worker.terminate();
|
|
110
|
+
```
|
|
@@ -14,7 +14,7 @@ Helper functions for modules.
|
|
|
14
14
|
|
|
15
15
|
## Properties
|
|
16
16
|
|
|
17
|
-
### CLASS\_NAME
|
|
17
|
+
### CLASS\_NAME {#class_name}
|
|
18
18
|
|
|
19
19
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
20
20
|
|
|
@@ -22,7 +22,7 @@ Runtime name for the class.
|
|
|
22
22
|
|
|
23
23
|
## Methods
|
|
24
24
|
|
|
25
|
-
### overrideImport()
|
|
25
|
+
### overrideImport() {#overrideimport}
|
|
26
26
|
|
|
27
27
|
> `static` **overrideImport**(`overrideImport`): `void`
|
|
28
28
|
|
|
@@ -42,7 +42,7 @@ The override import function.
|
|
|
42
42
|
|
|
43
43
|
***
|
|
44
44
|
|
|
45
|
-
### getModuleEntry()
|
|
45
|
+
### getModuleEntry() {#getmoduleentry}
|
|
46
46
|
|
|
47
47
|
> `static` **getModuleEntry**\<`T`\>(`module`, `entry`): `Promise`\<`T`\>
|
|
48
48
|
|
|
@@ -80,7 +80,7 @@ GeneralError if getting the module entry failed.
|
|
|
80
80
|
|
|
81
81
|
***
|
|
82
82
|
|
|
83
|
-
### getModuleMethod()
|
|
83
|
+
### getModuleMethod() {#getmodulemethod}
|
|
84
84
|
|
|
85
85
|
> `static` **getModuleMethod**\<`T`\>(`module`, `method`): `Promise`\<`T`\>
|
|
86
86
|
|
|
@@ -118,7 +118,7 @@ GeneralError if executing the module entry failed.
|
|
|
118
118
|
|
|
119
119
|
***
|
|
120
120
|
|
|
121
|
-
### execModuleMethod()
|
|
121
|
+
### execModuleMethod() {#execmodulemethod}
|
|
122
122
|
|
|
123
123
|
> `static` **execModuleMethod**\<`T`\>(`module`, `method`, `args?`): `Promise`\<`T`\>
|
|
124
124
|
|
|
@@ -162,7 +162,7 @@ GeneralError if executing the module entry failed.
|
|
|
162
162
|
|
|
163
163
|
***
|
|
164
164
|
|
|
165
|
-
### execModuleMethodThread()
|
|
165
|
+
### execModuleMethodThread() {#execmodulemethodthread}
|
|
166
166
|
|
|
167
167
|
> `static` **execModuleMethodThread**\<`T`\>(`module`, `method`, `args?`, `contextIds?`): `Promise`\<`T`\>
|
|
168
168
|
|
|
@@ -212,7 +212,7 @@ GeneralError if executing the module entry failed.
|
|
|
212
212
|
|
|
213
213
|
***
|
|
214
214
|
|
|
215
|
-
### execModuleMethodThreadMessage()
|
|
215
|
+
### execModuleMethodThreadMessage() {#execmodulemethodthreadmessage}
|
|
216
216
|
|
|
217
217
|
> `static` **execModuleMethodThreadMessage**(`module`, `completed`, `options?`): [`IModuleWorker`](../interfaces/IModuleWorker.md)
|
|
218
218
|
|
|
@@ -254,7 +254,7 @@ GeneralError if executing the module entry failed.
|
|
|
254
254
|
|
|
255
255
|
***
|
|
256
256
|
|
|
257
|
-
### isLocalModule()
|
|
257
|
+
### isLocalModule() {#islocalmodule}
|
|
258
258
|
|
|
259
259
|
> `static` **isLocalModule**(`name`): `boolean`
|
|
260
260
|
|
|
@@ -276,7 +276,7 @@ True if the module is local, false otherwise.
|
|
|
276
276
|
|
|
277
277
|
***
|
|
278
278
|
|
|
279
|
-
### isRelativeModule()
|
|
279
|
+
### isRelativeModule() {#isrelativemodule}
|
|
280
280
|
|
|
281
281
|
> `static` **isRelativeModule**(`name`): `boolean`
|
|
282
282
|
|
|
@@ -4,7 +4,7 @@ Worker definition for modules.
|
|
|
4
4
|
|
|
5
5
|
## Methods
|
|
6
6
|
|
|
7
|
-
### executeMethod()
|
|
7
|
+
### executeMethod() {#executemethod}
|
|
8
8
|
|
|
9
9
|
> **executeMethod**(`method`, `args?`, `contextIds?`): `void`
|
|
10
10
|
|
|
@@ -38,7 +38,7 @@ The result of the method.
|
|
|
38
38
|
|
|
39
39
|
***
|
|
40
40
|
|
|
41
|
-
### terminate()
|
|
41
|
+
### terminate() {#terminate}
|
|
42
42
|
|
|
43
43
|
> **terminate**(): `Promise`\<`number`\>
|
|
44
44
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/modules",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.24",
|
|
4
4
|
"description": "Helper classes for loading and executing from modules",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/context": "0.0.3-next.
|
|
18
|
-
"@twin.org/core": "0.0.3-next.
|
|
19
|
-
"@twin.org/nameof": "0.0.3-next.
|
|
17
|
+
"@twin.org/context": "0.0.3-next.24",
|
|
18
|
+
"@twin.org/core": "0.0.3-next.24",
|
|
19
|
+
"@twin.org/nameof": "0.0.3-next.24"
|
|
20
20
|
},
|
|
21
21
|
"main": "./dist/es/index.js",
|
|
22
22
|
"types": "./dist/types/index.d.ts",
|