electron-injector 1.1.2 → 1.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/dist/index.cjs CHANGED
@@ -52,7 +52,8 @@ __export(index_exports, {
52
52
  Reflector: () => Reflector,
53
53
  SetMetadata: () => SetMetadata,
54
54
  UseGuards: () => UseGuards,
55
- applyDecorators: () => applyDecorators
55
+ applyDecorators: () => applyDecorators,
56
+ createParamDecorator: () => createParamDecorator
56
57
  });
57
58
  module.exports = __toCommonJS(index_exports);
58
59
  var import_reflect_metadata = require("reflect-metadata");
@@ -200,6 +201,14 @@ function applyDecorators(...decorators) {
200
201
  };
201
202
  }
202
203
  __name(applyDecorators, "applyDecorators");
204
+ function createParamDecorator(fn) {
205
+ return () => function(target, propertyKey, paramIndex) {
206
+ const params = Reflect.getMetadata(PARAM, target, propertyKey) ?? [];
207
+ params[paramIndex] = fn;
208
+ Reflect.defineMetadata(PARAM, params, target, propertyKey);
209
+ };
210
+ }
211
+ __name(createParamDecorator, "createParamDecorator");
203
212
 
204
213
  // src/container.ts
205
214
  var Container = class {
@@ -362,6 +371,9 @@ var Application = class _Application {
362
371
  }
363
372
  return executionContext.payload;
364
373
  }
374
+ if (typeof param === "function") {
375
+ return param(executionContext);
376
+ }
365
377
  return void 0;
366
378
  }));
367
379
  }
@@ -553,5 +565,6 @@ __name(Catch, "Catch");
553
565
  Reflector,
554
566
  SetMetadata,
555
567
  UseGuards,
556
- applyDecorators
568
+ applyDecorators,
569
+ createParamDecorator
557
570
  });
package/dist/index.d.cts CHANGED
@@ -21,6 +21,7 @@ declare class ExecutionContext {
21
21
  set payload(payload: any);
22
22
  }
23
23
  declare function applyDecorators(...decorators: CallableFunction[]): (target: Object, _propertyKey?: string | symbol, descriptor?: PropertyDescriptor) => void;
24
+ declare function createParamDecorator(fn: (context: ExecutionContext) => any): ParameterDecorator;
24
25
 
25
26
  type Class<T = any> = new (...args: any[]) => T;
26
27
  type InjectableType = 'singleton' | 'transient';
@@ -100,4 +101,4 @@ declare class ForbiddenAccessError extends ElectronInjectorError {
100
101
  constructor(path: string, guardName: string);
101
102
  }
102
103
 
103
- export { Application, type CanActivate, Catch, CircularDependency, type ConfigOptions, Controller, ControllerIsNotValid, Ctx, DataValidationError, ElectronInjectorError, Event, type ExceptionFilter, ExecutionContext, ForbiddenAccessError, Injectable, type InjectableType, IsNotExceptionFilter, OnInvoke, OnSend, Payload, ProviderIsNotInjectable, ProviderNotFound, Reflector, SetMetadata, UseGuards, applyDecorators };
104
+ export { Application, type CanActivate, Catch, CircularDependency, type ConfigOptions, Controller, ControllerIsNotValid, Ctx, DataValidationError, ElectronInjectorError, Event, type ExceptionFilter, ExecutionContext, ForbiddenAccessError, Injectable, type InjectableType, IsNotExceptionFilter, OnInvoke, OnSend, Payload, ProviderIsNotInjectable, ProviderNotFound, Reflector, SetMetadata, UseGuards, applyDecorators, createParamDecorator };
package/dist/index.d.ts CHANGED
@@ -21,6 +21,7 @@ declare class ExecutionContext {
21
21
  set payload(payload: any);
22
22
  }
23
23
  declare function applyDecorators(...decorators: CallableFunction[]): (target: Object, _propertyKey?: string | symbol, descriptor?: PropertyDescriptor) => void;
24
+ declare function createParamDecorator(fn: (context: ExecutionContext) => any): ParameterDecorator;
24
25
 
25
26
  type Class<T = any> = new (...args: any[]) => T;
26
27
  type InjectableType = 'singleton' | 'transient';
@@ -100,4 +101,4 @@ declare class ForbiddenAccessError extends ElectronInjectorError {
100
101
  constructor(path: string, guardName: string);
101
102
  }
102
103
 
103
- export { Application, type CanActivate, Catch, CircularDependency, type ConfigOptions, Controller, ControllerIsNotValid, Ctx, DataValidationError, ElectronInjectorError, Event, type ExceptionFilter, ExecutionContext, ForbiddenAccessError, Injectable, type InjectableType, IsNotExceptionFilter, OnInvoke, OnSend, Payload, ProviderIsNotInjectable, ProviderNotFound, Reflector, SetMetadata, UseGuards, applyDecorators };
104
+ export { Application, type CanActivate, Catch, CircularDependency, type ConfigOptions, Controller, ControllerIsNotValid, Ctx, DataValidationError, ElectronInjectorError, Event, type ExceptionFilter, ExecutionContext, ForbiddenAccessError, Injectable, type InjectableType, IsNotExceptionFilter, OnInvoke, OnSend, Payload, ProviderIsNotInjectable, ProviderNotFound, Reflector, SetMetadata, UseGuards, applyDecorators, createParamDecorator };
package/dist/index.js CHANGED
@@ -147,6 +147,14 @@ function applyDecorators(...decorators) {
147
147
  };
148
148
  }
149
149
  __name(applyDecorators, "applyDecorators");
150
+ function createParamDecorator(fn) {
151
+ return () => function(target, propertyKey, paramIndex) {
152
+ const params = Reflect.getMetadata(PARAM, target, propertyKey) ?? [];
153
+ params[paramIndex] = fn;
154
+ Reflect.defineMetadata(PARAM, params, target, propertyKey);
155
+ };
156
+ }
157
+ __name(createParamDecorator, "createParamDecorator");
150
158
 
151
159
  // src/container.ts
152
160
  var Container = class {
@@ -309,6 +317,9 @@ var Application = class _Application {
309
317
  }
310
318
  return executionContext.payload;
311
319
  }
320
+ if (typeof param === "function") {
321
+ return param(executionContext);
322
+ }
312
323
  return void 0;
313
324
  }));
314
325
  }
@@ -499,5 +510,6 @@ export {
499
510
  Reflector,
500
511
  SetMetadata,
501
512
  UseGuards,
502
- applyDecorators
513
+ applyDecorators,
514
+ createParamDecorator
503
515
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electron-injector",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "Biblioteca para el desarrollo de aplicaciones con electron que proporciona una arquitectura robusta con inyección e inversion de dependencias.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",