@hamak/microkernel-impl 0.2.3 ā 0.2.4
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/dist/es2015/runtime/di.js +50 -7
- package/dist/es2015/runtime/host.js +84 -14
- package/dist/es2015/runtime/loader.js +10 -0
- package/dist/runtime/di.d.ts +9 -1
- package/dist/runtime/di.d.ts.map +1 -1
- package/dist/runtime/di.js +50 -7
- package/dist/runtime/di.js.map +1 -1
- package/dist/runtime/host.d.ts +6 -1
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/host.js +84 -14
- package/dist/runtime/host.js.map +1 -1
- package/dist/runtime/loader.d.ts +7 -0
- package/dist/runtime/loader.d.ts.map +1 -1
- package/dist/runtime/loader.js +10 -0
- package/dist/runtime/loader.js.map +1 -1
- package/package.json +3 -3
- package/src/runtime/di.ts +93 -12
- package/src/runtime/host.ts +103 -15
- package/src/runtime/loader.ts +11 -0
|
@@ -1,22 +1,49 @@
|
|
|
1
1
|
const INJECT_KEY = Symbol('di:inject');
|
|
2
|
-
export function Injectable(deps = []) {
|
|
2
|
+
export function Injectable(deps = []) {
|
|
3
|
+
return (t) => {
|
|
4
|
+
t[INJECT_KEY] = deps;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
3
7
|
export class Container {
|
|
4
|
-
constructor(parent) {
|
|
8
|
+
constructor(parent, config = {}) {
|
|
5
9
|
this.providers = new Map();
|
|
6
10
|
this.instances = new Map();
|
|
7
11
|
this.parent = parent;
|
|
12
|
+
this.config = config;
|
|
13
|
+
}
|
|
14
|
+
createChild() {
|
|
15
|
+
return new Container(this, this.config);
|
|
16
|
+
}
|
|
17
|
+
provide(prov) {
|
|
18
|
+
if (this.config.debug) {
|
|
19
|
+
const tokenName = this.getTokenName(prov.provide);
|
|
20
|
+
const context = this.config.pluginContext ? `[${this.config.pluginContext}] ` : '';
|
|
21
|
+
console.log(`š§ ${context}Providing token: ${tokenName}`);
|
|
22
|
+
}
|
|
23
|
+
this.providers.set(prov.provide, prov);
|
|
24
|
+
return this;
|
|
8
25
|
}
|
|
9
|
-
createChild() { return new Container(this); }
|
|
10
|
-
provide(prov) { this.providers.set(prov.provide, prov); return this; }
|
|
11
26
|
resolve(token) {
|
|
12
27
|
var _a, _b;
|
|
13
|
-
if (this.instances.has(token))
|
|
28
|
+
if (this.instances.has(token)) {
|
|
29
|
+
if (this.config.debug) {
|
|
30
|
+
const tokenName = this.getTokenName(token);
|
|
31
|
+
const context = this.config.pluginContext ? `[${this.config.pluginContext}] ` : '';
|
|
32
|
+
console.log(`ā ${context}Resolving token (cached): ${tokenName}`);
|
|
33
|
+
}
|
|
14
34
|
return this.instances.get(token);
|
|
35
|
+
}
|
|
15
36
|
if (this.providers.has(token)) {
|
|
37
|
+
if (this.config.debug) {
|
|
38
|
+
const tokenName = this.getTokenName(token);
|
|
39
|
+
const context = this.config.pluginContext ? `[${this.config.pluginContext}] ` : '';
|
|
40
|
+
console.log(`š ${context}Resolving token: ${tokenName}`);
|
|
41
|
+
}
|
|
16
42
|
const prov = this.providers.get(token);
|
|
17
43
|
let value;
|
|
18
|
-
if ('useValue' in prov)
|
|
44
|
+
if ('useValue' in prov) {
|
|
19
45
|
value = prov.useValue;
|
|
46
|
+
}
|
|
20
47
|
else if ('useClass' in prov) {
|
|
21
48
|
const C = prov.useClass;
|
|
22
49
|
const deps = C[INJECT_KEY] || [];
|
|
@@ -31,8 +58,24 @@ export class Container {
|
|
|
31
58
|
this.instances.set(token, value);
|
|
32
59
|
return value;
|
|
33
60
|
}
|
|
34
|
-
if (this.parent)
|
|
61
|
+
if (this.parent) {
|
|
35
62
|
return this.parent.resolve(token);
|
|
63
|
+
}
|
|
36
64
|
throw new Error(`No provider for token: ${(_b = (_a = token.toString) === null || _a === void 0 ? void 0 : _a.call(token)) !== null && _b !== void 0 ? _b : String(token)}`);
|
|
37
65
|
}
|
|
66
|
+
setPluginContext(pluginName) {
|
|
67
|
+
this.config.pluginContext = pluginName;
|
|
68
|
+
}
|
|
69
|
+
clearPluginContext() {
|
|
70
|
+
this.config.pluginContext = undefined;
|
|
71
|
+
}
|
|
72
|
+
getTokenName(token) {
|
|
73
|
+
if (typeof token === 'symbol') {
|
|
74
|
+
return token.toString();
|
|
75
|
+
}
|
|
76
|
+
if (typeof token === 'function') {
|
|
77
|
+
return token.name || 'AnonymousClass';
|
|
78
|
+
}
|
|
79
|
+
return String(token);
|
|
80
|
+
}
|
|
38
81
|
}
|
|
@@ -44,11 +44,16 @@ function createActivateContext(container, registries, env) {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
export class Host {
|
|
47
|
-
constructor(initialProviders = [], env) {
|
|
48
|
-
|
|
47
|
+
constructor(initialProviders = [], env, config = {}) {
|
|
48
|
+
const containerConfig = { debug: config.debug };
|
|
49
|
+
this.root = new Container(undefined, containerConfig);
|
|
49
50
|
initialProviders.forEach(p => this.root.provide(p));
|
|
50
51
|
this._registry = new PluginRegistry();
|
|
51
52
|
this.env = env;
|
|
53
|
+
this.config = config;
|
|
54
|
+
if (this.config.debug) {
|
|
55
|
+
console.log('š Microkernel Host created with debug logging enabled');
|
|
56
|
+
}
|
|
52
57
|
}
|
|
53
58
|
loadPlugins(manifests) {
|
|
54
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -85,32 +90,64 @@ export class Host {
|
|
|
85
90
|
var _a, _b;
|
|
86
91
|
const registries = createSharedRegistries();
|
|
87
92
|
const initCtx = createInitContext(this.root, registries, this.env);
|
|
88
|
-
const
|
|
93
|
+
const plugins = this._registry.getModulesWithNamesInOrder('all');
|
|
94
|
+
if (this.config.debug) {
|
|
95
|
+
console.log('\nš Plugin initialization order:', plugins.map(p => p.name).join(' ā '));
|
|
96
|
+
console.log('\n--- INITIALIZATION PHASE ---\n');
|
|
97
|
+
}
|
|
89
98
|
// Initialize phase with error handling
|
|
90
|
-
for (const
|
|
99
|
+
for (const { name, module } of plugins) {
|
|
91
100
|
try {
|
|
92
|
-
|
|
101
|
+
if (this.config.debug) {
|
|
102
|
+
console.log(`āļø Initializing plugin: ${name}`);
|
|
103
|
+
this.root.setPluginContext(name);
|
|
104
|
+
}
|
|
105
|
+
yield ((_a = module.initialize) === null || _a === void 0 ? void 0 : _a.call(module, initCtx));
|
|
106
|
+
if (this.config.debug) {
|
|
107
|
+
console.log(`ā
Plugin initialized: ${name}\n`);
|
|
108
|
+
this.root.clearPluginContext();
|
|
109
|
+
}
|
|
93
110
|
}
|
|
94
111
|
catch (error) {
|
|
95
112
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
96
113
|
const initError = new Error(`Plugin initialization failed: ${err.message}`);
|
|
97
114
|
initError.cause = error;
|
|
115
|
+
if (this.config.debug) {
|
|
116
|
+
console.error(`ā Plugin initialization failed: ${name}`, err);
|
|
117
|
+
}
|
|
98
118
|
throw initError;
|
|
99
119
|
}
|
|
100
120
|
}
|
|
121
|
+
if (this.config.debug) {
|
|
122
|
+
console.log('--- ACTIVATION PHASE ---\n');
|
|
123
|
+
}
|
|
101
124
|
const actCtx = createActivateContext(this.root, registries, this.env);
|
|
102
125
|
this.rootActivationCtx = actCtx;
|
|
103
126
|
// Activation phase with error handling
|
|
104
|
-
for (const
|
|
127
|
+
for (const { name, module } of plugins) {
|
|
105
128
|
try {
|
|
106
|
-
|
|
129
|
+
if (this.config.debug) {
|
|
130
|
+
console.log(`š Activating plugin: ${name}`);
|
|
131
|
+
this.root.setPluginContext(name);
|
|
132
|
+
}
|
|
133
|
+
yield ((_b = module.activate) === null || _b === void 0 ? void 0 : _b.call(module, actCtx));
|
|
134
|
+
if (this.config.debug) {
|
|
135
|
+
console.log(`ā
Plugin activated: ${name}\n`);
|
|
136
|
+
this.root.clearPluginContext();
|
|
137
|
+
}
|
|
107
138
|
}
|
|
108
139
|
catch (error) {
|
|
109
140
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
110
141
|
console.error(`Plugin activation failed:`, err);
|
|
142
|
+
if (this.config.debug) {
|
|
143
|
+
console.error(`ā Plugin activation failed: ${name}`, err);
|
|
144
|
+
}
|
|
111
145
|
// Continue with other plugins rather than failing completely
|
|
112
146
|
}
|
|
113
147
|
}
|
|
148
|
+
if (this.config.debug) {
|
|
149
|
+
console.log('š All plugins bootstrapped successfully!\n');
|
|
150
|
+
}
|
|
114
151
|
actCtx.hooks.emit('host:activated');
|
|
115
152
|
});
|
|
116
153
|
}
|
|
@@ -118,45 +155,78 @@ export class Host {
|
|
|
118
155
|
const child = this.root.createChild();
|
|
119
156
|
overrides.forEach(p => child.provide(p));
|
|
120
157
|
const childEnv = Object.assign(Object.assign({}, (this.env || {})), (env || {}));
|
|
121
|
-
return new ChildHost(child, this._registry, childEnv);
|
|
158
|
+
return new ChildHost(child, this._registry, childEnv, this.config);
|
|
122
159
|
}
|
|
123
160
|
}
|
|
124
161
|
class ChildHost {
|
|
125
|
-
constructor(container, registry, env) {
|
|
162
|
+
constructor(container, registry, env, config = {}) {
|
|
126
163
|
this.container = container;
|
|
127
164
|
this.registry = registry;
|
|
128
165
|
this.env = env;
|
|
166
|
+
this.config = config;
|
|
129
167
|
}
|
|
130
168
|
bootstrap() {
|
|
131
169
|
return __awaiter(this, arguments, void 0, function* (pluginNames = 'all') {
|
|
132
170
|
var _a, _b;
|
|
133
171
|
const registries = createSharedRegistries();
|
|
134
172
|
const initCtx = createInitContext(this.container, registries, this.env);
|
|
135
|
-
const
|
|
173
|
+
const plugins = this.registry.getModulesWithNamesInOrder(pluginNames);
|
|
174
|
+
if (this.config.debug) {
|
|
175
|
+
console.log('\nš Child host plugin initialization order:', plugins.map(p => p.name).join(' ā '));
|
|
176
|
+
console.log('\n--- CHILD INITIALIZATION PHASE ---\n');
|
|
177
|
+
}
|
|
136
178
|
// Initialize phase with error handling
|
|
137
|
-
for (const
|
|
179
|
+
for (const { name, module } of plugins) {
|
|
138
180
|
try {
|
|
139
|
-
|
|
181
|
+
if (this.config.debug) {
|
|
182
|
+
console.log(`āļø Initializing plugin: ${name}`);
|
|
183
|
+
this.container.setPluginContext(name);
|
|
184
|
+
}
|
|
185
|
+
yield ((_a = module.initialize) === null || _a === void 0 ? void 0 : _a.call(module, initCtx));
|
|
186
|
+
if (this.config.debug) {
|
|
187
|
+
console.log(`ā
Plugin initialized: ${name}\n`);
|
|
188
|
+
this.container.clearPluginContext();
|
|
189
|
+
}
|
|
140
190
|
}
|
|
141
191
|
catch (error) {
|
|
142
192
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
143
193
|
const initError = new Error(`Plugin initialization failed: ${err.message}`);
|
|
144
194
|
initError.cause = error;
|
|
195
|
+
if (this.config.debug) {
|
|
196
|
+
console.error(`ā Plugin initialization failed: ${name}`, err);
|
|
197
|
+
}
|
|
145
198
|
throw initError;
|
|
146
199
|
}
|
|
147
200
|
}
|
|
201
|
+
if (this.config.debug) {
|
|
202
|
+
console.log('--- CHILD ACTIVATION PHASE ---\n');
|
|
203
|
+
}
|
|
148
204
|
const actCtx = createActivateContext(this.container, registries, this.env);
|
|
149
205
|
// Activation phase with error handling
|
|
150
|
-
for (const
|
|
206
|
+
for (const { name, module } of plugins) {
|
|
151
207
|
try {
|
|
152
|
-
|
|
208
|
+
if (this.config.debug) {
|
|
209
|
+
console.log(`š Activating plugin: ${name}`);
|
|
210
|
+
this.container.setPluginContext(name);
|
|
211
|
+
}
|
|
212
|
+
yield ((_b = module.activate) === null || _b === void 0 ? void 0 : _b.call(module, actCtx));
|
|
213
|
+
if (this.config.debug) {
|
|
214
|
+
console.log(`ā
Plugin activated: ${name}\n`);
|
|
215
|
+
this.container.clearPluginContext();
|
|
216
|
+
}
|
|
153
217
|
}
|
|
154
218
|
catch (error) {
|
|
155
219
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
156
220
|
console.error(`Plugin activation failed:`, err);
|
|
221
|
+
if (this.config.debug) {
|
|
222
|
+
console.error(`ā Plugin activation failed: ${name}`, err);
|
|
223
|
+
}
|
|
157
224
|
// Continue with other plugins rather than failing completely
|
|
158
225
|
}
|
|
159
226
|
}
|
|
227
|
+
if (this.config.debug) {
|
|
228
|
+
console.log('š Child host plugins bootstrapped successfully!\n');
|
|
229
|
+
}
|
|
160
230
|
actCtx.hooks.emit('child:activated');
|
|
161
231
|
});
|
|
162
232
|
}
|
|
@@ -67,4 +67,14 @@ export class PluginRegistry {
|
|
|
67
67
|
const order = topologicalSort(t.map(n => this.byName.get(n).manifest));
|
|
68
68
|
return order.map(m => this.byName.get(m.name).module).filter(Boolean);
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Get plugin modules with their names in dependency order
|
|
72
|
+
*/
|
|
73
|
+
getModulesWithNamesInOrder(names = 'all') {
|
|
74
|
+
const t = names === 'all' ? [...this.byName.keys()] : names;
|
|
75
|
+
const order = topologicalSort(t.map(n => this.byName.get(n).manifest));
|
|
76
|
+
return order
|
|
77
|
+
.map(m => ({ name: m.name, module: this.byName.get(m.name).module }))
|
|
78
|
+
.filter(item => item.module);
|
|
79
|
+
}
|
|
70
80
|
}
|
package/dist/runtime/di.d.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import type { Provider, Token } from '@hamak/microkernel-api';
|
|
2
2
|
export declare function Injectable(deps?: Token[]): ClassDecorator;
|
|
3
|
+
export interface ContainerConfig {
|
|
4
|
+
debug?: boolean;
|
|
5
|
+
pluginContext?: string;
|
|
6
|
+
}
|
|
3
7
|
export declare class Container {
|
|
4
8
|
private parent?;
|
|
5
9
|
private providers;
|
|
6
10
|
private instances;
|
|
7
|
-
|
|
11
|
+
private config;
|
|
12
|
+
constructor(parent?: Container, config?: ContainerConfig);
|
|
8
13
|
createChild(): Container;
|
|
9
14
|
provide<T>(prov: Provider<T>): this;
|
|
10
15
|
resolve<T>(token: Token<T>): T;
|
|
16
|
+
setPluginContext(pluginName: string): void;
|
|
17
|
+
clearPluginContext(): void;
|
|
18
|
+
private getTokenName;
|
|
11
19
|
}
|
|
12
20
|
//# sourceMappingURL=di.d.ts.map
|
package/dist/runtime/di.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"di.d.ts","sourceRoot":"","sources":["../../src/runtime/di.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"di.d.ts","sourceRoot":"","sources":["../../src/runtime/di.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAI9D,wBAAgB,UAAU,CAAC,IAAI,GAAE,KAAK,EAAO,GAAG,cAAc,CAI7D;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAC,CAAY;IAC3B,OAAO,CAAC,SAAS,CAA8B;IAC/C,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,MAAM,CAAkB;gBAEpB,MAAM,CAAC,EAAE,SAAS,EAAE,MAAM,GAAE,eAAoB;IAK5D,WAAW,IAAI,SAAS;IAIxB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI;IAUnC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;IA4C9B,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAI1C,kBAAkB,IAAI,IAAI;IAI1B,OAAO,CAAC,YAAY;CASrB"}
|
package/dist/runtime/di.js
CHANGED
|
@@ -1,21 +1,48 @@
|
|
|
1
1
|
const INJECT_KEY = Symbol('di:inject');
|
|
2
|
-
export function Injectable(deps = []) {
|
|
2
|
+
export function Injectable(deps = []) {
|
|
3
|
+
return (t) => {
|
|
4
|
+
t[INJECT_KEY] = deps;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
3
7
|
export class Container {
|
|
4
|
-
constructor(parent) {
|
|
8
|
+
constructor(parent, config = {}) {
|
|
5
9
|
this.providers = new Map();
|
|
6
10
|
this.instances = new Map();
|
|
7
11
|
this.parent = parent;
|
|
12
|
+
this.config = config;
|
|
13
|
+
}
|
|
14
|
+
createChild() {
|
|
15
|
+
return new Container(this, this.config);
|
|
16
|
+
}
|
|
17
|
+
provide(prov) {
|
|
18
|
+
if (this.config.debug) {
|
|
19
|
+
const tokenName = this.getTokenName(prov.provide);
|
|
20
|
+
const context = this.config.pluginContext ? `[${this.config.pluginContext}] ` : '';
|
|
21
|
+
console.log(`š§ ${context}Providing token: ${tokenName}`);
|
|
22
|
+
}
|
|
23
|
+
this.providers.set(prov.provide, prov);
|
|
24
|
+
return this;
|
|
8
25
|
}
|
|
9
|
-
createChild() { return new Container(this); }
|
|
10
|
-
provide(prov) { this.providers.set(prov.provide, prov); return this; }
|
|
11
26
|
resolve(token) {
|
|
12
|
-
if (this.instances.has(token))
|
|
27
|
+
if (this.instances.has(token)) {
|
|
28
|
+
if (this.config.debug) {
|
|
29
|
+
const tokenName = this.getTokenName(token);
|
|
30
|
+
const context = this.config.pluginContext ? `[${this.config.pluginContext}] ` : '';
|
|
31
|
+
console.log(`ā ${context}Resolving token (cached): ${tokenName}`);
|
|
32
|
+
}
|
|
13
33
|
return this.instances.get(token);
|
|
34
|
+
}
|
|
14
35
|
if (this.providers.has(token)) {
|
|
36
|
+
if (this.config.debug) {
|
|
37
|
+
const tokenName = this.getTokenName(token);
|
|
38
|
+
const context = this.config.pluginContext ? `[${this.config.pluginContext}] ` : '';
|
|
39
|
+
console.log(`š ${context}Resolving token: ${tokenName}`);
|
|
40
|
+
}
|
|
15
41
|
const prov = this.providers.get(token);
|
|
16
42
|
let value;
|
|
17
|
-
if ('useValue' in prov)
|
|
43
|
+
if ('useValue' in prov) {
|
|
18
44
|
value = prov.useValue;
|
|
45
|
+
}
|
|
19
46
|
else if ('useClass' in prov) {
|
|
20
47
|
const C = prov.useClass;
|
|
21
48
|
const deps = C[INJECT_KEY] || [];
|
|
@@ -30,9 +57,25 @@ export class Container {
|
|
|
30
57
|
this.instances.set(token, value);
|
|
31
58
|
return value;
|
|
32
59
|
}
|
|
33
|
-
if (this.parent)
|
|
60
|
+
if (this.parent) {
|
|
34
61
|
return this.parent.resolve(token);
|
|
62
|
+
}
|
|
35
63
|
throw new Error(`No provider for token: ${token.toString?.() ?? String(token)}`);
|
|
36
64
|
}
|
|
65
|
+
setPluginContext(pluginName) {
|
|
66
|
+
this.config.pluginContext = pluginName;
|
|
67
|
+
}
|
|
68
|
+
clearPluginContext() {
|
|
69
|
+
this.config.pluginContext = undefined;
|
|
70
|
+
}
|
|
71
|
+
getTokenName(token) {
|
|
72
|
+
if (typeof token === 'symbol') {
|
|
73
|
+
return token.toString();
|
|
74
|
+
}
|
|
75
|
+
if (typeof token === 'function') {
|
|
76
|
+
return token.name || 'AnonymousClass';
|
|
77
|
+
}
|
|
78
|
+
return String(token);
|
|
79
|
+
}
|
|
37
80
|
}
|
|
38
81
|
//# sourceMappingURL=di.js.map
|
package/dist/runtime/di.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"di.js","sourceRoot":"","sources":["../../src/runtime/di.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"di.js","sourceRoot":"","sources":["../../src/runtime/di.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AAEvC,MAAM,UAAU,UAAU,CAAC,OAAgB,EAAE;IAC3C,OAAO,CAAC,CAAM,EAAE,EAAE;QACf,CAAS,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IAChC,CAAC,CAAC;AACJ,CAAC;AAOD,MAAM,OAAO,SAAS;IAMpB,YAAY,MAAkB,EAAE,SAA0B,EAAE;QAJpD,cAAS,GAAG,IAAI,GAAG,EAAmB,CAAC;QACvC,cAAS,GAAG,IAAI,GAA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AI,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;YACnC,CAAC;YAED,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACjC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,0BAA0B,KAAK,CAAC,QAAQ,EAAE,EAAE,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACnF,CAAC;IAED,gBAAgB,CAAC,UAAkB;QACjC,IAAI,CAAC,MAAM,CAAC,aAAa,GAAG,UAAU,CAAC;IACzC,CAAC;IAED,kBAAkB;QAChB,IAAI,CAAC,MAAM,CAAC,aAAa,GAAG,SAAS,CAAC;IACxC,CAAC;IAEO,YAAY,CAAC,KAAY;QAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC1B,CAAC;QACD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;YAChC,OAAO,KAAK,CAAC,IAAI,IAAI,gBAAgB,CAAC;QACxC,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;CACF"}
|
package/dist/runtime/host.d.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import type { ActivateContext, IChildHost, IHost, PluginManifest, Provider } from '@hamak/microkernel-api';
|
|
2
2
|
import { Container } from './di';
|
|
3
3
|
import type { PluginModule } from '@hamak/microkernel-spi';
|
|
4
|
+
export interface HostConfig {
|
|
5
|
+
/** Enable debug logging for plugin lifecycle and DI operations */
|
|
6
|
+
debug?: boolean;
|
|
7
|
+
}
|
|
4
8
|
export declare class Host implements IHost {
|
|
5
9
|
readonly root: Container;
|
|
6
10
|
private readonly _registry;
|
|
7
11
|
private env?;
|
|
12
|
+
private config;
|
|
8
13
|
rootActivationCtx?: ActivateContext;
|
|
9
|
-
constructor(initialProviders?: Provider[], env?: Record<string, any
|
|
14
|
+
constructor(initialProviders?: Provider[], env?: Record<string, any>, config?: HostConfig);
|
|
10
15
|
loadPlugins(manifests: Array<string | PluginManifest>): Promise<void>;
|
|
11
16
|
/**
|
|
12
17
|
* Register a plugin programmatically (useful for testing/inline plugins)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/runtime/host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAwC,MAAM,wBAAwB,CAAC;AACjJ,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/runtime/host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAwC,MAAM,wBAAwB,CAAC;AACjJ,OAAO,EAAE,SAAS,EAAwB,MAAM,MAAM,CAAC;AAGvD,OAAO,KAAK,EAAyB,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAElF,MAAM,WAAW,UAAU;IACzB,kEAAkE;IAClE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAoDD,qBAAa,IAAK,YAAW,KAAK;IAChC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiB;IAC3C,OAAO,CAAC,GAAG,CAAC,CAAsB;IAClC,OAAO,CAAC,MAAM,CAAa;IAC3B,iBAAiB,CAAC,EAAE,eAAe,CAAC;gBAExB,gBAAgB,GAAE,QAAQ,EAAO,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAE,UAAe;IAa3F,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,GAAC,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzE;;;;;OAKG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI;IAIlF;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAInD;;;OAGG;IACH,WAAW,IAAI,cAAc,EAAE;IAIzB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAqEzC,eAAe,CAAC,SAAS,GAAE,QAAQ,EAAO,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,UAAU;CAMnF"}
|
package/dist/runtime/host.js
CHANGED
|
@@ -35,11 +35,16 @@ function createActivateContext(container, registries, env) {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
export class Host {
|
|
38
|
-
constructor(initialProviders = [], env) {
|
|
39
|
-
|
|
38
|
+
constructor(initialProviders = [], env, config = {}) {
|
|
39
|
+
const containerConfig = { debug: config.debug };
|
|
40
|
+
this.root = new Container(undefined, containerConfig);
|
|
40
41
|
initialProviders.forEach(p => this.root.provide(p));
|
|
41
42
|
this._registry = new PluginRegistry();
|
|
42
43
|
this.env = env;
|
|
44
|
+
this.config = config;
|
|
45
|
+
if (this.config.debug) {
|
|
46
|
+
console.log('š Microkernel Host created with debug logging enabled');
|
|
47
|
+
}
|
|
43
48
|
}
|
|
44
49
|
async loadPlugins(manifests) {
|
|
45
50
|
await this._registry.loadAllAtRoot(manifests);
|
|
@@ -71,75 +76,140 @@ export class Host {
|
|
|
71
76
|
async bootstrapAllAtRoot() {
|
|
72
77
|
const registries = createSharedRegistries();
|
|
73
78
|
const initCtx = createInitContext(this.root, registries, this.env);
|
|
74
|
-
const
|
|
79
|
+
const plugins = this._registry.getModulesWithNamesInOrder('all');
|
|
80
|
+
if (this.config.debug) {
|
|
81
|
+
console.log('\nš Plugin initialization order:', plugins.map(p => p.name).join(' ā '));
|
|
82
|
+
console.log('\n--- INITIALIZATION PHASE ---\n');
|
|
83
|
+
}
|
|
75
84
|
// Initialize phase with error handling
|
|
76
|
-
for (const
|
|
85
|
+
for (const { name, module } of plugins) {
|
|
77
86
|
try {
|
|
78
|
-
|
|
87
|
+
if (this.config.debug) {
|
|
88
|
+
console.log(`āļø Initializing plugin: ${name}`);
|
|
89
|
+
this.root.setPluginContext(name);
|
|
90
|
+
}
|
|
91
|
+
await module.initialize?.(initCtx);
|
|
92
|
+
if (this.config.debug) {
|
|
93
|
+
console.log(`ā
Plugin initialized: ${name}\n`);
|
|
94
|
+
this.root.clearPluginContext();
|
|
95
|
+
}
|
|
79
96
|
}
|
|
80
97
|
catch (error) {
|
|
81
98
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
82
99
|
const initError = new Error(`Plugin initialization failed: ${err.message}`);
|
|
83
100
|
initError.cause = error;
|
|
101
|
+
if (this.config.debug) {
|
|
102
|
+
console.error(`ā Plugin initialization failed: ${name}`, err);
|
|
103
|
+
}
|
|
84
104
|
throw initError;
|
|
85
105
|
}
|
|
86
106
|
}
|
|
107
|
+
if (this.config.debug) {
|
|
108
|
+
console.log('--- ACTIVATION PHASE ---\n');
|
|
109
|
+
}
|
|
87
110
|
const actCtx = createActivateContext(this.root, registries, this.env);
|
|
88
111
|
this.rootActivationCtx = actCtx;
|
|
89
112
|
// Activation phase with error handling
|
|
90
|
-
for (const
|
|
113
|
+
for (const { name, module } of plugins) {
|
|
91
114
|
try {
|
|
92
|
-
|
|
115
|
+
if (this.config.debug) {
|
|
116
|
+
console.log(`š Activating plugin: ${name}`);
|
|
117
|
+
this.root.setPluginContext(name);
|
|
118
|
+
}
|
|
119
|
+
await module.activate?.(actCtx);
|
|
120
|
+
if (this.config.debug) {
|
|
121
|
+
console.log(`ā
Plugin activated: ${name}\n`);
|
|
122
|
+
this.root.clearPluginContext();
|
|
123
|
+
}
|
|
93
124
|
}
|
|
94
125
|
catch (error) {
|
|
95
126
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
96
127
|
console.error(`Plugin activation failed:`, err);
|
|
128
|
+
if (this.config.debug) {
|
|
129
|
+
console.error(`ā Plugin activation failed: ${name}`, err);
|
|
130
|
+
}
|
|
97
131
|
// Continue with other plugins rather than failing completely
|
|
98
132
|
}
|
|
99
133
|
}
|
|
134
|
+
if (this.config.debug) {
|
|
135
|
+
console.log('š All plugins bootstrapped successfully!\n');
|
|
136
|
+
}
|
|
100
137
|
actCtx.hooks.emit('host:activated');
|
|
101
138
|
}
|
|
102
139
|
createChildHost(overrides = [], env) {
|
|
103
140
|
const child = this.root.createChild();
|
|
104
141
|
overrides.forEach(p => child.provide(p));
|
|
105
142
|
const childEnv = { ...(this.env || {}), ...(env || {}) };
|
|
106
|
-
return new ChildHost(child, this._registry, childEnv);
|
|
143
|
+
return new ChildHost(child, this._registry, childEnv, this.config);
|
|
107
144
|
}
|
|
108
145
|
}
|
|
109
146
|
class ChildHost {
|
|
110
|
-
constructor(container, registry, env) {
|
|
147
|
+
constructor(container, registry, env, config = {}) {
|
|
111
148
|
this.container = container;
|
|
112
149
|
this.registry = registry;
|
|
113
150
|
this.env = env;
|
|
151
|
+
this.config = config;
|
|
114
152
|
}
|
|
115
153
|
async bootstrap(pluginNames = 'all') {
|
|
116
154
|
const registries = createSharedRegistries();
|
|
117
155
|
const initCtx = createInitContext(this.container, registries, this.env);
|
|
118
|
-
const
|
|
156
|
+
const plugins = this.registry.getModulesWithNamesInOrder(pluginNames);
|
|
157
|
+
if (this.config.debug) {
|
|
158
|
+
console.log('\nš Child host plugin initialization order:', plugins.map(p => p.name).join(' ā '));
|
|
159
|
+
console.log('\n--- CHILD INITIALIZATION PHASE ---\n');
|
|
160
|
+
}
|
|
119
161
|
// Initialize phase with error handling
|
|
120
|
-
for (const
|
|
162
|
+
for (const { name, module } of plugins) {
|
|
121
163
|
try {
|
|
122
|
-
|
|
164
|
+
if (this.config.debug) {
|
|
165
|
+
console.log(`āļø Initializing plugin: ${name}`);
|
|
166
|
+
this.container.setPluginContext(name);
|
|
167
|
+
}
|
|
168
|
+
await module.initialize?.(initCtx);
|
|
169
|
+
if (this.config.debug) {
|
|
170
|
+
console.log(`ā
Plugin initialized: ${name}\n`);
|
|
171
|
+
this.container.clearPluginContext();
|
|
172
|
+
}
|
|
123
173
|
}
|
|
124
174
|
catch (error) {
|
|
125
175
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
126
176
|
const initError = new Error(`Plugin initialization failed: ${err.message}`);
|
|
127
177
|
initError.cause = error;
|
|
178
|
+
if (this.config.debug) {
|
|
179
|
+
console.error(`ā Plugin initialization failed: ${name}`, err);
|
|
180
|
+
}
|
|
128
181
|
throw initError;
|
|
129
182
|
}
|
|
130
183
|
}
|
|
184
|
+
if (this.config.debug) {
|
|
185
|
+
console.log('--- CHILD ACTIVATION PHASE ---\n');
|
|
186
|
+
}
|
|
131
187
|
const actCtx = createActivateContext(this.container, registries, this.env);
|
|
132
188
|
// Activation phase with error handling
|
|
133
|
-
for (const
|
|
189
|
+
for (const { name, module } of plugins) {
|
|
134
190
|
try {
|
|
135
|
-
|
|
191
|
+
if (this.config.debug) {
|
|
192
|
+
console.log(`š Activating plugin: ${name}`);
|
|
193
|
+
this.container.setPluginContext(name);
|
|
194
|
+
}
|
|
195
|
+
await module.activate?.(actCtx);
|
|
196
|
+
if (this.config.debug) {
|
|
197
|
+
console.log(`ā
Plugin activated: ${name}\n`);
|
|
198
|
+
this.container.clearPluginContext();
|
|
199
|
+
}
|
|
136
200
|
}
|
|
137
201
|
catch (error) {
|
|
138
202
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
139
203
|
console.error(`Plugin activation failed:`, err);
|
|
204
|
+
if (this.config.debug) {
|
|
205
|
+
console.error(`ā Plugin activation failed: ${name}`, err);
|
|
206
|
+
}
|
|
140
207
|
// Continue with other plugins rather than failing completely
|
|
141
208
|
}
|
|
142
209
|
}
|
|
210
|
+
if (this.config.debug) {
|
|
211
|
+
console.log('š Child host plugins bootstrapped successfully!\n');
|
|
212
|
+
}
|
|
143
213
|
actCtx.hooks.emit('child:activated');
|
|
144
214
|
}
|
|
145
215
|
}
|
package/dist/runtime/host.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/runtime/host.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/runtime/host.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAwB,MAAM,MAAM,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAc1C,SAAS,sBAAsB;IAC7B,OAAO;QACL,QAAQ,EAAE,qBAAqB,EAAE;QACjC,KAAK,EAAE,kBAAkB,EAAE;QAC3B,KAAK,EAAE,WAAW,EAAE;KACrB,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CACxB,SAAoB,EACpB,UAA4B,EAC5B,GAAyB;IAEzB,OAAO;QACL,OAAO,EAAE,CAAC,IAAc,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;QACpD,OAAO,EAAE,CAAI,CAAM,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAC5C,QAAQ,EAAE;YACR,QAAQ,EAAE,CAAC,EAAU,EAAE,CAAuB,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;SACvF;QACD,KAAK,EAAE;YACL,QAAQ,EAAE,CAAC,IAAY,EAAE,EAAO,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,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tC,IAAI,CAAC;gBACH,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;oBACtB,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,EAAE,CAAC,CAAC;oBAC7C,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;gBACxC,CAAC;gBACD,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC;gBAChC,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;oBACtB,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,IAAI,CAAC,CAAC;oBAC7C,IAAI,CAAC,SAAS,CAAC,kBAAkB,EAAE,CAAC;gBACtC,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;gBACtE,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAC;gBAChD,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;oBACtB,OAAO,CAAC,KAAK,CAAC,+BAA+B,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;gBAC5D,CAAC;gBACD,6DAA6D;YAC/D,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACtB,OAAO,CAAC,GAAG,CAAC,oDAAoD,CAAC,CAAC;QACpE,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;CACF"}
|
package/dist/runtime/loader.d.ts
CHANGED
|
@@ -27,6 +27,13 @@ export declare class PluginRegistry {
|
|
|
27
27
|
* Get plugin modules in dependency order
|
|
28
28
|
*/
|
|
29
29
|
getModulesInOrder(names?: string[] | 'all'): PluginModule[];
|
|
30
|
+
/**
|
|
31
|
+
* Get plugin modules with their names in dependency order
|
|
32
|
+
*/
|
|
33
|
+
getModulesWithNamesInOrder(names?: string[] | 'all'): Array<{
|
|
34
|
+
name: string;
|
|
35
|
+
module: PluginModule;
|
|
36
|
+
}>;
|
|
30
37
|
}
|
|
31
38
|
export {};
|
|
32
39
|
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/runtime/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG3D,cAAM,YAAY;IACG,QAAQ,EAAE,cAAc;IAAS,MAAM,CAAC;gBAAxC,QAAQ,EAAE,cAAc,EAAS,MAAM,CAAC,0BAAc;CAC1E;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAmC;IAEjD;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM;IAIhB;;OAEG;IACH,IAAI;IAIJ;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI;IAI5E;;OAEG;IACG,aAAa,CAAC,cAAc,EAAE,KAAK,CAAC,MAAM,GAAG,cAAc,CAAC;IAiBlE;;OAEG;IACH,iBAAiB,CAAC,KAAK,GAAE,MAAM,EAAE,GAAG,KAAa;
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/runtime/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG3D,cAAM,YAAY;IACG,QAAQ,EAAE,cAAc;IAAS,MAAM,CAAC;gBAAxC,QAAQ,EAAE,cAAc,EAAS,MAAM,CAAC,0BAAc;CAC1E;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAmC;IAEjD;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM;IAIhB;;OAEG;IACH,IAAI;IAIJ;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI;IAI5E;;OAEG;IACG,aAAa,CAAC,cAAc,EAAE,KAAK,CAAC,MAAM,GAAG,cAAc,CAAC;IAiBlE;;OAEG;IACH,iBAAiB,CAAC,KAAK,GAAE,MAAM,EAAE,GAAG,KAAa;IAMjD;;OAEG;IACH,0BAA0B,CAAC,KAAK,GAAE,MAAM,EAAE,GAAG,KAAa,GAAG,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,YAAY,CAAA;KAAE,CAAC;CAO3G"}
|
package/dist/runtime/loader.js
CHANGED
|
@@ -55,5 +55,15 @@ export class PluginRegistry {
|
|
|
55
55
|
const order = topologicalSort(t.map(n => this.byName.get(n).manifest));
|
|
56
56
|
return order.map(m => this.byName.get(m.name).module).filter(Boolean);
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Get plugin modules with their names in dependency order
|
|
60
|
+
*/
|
|
61
|
+
getModulesWithNamesInOrder(names = 'all') {
|
|
62
|
+
const t = names === 'all' ? [...this.byName.keys()] : names;
|
|
63
|
+
const order = topologicalSort(t.map(n => this.byName.get(n).manifest));
|
|
64
|
+
return order
|
|
65
|
+
.map(m => ({ name: m.name, module: this.byName.get(m.name).module }))
|
|
66
|
+
.filter(item => item.module);
|
|
67
|
+
}
|
|
58
68
|
}
|
|
59
69
|
//# sourceMappingURL=loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/runtime/loader.ts"],"names":[],"mappings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AI,CAAE,CAAC,MAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC1E,CAAC;IAED;;OAEG;IACH,0BAA0B,CAAC,QAA0B,KAAK;QACxD,MAAM,CAAC,GAAG,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAC5D,MAAM,KAAK,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;QACxE,OAAO,KAAK;aACT,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAE,CAAC,MAAO,EAAE,CAAC,CAAC;aACtE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hamak/microkernel-impl",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Microkernel Implementation - Core microkernel functionality",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@hamak/microkernel-api": "0.2.
|
|
35
|
-
"@hamak/microkernel-spi": "0.2.
|
|
34
|
+
"@hamak/microkernel-api": "0.2.4",
|
|
35
|
+
"@hamak/microkernel-spi": "0.2.4"
|
|
36
36
|
}
|
|
37
37
|
}
|
package/src/runtime/di.ts
CHANGED
|
@@ -1,21 +1,102 @@
|
|
|
1
1
|
import type { Provider, Token } from '@hamak/microkernel-api';
|
|
2
|
+
|
|
2
3
|
const INJECT_KEY = Symbol('di:inject');
|
|
3
|
-
|
|
4
|
+
|
|
5
|
+
export function Injectable(deps: Token[] = []): ClassDecorator {
|
|
6
|
+
return (t: any) => {
|
|
7
|
+
(t as any)[INJECT_KEY] = deps;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ContainerConfig {
|
|
12
|
+
debug?: boolean;
|
|
13
|
+
pluginContext?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
4
16
|
export class Container {
|
|
5
|
-
private parent?: Container;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
17
|
+
private parent?: Container;
|
|
18
|
+
private providers = new Map<Token, Provider>();
|
|
19
|
+
private instances = new Map<Token, any>();
|
|
20
|
+
private config: ContainerConfig;
|
|
21
|
+
|
|
22
|
+
constructor(parent?: Container, config: ContainerConfig = {}) {
|
|
23
|
+
this.parent = parent;
|
|
24
|
+
this.config = config;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
createChild(): Container {
|
|
28
|
+
return new Container(this, this.config);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
provide<T>(prov: Provider<T>): this {
|
|
32
|
+
if (this.config.debug) {
|
|
33
|
+
const tokenName = this.getTokenName(prov.provide);
|
|
34
|
+
const context = this.config.pluginContext ? `[${this.config.pluginContext}] ` : '';
|
|
35
|
+
console.log(`š§ ${context}Providing token: ${tokenName}`);
|
|
36
|
+
}
|
|
37
|
+
this.providers.set(prov.provide, prov);
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
|
|
9
41
|
resolve<T>(token: Token<T>): T {
|
|
10
|
-
if (this.instances.has(token))
|
|
42
|
+
if (this.instances.has(token)) {
|
|
43
|
+
if (this.config.debug) {
|
|
44
|
+
const tokenName = this.getTokenName(token);
|
|
45
|
+
const context = this.config.pluginContext ? `[${this.config.pluginContext}] ` : '';
|
|
46
|
+
console.log(`ā ${context}Resolving token (cached): ${tokenName}`);
|
|
47
|
+
}
|
|
48
|
+
return this.instances.get(token);
|
|
49
|
+
}
|
|
50
|
+
|
|
11
51
|
if (this.providers.has(token)) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
52
|
+
if (this.config.debug) {
|
|
53
|
+
const tokenName = this.getTokenName(token);
|
|
54
|
+
const context = this.config.pluginContext ? `[${this.config.pluginContext}] ` : '';
|
|
55
|
+
console.log(`š ${context}Resolving token: ${tokenName}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const prov: any = this.providers.get(token)!;
|
|
59
|
+
let value: any;
|
|
60
|
+
|
|
61
|
+
if ('useValue' in prov) {
|
|
62
|
+
value = prov.useValue;
|
|
63
|
+
} else if ('useClass' in prov) {
|
|
64
|
+
const C = prov.useClass;
|
|
65
|
+
const deps: Token[] = (C as any)[INJECT_KEY] || [];
|
|
66
|
+
const args = deps.map((d) => this.resolve(d));
|
|
67
|
+
value = new C(...args);
|
|
68
|
+
} else {
|
|
69
|
+
const deps: Token[] = prov.deps || [];
|
|
70
|
+
const args = deps.map((d) => this.resolve(d));
|
|
71
|
+
value = prov.useFactory(...args);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
this.instances.set(token, value);
|
|
75
|
+
return value;
|
|
17
76
|
}
|
|
18
|
-
|
|
77
|
+
|
|
78
|
+
if (this.parent) {
|
|
79
|
+
return this.parent.resolve(token);
|
|
80
|
+
}
|
|
81
|
+
|
|
19
82
|
throw new Error(`No provider for token: ${token.toString?.() ?? String(token)}`);
|
|
20
83
|
}
|
|
84
|
+
|
|
85
|
+
setPluginContext(pluginName: string): void {
|
|
86
|
+
this.config.pluginContext = pluginName;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
clearPluginContext(): void {
|
|
90
|
+
this.config.pluginContext = undefined;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private getTokenName(token: Token): string {
|
|
94
|
+
if (typeof token === 'symbol') {
|
|
95
|
+
return token.toString();
|
|
96
|
+
}
|
|
97
|
+
if (typeof token === 'function') {
|
|
98
|
+
return token.name || 'AnonymousClass';
|
|
99
|
+
}
|
|
100
|
+
return String(token);
|
|
101
|
+
}
|
|
21
102
|
}
|
package/src/runtime/host.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import type { ActivateContext, IChildHost, IHost, PluginManifest, Provider, CommandRegistry, ViewRegistry, Hooks } from '@hamak/microkernel-api';
|
|
2
|
-
import { Container } from './di';
|
|
2
|
+
import { Container, type ContainerConfig } from './di';
|
|
3
3
|
import { createCommandRegistry, createHooks, createViewRegistry } from './registries';
|
|
4
4
|
import { PluginRegistry } from './loader';
|
|
5
5
|
import type { InitializationContext, PluginModule } from '@hamak/microkernel-spi';
|
|
6
6
|
|
|
7
|
+
export interface HostConfig {
|
|
8
|
+
/** Enable debug logging for plugin lifecycle and DI operations */
|
|
9
|
+
debug?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
type SharedRegistries = {
|
|
8
13
|
commands: CommandRegistry;
|
|
9
14
|
views: ViewRegistry;
|
|
@@ -58,13 +63,20 @@ export class Host implements IHost {
|
|
|
58
63
|
readonly root: Container;
|
|
59
64
|
private readonly _registry: PluginRegistry;
|
|
60
65
|
private env?: Record<string, any>;
|
|
66
|
+
private config: HostConfig;
|
|
61
67
|
rootActivationCtx?: ActivateContext;
|
|
62
68
|
|
|
63
|
-
constructor(initialProviders: Provider[] = [], env?: Record<string, any
|
|
64
|
-
|
|
69
|
+
constructor(initialProviders: Provider[] = [], env?: Record<string, any>, config: HostConfig = {}){
|
|
70
|
+
const containerConfig: ContainerConfig = { debug: config.debug };
|
|
71
|
+
this.root = new Container(undefined, containerConfig);
|
|
65
72
|
initialProviders.forEach(p=>this.root.provide(p));
|
|
66
73
|
this._registry = new PluginRegistry();
|
|
67
74
|
this.env = env;
|
|
75
|
+
this.config = config;
|
|
76
|
+
|
|
77
|
+
if (this.config.debug) {
|
|
78
|
+
console.log('š Microkernel Host created with debug logging enabled');
|
|
79
|
+
}
|
|
68
80
|
}
|
|
69
81
|
|
|
70
82
|
async loadPlugins(manifests: Array<string|PluginManifest>): Promise<void>{
|
|
@@ -101,34 +113,69 @@ export class Host implements IHost {
|
|
|
101
113
|
async bootstrapAllAtRoot(): Promise<void>{
|
|
102
114
|
const registries = createSharedRegistries();
|
|
103
115
|
const initCtx = createInitContext(this.root, registries, this.env);
|
|
104
|
-
const
|
|
116
|
+
const plugins = this._registry.getModulesWithNamesInOrder('all');
|
|
117
|
+
|
|
118
|
+
if (this.config.debug) {
|
|
119
|
+
console.log('\nš Plugin initialization order:', plugins.map(p => p.name).join(' ā '));
|
|
120
|
+
console.log('\n--- INITIALIZATION PHASE ---\n');
|
|
121
|
+
}
|
|
105
122
|
|
|
106
123
|
// Initialize phase with error handling
|
|
107
|
-
for(const
|
|
124
|
+
for(const { name, module } of plugins) {
|
|
108
125
|
try {
|
|
109
|
-
|
|
126
|
+
if (this.config.debug) {
|
|
127
|
+
console.log(`āļø Initializing plugin: ${name}`);
|
|
128
|
+
this.root.setPluginContext(name);
|
|
129
|
+
}
|
|
130
|
+
await module.initialize?.(initCtx);
|
|
131
|
+
if (this.config.debug) {
|
|
132
|
+
console.log(`ā
Plugin initialized: ${name}\n`);
|
|
133
|
+
this.root.clearPluginContext();
|
|
134
|
+
}
|
|
110
135
|
} catch (error) {
|
|
111
136
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
112
137
|
const initError = new Error(`Plugin initialization failed: ${err.message}`);
|
|
113
138
|
(initError as any).cause = error;
|
|
139
|
+
if (this.config.debug) {
|
|
140
|
+
console.error(`ā Plugin initialization failed: ${name}`, err);
|
|
141
|
+
}
|
|
114
142
|
throw initError;
|
|
115
143
|
}
|
|
116
144
|
}
|
|
117
145
|
|
|
146
|
+
if (this.config.debug) {
|
|
147
|
+
console.log('--- ACTIVATION PHASE ---\n');
|
|
148
|
+
}
|
|
149
|
+
|
|
118
150
|
const actCtx = createActivateContext(this.root, registries, this.env);
|
|
119
151
|
this.rootActivationCtx = actCtx;
|
|
120
152
|
|
|
121
153
|
// Activation phase with error handling
|
|
122
|
-
for(const
|
|
154
|
+
for(const { name, module } of plugins) {
|
|
123
155
|
try {
|
|
124
|
-
|
|
156
|
+
if (this.config.debug) {
|
|
157
|
+
console.log(`š Activating plugin: ${name}`);
|
|
158
|
+
this.root.setPluginContext(name);
|
|
159
|
+
}
|
|
160
|
+
await module.activate?.(actCtx);
|
|
161
|
+
if (this.config.debug) {
|
|
162
|
+
console.log(`ā
Plugin activated: ${name}\n`);
|
|
163
|
+
this.root.clearPluginContext();
|
|
164
|
+
}
|
|
125
165
|
} catch (error) {
|
|
126
166
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
127
167
|
console.error(`Plugin activation failed:`, err);
|
|
168
|
+
if (this.config.debug) {
|
|
169
|
+
console.error(`ā Plugin activation failed: ${name}`, err);
|
|
170
|
+
}
|
|
128
171
|
// Continue with other plugins rather than failing completely
|
|
129
172
|
}
|
|
130
173
|
}
|
|
131
174
|
|
|
175
|
+
if (this.config.debug) {
|
|
176
|
+
console.log('š All plugins bootstrapped successfully!\n');
|
|
177
|
+
}
|
|
178
|
+
|
|
132
179
|
actCtx.hooks.emit('host:activated');
|
|
133
180
|
}
|
|
134
181
|
|
|
@@ -136,42 +183,83 @@ export class Host implements IHost {
|
|
|
136
183
|
const child = this.root.createChild();
|
|
137
184
|
overrides.forEach(p=>child.provide(p));
|
|
138
185
|
const childEnv = { ...(this.env||{}), ...(env||{}) };
|
|
139
|
-
return new ChildHost(child, this._registry, childEnv);
|
|
186
|
+
return new ChildHost(child, this._registry, childEnv, this.config);
|
|
140
187
|
}
|
|
141
188
|
}
|
|
142
189
|
|
|
143
190
|
class ChildHost implements IChildHost {
|
|
144
|
-
constructor(
|
|
191
|
+
constructor(
|
|
192
|
+
private readonly container: Container,
|
|
193
|
+
private readonly registry: PluginRegistry,
|
|
194
|
+
private readonly env?: Record<string, any>,
|
|
195
|
+
private readonly config: HostConfig = {}
|
|
196
|
+
) {}
|
|
197
|
+
|
|
145
198
|
async bootstrap(pluginNames: string[]|'all'='all'): Promise<void>{
|
|
146
199
|
const registries = createSharedRegistries();
|
|
147
200
|
const initCtx = createInitContext(this.container, registries, this.env);
|
|
148
|
-
const
|
|
201
|
+
const plugins = this.registry.getModulesWithNamesInOrder(pluginNames);
|
|
202
|
+
|
|
203
|
+
if (this.config.debug) {
|
|
204
|
+
console.log('\nš Child host plugin initialization order:', plugins.map(p => p.name).join(' ā '));
|
|
205
|
+
console.log('\n--- CHILD INITIALIZATION PHASE ---\n');
|
|
206
|
+
}
|
|
149
207
|
|
|
150
208
|
// Initialize phase with error handling
|
|
151
|
-
for(const
|
|
209
|
+
for(const { name, module } of plugins) {
|
|
152
210
|
try {
|
|
153
|
-
|
|
211
|
+
if (this.config.debug) {
|
|
212
|
+
console.log(`āļø Initializing plugin: ${name}`);
|
|
213
|
+
this.container.setPluginContext(name);
|
|
214
|
+
}
|
|
215
|
+
await module.initialize?.(initCtx);
|
|
216
|
+
if (this.config.debug) {
|
|
217
|
+
console.log(`ā
Plugin initialized: ${name}\n`);
|
|
218
|
+
this.container.clearPluginContext();
|
|
219
|
+
}
|
|
154
220
|
} catch (error) {
|
|
155
221
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
156
222
|
const initError = new Error(`Plugin initialization failed: ${err.message}`);
|
|
157
223
|
(initError as any).cause = error;
|
|
224
|
+
if (this.config.debug) {
|
|
225
|
+
console.error(`ā Plugin initialization failed: ${name}`, err);
|
|
226
|
+
}
|
|
158
227
|
throw initError;
|
|
159
228
|
}
|
|
160
229
|
}
|
|
161
230
|
|
|
231
|
+
if (this.config.debug) {
|
|
232
|
+
console.log('--- CHILD ACTIVATION PHASE ---\n');
|
|
233
|
+
}
|
|
234
|
+
|
|
162
235
|
const actCtx = createActivateContext(this.container, registries, this.env);
|
|
163
236
|
|
|
164
237
|
// Activation phase with error handling
|
|
165
|
-
for(const
|
|
238
|
+
for(const { name, module } of plugins) {
|
|
166
239
|
try {
|
|
167
|
-
|
|
240
|
+
if (this.config.debug) {
|
|
241
|
+
console.log(`š Activating plugin: ${name}`);
|
|
242
|
+
this.container.setPluginContext(name);
|
|
243
|
+
}
|
|
244
|
+
await module.activate?.(actCtx);
|
|
245
|
+
if (this.config.debug) {
|
|
246
|
+
console.log(`ā
Plugin activated: ${name}\n`);
|
|
247
|
+
this.container.clearPluginContext();
|
|
248
|
+
}
|
|
168
249
|
} catch (error) {
|
|
169
250
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
170
251
|
console.error(`Plugin activation failed:`, err);
|
|
252
|
+
if (this.config.debug) {
|
|
253
|
+
console.error(`ā Plugin activation failed: ${name}`, err);
|
|
254
|
+
}
|
|
171
255
|
// Continue with other plugins rather than failing completely
|
|
172
256
|
}
|
|
173
257
|
}
|
|
174
258
|
|
|
259
|
+
if (this.config.debug) {
|
|
260
|
+
console.log('š Child host plugins bootstrapped successfully!\n');
|
|
261
|
+
}
|
|
262
|
+
|
|
175
263
|
actCtx.hooks.emit('child:activated');
|
|
176
264
|
}
|
|
177
265
|
}
|
package/src/runtime/loader.ts
CHANGED
|
@@ -58,4 +58,15 @@ export class PluginRegistry {
|
|
|
58
58
|
const order = topologicalSort(t.map(n => this.byName.get(n)!.manifest));
|
|
59
59
|
return order.map(m => this.byName.get(m.name)!.module!).filter(Boolean);
|
|
60
60
|
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Get plugin modules with their names in dependency order
|
|
64
|
+
*/
|
|
65
|
+
getModulesWithNamesInOrder(names: string[] | 'all' = 'all'): Array<{ name: string; module: PluginModule }> {
|
|
66
|
+
const t = names === 'all' ? [...this.byName.keys()] : names;
|
|
67
|
+
const order = topologicalSort(t.map(n => this.byName.get(n)!.manifest));
|
|
68
|
+
return order
|
|
69
|
+
.map(m => ({ name: m.name, module: this.byName.get(m.name)!.module! }))
|
|
70
|
+
.filter(item => item.module);
|
|
71
|
+
}
|
|
61
72
|
}
|