composed-di 0.2.8 → 0.2.9-ts4

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 (46) hide show
  1. package/dist/index.d.ts +4 -4
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +4 -4
  4. package/dist/index.js.map +1 -1
  5. package/dist/serviceFactory.d.ts +6 -6
  6. package/dist/serviceFactory.d.ts.map +1 -1
  7. package/dist/serviceFactory.js +1 -1
  8. package/dist/serviceFactory.js.map +1 -1
  9. package/dist/serviceKey.d.ts +1 -1
  10. package/dist/serviceKey.d.ts.map +1 -1
  11. package/dist/serviceKey.js +1 -1
  12. package/dist/serviceKey.js.map +1 -1
  13. package/dist/serviceModule.d.ts +5 -5
  14. package/dist/serviceModule.d.ts.map +1 -1
  15. package/dist/serviceModule.js +1 -1
  16. package/dist/serviceModule.js.map +1 -1
  17. package/dist/{ServiceScope.d.ts → serviceScope.d.ts} +1 -1
  18. package/dist/serviceScope.d.ts.map +1 -0
  19. package/dist/{ServiceScope.js → serviceScope.js} +1 -1
  20. package/dist/serviceScope.js.map +1 -0
  21. package/dist/utils.d.ts +1 -1
  22. package/package.json +3 -2
  23. package/src/index.ts +5 -5
  24. package/src/{ServiceFactory.ts → serviceFactory.ts} +83 -83
  25. package/src/{ServiceModule.ts → serviceModule.ts} +123 -123
  26. package/src/{ServiceScope.ts → serviceScope.ts} +7 -7
  27. package/src/utils.ts +152 -152
  28. package/dist/ServiceScope.d.ts.map +0 -1
  29. package/dist/ServiceScope.js.map +0 -1
  30. package/dist/main.d.ts +0 -2
  31. package/dist/main.d.ts.map +0 -1
  32. package/dist/main.js +0 -15
  33. package/dist/main.js.map +0 -1
  34. package/dist/plugin/index.d.ts +0 -66
  35. package/dist/plugin/index.d.ts.map +0 -1
  36. package/dist/plugin/index.js +0 -397
  37. package/dist/plugin/index.js.map +0 -1
  38. package/dist/serviceProvider.d.ts +0 -5
  39. package/dist/serviceProvider.d.ts.map +0 -1
  40. package/dist/serviceProvider.js +0 -3
  41. package/dist/serviceProvider.js.map +0 -1
  42. package/dist/test-from.d.ts +0 -2
  43. package/dist/test-from.d.ts.map +0 -1
  44. package/dist/test-from.js +0 -68
  45. package/dist/test-from.js.map +0 -1
  46. /package/src/{ServiceKey.ts → serviceKey.ts} +0 -0
@@ -1,123 +1,123 @@
1
- import { ServiceKey } from './ServiceKey';
2
- import { ServiceFactory } from './ServiceFactory';
3
- import { ServiceScope } from './ServiceScope';
4
-
5
- type GenericFactory = ServiceFactory<unknown, readonly ServiceKey<any>[]>;
6
- type GenericKey = ServiceKey<any>;
7
-
8
- export class ServiceModule {
9
- private constructor(readonly factories: GenericFactory[]) {
10
- factories.forEach((factory) => {
11
- checkRecursiveDependencies(factory);
12
- checkMissingDependencies(factory, this.factories);
13
- });
14
- }
15
-
16
- public async get<T>(key: ServiceKey<T>): Promise<T> {
17
- const factory = this.factories.find((factory: GenericFactory) => {
18
- return isSuitable(key, factory);
19
- });
20
-
21
- // Check if a factory to supply the requested key was not found
22
- if (!factory) {
23
- throw new Error(`Could not find a suitable factory for ${key.name}`);
24
- }
25
-
26
- // Resolve all dependencies first
27
- const dependencies = await Promise.all(
28
- factory.dependsOn.map((dependencyKey: ServiceKey<unknown>) => {
29
- return this.get(dependencyKey);
30
- }),
31
- );
32
-
33
- // Call the factory to retrieve the dependency
34
- return factory.initialize(...dependencies);
35
- }
36
-
37
- /**
38
- * Disposes of service factories within the specified scope or all factories if no scope is provided.
39
- *
40
- * This method is useful for cleaning up resources and instances held by service factories,
41
- * such as singleton factories, as they may hold database connections or other resources that need to be released.
42
- *
43
- * @param {ServiceScope} [scope] The scope to filter the factories to be disposed.
44
- * If not provided, all factories are disposed of.
45
- * @return {void} No return value.
46
- */
47
- public dispose(scope?: ServiceScope) {
48
- const factories = scope
49
- ? this.factories.filter((f) => f.scope === scope)
50
- : this.factories;
51
-
52
- factories.forEach((factory) => factory.dispose?.());
53
- }
54
-
55
- /**
56
- * Creates a new ServiceModule instance by aggregating and deduplicating a list of
57
- * ServiceModule or GenericFactory instances.
58
- * If multiple factories provide the same
59
- * ServiceKey, the last one in the list takes precedence.
60
- *
61
- * @param {Array<ServiceModule | GenericFactory>} entries - An array of ServiceModule or GenericFactory
62
- * instances to be processed into a single ServiceModule.
63
- * @return {ServiceModule} A new ServiceModule containing the deduplicated factories.
64
- */
65
- static from(entries: (ServiceModule | GenericFactory)[]): ServiceModule {
66
- // Flatten entries and keep only the last factory for each ServiceKey
67
- const flattened = entries.flatMap((e) =>
68
- e instanceof ServiceModule ? e.factories : [e],
69
- );
70
-
71
- const byKey = new Map<symbol, GenericFactory>();
72
- // Later factories overwrite earlier ones (last-wins)
73
- for (const f of flattened) {
74
- byKey.set(f.provides.symbol, f);
75
- }
76
-
77
- return new ServiceModule(Array.from(byKey.values()));
78
- }
79
- }
80
-
81
- function checkRecursiveDependencies(factory: GenericFactory) {
82
- const recursive = factory.dependsOn.some((dependencyKey) => {
83
- return dependencyKey === factory.provides;
84
- });
85
-
86
- if (recursive) {
87
- throw new Error(
88
- 'Recursive dependency detected on: ' + factory.provides.name,
89
- );
90
- }
91
- }
92
-
93
- function checkMissingDependencies(
94
- factory: GenericFactory,
95
- factories: GenericFactory[],
96
- ) {
97
- const missingDependencies = factory.dependsOn.filter(
98
- (dependencyKey: GenericKey) => {
99
- return !isRegistered(dependencyKey, factories);
100
- },
101
- );
102
- if (missingDependencies.length === 0) {
103
- return;
104
- }
105
-
106
- const dependencyList = missingDependencies
107
- .map((dependencyKey) => ` -> ${dependencyKey.name}`)
108
- .join('\n');
109
- throw new Error(
110
- `${factory.provides.name} will fail because it depends on:\n ${dependencyList}`,
111
- );
112
- }
113
-
114
- function isRegistered(key: GenericKey, factories: GenericFactory[]) {
115
- return factories.some((factory) => factory.provides?.symbol === key?.symbol);
116
- }
117
-
118
- function isSuitable<T, D extends readonly ServiceKey<any>[]>(
119
- key: ServiceKey<T>,
120
- factory: ServiceFactory<any, D>,
121
- ): factory is ServiceFactory<T, D> {
122
- return factory?.provides?.symbol === key?.symbol;
123
- }
1
+ import { ServiceKey } from './serviceKey';
2
+ import { ServiceFactory } from './serviceFactory';
3
+ import { ServiceScope } from './serviceScope';
4
+
5
+ type GenericFactory = ServiceFactory<any, readonly ServiceKey<any>[]>;
6
+ type GenericKey = ServiceKey<any>;
7
+
8
+ export class ServiceModule {
9
+ private constructor(readonly factories: GenericFactory[]) {
10
+ factories.forEach((factory) => {
11
+ checkRecursiveDependencies(factory);
12
+ checkMissingDependencies(factory, this.factories);
13
+ });
14
+ }
15
+
16
+ public async get<T>(key: ServiceKey<T>): Promise<T> {
17
+ const factory = this.factories.find((factory: GenericFactory) => {
18
+ return isSuitable(key, factory);
19
+ });
20
+
21
+ // Check if a factory to supply the requested key was not found
22
+ if (!factory) {
23
+ throw new Error(`Could not find a suitable factory for ${key.name}`);
24
+ }
25
+
26
+ // Resolve all dependencies first
27
+ const dependencies = await Promise.all(
28
+ factory.dependsOn.map((dependencyKey: ServiceKey<unknown>) => {
29
+ return this.get(dependencyKey);
30
+ }),
31
+ );
32
+
33
+ // Call the factory to retrieve the dependency
34
+ return factory.initialize(...dependencies);
35
+ }
36
+
37
+ /**
38
+ * Disposes of service factories within the specified scope or all factories if no scope is provided.
39
+ *
40
+ * This method is useful for cleaning up resources and instances held by service factories,
41
+ * such as singleton factories, as they may hold database connections or other resources that need to be released.
42
+ *
43
+ * @param {ServiceScope} [scope] The scope to filter the factories to be disposed.
44
+ * If not provided, all factories are disposed of.
45
+ * @return {void} No return value.
46
+ */
47
+ public dispose(scope?: ServiceScope) {
48
+ const factories = scope
49
+ ? this.factories.filter((f) => f.scope === scope)
50
+ : this.factories;
51
+
52
+ factories.forEach((factory) => factory.dispose?.());
53
+ }
54
+
55
+ /**
56
+ * Creates a new ServiceModule instance by aggregating and deduplicating a list of
57
+ * ServiceModule or GenericFactory instances.
58
+ * If multiple factories provide the same
59
+ * ServiceKey, the last one in the list takes precedence.
60
+ *
61
+ * @param {Array<ServiceModule | GenericFactory>} entries - An array of ServiceModule or GenericFactory
62
+ * instances to be processed into a single ServiceModule.
63
+ * @return {ServiceModule} A new ServiceModule containing the deduplicated factories.
64
+ */
65
+ static from(entries: (ServiceModule | GenericFactory)[]): ServiceModule {
66
+ // Flatten entries and keep only the last factory for each ServiceKey
67
+ const flattened = entries.flatMap((e) =>
68
+ e instanceof ServiceModule ? e.factories : [e],
69
+ );
70
+
71
+ const byKey = new Map<symbol, GenericFactory>();
72
+ // Later factories overwrite earlier ones (last-wins)
73
+ for (const f of flattened) {
74
+ byKey.set(f.provides.symbol, f);
75
+ }
76
+
77
+ return new ServiceModule(Array.from(byKey.values()));
78
+ }
79
+ }
80
+
81
+ function checkRecursiveDependencies(factory: GenericFactory) {
82
+ const recursive = factory.dependsOn.some((dependencyKey) => {
83
+ return dependencyKey === factory.provides;
84
+ });
85
+
86
+ if (recursive) {
87
+ throw new Error(
88
+ 'Recursive dependency detected on: ' + factory.provides.name,
89
+ );
90
+ }
91
+ }
92
+
93
+ function checkMissingDependencies(
94
+ factory: GenericFactory,
95
+ factories: GenericFactory[],
96
+ ) {
97
+ const missingDependencies = factory.dependsOn.filter(
98
+ (dependencyKey: GenericKey) => {
99
+ return !isRegistered(dependencyKey, factories);
100
+ },
101
+ );
102
+ if (missingDependencies.length === 0) {
103
+ return;
104
+ }
105
+
106
+ const dependencyList = missingDependencies
107
+ .map((dependencyKey) => ` -> ${dependencyKey.name}`)
108
+ .join('\n');
109
+ throw new Error(
110
+ `${factory.provides.name} will fail because it depends on:\n ${dependencyList}`,
111
+ );
112
+ }
113
+
114
+ function isRegistered(key: GenericKey, factories: GenericFactory[]) {
115
+ return factories.some((factory) => factory.provides?.symbol === key?.symbol);
116
+ }
117
+
118
+ function isSuitable<T, D extends readonly ServiceKey<any>[]>(
119
+ key: ServiceKey<T>,
120
+ factory: ServiceFactory<any, D>,
121
+ ): factory is ServiceFactory<T, D> {
122
+ return factory?.provides?.symbol === key?.symbol;
123
+ }
@@ -1,7 +1,7 @@
1
- export class ServiceScope {
2
- readonly symbol: symbol;
3
-
4
- constructor(readonly name: string) {
5
- this.symbol = Symbol(name);
6
- }
7
- }
1
+ export class ServiceScope {
2
+ readonly symbol: symbol;
3
+
4
+ constructor(readonly name: string) {
5
+ this.symbol = Symbol(name);
6
+ }
7
+ }
package/src/utils.ts CHANGED
@@ -1,152 +1,152 @@
1
- import { ServiceModule } from './ServiceModule';
2
- import { ServiceKey } from './ServiceKey';
3
-
4
- export interface DotGraphOptions {
5
- /** Graph direction: 'TB' (top-bottom), 'LR' (left-right), 'BT' (bottom-top), 'RL' (right-left) */
6
- direction?: 'TB' | 'LR' | 'BT' | 'RL';
7
- /** Title for the graph */
8
- title?: string;
9
- /** Show nodes with no dependencies in a different color */
10
- highlightLeaves?: boolean;
11
- /** Show nodes with no dependents in a different color */
12
- highlightRoots?: boolean;
13
- }
14
-
15
- /**
16
- * Escapes special characters in strings for DOT notation
17
- */
18
- function escapeDotString(str: string): string {
19
- return str.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n');
20
- }
21
-
22
- /**
23
- * Generates a DOT notation graph from a ServiceModule.
24
- * The output can be visualized using Graphviz tools or online viewers like:
25
- * - https://dreampuf.github.io/GraphvizOnline/
26
- * - https://edotor.net/
27
- *
28
- * Arrows point from dependencies to dependents (from what is needed to what needs it).
29
- *
30
- * @param {ServiceModule} module - The ServiceModule to convert to DOT notation
31
- * @param {DotGraphOptions} options - Optional configuration for the graph appearance
32
- * @returns {string} A string containing the DOT notation graph
33
- */
34
- export function createDotGraph(
35
- module: ServiceModule,
36
- { direction, title, highlightLeaves, highlightRoots }: DotGraphOptions = {
37
- direction: 'TB',
38
- title: 'Service Dependency Graph',
39
- highlightLeaves: true,
40
- highlightRoots: true,
41
- },
42
- ): string {
43
- const factories = module.factories;
44
- const lines: string[] = [];
45
-
46
- // Start the digraph
47
- lines.push('digraph ServiceDependencies {');
48
- lines.push(` label="${title}";`);
49
- lines.push(' labelloc="t";');
50
- lines.push(' fontsize=16;');
51
- lines.push(` rankdir=${direction};`);
52
- lines.push('');
53
-
54
- // Default node styling
55
- lines.push(' node [');
56
- lines.push(' shape=box,');
57
- lines.push(' style="rounded,filled",');
58
- lines.push(' fillcolor="#e1f5ff",');
59
- lines.push(' color="#0288d1",');
60
- lines.push(' fontname="Arial",');
61
- lines.push(' fontsize=12');
62
- lines.push(' ];');
63
- lines.push('');
64
-
65
- // Default edge styling
66
- lines.push(' edge [');
67
- lines.push(' color="#666666",');
68
- lines.push(' arrowsize=0.8');
69
- lines.push(' ];');
70
- lines.push('');
71
-
72
- // Build dependency maps to identify leaves and roots
73
- const hasDependencies = new Set<string>();
74
- const hasDependents = new Set<string>();
75
-
76
- factories.forEach((factory) => {
77
- const serviceName = factory.provides.name;
78
-
79
- if (factory.dependsOn.length > 0) {
80
- hasDependencies.add(serviceName);
81
- }
82
-
83
- factory.dependsOn.forEach((dependency: ServiceKey<unknown>) => {
84
- hasDependents.add(dependency.name);
85
- });
86
- });
87
-
88
- // Define nodes with special styling for leaves and roots
89
- const nodeIds = new Map<string, string>();
90
- let nodeCounter = 0;
91
-
92
- factories.forEach((factory) => {
93
- const serviceName = factory.provides.name;
94
- const nodeId = `node${nodeCounter++}`;
95
- nodeIds.set(serviceName, nodeId);
96
-
97
- const isLeaf = !hasDependencies.has(serviceName);
98
- const isRoot = !hasDependents.has(serviceName);
99
-
100
- let nodeStyle = '';
101
-
102
- if (highlightLeaves && isLeaf) {
103
- nodeStyle = ' [fillcolor="#c8e6c9", color="#388e3c"]';
104
- } else if (highlightRoots && isRoot) {
105
- nodeStyle = ' [fillcolor="#ffccbc", color="#d84315"]';
106
- }
107
-
108
- lines.push(
109
- ` ${nodeId} [label="${escapeDotString(serviceName)}"]${nodeStyle};`,
110
- );
111
- });
112
-
113
- lines.push('');
114
-
115
- // Define edges (dependencies)
116
- factories.forEach((factory) => {
117
- const serviceName = factory.provides.name;
118
- const serviceNodeId = nodeIds.get(serviceName)!;
119
-
120
- factory.dependsOn.forEach((dependency: ServiceKey<unknown>) => {
121
- const depName = dependency.name;
122
- const depNodeId = nodeIds.get(depName);
123
-
124
- if (depNodeId) {
125
- // Arrow points from dependent to dependency (what needs it -> what provides it)
126
- lines.push(` ${serviceNodeId} -> ${depNodeId};`);
127
- }
128
- });
129
- });
130
-
131
- // Close the digraph
132
- lines.push('}');
133
-
134
- return lines.join('\n');
135
- }
136
-
137
- /**
138
- * Prints a DOT representation of a service module graph to the console.
139
- * The output can be used to visualize the graph using online graph visualization tools.
140
- *
141
- * @param {ServiceModule} module - The service module representing the graph to be converted into DOT format.
142
- * @param {DotGraphOptions} [options] - Optional configurations to customize the output of the DOT graph.
143
- * @return {void} - This function does not return a value.
144
- */
145
- export function printDotGraph(
146
- module: ServiceModule,
147
- options?: DotGraphOptions,
148
- ): void {
149
- console.log(createDotGraph(module, options));
150
- console.log('\n\nCopy the DOT output above and paste it into:');
151
- console.log('https://dreampuf.github.io/GraphvizOnline/');
152
- }
1
+ import { ServiceModule } from './serviceModule';
2
+ import { ServiceKey } from './serviceKey';
3
+
4
+ export interface DotGraphOptions {
5
+ /** Graph direction: 'TB' (top-bottom), 'LR' (left-right), 'BT' (bottom-top), 'RL' (right-left) */
6
+ direction?: 'TB' | 'LR' | 'BT' | 'RL';
7
+ /** Title for the graph */
8
+ title?: string;
9
+ /** Show nodes with no dependencies in a different color */
10
+ highlightLeaves?: boolean;
11
+ /** Show nodes with no dependents in a different color */
12
+ highlightRoots?: boolean;
13
+ }
14
+
15
+ /**
16
+ * Escapes special characters in strings for DOT notation
17
+ */
18
+ function escapeDotString(str: string): string {
19
+ return str.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n');
20
+ }
21
+
22
+ /**
23
+ * Generates a DOT notation graph from a ServiceModule.
24
+ * The output can be visualized using Graphviz tools or online viewers like:
25
+ * - https://dreampuf.github.io/GraphvizOnline/
26
+ * - https://edotor.net/
27
+ *
28
+ * Arrows point from dependencies to dependents (from what is needed to what needs it).
29
+ *
30
+ * @param {ServiceModule} module - The ServiceModule to convert to DOT notation
31
+ * @param {DotGraphOptions} options - Optional configuration for the graph appearance
32
+ * @returns {string} A string containing the DOT notation graph
33
+ */
34
+ export function createDotGraph(
35
+ module: ServiceModule,
36
+ { direction, title, highlightLeaves, highlightRoots }: DotGraphOptions = {
37
+ direction: 'TB',
38
+ title: 'Service Dependency Graph',
39
+ highlightLeaves: true,
40
+ highlightRoots: true,
41
+ },
42
+ ): string {
43
+ const factories = module.factories;
44
+ const lines: string[] = [];
45
+
46
+ // Start the digraph
47
+ lines.push('digraph ServiceDependencies {');
48
+ lines.push(` label="${title}";`);
49
+ lines.push(' labelloc="t";');
50
+ lines.push(' fontsize=16;');
51
+ lines.push(` rankdir=${direction};`);
52
+ lines.push('');
53
+
54
+ // Default node styling
55
+ lines.push(' node [');
56
+ lines.push(' shape=box,');
57
+ lines.push(' style="rounded,filled",');
58
+ lines.push(' fillcolor="#e1f5ff",');
59
+ lines.push(' color="#0288d1",');
60
+ lines.push(' fontname="Arial",');
61
+ lines.push(' fontsize=12');
62
+ lines.push(' ];');
63
+ lines.push('');
64
+
65
+ // Default edge styling
66
+ lines.push(' edge [');
67
+ lines.push(' color="#666666",');
68
+ lines.push(' arrowsize=0.8');
69
+ lines.push(' ];');
70
+ lines.push('');
71
+
72
+ // Build dependency maps to identify leaves and roots
73
+ const hasDependencies = new Set<string>();
74
+ const hasDependents = new Set<string>();
75
+
76
+ factories.forEach((factory) => {
77
+ const serviceName = factory.provides.name;
78
+
79
+ if (factory.dependsOn.length > 0) {
80
+ hasDependencies.add(serviceName);
81
+ }
82
+
83
+ factory.dependsOn.forEach((dependency: ServiceKey<unknown>) => {
84
+ hasDependents.add(dependency.name);
85
+ });
86
+ });
87
+
88
+ // Define nodes with special styling for leaves and roots
89
+ const nodeIds = new Map<string, string>();
90
+ let nodeCounter = 0;
91
+
92
+ factories.forEach((factory) => {
93
+ const serviceName = factory.provides.name;
94
+ const nodeId = `node${nodeCounter++}`;
95
+ nodeIds.set(serviceName, nodeId);
96
+
97
+ const isLeaf = !hasDependencies.has(serviceName);
98
+ const isRoot = !hasDependents.has(serviceName);
99
+
100
+ let nodeStyle = '';
101
+
102
+ if (highlightLeaves && isLeaf) {
103
+ nodeStyle = ' [fillcolor="#c8e6c9", color="#388e3c"]';
104
+ } else if (highlightRoots && isRoot) {
105
+ nodeStyle = ' [fillcolor="#ffccbc", color="#d84315"]';
106
+ }
107
+
108
+ lines.push(
109
+ ` ${nodeId} [label="${escapeDotString(serviceName)}"]${nodeStyle};`,
110
+ );
111
+ });
112
+
113
+ lines.push('');
114
+
115
+ // Define edges (dependencies)
116
+ factories.forEach((factory) => {
117
+ const serviceName = factory.provides.name;
118
+ const serviceNodeId = nodeIds.get(serviceName)!;
119
+
120
+ factory.dependsOn.forEach((dependency: ServiceKey<unknown>) => {
121
+ const depName = dependency.name;
122
+ const depNodeId = nodeIds.get(depName);
123
+
124
+ if (depNodeId) {
125
+ // Arrow points from dependent to dependency (what needs it -> what provides it)
126
+ lines.push(` ${serviceNodeId} -> ${depNodeId};`);
127
+ }
128
+ });
129
+ });
130
+
131
+ // Close the digraph
132
+ lines.push('}');
133
+
134
+ return lines.join('\n');
135
+ }
136
+
137
+ /**
138
+ * Prints a DOT representation of a service module graph to the console.
139
+ * The output can be used to visualize the graph using online graph visualization tools.
140
+ *
141
+ * @param {ServiceModule} module - The service module representing the graph to be converted into DOT format.
142
+ * @param {DotGraphOptions} [options] - Optional configurations to customize the output of the DOT graph.
143
+ * @return {void} - This function does not return a value.
144
+ */
145
+ export function printDotGraph(
146
+ module: ServiceModule,
147
+ options?: DotGraphOptions,
148
+ ): void {
149
+ console.log(createDotGraph(module, options));
150
+ console.log('\n\nCopy the DOT output above and paste it into:');
151
+ console.log('https://dreampuf.github.io/GraphvizOnline/');
152
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"ServiceScope.d.ts","sourceRoot":"","sources":["../src/ServiceScope.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAY;IAGX,QAAQ,CAAC,IAAI,EAAE,MAAM;IAFjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEH,IAAI,EAAE,MAAM;CAGlC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ServiceScope.js","sourceRoot":"","sources":["../src/ServiceScope.ts"],"names":[],"mappings":";;;AAAA,MAAa,YAAY;IAGvB,YAAqB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAND,oCAMC"}
package/dist/main.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=main.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":""}
package/dist/main.js DELETED
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const serviceKey_1 = require("./serviceKey");
4
- const serviceFactory_1 = require("./serviceFactory");
5
- const TEST_SERVICE_KEY = new serviceKey_1.ServiceKey('testService');
6
- const FOO_KEY = new serviceKey_1.ServiceKey('foo');
7
- const BAR_KEY = new serviceKey_1.ServiceKey('bar');
8
- const TestServiceFactory = (0, serviceFactory_1.singletonFactory)({
9
- provides: TEST_SERVICE_KEY,
10
- dependsOn: [FOO_KEY, BAR_KEY],
11
- initialize: (foo, bar) => {
12
- return { foo, bar };
13
- },
14
- });
15
- //# sourceMappingURL=main.js.map
package/dist/main.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,6CAA0C;AAC1C,qDAAoD;AAEpD,MAAM,gBAAgB,GAAG,IAAI,uBAAU,CAAc,aAAa,CAAC,CAAC;AACpE,MAAM,OAAO,GAAG,IAAI,uBAAU,CAAS,KAAK,CAAC,CAAC;AAC9C,MAAM,OAAO,GAAG,IAAI,uBAAU,CAAS,KAAK,CAAC,CAAC;AAO9C,MAAM,kBAAkB,GAAG,IAAA,iCAAgB,EAAC;IAC1C,QAAQ,EAAE,gBAAgB;IAC1B,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,CAAU;IACtC,UAAU,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACvB,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IACtB,CAAC;CACF,CAAC,CAAC"}
@@ -1,66 +0,0 @@
1
- import * as ts from 'typescript';
2
- import { ServiceModule } from '../ServiceModule';
3
- import { DotGraphOptions } from '../utils';
4
- export interface GraphGeneratorOptions {
5
- /** Output directory for generated graph files (default: './graphs') */
6
- outputDir?: string;
7
- /** Options to pass to createDotGraph */
8
- graphOptions?: DotGraphOptions;
9
- /** File extension for output files (default: '.dot') */
10
- fileExtension?: string;
11
- /** Whether to require compiled JS files instead of TS (default: false) */
12
- useCompiledFiles?: boolean;
13
- }
14
- interface ServiceModuleInfo {
15
- name: string;
16
- filePath: string;
17
- line: number;
18
- }
19
- /**
20
- * Finds all ServiceModule constant declarations in a TypeScript project.
21
- *
22
- * @param projectPath - Path to the tsconfig.json or project directory
23
- * @returns Array of information about found ServiceModule declarations
24
- */
25
- export declare function findServiceModuleDeclarations(projectPath: string): ServiceModuleInfo[];
26
- /**
27
- * Evaluates a TypeScript/JavaScript file and extracts ServiceModule instances.
28
- *
29
- * @param filePath - Path to the file to evaluate
30
- * @param moduleNames - Names of the ServiceModule variables to extract
31
- * @returns Map of variable names to ServiceModule instances
32
- */
33
- export declare function evaluateServiceModules(filePath: string, moduleNames: string[]): Promise<Map<string, ServiceModule>>;
34
- /**
35
- * Generates DOT graph files for all ServiceModule declarations found in a project.
36
- *
37
- * @param projectPath - Path to the tsconfig.json or project directory
38
- * @param options - Options for graph generation
39
- */
40
- export declare function generateGraphFiles(projectPath: string, options?: GraphGeneratorOptions): Promise<void>;
41
- /**
42
- * Creates a ts-node plugin that automatically finds ServiceModule declarations
43
- * and generates DOT graph files.
44
- *
45
- * Usage in tsconfig.json:
46
- * {
47
- * "compilerOptions": {
48
- * "plugins": [
49
- * {
50
- * "name": "composed-di/plugin",
51
- * "outputDir": "./graphs"
52
- * }
53
- * ]
54
- * }
55
- * }
56
- */
57
- export declare function createPlugin(options?: GraphGeneratorOptions): {
58
- create(info: ts.server.PluginCreateInfo): ts.LanguageService;
59
- };
60
- /**
61
- * CLI entry point for generating graph files.
62
- * Can be run directly: npx ts-node src/plugin/index.ts [projectPath] [outputDir]
63
- */
64
- export declare function main(args?: string[]): Promise<void>;
65
- export default createPlugin;
66
- //# sourceMappingURL=index.d.ts.map