structured-fw 0.8.5 → 0.8.6

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.
@@ -61,9 +61,9 @@ function createTsconfig() {
61
61
  "strictNullChecks": true,
62
62
  "strictPropertyInitialization": true,
63
63
  "strictBindCallApply": true,
64
- "moduleResolution": "bundler",
64
+ "moduleResolution": "node16",
65
65
  "outDir": "./build",
66
- "module": "ES2020",
66
+ "module": "Node16",
67
67
  "target": "ES2021",
68
68
  "allowSyntheticDefaultImports": true,
69
69
  "preserveSymlinks": true,
@@ -26,7 +26,7 @@ export declare class Application {
26
26
  importEnv<T extends LooseObject>(smartPrimitives?: boolean): T;
27
27
  exportContextFields(...fields: Array<keyof RequestContextData>): void;
28
28
  contentType(extension: string): string | false;
29
- registerPlugin(callback: (app: Application) => void): void;
29
+ registerPlugin(callback: (app: Application, ...args: Array<any>) => void | Promise<void>, ...args: Array<any>): Promise<void>;
30
30
  private respondWithComponent;
31
31
  memoryUsage(): NodeJS.MemoryUsage;
32
32
  printMemoryUsage(): void;
@@ -141,11 +141,11 @@ export class Application {
141
141
  contentType(extension) {
142
142
  return mime.contentType(extension);
143
143
  }
144
- registerPlugin(callback) {
144
+ async registerPlugin(callback, ...args) {
145
145
  if (this.initialized) {
146
146
  console.warn('Plugin registered after app is initialized, some plugin features may not work.');
147
147
  }
148
- callback(this);
148
+ await callback.apply(this, [this, ...args]);
149
149
  }
150
150
  async respondWithComponent(ctx, componentName, attributes, unwrap = true) {
151
151
  const component = this.components.getByName(componentName);
package/index.ts CHANGED
@@ -3,6 +3,10 @@ import { config } from './Config.js';
3
3
 
4
4
  const app = new Application(config);
5
5
 
6
+ app.registerPlugin((app, a, b) => {
7
+ console.log(a, b)
8
+ }, 'a', 'b');
9
+
6
10
  // app.on('afterComponentsLoaded', (components) => {
7
11
  // components.componentNames.forEach((componentName) => {
8
12
  // console.log(componentName)
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "license": "MIT",
15
15
  "type": "module",
16
16
  "main": "build/index",
17
- "version": "0.8.5",
17
+ "version": "0.8.6",
18
18
  "scripts": {
19
19
  "develop": "tsc --watch",
20
20
  "startDev": "cd build && nodemon --watch '../app/**/*' --watch '../build/**/*' -e js,html,css index.js",