@thi.ng/system 2.1.84 → 2.1.86

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-12-03T12:13:31Z
3
+ - **Last updated**: 2023-12-11T10:07:09Z
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.
package/README.md CHANGED
@@ -54,7 +54,7 @@ For Node.js REPL:
54
54
  const system = await import("@thi.ng/system");
55
55
  ```
56
56
 
57
- Package sizes (brotli'd, pre-treeshake): ESM: 489 bytes
57
+ Package sizes (brotli'd, pre-treeshake): ESM: 490 bytes
58
58
 
59
59
  ## Dependencies
60
60
 
package/api.js CHANGED
@@ -1,9 +1,7 @@
1
1
  import { NULL_LOGGER } from "@thi.ng/logger/null";
2
- /** @internal */
3
- export let LOGGER = NULL_LOGGER;
4
- /**
5
- * Sets package logger to given instance.
6
- *
7
- * @param logger -
8
- */
9
- export const setLogger = (logger) => (LOGGER = logger);
2
+ let LOGGER = NULL_LOGGER;
3
+ const setLogger = (logger) => LOGGER = logger;
4
+ export {
5
+ LOGGER,
6
+ setLogger
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/system",
3
- "version": "2.1.84",
3
+ "version": "2.1.86",
4
4
  "description": "Minimal and explicit dependency-injection & lifecycle container for stateful app components",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -27,7 +27,9 @@
27
27
  ],
28
28
  "license": "Apache-2.0",
29
29
  "scripts": {
30
- "build": "yarn clean && tsc --declaration",
30
+ "build": "yarn build:esbuild && yarn build:decl",
31
+ "build:decl": "tsc --declaration --emitDeclarationOnly",
32
+ "build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
31
33
  "clean": "rimraf --glob '*.js' '*.d.ts' '*.map' doc",
32
34
  "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
33
35
  "doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
@@ -36,13 +38,13 @@
36
38
  "test": "bun test"
37
39
  },
38
40
  "dependencies": {
39
- "@thi.ng/api": "^8.9.10",
40
- "@thi.ng/dgraph": "^2.1.80",
41
- "@thi.ng/logger": "^2.0.1"
41
+ "@thi.ng/api": "^8.9.12",
42
+ "@thi.ng/dgraph": "^2.1.82",
43
+ "@thi.ng/logger": "^2.0.2"
42
44
  },
43
45
  "devDependencies": {
44
46
  "@microsoft/api-extractor": "^7.38.3",
45
- "@thi.ng/testament": "^0.4.3",
47
+ "esbuild": "^0.19.8",
46
48
  "rimraf": "^5.0.5",
47
49
  "tools": "^0.0.1",
48
50
  "typedoc": "^0.25.4",
@@ -83,5 +85,5 @@
83
85
  "thi.ng": {
84
86
  "year": 2020
85
87
  },
86
- "gitHead": "04d1de79f256d7a53c6b5fd157b37f49bc88e11d\n"
88
+ "gitHead": "5e7bafedfc3d53bc131469a28de31dd8e5b4a3ff\n"
87
89
  }
package/system.js CHANGED
@@ -1,66 +1,70 @@
1
1
  import { DGraph } from "@thi.ng/dgraph";
2
- import { LOGGER, } from "./api.js";
3
- export const defSystem = (map) => new System(map);
4
- export class System {
5
- components;
6
- topology;
7
- graph;
8
- constructor(map) {
9
- this.graph = new DGraph();
10
- for (let id in map) {
11
- const deps = map[id].deps;
12
- deps
13
- ? this.graph.addDependencies(id, deps)
14
- : this.graph.addNode(id);
15
- }
16
- this.topology = this.graph.sort();
17
- this.components = {};
18
- for (let id of this.topology) {
19
- this.components[id] = map[id].factory(this.components);
20
- }
2
+ import {
3
+ LOGGER
4
+ } from "./api.js";
5
+ const defSystem = (map) => new System(map);
6
+ class System {
7
+ components;
8
+ topology;
9
+ graph;
10
+ constructor(map) {
11
+ this.graph = new DGraph();
12
+ for (let id in map) {
13
+ const deps = map[id].deps;
14
+ deps ? this.graph.addDependencies(id, deps) : this.graph.addNode(id);
21
15
  }
22
- /**
23
- * Initializes all system components in dependency order. If any
24
- * component's `start()` method returns false, system start up will
25
- * be stopped and this method returns false itself.
26
- *
27
- * Also any errors thrown during child component startup will not be
28
- * intercepted.
29
- */
30
- async start() {
31
- for (let id of this.topology) {
32
- const comp = this.components[id];
33
- if (comp.start && !(await comp.start())) {
34
- LOGGER.warn(`error starting component: ${String(id)}`);
35
- return false;
36
- }
37
- }
38
- return true;
16
+ this.topology = this.graph.sort();
17
+ this.components = {};
18
+ for (let id of this.topology) {
19
+ this.components[id] = map[id].factory(this.components);
39
20
  }
40
- /**
41
- * Stops all system components in reverse dependency order. If any
42
- * component's `stop()` method returns false, a warning message will
43
- * be logged, but unlike {@link System.start}, the shutdown
44
- * process of other components will not be stopped.
45
- *
46
- * Any errors thrown during child component shutdown will not be
47
- * intercepted.
48
- */
49
- async stop() {
50
- const topo = this.topology;
51
- for (let i = topo.length; i-- > 0;) {
52
- const id = topo[i];
53
- const comp = this.components[id];
54
- if (comp.stop && !(await comp.stop())) {
55
- LOGGER.warn(`error stopping component: ${String(id)}`);
56
- }
57
- }
58
- return true;
21
+ }
22
+ /**
23
+ * Initializes all system components in dependency order. If any
24
+ * component's `start()` method returns false, system start up will
25
+ * be stopped and this method returns false itself.
26
+ *
27
+ * Also any errors thrown during child component startup will not be
28
+ * intercepted.
29
+ */
30
+ async start() {
31
+ for (let id of this.topology) {
32
+ const comp = this.components[id];
33
+ if (comp.start && !await comp.start()) {
34
+ LOGGER.warn(`error starting component: ${String(id)}`);
35
+ return false;
36
+ }
59
37
  }
60
- /**
61
- * Syntax sugar for `stop() && start()` sequence.
62
- */
63
- async reset() {
64
- return (await this.stop()) && (await this.start());
38
+ return true;
39
+ }
40
+ /**
41
+ * Stops all system components in reverse dependency order. If any
42
+ * component's `stop()` method returns false, a warning message will
43
+ * be logged, but unlike {@link System.start}, the shutdown
44
+ * process of other components will not be stopped.
45
+ *
46
+ * Any errors thrown during child component shutdown will not be
47
+ * intercepted.
48
+ */
49
+ async stop() {
50
+ const topo = this.topology;
51
+ for (let i = topo.length; i-- > 0; ) {
52
+ const id = topo[i];
53
+ const comp = this.components[id];
54
+ if (comp.stop && !await comp.stop()) {
55
+ LOGGER.warn(`error stopping component: ${String(id)}`);
56
+ }
65
57
  }
58
+ return true;
59
+ }
60
+ /**
61
+ * Syntax sugar for `stop() && start()` sequence.
62
+ */
63
+ async reset() {
64
+ return await this.stop() && await this.start();
65
+ }
66
66
  }
67
+ export {
68
+ System,
69
+ defSystem
70
+ };