@kanian77/choux 0.2.1 → 0.2.2
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 +85 -53
- package/bun.lock +5 -3
- package/dist/core/ChouxModule.d.ts +1 -1
- package/dist/core/ChouxModule.d.ts.map +1 -1
- package/dist/core/ChouxModule.js +1 -1
- package/dist/core/ChouxModule.js.map +1 -1
- package/dist/core/HookRegistry.js +121 -59
- package/dist/core/HookRegistry.js.map +1 -1
- package/dist/core/HookRegistry.spec.js +28 -19
- package/dist/core/HookRegistry.spec.js.map +1 -1
- package/dist/core/Plugin.d.ts +1 -6
- package/dist/core/Plugin.d.ts.map +1 -1
- package/dist/core/Plugin.js +1 -2
- package/dist/core/Plugin.js.map +1 -1
- package/dist/core/PluginManager.d.ts +8 -4
- package/dist/core/PluginManager.d.ts.map +1 -1
- package/dist/core/PluginManager.js +168 -55
- package/dist/core/PluginManager.js.map +1 -1
- package/dist/core/PluginManager.spec.js +42 -31
- package/dist/core/PluginManager.spec.js.map +1 -1
- package/dist/decorators/enableHooksDecorator.d.ts.map +1 -1
- package/dist/decorators/enableHooksDecorator.js +4 -1
- package/dist/decorators/enableHooksDecorator.js.map +1 -1
- package/dist/decorators/hookDecorator.d.ts +5 -1
- package/dist/decorators/hookDecorator.d.ts.map +1 -1
- package/dist/decorators/hookDecorator.js +46 -9
- package/dist/decorators/hookDecorator.js.map +1 -1
- package/dist/decorators/hookDecorator.spec.js +107 -25
- package/dist/decorators/hookDecorator.spec.js.map +1 -1
- package/dist/lib/functions/index.d.ts +3 -2
- package/dist/lib/functions/index.d.ts.map +1 -1
- package/dist/lib/functions/index.js +3 -2
- package/dist/lib/functions/index.js.map +1 -1
- package/dist/lib/functions/registerHookHandler.d.ts.map +1 -1
- package/dist/lib/functions/registerHookHandler.js +1 -1
- package/dist/lib/functions/registerHookHandler.js.map +1 -1
- package/dist/lib/functions/registerHooksForInstance.d.ts.map +1 -1
- package/dist/lib/functions/registerHooksForInstance.js +2 -2
- package/dist/lib/functions/registerHooksForInstance.js.map +1 -1
- package/dist/lib/functions/registerInstanceHooks.d.ts.map +1 -1
- package/dist/lib/functions/registerInstanceHooks.js +19 -10
- package/dist/lib/functions/registerInstanceHooks.js.map +1 -1
- package/dist/lib/functions/registerStaticHooks.d.ts +2 -0
- package/dist/lib/functions/registerStaticHooks.d.ts.map +1 -0
- package/dist/lib/functions/registerStaticHooks.js +36 -0
- package/dist/lib/functions/registerStaticHooks.js.map +1 -0
- package/dist/lib/test-related/plugins/plugin-a/module.d.ts +5 -2
- package/dist/lib/test-related/plugins/plugin-a/module.d.ts.map +1 -1
- package/dist/lib/test-related/plugins/plugin-a/module.js +156 -77
- package/dist/lib/test-related/plugins/plugin-a/module.js.map +1 -1
- package/dist/lib/test-related/plugins/plugin-b/module.d.ts +5 -2
- package/dist/lib/test-related/plugins/plugin-b/module.d.ts.map +1 -1
- package/dist/lib/test-related/plugins/plugin-b/module.js +158 -77
- package/dist/lib/test-related/plugins/plugin-b/module.js.map +1 -1
- package/dist/lib/test-related/services.d.ts +17 -0
- package/dist/lib/test-related/services.d.ts.map +1 -0
- package/dist/lib/test-related/services.js +104 -0
- package/dist/lib/test-related/services.js.map +1 -0
- package/dist/lib/types/IHookMetadata.d.ts +6 -0
- package/dist/lib/types/IHookMetadata.d.ts.map +1 -0
- package/dist/lib/types/IHookMetadata.js +2 -0
- package/dist/lib/types/IHookMetadata.js.map +1 -0
- package/dist/lib/types/IHookRegistry.js +1 -0
- package/dist/lib/types/IPluginManager.d.ts +3 -1
- package/dist/lib/types/IPluginManager.d.ts.map +1 -1
- package/dist/lib/types/IPluginManager.js +1 -0
- package/dist/lib/types/LoadedPlugin.d.ts +2 -2
- package/dist/lib/types/LoadedPlugin.d.ts.map +1 -1
- package/dist/lib/types/LoadedPlugin.js +1 -0
- package/dist/lib/types/PluginMetadata.js +1 -0
- package/dist/lib/types/PluginModule.d.ts +10 -0
- package/dist/lib/types/PluginModule.d.ts.map +1 -0
- package/dist/lib/types/PluginModule.js +14 -0
- package/dist/lib/types/PluginModule.js.map +1 -0
- package/dist/lib/types/index.d.ts +1 -1
- package/dist/lib/types/index.d.ts.map +1 -1
- package/dist/lib/types/index.js +1 -1
- package/dist/lib/types/index.js.map +1 -1
- package/package.json +2 -2
- package/tsconfig.json +15 -9
- package/dist/core/PluginLoader.d.ts +0 -13
- package/dist/core/PluginLoader.d.ts.map +0 -1
- package/dist/core/PluginLoader.js +0 -147
- package/dist/core/PluginLoader.js.map +0 -1
- package/dist/core/PluginLoader.spec.d.ts +0 -2
- package/dist/core/PluginLoader.spec.d.ts.map +0 -1
- package/dist/core/PluginLoader.spec.js +0 -114
- package/dist/core/PluginLoader.spec.js.map +0 -1
- package/dist/example-plugin/module.d.ts +0 -20
- package/dist/example-plugin/module.d.ts.map +0 -1
- package/dist/example-plugin/module.js +0 -90
- package/dist/example-plugin/module.js.map +0 -1
- package/dist/example-plugin/services.d.ts +0 -9
- package/dist/example-plugin/services.d.ts.map +0 -1
- package/dist/example-plugin/services.js +0 -29
- package/dist/example-plugin/services.js.map +0 -1
- package/dist/example-plugin/tokens.d.ts +0 -2
- package/dist/example-plugin/tokens.d.ts.map +0 -1
- package/dist/example-plugin/tokens.js +0 -2
- package/dist/example-plugin/tokens.js.map +0 -1
- package/dist/lib/types/HookMetadata.d.ts +0 -5
- package/dist/lib/types/HookMetadata.d.ts.map +0 -1
- package/dist/lib/types/HookMetadata.js +0 -1
- package/dist/lib/types/HookMetadata.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Choux Plugin System
|
|
2
2
|
|
|
3
|
-
Choux is a modular, type-safe plugin system for Node.js/TypeScript applications, built on top of the `@kanian77/
|
|
3
|
+
Choux is a modular, type-safe plugin system for Node.js/TypeScript applications, built on top of the `@kanian77/tject` dependency injection framework. It enables plugin lifecycle management and custom hooks, making it easy to extend your application with isolated, reusable modules.
|
|
4
4
|
|
|
5
5
|
## Core Concepts
|
|
6
6
|
|
|
@@ -11,18 +11,17 @@ A plugin is a class extending the abstract `Plugin` base class (`src/core/Plugin
|
|
|
11
11
|
- `onLoad`: Called when the plugin is loaded, before dependencies are resolved.
|
|
12
12
|
- `onInit`: Called after dependencies are resolved and injected.
|
|
13
13
|
- `onDestroy`: Called when the plugin is being unloaded.
|
|
14
|
-
- `registerCustomHooks`: Register custom hooks for other plugins to use.
|
|
15
14
|
|
|
16
|
-
Plugins are
|
|
15
|
+
Plugins are implemented as `PluginModule` classes, which extend the base `Module` class from `@kanian77/tject`.
|
|
17
16
|
|
|
18
|
-
### Plugin
|
|
17
|
+
### Plugin Loading & Management
|
|
19
18
|
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
19
|
+
- **PluginManager (`src/core/PluginManager.ts`)**: Manages the initialization, lifecycle, and shutdown of plugins. It provides methods to load individual plugins, get loaded plugin instances, and properly shutdown plugins.
|
|
20
|
+
- **ChouxModule (`src/core/ChouxModule.ts`)**: The main entry point module that provides the core services (PluginManager and HookRegistry). Must be imported and bootstrapped in your application.
|
|
22
21
|
|
|
23
22
|
### Dependency Injection
|
|
24
23
|
|
|
25
|
-
All plugins and core services use the DI system from `@kanian77/
|
|
24
|
+
All plugins and core services use the DI system from `@kanian77/tject`. Tokens (see `src/core/tokens.ts`) are used to register and inject services, including plugin services and the hook registry.
|
|
26
25
|
|
|
27
26
|
### Hooks & Events
|
|
28
27
|
|
|
@@ -32,72 +31,112 @@ All plugins and core services use the DI system from `@kanian77/simple-di`. Toke
|
|
|
32
31
|
|
|
33
32
|
### Decorators & Utilities
|
|
34
33
|
|
|
35
|
-
- **Hook
|
|
34
|
+
- **Hook Decorators**: Two decorators work together to enable hook functionality:
|
|
35
|
+
- `@EnableHooks`: Class-level decorator that must be applied to any class using hook decorators
|
|
36
|
+
- `@Hook(hookName)`: Method decorator for registering hook handlers in classes
|
|
36
37
|
- **Function Utilities (`src/lib/functions/`)**: Helper functions for hook registration and plugin management.
|
|
37
|
-
- **Types (`src/lib/types/`)**: Shared interfaces and type definitions for plugins, hook registry, plugin
|
|
38
|
+
- **Types (`src/lib/types/`)**: Shared interfaces and type definitions for plugins, hook registry, plugin manager, and metadata.
|
|
38
39
|
|
|
39
|
-
##
|
|
40
|
+
## Usage
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
### Bootstrapping
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
- `services.ts`: Defines plugin-specific services, which can be injected elsewhere.
|
|
45
|
-
- `tokens.ts`: Declares DI tokens for plugin services.
|
|
44
|
+
To use Choux in your application:
|
|
46
45
|
|
|
47
|
-
|
|
46
|
+
1. Import and bootstrap the ChouxModule:
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
```typescript
|
|
49
|
+
import { bootstrap } from '@kanian77/tject';
|
|
50
|
+
import { ChouxModule } from '@choux/core';
|
|
51
|
+
import { YourPluginModule } from './plugins/your-plugin/module';
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
// Bootstrap the core module
|
|
54
|
+
bootstrap(ChouxModule);
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
- Get the plugin manager and initialize plugins from the plugins directory.
|
|
56
|
-
- Access plugin services via DI tokens.
|
|
56
|
+
// Get plugin manager
|
|
57
|
+
const pluginManager = inject<PluginManager>(PLUGIN_MANAGER_TOKEN);
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
// Initialize your plugins
|
|
60
|
+
await pluginManager.initializePlugins([YourPluginModule]);
|
|
61
|
+
```
|
|
59
62
|
|
|
60
|
-
|
|
63
|
+
### Creating a Plugin
|
|
64
|
+
|
|
65
|
+
Create a new plugin by extending the Plugin class and defining it as a PluginModule:
|
|
61
66
|
|
|
62
67
|
```typescript
|
|
63
|
-
import {
|
|
64
|
-
import {
|
|
65
|
-
|
|
68
|
+
import { Plugin, PluginModule, EnableHook, Hook } from '@kanian77/choux';
|
|
69
|
+
import { Service } from '@kanian77/tject';
|
|
70
|
+
|
|
71
|
+
export const YOUR_PLUGIN_TOKEN = 'YOUR_PLUGIN_TOKEN';
|
|
72
|
+
@Service({ token: YOUR_PLUGIN_TOKEN })
|
|
73
|
+
@EnableHooks
|
|
74
|
+
class YourPlugin extends Plugin {
|
|
75
|
+
readonly metadata = {
|
|
76
|
+
name: 'your-plugin',
|
|
77
|
+
version: '1.0.0',
|
|
78
|
+
description: 'Your plugin description',
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
async onInit() {
|
|
82
|
+
// Initialize your plugin
|
|
83
|
+
}
|
|
66
84
|
|
|
67
|
-
|
|
68
|
-
|
|
85
|
+
// Example of using hooks
|
|
86
|
+
@Hook('some:event')
|
|
87
|
+
onSomeEvent(data: any) {
|
|
88
|
+
// Handle the event
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Enable hook processing for the class
|
|
93
|
+
export const YourPluginModule = new PluginModule({
|
|
94
|
+
token: YOUR_PLUGIN_TOKEN,
|
|
95
|
+
providers: [
|
|
96
|
+
{
|
|
97
|
+
provide: YOUR_PLUGIN_TOKEN,
|
|
98
|
+
useClass: YourPlugin,
|
|
99
|
+
},
|
|
100
|
+
// Add your plugin's services here
|
|
101
|
+
],
|
|
102
|
+
});
|
|
69
103
|
```
|
|
70
104
|
|
|
71
|
-
|
|
105
|
+
### Accessing Plugin Services
|
|
72
106
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
107
|
+
You can inject services provided by plugins using their tokens:
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
import { inject } from '@kanian77/tject';
|
|
111
|
+
import { YOUR_SERVICE_TOKEN } from './tokens';
|
|
112
|
+
import { IYourService } from './services';
|
|
113
|
+
|
|
114
|
+
const yourService = inject<IYourService>(YOUR_SERVICE_TOKEN);
|
|
115
|
+
yourService.doSomething();
|
|
116
|
+
```
|
|
77
117
|
|
|
78
118
|
## Directory Overview
|
|
79
119
|
|
|
80
|
-
- `src/core/`: Core plugin system (Plugin,
|
|
120
|
+
- `src/core/`: Core plugin system (Plugin, PluginManager, HookRegistry, tokens, ChouxModule)
|
|
81
121
|
- `src/decorators/`: Hook decorator and registration utilities
|
|
82
122
|
- `src/lib/functions/`: Helper functions for hooks and plugins
|
|
83
123
|
- `src/lib/types/`: Shared type definitions
|
|
84
|
-
- `plugins/`: Example and user plugins
|
|
85
124
|
|
|
86
125
|
## License
|
|
87
126
|
|
|
88
127
|
MIT
|
|
128
|
+
|
|
89
129
|
## What's Already Great ✅
|
|
90
130
|
|
|
91
|
-
- **Core Architecture**:
|
|
131
|
+
- **Core Architecture**: Deep integration with `@kanian77/tject` for robust DI
|
|
92
132
|
- **Lifecycle Management**: Load, init, destroy with proper ordering
|
|
93
133
|
- **Hook System**: Both decorators and manual registration
|
|
94
|
-
- **
|
|
95
|
-
- **Type Safety**: Full TypeScript support with tokens
|
|
96
|
-
- **Documentation**: Clear structure and examples
|
|
134
|
+
- **Simplicity**: Direct plugin loading without file system complexity
|
|
97
135
|
|
|
98
136
|
## Areas for Enhancement 🔧
|
|
99
137
|
|
|
100
138
|
### 1. **Plugin Configuration System**
|
|
139
|
+
|
|
101
140
|
```typescript
|
|
102
141
|
// src/core/pluginConfig.ts
|
|
103
142
|
export interface PluginConfig {
|
|
@@ -107,11 +146,12 @@ export interface PluginConfig {
|
|
|
107
146
|
};
|
|
108
147
|
}
|
|
109
148
|
|
|
110
|
-
// In
|
|
111
|
-
async
|
|
149
|
+
// In PluginManager
|
|
150
|
+
async initializePlugins(plugins: PluginModule[], config?: PluginConfig): Promise<void>
|
|
112
151
|
```
|
|
113
152
|
|
|
114
153
|
### 2. **Plugin Validation & Health Checks**
|
|
154
|
+
|
|
115
155
|
```typescript
|
|
116
156
|
// Add to Plugin base class
|
|
117
157
|
async healthCheck?(): Promise<{ healthy: boolean; message?: string }>;
|
|
@@ -126,23 +166,15 @@ export function validatePluginMetadata(metadata: PluginMetadata): string[] {
|
|
|
126
166
|
```
|
|
127
167
|
|
|
128
168
|
### 3. **Error Handling & Recovery**
|
|
169
|
+
|
|
129
170
|
```typescript
|
|
130
|
-
// Enhanced error handling in
|
|
171
|
+
// Enhanced error handling in PluginManager
|
|
131
172
|
interface PluginLoadError {
|
|
132
|
-
|
|
173
|
+
pluginName: string;
|
|
133
174
|
error: Error;
|
|
134
|
-
phase: '
|
|
175
|
+
phase: 'load' | 'init';
|
|
135
176
|
}
|
|
136
177
|
|
|
137
178
|
// Add retry mechanisms for failed plugins
|
|
138
179
|
async retryFailedPlugin(pluginName: string): Promise<void>
|
|
139
180
|
```
|
|
140
|
-
|
|
141
|
-
### 4. **Plugin Hot Reloading** (Development)
|
|
142
|
-
```typescript
|
|
143
|
-
// src/core/pluginWatcher.ts
|
|
144
|
-
export class PluginWatcher {
|
|
145
|
-
async watchForChanges(pluginsDir: string): Promise<void>;
|
|
146
|
-
async reloadPlugin(pluginName: string): Promise<void>;
|
|
147
|
-
}
|
|
148
|
-
```
|
package/bun.lock
CHANGED
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
"": {
|
|
5
5
|
"name": "@kanian77/choux",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@kanian77/
|
|
7
|
+
"@kanian77/tject": "^1.2.1",
|
|
8
|
+
"reflect-metadata": "^0.2.2",
|
|
8
9
|
},
|
|
9
10
|
"devDependencies": {
|
|
10
11
|
"@types/bun": "latest",
|
|
12
|
+
"typescript": "~5.7.2",
|
|
11
13
|
},
|
|
12
14
|
"peerDependencies": {
|
|
13
15
|
"typescript": "^5",
|
|
@@ -15,7 +17,7 @@
|
|
|
15
17
|
},
|
|
16
18
|
},
|
|
17
19
|
"packages": {
|
|
18
|
-
"@kanian77/
|
|
20
|
+
"@kanian77/tject": ["@kanian77/tject@1.2.1", "", { "dependencies": { "@types/bun": "^1.2.4" } }, "sha512-fczkkGYTclUK95opNKTLdOJgmLDp/zavlmfz3lP5IN94OrCg1Nlt7xcz9oNiNEmq4q+pMfcv3/9XEaUzb2bdTw=="],
|
|
19
21
|
|
|
20
22
|
"@types/bun": ["@types/bun@1.2.19", "", { "dependencies": { "bun-types": "1.2.19" } }, "sha512-d9ZCmrH3CJ2uYKXQIUuZ/pUnTqIvLDS0SK7pFmbx8ma+ziH/FRMoAq5bYpRG7y+w1gl+HgyNZbtqgMq4W4e2Lg=="],
|
|
21
23
|
|
|
@@ -29,7 +31,7 @@
|
|
|
29
31
|
|
|
30
32
|
"reflect-metadata": ["reflect-metadata@0.2.2", "", {}, "sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q=="],
|
|
31
33
|
|
|
32
|
-
"typescript": ["typescript@5.
|
|
34
|
+
"typescript": ["typescript@5.7.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw=="],
|
|
33
35
|
|
|
34
36
|
"undici-types": ["undici-types@7.8.0", "", {}, "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw=="],
|
|
35
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChouxModule.d.ts","sourceRoot":"","sources":["../../src/core/ChouxModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ChouxModule.d.ts","sourceRoot":"","sources":["../../src/core/ChouxModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAKzC,eAAO,MAAM,WAAW,QAWtB,CAAC"}
|
package/dist/core/ChouxModule.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Module } from '@kanian77/
|
|
1
|
+
import { Module } from '@kanian77/tject';
|
|
2
2
|
import { HookRegistry } from './HookRegistry';
|
|
3
3
|
import { PluginManager } from './PluginManager';
|
|
4
4
|
import { HOOK_REGISTRY_TOKEN, PLUGIN_MANAGER_TOKEN } from '../lib/types/tokens';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChouxModule.js","sourceRoot":"","sources":["../../src/core/ChouxModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ChouxModule.js","sourceRoot":"","sources":["../../src/core/ChouxModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhF,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,MAAM,CAAC;IACpC,SAAS,EAAE;QACT;YACE,OAAO,EAAE,mBAAmB;YAC5B,QAAQ,EAAE,YAAY;SACvB;QACD;YACE,OAAO,EAAE,oBAAoB;YAC7B,QAAQ,EAAE,aAAa;SACxB;KACF;CACF,CAAC,CAAC"}
|
|
@@ -1,69 +1,131 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
27
|
+
};
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
6
34
|
};
|
|
7
|
-
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
45
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
46
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
47
|
+
};
|
|
48
|
+
import { Service } from '@kanian77/tject';
|
|
8
49
|
import { HOOK_REGISTRY_TOKEN } from '../lib/types/tokens';
|
|
9
50
|
/**
|
|
10
51
|
* Registry for application hooks.
|
|
11
52
|
*/
|
|
12
|
-
let HookRegistry =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* @param name The name of the hook to trigger.
|
|
26
|
-
* @param args Arguments to pass to the hook handlers.
|
|
27
|
-
*/
|
|
28
|
-
async trigger(name, ...args) {
|
|
29
|
-
const fns = this.hooks.get(name) || [];
|
|
30
|
-
for (const fn of fns) {
|
|
31
|
-
await fn(...args);
|
|
53
|
+
let HookRegistry = (() => {
|
|
54
|
+
let _classDecorators = [Service({ token: HOOK_REGISTRY_TOKEN })];
|
|
55
|
+
let _classDescriptor;
|
|
56
|
+
let _classExtraInitializers = [];
|
|
57
|
+
let _classThis;
|
|
58
|
+
var HookRegistry = _classThis = class {
|
|
59
|
+
constructor() {
|
|
60
|
+
Object.defineProperty(this, "hooks", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
configurable: true,
|
|
63
|
+
writable: true,
|
|
64
|
+
value: new Map()
|
|
65
|
+
});
|
|
32
66
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (!fn) {
|
|
42
|
-
this.hooks.delete(name);
|
|
43
|
-
return;
|
|
67
|
+
/**
|
|
68
|
+
* Register a hook handler.
|
|
69
|
+
* @param name The name of the hook to register the function for.
|
|
70
|
+
* @param fn The hook handler function.
|
|
71
|
+
*/
|
|
72
|
+
register(name, fn) {
|
|
73
|
+
const list = this.hooks.get(name) || [];
|
|
74
|
+
this.hooks.set(name, [...list, fn]);
|
|
44
75
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Trigger a hook, calling all registered handlers.
|
|
78
|
+
* @param name The name of the hook to trigger.
|
|
79
|
+
* @param args Arguments to pass to the hook handlers.
|
|
80
|
+
*/
|
|
81
|
+
trigger(name, ...args) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
const fns = this.hooks.get(name) || [];
|
|
84
|
+
for (const fn of fns) {
|
|
85
|
+
yield fn(...args);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Unregister a hook handler.
|
|
91
|
+
* If no function is provided, all handlers for the hook will be removed.
|
|
92
|
+
* @param name The name of the hook to unregister from.
|
|
93
|
+
* @param fn Optional specific handler to remove.
|
|
94
|
+
*/
|
|
95
|
+
unregister(name, fn) {
|
|
96
|
+
if (!fn) {
|
|
97
|
+
this.hooks.delete(name);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const list = this.hooks.get(name) || [];
|
|
101
|
+
const filtered = list.filter((registeredFn) => registeredFn !== fn);
|
|
102
|
+
this.hooks.set(name, filtered);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Get all registered handlers for a specific hook.
|
|
106
|
+
* @param name The name of the hook to retrieve handlers for.
|
|
107
|
+
* @returns An array of hook handler functions.
|
|
108
|
+
*/
|
|
109
|
+
getHooks(name) {
|
|
110
|
+
return this.hooks.get(name) || [];
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Clear all registered hooks.
|
|
114
|
+
*/
|
|
115
|
+
clear() {
|
|
116
|
+
this.hooks.clear();
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
__setFunctionName(_classThis, "HookRegistry");
|
|
120
|
+
(() => {
|
|
121
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
122
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
123
|
+
HookRegistry = _classThis = _classDescriptor.value;
|
|
124
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
125
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
126
|
+
})();
|
|
127
|
+
return HookRegistry = _classThis;
|
|
128
|
+
})();
|
|
67
129
|
export { HookRegistry };
|
|
68
130
|
// Standard lifecycle hooks
|
|
69
131
|
export const LIFECYCLE_HOOKS = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HookRegistry.js","sourceRoot":"","sources":["../../src/core/HookRegistry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HookRegistry.js","sourceRoot":"","sources":["../../src/core/HookRegistry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;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I,EAAE,QAAQ,CAAC,CAAC;QACjC,CAAC;QAED;;;;WAIG;QACH,QAAQ,CAAC,IAAY;YACnB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACpC,CAAC;QAED;;WAEG;QACH,KAAK;YACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC;;;;;QAxDH,6KAyDC;;;QAzDY,uDAAY;;;;SAAZ,YAAY;AA2DzB,2BAA2B;AAC3B,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,kBAAkB,EAAE,yBAAyB;IAC7C,iBAAiB,EAAE,wBAAwB;IAC3C,kBAAkB,EAAE,yBAAyB;IAC7C,iBAAiB,EAAE,wBAAwB;IAC3C,qBAAqB,EAAE,4BAA4B;IACnD,oBAAoB,EAAE,2BAA2B;IACjD,iBAAiB,EAAE,wBAAwB;IAC3C,oBAAoB,EAAE,2BAA2B;CACzC,CAAC"}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { describe, it, expect, beforeEach } from 'bun:test';
|
|
2
11
|
import { HookRegistry } from './HookRegistry';
|
|
3
12
|
describe('HookRegistry', () => {
|
|
@@ -5,16 +14,16 @@ describe('HookRegistry', () => {
|
|
|
5
14
|
beforeEach(() => {
|
|
6
15
|
registry = new HookRegistry();
|
|
7
16
|
});
|
|
8
|
-
it('registers and triggers a hook',
|
|
17
|
+
it('registers and triggers a hook', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
9
18
|
let called = false;
|
|
10
19
|
const fn = () => {
|
|
11
20
|
called = true;
|
|
12
21
|
};
|
|
13
22
|
registry.register('test:hook', fn);
|
|
14
|
-
|
|
23
|
+
yield registry.trigger('test:hook');
|
|
15
24
|
expect(called).toBe(true);
|
|
16
|
-
});
|
|
17
|
-
it('registers and triggers a hook with payload',
|
|
25
|
+
}));
|
|
26
|
+
it('registers and triggers a hook with payload', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
27
|
let called = false;
|
|
19
28
|
const payload = { test: 'data' };
|
|
20
29
|
const fn = (payload) => {
|
|
@@ -22,29 +31,29 @@ describe('HookRegistry', () => {
|
|
|
22
31
|
expect(payload).toEqual({ test: 'data' });
|
|
23
32
|
};
|
|
24
33
|
registry.register('test:hook', fn);
|
|
25
|
-
|
|
34
|
+
yield registry.trigger('test:hook', payload);
|
|
26
35
|
expect(called).toBe(true);
|
|
27
|
-
});
|
|
28
|
-
it('unregisters a specific hook handler',
|
|
36
|
+
}));
|
|
37
|
+
it('unregisters a specific hook handler', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
38
|
let called = false;
|
|
30
39
|
const fn = () => {
|
|
31
40
|
called = true;
|
|
32
41
|
};
|
|
33
42
|
registry.register('test:hook', fn);
|
|
34
43
|
registry.unregister('test:hook', fn);
|
|
35
|
-
|
|
44
|
+
yield registry.trigger('test:hook');
|
|
36
45
|
expect(called).toBe(false);
|
|
37
|
-
});
|
|
38
|
-
it('unregisters all handlers for a hook',
|
|
46
|
+
}));
|
|
47
|
+
it('unregisters all handlers for a hook', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
48
|
let called = false;
|
|
40
49
|
const fn = () => {
|
|
41
50
|
called = true;
|
|
42
51
|
};
|
|
43
52
|
registry.register('test:hook', fn);
|
|
44
53
|
registry.unregister('test:hook');
|
|
45
|
-
|
|
54
|
+
yield registry.trigger('test:hook');
|
|
46
55
|
expect(called).toBe(false);
|
|
47
|
-
});
|
|
56
|
+
}));
|
|
48
57
|
it('getHooks returns all registered handlers', () => {
|
|
49
58
|
const fn1 = () => { };
|
|
50
59
|
const fn2 = () => { };
|
|
@@ -61,18 +70,18 @@ describe('HookRegistry', () => {
|
|
|
61
70
|
registry.clear();
|
|
62
71
|
expect(registry.getHooks('test:hook').length).toBe(0);
|
|
63
72
|
});
|
|
64
|
-
it('trigger calls all registered async handlers',
|
|
73
|
+
it('trigger calls all registered async handlers', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
74
|
let result = '';
|
|
66
|
-
const fn1 =
|
|
75
|
+
const fn1 = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
76
|
result += 'a';
|
|
68
|
-
};
|
|
69
|
-
const fn2 =
|
|
77
|
+
});
|
|
78
|
+
const fn2 = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
79
|
result += 'b';
|
|
71
|
-
};
|
|
80
|
+
});
|
|
72
81
|
registry.register('test:hook', fn1);
|
|
73
82
|
registry.register('test:hook', fn2);
|
|
74
|
-
|
|
83
|
+
yield registry.trigger('test:hook');
|
|
75
84
|
expect(result).toBe('ab');
|
|
76
|
-
});
|
|
85
|
+
}));
|
|
77
86
|
});
|
|
78
87
|
//# sourceMappingURL=HookRegistry.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HookRegistry.spec.js","sourceRoot":"","sources":["../../src/core/HookRegistry.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,IAAI,QAAsB,CAAC;IAE3B,UAAU,CAAC,GAAG,EAAE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,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/core/Plugin.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Module } from '@kanian77/simple-di';
|
|
2
1
|
import type { PluginMetadata } from '../lib/types';
|
|
3
|
-
export declare abstract class Plugin
|
|
2
|
+
export declare abstract class Plugin {
|
|
4
3
|
abstract readonly metadata: PluginMetadata;
|
|
5
4
|
/**
|
|
6
5
|
* Called when plugin is loaded but before dependencies are resolved
|
|
@@ -14,9 +13,5 @@ export declare abstract class Plugin extends Module {
|
|
|
14
13
|
* Called when plugin is being unloaded
|
|
15
14
|
*/
|
|
16
15
|
onDestroy?(): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* Register custom hooks specific to this plugin
|
|
19
|
-
*/
|
|
20
|
-
protected registerCustomHooks?(): void;
|
|
21
16
|
}
|
|
22
17
|
//# sourceMappingURL=Plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/core/Plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/core/Plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,8BAAsB,MAAM;IAC1B,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAE3C;;OAEG;IACG,MAAM,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;OAEG;IACG,MAAM,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;OAEG;IACG,SAAS,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAClC"}
|
package/dist/core/Plugin.js
CHANGED
package/dist/core/Plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.js","sourceRoot":"","sources":["../../src/core/Plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Plugin.js","sourceRoot":"","sources":["../../src/core/Plugin.ts"],"names":[],"mappings":"AAGA,MAAM,OAAgB,MAAM;CAiB3B"}
|