@kanian77/choux 0.1.2 → 0.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanian77/choux",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "A simple plugin framework for TypeScript.",
5
5
  "author": {
6
6
  "name": "Patrick Assoa Adou",
@@ -28,12 +28,14 @@
28
28
  "prepublishOnly": "bun run clean && bun run build"
29
29
  },
30
30
  "devDependencies": {
31
- "@types/bun": "latest"
31
+ "@types/bun": "latest",
32
+ "typescript": "~5.7.2"
32
33
  },
33
34
  "peerDependencies": {
34
35
  "typescript": "^5"
35
36
  },
36
37
  "dependencies": {
37
- "@kanian77/simple-di": "^0.1.2"
38
+ "@kanian77/simple-di": "^0.1.2",
39
+ "reflect-metadata": "^0.2.2"
38
40
  }
39
41
  }
@@ -0,0 +1,20 @@
1
+ import { Plugin } from '../core/Plugin';
2
+ export default class ExamplePlugin extends Plugin {
3
+ readonly metadata: {
4
+ name: string;
5
+ version: string;
6
+ description: string;
7
+ dependencies: never[];
8
+ };
9
+ constructor();
10
+ onLoad(): Promise<void>;
11
+ onInit(): Promise<void>;
12
+ onDestroy(): Promise<void>;
13
+ protected registerCustomHooks(): void;
14
+ private handleExampleEvent;
15
+ private onApplicationStart;
16
+ private onBeforePluginLoad;
17
+ private registerAdditionalHooks;
18
+ private handleDynamicHook;
19
+ }
20
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["module.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAI/C,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,MAAM;IAC/C,QAAQ,CAAC,QAAQ;;;;;MAKf;;IAgBa,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAOvB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;cAItB,mBAAmB,IAAI,IAAI;YAQhC,kBAAkB;YAKlB,kBAAkB;YAKlB,kBAAkB;IAKhC,OAAO,CAAC,uBAAuB;YAOjB,iBAAiB;CAGhC"}
@@ -0,0 +1,90 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { ExampleService } from './services';
11
+ import { EXAMPLE_SERVICE_TOKEN } from './tokens';
12
+ import { Hook } from '../../src/decorators/hookDecorator';
13
+ import { inject } from '@kanian77/simple-di';
14
+ import { Plugin } from '../../src/core/Plugin';
15
+ import { HOOK_REGISTRY_TOKEN } from '../../src/lib/types/tokens';
16
+ export default class ExamplePlugin extends Plugin {
17
+ constructor() {
18
+ // Call parent Module constructor with plugin configuration
19
+ super({
20
+ providers: [
21
+ {
22
+ provide: EXAMPLE_SERVICE_TOKEN,
23
+ useClass: ExampleService,
24
+ },
25
+ ],
26
+ // Can also import other modules if needed
27
+ // imports: [SomeOtherModule],
28
+ });
29
+ this.metadata = {
30
+ name: 'example-plugin',
31
+ version: '1.0.0',
32
+ description: 'An example plugin',
33
+ dependencies: [], // other plugin names this depends on
34
+ };
35
+ }
36
+ async onLoad() {
37
+ console.log('ExamplePlugin loading...');
38
+ }
39
+ async onInit() {
40
+ console.log('ExamplePlugin initialized!');
41
+ // Additional manual hook registration if needed
42
+ this.registerAdditionalHooks();
43
+ }
44
+ async onDestroy() {
45
+ console.log('ExamplePlugin destroyed!');
46
+ }
47
+ registerCustomHooks() {
48
+ // Define custom hooks that this plugin provides
49
+ // Other plugins can listen to these hooks
50
+ console.log('Registering custom hooks for ExamplePlugin');
51
+ }
52
+ // These methods will be automatically registered as hook handlers
53
+ async handleExampleEvent(data) {
54
+ console.log('Handling example event via decorator:', data);
55
+ }
56
+ async onApplicationStart() {
57
+ console.log('ExamplePlugin responding to application start via decorator');
58
+ }
59
+ async onBeforePluginLoad(pluginPath) {
60
+ console.log('Another plugin is about to load:', pluginPath);
61
+ }
62
+ // Manual hook registration for dynamic scenarios
63
+ registerAdditionalHooks() {
64
+ const hookRegistry = inject(HOOK_REGISTRY_TOKEN);
65
+ // Register additional hooks manually if needed
66
+ hookRegistry.register('dynamic:custom-hook', this.handleDynamicHook.bind(this));
67
+ }
68
+ async handleDynamicHook(data) {
69
+ console.log('Handling dynamic hook:', data);
70
+ }
71
+ }
72
+ __decorate([
73
+ Hook('custom:example-event'),
74
+ __metadata("design:type", Function),
75
+ __metadata("design:paramtypes", [Object]),
76
+ __metadata("design:returntype", Promise)
77
+ ], ExamplePlugin.prototype, "handleExampleEvent", null);
78
+ __decorate([
79
+ Hook('core:application-start'),
80
+ __metadata("design:type", Function),
81
+ __metadata("design:paramtypes", []),
82
+ __metadata("design:returntype", Promise)
83
+ ], ExamplePlugin.prototype, "onApplicationStart", null);
84
+ __decorate([
85
+ Hook('core:before-plugin-load'),
86
+ __metadata("design:type", Function),
87
+ __metadata("design:paramtypes", [String]),
88
+ __metadata("design:returntype", Promise)
89
+ ], ExamplePlugin.prototype, "onBeforePluginLoad", null);
90
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["module.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,cAAc,EAAE,MAAM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,AAAN,KAAK,CAAC,kBAAkB;QAC9B,OAAO,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;IAC7E,CAAC;IAGa,AAAN,KAAK,CAAC,kBAAkB,CAAC,UAAkB;QACjD,OAAO,CAAC,GAAG,CAAC,kCAAkC,EAAE,UAAU,CAAC,CAAC;IAC9D,CAAC;IAED,iDAAiD;IACzC,uBAAuB;QAC7B,MAAM,YAAY,GAAG,MAAM,CAAgB,mBAAmB,CAAC,CAAC;QAEhE,+CAA+C;QAC/C,YAAY,CAAC,QAAQ,CAAC,qBAAqB,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAClF,CAAC;IAEO,KAAK,CAAC,iBAAiB,CAAC,IAAS;QACvC,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;CACF;AAzBe;IADb,IAAI,CAAC,sBAAsB,CAAC;;;;uDAG5B;AAGa;IADb,IAAI,CAAC,wBAAwB,CAAC;;;;uDAG9B;AAGa;IADb,IAAI,CAAC,yBAAyB,CAAC;;;;uDAG/B"}
@@ -1,11 +1,11 @@
1
1
  import { Module } from '@kanian77/simple-di';
2
2
  import { ExampleService } from './services';
3
3
  import { EXAMPLE_SERVICE_TOKEN } from './tokens';
4
- import { Hook } from '../../src/decorators/hookDecorator';
4
+ import { Hook } from '../decorators/hookDecorator';
5
5
  import { inject } from '@kanian77/simple-di';
6
- import { Plugin } from '../../src/core/Plugin';
6
+ import { Plugin } from '../core/Plugin';
7
7
  import type { IHookRegistry } from '../../src/lib/types';
8
- import { HOOK_REGISTRY_TOKEN } from '../../src/lib/types/tokens';
8
+ import { HOOK_REGISTRY_TOKEN } from '../lib/types/tokens';
9
9
 
10
10
  export default class ExamplePlugin extends Plugin {
11
11
  readonly metadata = {
@@ -0,0 +1,9 @@
1
+ export interface IExampleService {
2
+ doSomething(): void;
3
+ }
4
+ export declare class ExampleService implements IExampleService {
5
+ private hookRegistry;
6
+ constructor();
7
+ doSomething(): void;
8
+ }
9
+ //# sourceMappingURL=services.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.d.ts","sourceRoot":"","sources":["services.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,eAAe;IAC9B,WAAW,IAAI,IAAI,CAAC;CACrB;AAED,qBACa,cAAe,YAAW,eAAe;IACpD,OAAO,CAAC,YAAY,CAAgB;;IAKpC,WAAW,IAAI,IAAI;CAKpB"}
@@ -0,0 +1,28 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Service, inject } from '@kanian77/simple-di';
11
+ import { EXAMPLE_SERVICE_TOKEN } from './tokens';
12
+ import { HOOK_REGISTRY_TOKEN } from '../../src/lib/types/tokens';
13
+ let ExampleService = class ExampleService {
14
+ constructor() {
15
+ this.hookRegistry = inject(HOOK_REGISTRY_TOKEN);
16
+ }
17
+ doSomething() {
18
+ console.log('ExampleService doing something...');
19
+ // Can trigger custom hooks
20
+ this.hookRegistry.trigger('example:something-done', { data: 'example' });
21
+ }
22
+ };
23
+ ExampleService = __decorate([
24
+ Service({ token: EXAMPLE_SERVICE_TOKEN }),
25
+ __metadata("design:paramtypes", [])
26
+ ], ExampleService);
27
+ export { ExampleService };
28
+ //# sourceMappingURL=services.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.js","sourceRoot":"","sources":["services.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAQ1D,IAAM,cAAc,GAApB,MAAM,cAAc;IAEzB;QACE,IAAI,CAAC,YAAY,GAAG,MAAM,CAAgB,mBAAmB,CAAC,CAAC;IACjE,CAAC;IAED,WAAW;QACT,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;QACjD,2BAA2B;QAC3B,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,wBAAwB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAC3E,CAAC;CACF,CAAA;AAXY,cAAc;IAD1B,OAAO,CAAC,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC;;GAC7B,cAAc,CAW1B"}
@@ -1,6 +1,6 @@
1
1
  import { Service, Inject, inject } from '@kanian77/simple-di';
2
2
  import { EXAMPLE_SERVICE_TOKEN } from './tokens';
3
- import { HOOK_REGISTRY_TOKEN } from '../../src/lib/types/tokens';
3
+ import { HOOK_REGISTRY_TOKEN } from '../lib/types/tokens';
4
4
  import type { IHookRegistry } from '../../src/lib/types';
5
5
 
6
6
  export interface IExampleService {
@@ -0,0 +1,2 @@
1
+ export declare const EXAMPLE_SERVICE_TOKEN: unique symbol;
2
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["tokens.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,eAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const EXAMPLE_SERVICE_TOKEN = Symbol('ExampleService');
2
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["tokens.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { inject } from '@kanian77/simple-di';
2
- import { ExampleService } from '../../../../../plugins/example-plugin/services';
2
+ import { ExampleService } from '../../../../example-plugin/services';
3
3
  import { Plugin } from '../../../../core';
4
4
  import { Hook } from '../../../../decorators';
5
5
  import type { IHookRegistry } from '../../../types';
@@ -1,5 +1,5 @@
1
1
  import { inject } from '@kanian77/simple-di';
2
- import { ExampleService } from '../../../../../plugins/example-plugin/services';
2
+ import { ExampleService } from '../../../../example-plugin/services';
3
3
  import { Plugin } from '../../../../core';
4
4
  import { Hook } from '../../../../decorators';
5
5
  import type { IHookRegistry } from '../../../types';
package/tsconfig.json CHANGED
@@ -1,35 +1,22 @@
1
1
  {
2
2
  "compilerOptions": {
3
- // Environment setup & latest features
4
- "lib": ["ESNext"],
5
- "target": "ESNext",
6
- "module": "Preserve",
7
- "moduleDetection": "force",
8
- "jsx": "react-jsx",
9
- "allowJs": true,
10
- "declaration": true,
11
- "declarationMap": true,
12
- "emitDeclarationOnly": false,
13
3
  "outDir": "dist",
14
- // Bundler mode
4
+ "rootDir": "src",
5
+ "experimentalDecorators": true,
6
+ "emitDecoratorMetadata": true,
7
+ "target": "ESNext",
8
+ "module": "preserve",
15
9
  "moduleResolution": "bundler",
16
- "allowImportingTsExtensions": true,
17
- "verbatimModuleSyntax": true,
18
- "noEmit": true,
19
10
 
20
- // Best practices
11
+ "esModuleInterop": true,
21
12
  "strict": true,
22
13
  "skipLibCheck": true,
23
- "noFallthroughCasesInSwitch": true,
24
- "noUncheckedIndexedAccess": true,
25
- "noImplicitOverride": true,
26
-
27
- // Some stricter flags (disabled by default)
28
- "noUnusedLocals": false,
29
- "noUnusedParameters": false,
30
- "noPropertyAccessFromIndexSignature": false,
31
-
32
- "experimentalDecorators": true,
33
- "emitDecoratorMetadata": true
34
- }
14
+ "forceConsistentCasingInFileNames": true,
15
+ "resolveJsonModule": true,
16
+ "emitDeclarationOnly": false,
17
+ "declaration": true,
18
+ "declarationMap": true, // Optional: creates sourcemap for .d.ts files
19
+ "sourceMap": true // Optional: creates sourcemaps for .js files
20
+ },
21
+ "include": ["src/**/*"]
35
22
  }
File without changes