@thi.ng/system 2.2.1 → 2.3.0
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/CHANGELOG.md +8 -1
- package/api.d.ts +4 -3
- package/package.json +2 -2
- package/system.d.ts +1 -1
- package/system.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-01-
|
|
3
|
+
- **Last updated**: 2024-01-31T12:41:36Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,13 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [2.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/system@2.3.0) (2024-01-31)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- update ILifecycle, add system arg ([89d341a](https://github.com/thi-ng/umbrella/commit/89d341a))
|
|
17
|
+
- add/update tests
|
|
18
|
+
|
|
12
19
|
## [2.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/system@2.2.0) (2024-01-30)
|
|
13
20
|
|
|
14
21
|
#### 🚀 Features
|
package/api.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Fn, Keys } from "@thi.ng/api";
|
|
2
2
|
import type { ILogger } from "@thi.ng/logger";
|
|
3
|
-
|
|
3
|
+
import type { System } from "./system.js";
|
|
4
|
+
export interface ILifecycle<T extends SystemMap<T> = any> {
|
|
4
5
|
/**
|
|
5
6
|
* Starts component. Defined as async method to simplify internal use of
|
|
6
7
|
* `await` for starting any child/sub-components. Usually called by
|
|
@@ -15,7 +16,7 @@ export interface ILifecycle {
|
|
|
15
16
|
* components will be stopped (see {@link ILifecycle.stop}) in reverse
|
|
16
17
|
* order.
|
|
17
18
|
*/
|
|
18
|
-
start?(): Promise<boolean>;
|
|
19
|
+
start?(sys: System<T>): Promise<boolean>;
|
|
19
20
|
/**
|
|
20
21
|
* Similar to {@link ILifecycle.start} but for stopping components.
|
|
21
22
|
*
|
|
@@ -23,7 +24,7 @@ export interface ILifecycle {
|
|
|
23
24
|
* {@link ILifecycle.start}, returning false will **not** stop the shutdown
|
|
24
25
|
* of other components.
|
|
25
26
|
*/
|
|
26
|
-
stop?(): Promise<boolean>;
|
|
27
|
+
stop?(sys: System<T>): Promise<boolean>;
|
|
27
28
|
[id: string]: any;
|
|
28
29
|
}
|
|
29
30
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/system",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Minimal and explicit dependency-injection & lifecycle container for stateful app components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"thi.ng": {
|
|
85
85
|
"year": 2020
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "0edcb19135b9d56983e44541b949a057ee11b683\n"
|
|
88
88
|
}
|
package/system.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { type ILifecycle, type SystemMap, type SystemSpecs } from "./api.js";
|
|
|
7
7
|
* @param map
|
|
8
8
|
*/
|
|
9
9
|
export declare const defSystem: <T extends SystemMap<T>>(map: SystemSpecs<T>) => System<T>;
|
|
10
|
-
export declare class System<T extends SystemMap<T>> implements ILifecycle {
|
|
10
|
+
export declare class System<T extends SystemMap<T>> implements ILifecycle<T> {
|
|
11
11
|
components: T;
|
|
12
12
|
topology: Keys<T>[];
|
|
13
13
|
graph: DGraph<Keys<T>>;
|
package/system.js
CHANGED
|
@@ -34,7 +34,7 @@ class System {
|
|
|
34
34
|
for (let i = 0; i < topo.length; i++) {
|
|
35
35
|
const id = topo[i];
|
|
36
36
|
const comp = this.components[id];
|
|
37
|
-
if (comp.start && !await comp.start()) {
|
|
37
|
+
if (comp.start && !await comp.start(this)) {
|
|
38
38
|
LOGGER.warn(`error starting component: ${String(id)}`);
|
|
39
39
|
await this.__stop(topo, i);
|
|
40
40
|
return false;
|
|
@@ -73,7 +73,7 @@ class System {
|
|
|
73
73
|
for (let i = n; i-- > 0; ) {
|
|
74
74
|
const id = topo[i];
|
|
75
75
|
const comp = this.components[id];
|
|
76
|
-
if (comp.stop && !await comp.stop()) {
|
|
76
|
+
if (comp.stop && !await comp.stop(this)) {
|
|
77
77
|
LOGGER.warn(`error stopping component: ${String(id)}`);
|
|
78
78
|
result = false;
|
|
79
79
|
}
|