@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
|
@@ -1,17 +1,55 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
+
var useValue = arguments.length > 2;
|
|
3
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
+
}
|
|
6
|
+
return useValue ? value : void 0;
|
|
6
7
|
};
|
|
7
|
-
var
|
|
8
|
-
if (
|
|
8
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
+
var _, done = false;
|
|
14
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
+
var context = {};
|
|
16
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
+
if (kind === "accessor") {
|
|
21
|
+
if (result === void 0) continue;
|
|
22
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
+
}
|
|
27
|
+
else if (_ = accept(result)) {
|
|
28
|
+
if (kind === "field") initializers.unshift(_);
|
|
29
|
+
else descriptor[key] = _;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
+
done = true;
|
|
34
|
+
};
|
|
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 });
|
|
9
47
|
};
|
|
10
48
|
import 'reflect-metadata';
|
|
11
49
|
import { describe, it, expect, beforeAll } from 'bun:test';
|
|
12
50
|
import { HookRegistry } from '../core';
|
|
13
51
|
import { Hook } from './hookDecorator';
|
|
14
|
-
import { bootstrap, inject, Module } from '@kanian77/
|
|
52
|
+
import { bootstrap, inject, Module } from '@kanian77/tject';
|
|
15
53
|
import { HOOK_REGISTRY_TOKEN } from '../lib/types';
|
|
16
54
|
import { EnableHooks } from './enableHooksDecorator';
|
|
17
55
|
describe('hook decorators', () => {
|
|
@@ -27,25 +65,69 @@ describe('hook decorators', () => {
|
|
|
27
65
|
});
|
|
28
66
|
bootstrap(RegistryModule);
|
|
29
67
|
});
|
|
30
|
-
it('registers a hook',
|
|
68
|
+
it('registers a hook', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
69
|
let called = false;
|
|
32
|
-
let TestClass =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
70
|
+
let TestClass = (() => {
|
|
71
|
+
let _classDecorators = [EnableHooks];
|
|
72
|
+
let _classDescriptor;
|
|
73
|
+
let _classExtraInitializers = [];
|
|
74
|
+
let _classThis;
|
|
75
|
+
let _instanceExtraInitializers = [];
|
|
76
|
+
let _testMethod_decorators;
|
|
77
|
+
var TestClass = _classThis = class {
|
|
78
|
+
testMethod() {
|
|
79
|
+
called = true;
|
|
80
|
+
}
|
|
81
|
+
constructor() {
|
|
82
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
__setFunctionName(_classThis, "TestClass");
|
|
86
|
+
(() => {
|
|
87
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
88
|
+
_testMethod_decorators = [Hook('test:hook')];
|
|
89
|
+
__esDecorate(_classThis, null, _testMethod_decorators, { kind: "method", name: "testMethod", static: false, private: false, access: { has: obj => "testMethod" in obj, get: obj => obj.testMethod }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
90
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
91
|
+
TestClass = _classThis = _classDescriptor.value;
|
|
92
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
93
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
94
|
+
})();
|
|
95
|
+
return TestClass = _classThis;
|
|
96
|
+
})();
|
|
46
97
|
const instance = new TestClass();
|
|
47
|
-
|
|
98
|
+
yield inject(HOOK_REGISTRY_TOKEN).trigger('test:hook');
|
|
48
99
|
expect(called).toBe(true);
|
|
49
|
-
});
|
|
100
|
+
}));
|
|
101
|
+
it('registers a hook on static method', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
+
let called = false;
|
|
103
|
+
let TestClass = (() => {
|
|
104
|
+
let _classDecorators = [EnableHooks];
|
|
105
|
+
let _classDescriptor;
|
|
106
|
+
let _classExtraInitializers = [];
|
|
107
|
+
let _classThis;
|
|
108
|
+
let _staticExtraInitializers = [];
|
|
109
|
+
let _static_testMethod_decorators;
|
|
110
|
+
var TestClass = _classThis = class {
|
|
111
|
+
static testMethod() {
|
|
112
|
+
called = true;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
__setFunctionName(_classThis, "TestClass");
|
|
116
|
+
(() => {
|
|
117
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
118
|
+
_static_testMethod_decorators = [Hook('test:hook')];
|
|
119
|
+
__esDecorate(_classThis, null, _static_testMethod_decorators, { kind: "method", name: "testMethod", static: true, private: false, access: { has: obj => "testMethod" in obj, get: obj => obj.testMethod }, metadata: _metadata }, null, _staticExtraInitializers);
|
|
120
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
121
|
+
TestClass = _classThis = _classDescriptor.value;
|
|
122
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
123
|
+
__runInitializers(_classThis, _staticExtraInitializers);
|
|
124
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
125
|
+
})();
|
|
126
|
+
return TestClass = _classThis;
|
|
127
|
+
})();
|
|
128
|
+
const instance = new TestClass();
|
|
129
|
+
yield inject(HOOK_REGISTRY_TOKEN).trigger('test:hook');
|
|
130
|
+
expect(called).toBe(true);
|
|
131
|
+
}));
|
|
50
132
|
});
|
|
51
133
|
//# sourceMappingURL=hookDecorator.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hookDecorator.spec.js","sourceRoot":"","sources":["../../src/decorators/hookDecorator.spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hookDecorator.spec.js","sourceRoot":"","sources":["../../src/decorators/hookDecorator.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAI,QAAsB,CAAC;IAE3B,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,cAAc,GAAG,IAAI,MAAM,CAAC;YAChC,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,mBAAmB;oBAC5B,QAAQ,EAAE,YAAY;iBACvB;aACF;SACF,CAAC,CAAC;QACH,SAAS,CAAC,cAAc,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kBAAkB,EAAE,GAAS,EAAE;QAChC,IAAI,MAAM,GAAG,KAAK,CAAC;YAEb,SAAS;oCADd,WAAW;;;;;;;gBAGV,UAAU;oBACR,MAAM,GAAG,IAAI,CAAC;gBAChB,CAAC;;oBAJG,mDAAS;;;;;;0CACZ,IAAI,CAAC,WAAW,CAAC;gBAClB,uLAAA,UAAU,6DAET;gBAJH,6KAKC;;;gBALK,uDAAS;;;;QAMf,MAAM,QAAQ,GAAG,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,MAAM,CAAe,mBAAmB,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACrE,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAA,CAAC,CAAC;IACH,EAAE,CAAC,mCAAmC,EAAE,GAAS,EAAE;QACjD,IAAI,MAAM,GAAG,KAAK,CAAC;YAEb,SAAS;oCADd,WAAW;;;;;;;gBAGV,MAAM,CAAC,UAAU;oBACf,MAAM,GAAG,IAAI,CAAC;gBAChB,CAAC;;;;;iDAHA,IAAI,CAAC,WAAW,CAAC;gBAClB,6LAAO,UAAU,2DAEhB;gBAJH,6KAKC;;;gBALK,uDAAS,CAAA;gBAAT,uDAAS;;;;QAMf,MAAM,QAAQ,GAAG,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,MAAM,CAAe,mBAAmB,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACrE,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/functions/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/functions/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerHookHandler.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/registerHookHandler.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"registerHookHandler.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/registerHookHandler.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB,aACpB,MAAM,WACP,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,SAIlD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerHookHandler.js","sourceRoot":"","sources":["../../../src/lib/functions/registerHookHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"registerHookHandler.js","sourceRoot":"","sources":["../../../src/lib/functions/registerHookHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,QAAgB,EAChB,OAAiD,EACjD,EAAE;IACF,MAAM,YAAY,GAAG,MAAM,CAAgB,mBAAmB,CAAC,CAAC;IAChE,YAAY,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerHooksForInstance.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/registerHooksForInstance.ts"],"names":[],"mappings":"AAKA,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"registerHooksForInstance.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/registerHooksForInstance.ts"],"names":[],"mappings":"AAKA,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI,CAuB5D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { inject } from
|
|
2
|
-
import { HOOK_METADATA_KEY, HOOK_REGISTRY_TOKEN } from
|
|
1
|
+
import { inject } from '@kanian77/tject';
|
|
2
|
+
import { HOOK_METADATA_KEY, HOOK_REGISTRY_TOKEN } from '../types/tokens';
|
|
3
3
|
export function registerHooksForInstance(instance) {
|
|
4
4
|
const constructor = instance.constructor;
|
|
5
5
|
const hookMetadata = constructor[HOOK_METADATA_KEY] || [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerHooksForInstance.js","sourceRoot":"","sources":["../../../src/lib/functions/registerHooksForInstance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"registerHooksForInstance.js","sourceRoot":"","sources":["../../../src/lib/functions/registerHooksForInstance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEzE,MAAM,UAAU,wBAAwB,CAAC,QAAa;IACpD,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC;IACzC,MAAM,YAAY,GAAoB,WAAW,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC;IAE3E,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,MAAM,CAAgB,mBAAmB,CAAC,CAAC;QAEhE,KAAK,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,YAAY,EAAE,CAAC;YACpD,MAAM,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;YACpC,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;gBACjC,YAAY,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CACV,mEAAmE,EACnE,KAAK,CACN,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerInstanceHooks.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/registerInstanceHooks.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"registerInstanceHooks.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/registerInstanceHooks.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB,aAAc,GAAG,KAAG,IA6BrD,CAAC"}
|
|
@@ -1,19 +1,28 @@
|
|
|
1
|
-
import { HOOK_METADATA_KEY } from
|
|
2
|
-
import { registerHookHandler } from
|
|
1
|
+
import { HOOK_METADATA_KEY } from '../types';
|
|
2
|
+
import { registerHookHandler } from './registerHookHandler';
|
|
3
3
|
export const registerInstanceHooks = (instance) => {
|
|
4
4
|
try {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
// Get the metadata
|
|
6
|
+
const hookMetadata = (instance.constructor[HOOK_METADATA_KEY] ||
|
|
7
|
+
[]);
|
|
8
|
+
for (const { hookName, methodName, isStatic } of hookMetadata) {
|
|
9
|
+
// Only register INSTANCE methods here
|
|
10
|
+
if (!isStatic) {
|
|
11
|
+
// Get method from the instance
|
|
12
|
+
const method = instance[methodName];
|
|
13
|
+
if (typeof method === 'function') {
|
|
14
|
+
const originalMethod = method.__original || method;
|
|
15
|
+
// Bind to the instance
|
|
16
|
+
registerHookHandler(hookName, originalMethod.bind(instance));
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
console.warn(`Instance @Hook method "${methodName}" not found on instance of ${instance.constructor.name}.`);
|
|
20
|
+
}
|
|
12
21
|
}
|
|
13
22
|
}
|
|
14
23
|
}
|
|
15
24
|
catch (error) {
|
|
16
|
-
console.warn(
|
|
25
|
+
console.warn(`Failed to register instance hooks for ${instance.constructor.name}:`, error);
|
|
17
26
|
}
|
|
18
27
|
};
|
|
19
28
|
//# sourceMappingURL=registerInstanceHooks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerInstanceHooks.js","sourceRoot":"","sources":["../../../src/lib/functions/registerInstanceHooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"registerInstanceHooks.js","sourceRoot":"","sources":["../../../src/lib/functions/registerInstanceHooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAiB,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,QAAa,EAAQ,EAAE;IAC3D,IAAI,CAAC;QACH,mBAAmB;QACnB,MAAM,YAAY,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,iBAAiB,CAAC;YAC3D,EAAE,CAAoB,CAAC;QAEzB,KAAK,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,YAAY,EAAE,CAAC;YAC9D,sCAAsC;YACtC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,+BAA+B;gBAC/B,MAAM,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;gBAEpC,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;oBACjC,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC;oBACnD,uBAAuB;oBACvB,mBAAmB,CAAC,QAAQ,EAAE,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAC/D,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,IAAI,CACV,0BAA0B,UAAU,8BAA8B,QAAQ,CAAC,WAAW,CAAC,IAAI,GAAG,CAC/F,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CACV,yCAAyC,QAAQ,CAAC,WAAW,CAAC,IAAI,GAAG,EACrE,KAAK,CACN,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerStaticHooks.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/registerStaticHooks.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,mBAAmB,gBAAiB,GAAG,KAAG,IAmCtD,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { HOOK_METADATA_KEY } from '../types';
|
|
2
|
+
import { registerHookHandler } from './registerHookHandler';
|
|
3
|
+
// A unique symbol to track if static hooks are already registered for a class
|
|
4
|
+
const STATIC_HOOKS_REGISTERED = Symbol.for('staticHooksRegistered');
|
|
5
|
+
export const registerStaticHooks = (constructor) => {
|
|
6
|
+
if (constructor[STATIC_HOOKS_REGISTERED]) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
// Get the metadata
|
|
11
|
+
const hookMetadata = (constructor[HOOK_METADATA_KEY] ||
|
|
12
|
+
[]);
|
|
13
|
+
for (const { hookName, methodName, isStatic } of hookMetadata) {
|
|
14
|
+
if (isStatic) {
|
|
15
|
+
const method = constructor[methodName];
|
|
16
|
+
if (typeof method === 'function') {
|
|
17
|
+
const originalMethod = method.__original || method;
|
|
18
|
+
registerHookHandler(hookName, originalMethod.bind(constructor));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
console.warn(`Static @Hook method "${methodName}" not found on class ${constructor.name}.`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(constructor, STATIC_HOOKS_REGISTERED, {
|
|
26
|
+
value: true,
|
|
27
|
+
configurable: false,
|
|
28
|
+
writable: false,
|
|
29
|
+
enumerable: false,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.warn(`Failed to register static hooks for ${constructor.name}:`, error);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=registerStaticHooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerStaticHooks.js","sourceRoot":"","sources":["../../../src/lib/functions/registerStaticHooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAiB,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,8EAA8E;AAC9E,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAEpE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,WAAgB,EAAQ,EAAE;IAC5D,IAAI,WAAW,CAAC,uBAAuB,CAAC,EAAE,CAAC;QACzC,OAAO;IACT,CAAC;IACD,IAAI,CAAC;QACH,mBAAmB;QACnB,MAAM,YAAY,GAAG,CAAC,WAAW,CAAC,iBAAiB,CAAC;YAClD,EAAE,CAAoB,CAAC;QAEzB,KAAK,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,YAAY,EAAE,CAAC;YAC9D,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;gBAEvC,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;oBACjC,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC;oBACnD,mBAAmB,CAAC,QAAQ,EAAE,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;gBAClE,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,IAAI,CACV,wBAAwB,UAAU,wBAAwB,WAAW,CAAC,IAAI,GAAG,CAC9E,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QACD,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,uBAAuB,EAAE;YAC1D,KAAK,EAAE,IAAI;YACX,YAAY,EAAE,KAAK;YACnB,QAAQ,EAAE,KAAK;YACf,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CACV,uCAAuC,WAAW,CAAC,IAAI,GAAG,EAC1D,KAAK,CACN,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import { Plugin } from '../../../../core';
|
|
2
|
+
import { PluginModule } from '../../../types/PluginModule';
|
|
3
|
+
import { ExampleServiceA } from '../../services';
|
|
2
4
|
export declare const PLUGIN_A_TOKEN = "PLUGIN_A_TOKEN";
|
|
3
5
|
export default class PluginA extends Plugin {
|
|
6
|
+
private exampleServiceA;
|
|
4
7
|
readonly metadata: {
|
|
5
8
|
name: string;
|
|
6
9
|
version: string;
|
|
7
10
|
description: string;
|
|
8
11
|
dependencies: never[];
|
|
9
12
|
};
|
|
10
|
-
constructor();
|
|
13
|
+
constructor(exampleServiceA: ExampleServiceA);
|
|
11
14
|
onLoad(): Promise<void>;
|
|
12
15
|
onInit(): Promise<void>;
|
|
13
16
|
onDestroy(): Promise<void>;
|
|
14
|
-
protected registerCustomHooks(): void;
|
|
15
17
|
private handleExampleEvent;
|
|
16
18
|
private onApplicationStart;
|
|
17
19
|
private onBeforePluginLoad;
|
|
18
20
|
private registerAdditionalHooks;
|
|
19
21
|
private handleDynamicHook;
|
|
20
22
|
}
|
|
23
|
+
export declare const PluginAModule: PluginModule;
|
|
21
24
|
//# sourceMappingURL=module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../../src/lib/test-related/plugins/plugin-a/module.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../../src/lib/test-related/plugins/plugin-a/module.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI1C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAEL,eAAe,EAEhB,MAAM,gBAAgB,CAAC;AAExB,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAG/C,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,MAAM;IAQ7B,OAAO,CAAC,eAAe;IAPnC,QAAQ,CAAC,QAAQ;;;;;MAKf;gBAEkB,eAAe,EAAE,eAAe;IAIrC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAOvB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;YAM3B,kBAAkB;YAKlB,kBAAkB;YAKlB,kBAAkB;IAIhC,OAAO,CAAC,uBAAuB;YAOjB,iBAAiB;CAIhC;AAED,eAAO,MAAM,aAAa,cAcxB,CAAC"}
|
|
@@ -1,84 +1,163 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
+
var useValue = arguments.length > 2;
|
|
3
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
+
}
|
|
6
|
+
return useValue ? value : void 0;
|
|
7
|
+
};
|
|
8
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
+
var _, done = false;
|
|
14
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
+
var context = {};
|
|
16
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
+
if (kind === "accessor") {
|
|
21
|
+
if (result === void 0) continue;
|
|
22
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
+
}
|
|
27
|
+
else if (_ = accept(result)) {
|
|
28
|
+
if (kind === "field") initializers.unshift(_);
|
|
29
|
+
else descriptor[key] = _;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
+
done = true;
|
|
34
|
+
};
|
|
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
|
+
});
|
|
6
43
|
};
|
|
7
|
-
var
|
|
8
|
-
if (typeof
|
|
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 });
|
|
9
47
|
};
|
|
10
|
-
import { inject } from '@kanian77/
|
|
11
|
-
import { ExampleService } from '../../../../example-plugin/services';
|
|
48
|
+
import { inject, Service } from '@kanian77/tject';
|
|
12
49
|
import { Plugin } from '../../../../core';
|
|
13
|
-
import { Hook } from '../../../../decorators';
|
|
50
|
+
import { EnableHooks, Hook } from '../../../../decorators';
|
|
14
51
|
import { HOOK_REGISTRY_TOKEN } from '../../../types/tokens';
|
|
52
|
+
import { PluginModule } from '../../../types/PluginModule';
|
|
53
|
+
import { EXAMPLE_SERVICE_A_TOKEN, ExampleServiceAModule, } from '../../services';
|
|
15
54
|
export const PLUGIN_A_TOKEN = 'PLUGIN_A_TOKEN';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
55
|
+
let PluginA = (() => {
|
|
56
|
+
let _classDecorators = [Service({ token: PLUGIN_A_TOKEN }), EnableHooks];
|
|
57
|
+
let _classDescriptor;
|
|
58
|
+
let _classExtraInitializers = [];
|
|
59
|
+
let _classThis;
|
|
60
|
+
let _classSuper = Plugin;
|
|
61
|
+
let _instanceExtraInitializers = [];
|
|
62
|
+
let _handleExampleEvent_decorators;
|
|
63
|
+
let _onApplicationStart_decorators;
|
|
64
|
+
let _onBeforePluginLoad_decorators;
|
|
65
|
+
var PluginA = _classThis = class extends _classSuper {
|
|
66
|
+
constructor(exampleServiceA) {
|
|
67
|
+
super();
|
|
68
|
+
Object.defineProperty(this, "exampleServiceA", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
configurable: true,
|
|
71
|
+
writable: true,
|
|
72
|
+
value: (__runInitializers(this, _instanceExtraInitializers), exampleServiceA)
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(this, "metadata", {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
configurable: true,
|
|
77
|
+
writable: true,
|
|
78
|
+
value: {
|
|
79
|
+
name: 'pluginA',
|
|
80
|
+
version: '1.0.0',
|
|
81
|
+
description: 'An example plugin',
|
|
82
|
+
dependencies: [], // other plugin names this depends on
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
onLoad() {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
console.log('PluginA loading...');
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
onInit() {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
console.log('PluginA initialized!');
|
|
94
|
+
// Additional manual hook registration if needed
|
|
95
|
+
this.registerAdditionalHooks();
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
onDestroy() {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
console.log('PluginA destroyed!');
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
// These methods will be automatically registered as hook handlers
|
|
104
|
+
handleExampleEvent(data) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
console.log('Handling example event via decorator:', data);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
onApplicationStart() {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
console.log('PluginA responding to application start via decorator');
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
onBeforePluginLoad(pluginPath) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
console.log('Another plugin is about to load:', pluginPath);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
registerAdditionalHooks() {
|
|
120
|
+
const hookRegistry = inject(HOOK_REGISTRY_TOKEN);
|
|
121
|
+
hookRegistry.register('dynamic:custom-hook', this.handleDynamicHook.bind(this));
|
|
122
|
+
}
|
|
123
|
+
handleDynamicHook(data) {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
console.log('Handling dynamic hook:', data);
|
|
126
|
+
console.log(this.exampleServiceA.doSomething());
|
|
127
|
+
});
|
|
128
|
+
}
|
|
22
129
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
console.log('Another plugin is about to load:', pluginPath);
|
|
57
|
-
}
|
|
58
|
-
registerAdditionalHooks() {
|
|
59
|
-
const hookRegistry = inject(HOOK_REGISTRY_TOKEN);
|
|
60
|
-
hookRegistry.register('dynamic:custom-hook', this.handleDynamicHook.bind(this));
|
|
61
|
-
}
|
|
62
|
-
async handleDynamicHook(data) {
|
|
63
|
-
console.log('Handling dynamic hook:', data);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
__decorate([
|
|
67
|
-
Hook('custom:example-event'),
|
|
68
|
-
__metadata("design:type", Function),
|
|
69
|
-
__metadata("design:paramtypes", [Object]),
|
|
70
|
-
__metadata("design:returntype", Promise)
|
|
71
|
-
], PluginA.prototype, "handleExampleEvent", null);
|
|
72
|
-
__decorate([
|
|
73
|
-
Hook('core:application-start'),
|
|
74
|
-
__metadata("design:type", Function),
|
|
75
|
-
__metadata("design:paramtypes", []),
|
|
76
|
-
__metadata("design:returntype", Promise)
|
|
77
|
-
], PluginA.prototype, "onApplicationStart", null);
|
|
78
|
-
__decorate([
|
|
79
|
-
Hook('core:before-plugin-load'),
|
|
80
|
-
__metadata("design:type", Function),
|
|
81
|
-
__metadata("design:paramtypes", [String]),
|
|
82
|
-
__metadata("design:returntype", Promise)
|
|
83
|
-
], PluginA.prototype, "onBeforePluginLoad", null);
|
|
130
|
+
__setFunctionName(_classThis, "PluginA");
|
|
131
|
+
(() => {
|
|
132
|
+
var _a;
|
|
133
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
|
|
134
|
+
_handleExampleEvent_decorators = [Hook('custom:example-event')];
|
|
135
|
+
_onApplicationStart_decorators = [Hook('core:application-start')];
|
|
136
|
+
_onBeforePluginLoad_decorators = [Hook('core:before-plugin-load')];
|
|
137
|
+
__esDecorate(_classThis, null, _handleExampleEvent_decorators, { kind: "method", name: "handleExampleEvent", static: false, private: false, access: { has: obj => "handleExampleEvent" in obj, get: obj => obj.handleExampleEvent }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
138
|
+
__esDecorate(_classThis, null, _onApplicationStart_decorators, { kind: "method", name: "onApplicationStart", static: false, private: false, access: { has: obj => "onApplicationStart" in obj, get: obj => obj.onApplicationStart }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
139
|
+
__esDecorate(_classThis, null, _onBeforePluginLoad_decorators, { kind: "method", name: "onBeforePluginLoad", static: false, private: false, access: { has: obj => "onBeforePluginLoad" in obj, get: obj => obj.onBeforePluginLoad }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
140
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
141
|
+
PluginA = _classThis = _classDescriptor.value;
|
|
142
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
143
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
144
|
+
})();
|
|
145
|
+
return PluginA = _classThis;
|
|
146
|
+
})();
|
|
147
|
+
export default PluginA;
|
|
148
|
+
export const PluginAModule = new PluginModule({
|
|
149
|
+
token: PLUGIN_A_TOKEN,
|
|
150
|
+
providers: [
|
|
151
|
+
{
|
|
152
|
+
provide: PLUGIN_A_TOKEN,
|
|
153
|
+
useClass: PluginA,
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
imports: [
|
|
157
|
+
{
|
|
158
|
+
module: ExampleServiceAModule,
|
|
159
|
+
binds: [{ from: EXAMPLE_SERVICE_A_TOKEN, to: PLUGIN_A_TOKEN }],
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
});
|
|
84
163
|
//# sourceMappingURL=module.js.map
|