assemblerjs 1.1.0 → 1.1.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.
Files changed (66) hide show
  1. package/dist/index.d.ts +27 -8
  2. package/dist/index11.js +2 -2
  3. package/dist/index11.mjs +2 -2
  4. package/dist/index13.js +2 -2
  5. package/dist/index13.mjs +2 -2
  6. package/dist/index16.js +1 -1
  7. package/dist/index16.mjs +1 -1
  8. package/dist/index17.js +1 -1
  9. package/dist/index17.mjs +1 -1
  10. package/dist/index18.js +1 -1
  11. package/dist/index18.mjs +1 -1
  12. package/dist/index19.js +1 -1
  13. package/dist/index19.mjs +1 -1
  14. package/dist/index2.js +2 -2
  15. package/dist/index2.mjs +2 -2
  16. package/dist/index20.js +1 -1
  17. package/dist/index20.mjs +1 -1
  18. package/dist/index21.js +1 -1
  19. package/dist/index21.mjs +1 -1
  20. package/dist/index22.js +2 -2
  21. package/dist/index22.mjs +2 -2
  22. package/dist/index23.js +2 -2
  23. package/dist/index23.mjs +2 -2
  24. package/dist/index24.js +2 -2
  25. package/dist/index24.mjs +2 -2
  26. package/dist/index25.js +1 -1
  27. package/dist/index25.mjs +1 -1
  28. package/dist/index26.js +1 -1
  29. package/dist/index26.mjs +1 -1
  30. package/dist/index29.js +33 -56
  31. package/dist/index29.mjs +32 -56
  32. package/dist/index3.js +1 -1
  33. package/dist/index3.mjs +1 -1
  34. package/dist/index30.js +54 -20
  35. package/dist/index30.mjs +54 -20
  36. package/dist/index31.js +23 -57
  37. package/dist/index31.mjs +23 -57
  38. package/dist/index32.js +61 -27
  39. package/dist/index32.mjs +61 -27
  40. package/dist/index33.js +29 -29
  41. package/dist/index33.mjs +29 -29
  42. package/dist/index34.js +32 -18
  43. package/dist/index34.mjs +32 -15
  44. package/dist/index35.js +18 -23
  45. package/dist/index35.mjs +15 -23
  46. package/dist/index36.js +100 -33
  47. package/dist/index36.mjs +98 -32
  48. package/dist/index37.js +100 -96
  49. package/dist/index37.mjs +100 -94
  50. package/dist/index38.js +24 -96
  51. package/dist/index38.mjs +24 -96
  52. package/dist/index39.js +18 -24
  53. package/dist/index39.mjs +18 -24
  54. package/dist/index4.js +5 -5
  55. package/dist/index4.mjs +5 -5
  56. package/dist/index41.js +18 -4
  57. package/dist/index41.mjs +18 -5
  58. package/dist/index43.js +92 -70
  59. package/dist/index43.mjs +92 -70
  60. package/dist/index47.js +1 -1
  61. package/dist/index47.mjs +1 -1
  62. package/dist/index48.js +18 -7
  63. package/dist/index48.mjs +18 -7
  64. package/dist/index49.js +1 -1
  65. package/dist/index49.mjs +1 -1
  66. package/package.json +1 -5
package/dist/index.d.ts CHANGED
@@ -79,7 +79,8 @@ declare abstract class AbstractInjectable<T> {
79
79
  abstract readonly privateContext: AssemblerPrivateContext;
80
80
  abstract readonly publicContext: AssemblerContext;
81
81
  abstract readonly identifier: Identifier<T> | string | symbol;
82
- abstract readonly concrete: Concrete<T>;
82
+ abstract readonly concrete?: Concrete<T>;
83
+ abstract readonly factory?: Factory<T>;
83
84
  abstract readonly configuration: Record<string, any>;
84
85
  abstract dependencies: (Identifier<unknown> | any)[];
85
86
  abstract definition: AssemblageDefinition;
@@ -429,8 +430,9 @@ export declare function Before(pointcut: string, priority?: number): (target: an
429
430
  */
430
431
  declare interface Buildable<T> {
431
432
  identifier: Identifier<T>;
432
- concrete: Concrete<T>;
433
+ concrete?: Concrete<T>;
433
434
  instance?: T;
435
+ factory?: () => T;
434
436
  configuration: Record<string, any>;
435
437
  }
436
438
 
@@ -557,7 +559,7 @@ export declare const decorateGlobal: (identifier: string | symbol, target: any,
557
559
  * @param target The target class
558
560
  * @param index The parameter index
559
561
  */
560
- export declare const decorateUse: (identifier: string | symbol, target: any, index: number) => void;
562
+ export declare const decorateUse: (identifier: UseIdentifier, target: any, index: number) => void;
561
563
 
562
564
  /**
563
565
  * Type for a function that creates a decorator.
@@ -621,6 +623,11 @@ export declare class EventManager implements AbstractEventManager {
621
623
  private cleanChannel;
622
624
  }
623
625
 
626
+ /**
627
+ * Factory function that returns an instance of type T.
628
+ */
629
+ declare type Factory<T> = () => T;
630
+
624
631
  export declare const getAssemblageContext: <T>(target: Concrete<T> | Function) => AssemblerContext;
625
632
 
626
633
  export declare const getAssemblageDefinition: <T>(target: Concrete<T>) => AssemblageDefinition;
@@ -698,7 +705,7 @@ declare class Injectable<T> implements AbstractInjectable<T> {
698
705
  /** Unique identifier for this injectable. */
699
706
  readonly identifier: Identifier<T> | string | symbol;
700
707
  /** The concrete class to instantiate. */
701
- readonly concrete: Concrete<T>;
708
+ readonly concrete: Concrete<T> | undefined;
702
709
  /** Base configuration for this injectable. */
703
710
  readonly configuration: Record<string, any>;
704
711
  /** Merged configuration used during build (base + runtime). */
@@ -720,6 +727,7 @@ declare class Injectable<T> implements AbstractInjectable<T> {
720
727
  private dependenciesIds;
721
728
  protected singletonInstance: T | undefined;
722
729
  private builder;
730
+ readonly factory?: () => T;
723
731
  static of<TNew>(buildable: Buildable<TNew>, privateContext: AssemblerPrivateContext, publicContext: AssemblerContext): Injectable<TNew>;
724
732
  private constructor();
725
733
  /**
@@ -834,9 +842,10 @@ declare interface InjectableResolver {
834
842
  declare type Injection<T> = BaseInjection<T> | ConfiguredInjection<T> | ConcreteInjection<T> | ConcreteConfiguredInjection<T>;
835
843
 
836
844
  /**
837
- * Injectable binds an instance of a class to an identifier (abstract or concrete).
845
+ * Injectable binds an instance or factory of a class to an identifier (abstract or concrete).
846
+ * The second element can be either an instance or a factory function that returns an instance.
838
847
  */
839
- declare type InstanceInjection<T> = Tuple<[Identifier<T> | string | symbol, T]>;
848
+ declare type InstanceInjection<T> = Tuple<[Identifier<T> | string | symbol, T | Factory<T>]>;
840
849
 
841
850
  /**
842
851
  * Check if a given class is an `Assemblage`.
@@ -1307,10 +1316,20 @@ export declare interface TransversalMetadata {
1307
1316
  }
1308
1317
 
1309
1318
  /**
1310
- * Injects an object passed with `string` or `symbol` identifier.
1319
+ * Injects an object passed with `string`, `symbol` or abstract class identifier.
1320
+ * The identifier can be:
1321
+ * - A string: @Use('logger')
1322
+ * - A symbol: @Use(Symbol.for('logger'))
1323
+ * - An abstract class: @Use(ILogger)
1324
+ *
1311
1325
  * @param identifier The identifier of the object to inject
1312
1326
  * @returns A parameter decorator
1313
1327
  */
1314
- export declare const Use: (param?: string | symbol | undefined) => ParameterDecorator;
1328
+ export declare const Use: (param?: UseIdentifier | undefined) => ParameterDecorator;
1329
+
1330
+ /**
1331
+ * Identifier can be a string, symbol, or an abstract class/interface.
1332
+ */
1333
+ export declare type UseIdentifier = string | symbol | Function;
1315
1334
 
1316
1335
  export { }
package/dist/index11.js CHANGED
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const constants = require('./index28.js');
6
- const reflection = require('./index34.js');
6
+ const reflection = require('./index35.js');
7
7
  const decorator = require('./index2.js');
8
- const schema = require('./index37.js');
8
+ const schema = require('./index36.js');
9
9
 
10
10
  function isTransversal(e) {
11
11
  try {
package/dist/index11.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ReflectValue } from './index28.mjs';
2
- import { getCustomMetadata, defineCustomMetadata } from './index34.mjs';
2
+ import { getCustomMetadata, defineCustomMetadata } from './index35.mjs';
3
3
  import { Assemblage } from './index2.mjs';
4
- import { getDefinition } from './index37.mjs';
4
+ import { getDefinition } from './index36.mjs';
5
5
 
6
6
  function isTransversal(e) {
7
7
  try {
package/dist/index13.js CHANGED
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const core = require('@assemblerjs/core');
6
- const pointcutMatcher = require('./index39.js');
6
+ const pointcutMatcher = require('./index38.js');
7
7
  const affect = require('./index12.js');
8
- const schema = require('./index37.js');
8
+ const schema = require('./index36.js');
9
9
 
10
10
  class TransversalManager {
11
11
  static getInstance(e) {
package/dist/index13.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { isClass } from '@assemblerjs/core';
2
- import { PointcutMatcher } from './index39.mjs';
2
+ import { PointcutMatcher } from './index38.mjs';
3
3
  import { getAffectedMethods } from './index12.mjs';
4
- import { getDefinition } from './index37.mjs';
4
+ import { getDefinition } from './index36.mjs';
5
5
 
6
6
  class TransversalManager {
7
7
  static getInstance(e) {
package/dist/index16.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const reflection = require('./index34.js');
5
+ const reflection = require('./index35.js');
6
6
 
7
7
  const t = (t)=>()=>{
8
8
  return (e, c, n)=>{
package/dist/index16.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getOwnCustomMetadata, defineCustomMetadata } from './index34.mjs';
1
+ import { getOwnCustomMetadata, defineCustomMetadata } from './index35.mjs';
2
2
 
3
3
  const t = (t)=>()=>{
4
4
  return (e, c, n)=>{
package/dist/index17.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const reflection = require('./index34.js');
5
+ const reflection = require('./index35.js');
6
6
 
7
7
  class ParameterDecoratorFactory {
8
8
  static create(e) {
package/dist/index17.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getOwnCustomMetadata, defineCustomMetadata } from './index34.mjs';
1
+ import { getOwnCustomMetadata, defineCustomMetadata } from './index35.mjs';
2
2
 
3
3
  class ParameterDecoratorFactory {
4
4
  static create(e) {
package/dist/index18.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const parameterDecoratorFactory = require('./index17.js');
6
- const resolverStore = require('./index35.js');
6
+ const resolverStore = require('./index39.js');
7
7
 
8
8
  let ContextResolver = class ContextResolver {
9
9
  resolve(e, r, t) {
package/dist/index18.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ParameterDecoratorFactory } from './index17.mjs';
2
- import { ResolverStore } from './index35.mjs';
2
+ import { ResolverStore } from './index39.mjs';
3
3
 
4
4
  let ContextResolver = class ContextResolver {
5
5
  resolve(e, r, t) {
package/dist/index19.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const parameterDecoratorFactory = require('./index17.js');
6
- const resolverStore = require('./index35.js');
6
+ const resolverStore = require('./index39.js');
7
7
 
8
8
  let ConfigurationResolver = class ConfigurationResolver {
9
9
  resolve(r, o, e, n) {
package/dist/index19.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ParameterDecoratorFactory } from './index17.mjs';
2
- import { ResolverStore } from './index35.mjs';
2
+ import { ResolverStore } from './index39.mjs';
3
3
 
4
4
  let ConfigurationResolver = class ConfigurationResolver {
5
5
  resolve(r, o, e, n) {
package/dist/index2.js CHANGED
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const constants = require('./index28.js');
6
- const reflection = require('./index34.js');
7
- const schema = require('./index37.js');
6
+ const reflection = require('./index35.js');
7
+ const schema = require('./index36.js');
8
8
 
9
9
  const Assemblage = (e)=>{
10
10
  return (r)=>{
package/dist/index2.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ReflectFlags, ReflectValue } from './index28.mjs';
2
- import { defineCustomMetadata } from './index34.mjs';
3
- import { validateDefinition } from './index37.mjs';
2
+ import { defineCustomMetadata } from './index35.mjs';
3
+ import { validateDefinition } from './index36.mjs';
4
4
 
5
5
  const Assemblage = (e)=>{
6
6
  return (r)=>{
package/dist/index20.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const parameterDecoratorFactory = require('./index17.js');
6
- const resolverStore = require('./index35.js');
6
+ const resolverStore = require('./index39.js');
7
7
 
8
8
  let DefinitionResolver = class DefinitionResolver {
9
9
  resolve(e, r) {
package/dist/index20.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ParameterDecoratorFactory } from './index17.mjs';
2
- import { ResolverStore } from './index35.mjs';
2
+ import { ResolverStore } from './index39.mjs';
3
3
 
4
4
  let DefinitionResolver = class DefinitionResolver {
5
5
  resolve(e, r) {
package/dist/index21.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const parameterDecoratorFactory = require('./index17.js');
6
- const resolverStore = require('./index35.js');
6
+ const resolverStore = require('./index39.js');
7
7
 
8
8
  let DisposeResolver = class DisposeResolver {
9
9
  resolve(e, r, s) {
package/dist/index21.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ParameterDecoratorFactory } from './index17.mjs';
2
- import { ResolverStore } from './index35.mjs';
2
+ import { ResolverStore } from './index39.mjs';
3
3
 
4
4
  let DisposeResolver = class DisposeResolver {
5
5
  resolve(e, r, s) {
package/dist/index22.js CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const reflection = require('./index34.js');
5
+ const reflection = require('./index35.js');
6
6
  const parameterDecoratorFactory = require('./index17.js');
7
7
  const helpers = require('./index25.js');
8
- const resolverStore = require('./index35.js');
8
+ const resolverStore = require('./index39.js');
9
9
 
10
10
  let UseResolver = class UseResolver {
11
11
  resolve(r, o, t) {
package/dist/index22.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { getOwnCustomMetadata } from './index34.mjs';
1
+ import { getOwnCustomMetadata } from './index35.mjs';
2
2
  import { ParameterDecoratorFactory } from './index17.mjs';
3
3
  import { getParamValueKey } from './index25.mjs';
4
- import { ResolverStore } from './index35.mjs';
4
+ import { ResolverStore } from './index39.mjs';
5
5
 
6
6
  let UseResolver = class UseResolver {
7
7
  resolve(r, o, t) {
package/dist/index23.js CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const reflection = require('./index34.js');
5
+ const reflection = require('./index35.js');
6
6
  const parameterDecoratorFactory = require('./index17.js');
7
7
  const helpers = require('./index25.js');
8
- const resolverStore = require('./index35.js');
8
+ const resolverStore = require('./index39.js');
9
9
 
10
10
  let GlobalResolver = class GlobalResolver {
11
11
  resolve(e, r, a) {
package/dist/index23.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { getOwnCustomMetadata } from './index34.mjs';
1
+ import { getOwnCustomMetadata } from './index35.mjs';
2
2
  import { ParameterDecoratorFactory } from './index17.mjs';
3
3
  import { getParamValueKey } from './index25.mjs';
4
- import { ResolverStore } from './index35.mjs';
4
+ import { ResolverStore } from './index39.mjs';
5
5
 
6
6
  let GlobalResolver = class GlobalResolver {
7
7
  resolve(e, r, a) {
package/dist/index24.js CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const reflection = require('./index34.js');
5
+ const reflection = require('./index35.js');
6
6
  const parameterDecoratorFactory = require('./index17.js');
7
7
  const helpers = require('./index25.js');
8
- const resolverStore = require('./index35.js');
8
+ const resolverStore = require('./index39.js');
9
9
 
10
10
  let OptionalResolver = class OptionalResolver {
11
11
  resolve(o, t, n) {
package/dist/index24.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { getParamTypes, getOwnCustomMetadata } from './index34.mjs';
1
+ import { getParamTypes, getOwnCustomMetadata } from './index35.mjs';
2
2
  import { ParameterDecoratorFactory } from './index17.mjs';
3
3
  import { getParamValueKey } from './index25.mjs';
4
- import { ResolverStore } from './index35.mjs';
4
+ import { ResolverStore } from './index39.mjs';
5
5
 
6
6
  let OptionalResolver = class OptionalResolver {
7
7
  resolve(o, t, n) {
package/dist/index25.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const reflection = require('./index34.js');
5
+ const reflection = require('./index35.js');
6
6
  const parameterDecoratorFactory = require('./index17.js');
7
7
 
8
8
  const getParamIndexKey = (e)=>{
package/dist/index25.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getOwnCustomMetadata } from './index34.mjs';
1
+ import { getOwnCustomMetadata } from './index35.mjs';
2
2
  import { ParameterDecoratorFactory } from './index17.mjs';
3
3
 
4
4
  const getParamIndexKey = (e)=>{
package/dist/index26.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const constants = require('./index28.js');
6
- const reflection = require('./index34.js');
6
+ const reflection = require('./index35.js');
7
7
  const helpers = require('./index25.js');
8
8
  const parameterDecoratorFactory = require('./index17.js');
9
9
  const decorator = require('./index2.js');
package/dist/index26.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ReflectParamTypes, ReflectValue } from './index28.mjs';
2
- import { getOwnCustomMetadata, defineCustomMetadata } from './index34.mjs';
2
+ import { getOwnCustomMetadata, defineCustomMetadata } from './index35.mjs';
3
3
  import { getDecoratedParametersIndexes, getParamValueKey, getParamIndexKey } from './index25.mjs';
4
4
  import { ParameterDecoratorFactory } from './index17.mjs';
5
5
  import { decorateAssemblage } from './index2.mjs';
package/dist/index29.js CHANGED
@@ -2,68 +2,45 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const hookManager = require('./index31.js');
6
- const resolutionStrategies = require('./index40.js');
7
- const use = require('./index41.js');
8
- const inject = require('./index42.js');
9
- const injectable = require('./index43.js');
5
+ const eventManager = require('./index6.js');
10
6
 
11
- class InjectableManager {
12
- setContexts(e, t) {
13
- this.privateContext = e;
14
- this.publicContext = t;
15
- }
16
- register(r, n = false) {
17
- const o = n === true ? use.resolveInstanceInjectionTuple(r) : inject.resolveInjectionTuple(r);
18
- if (this.has(o.identifier)) {
19
- throw new Error(`An assemblage is already registered with identifier '${o.identifier.name}'.`);
7
+ const registerEvents = (t, n)=>{
8
+ const o = t.concrete !== undefined && t.concrete.prototype instanceof eventManager.EventManager;
9
+ if (o) {
10
+ const e = n;
11
+ const o = e.channels;
12
+ for (const n of t.events){
13
+ if (!o.has(n)) e.addChannels(n);
14
+ if (!t.privateContext.events.has(n)) t.privateContext.addChannels(n);
20
15
  }
21
- const a = injectable.Injectable.of(o, this.privateContext, this.publicContext);
22
- this.injectables.set(a.identifier, a);
23
- hookManager.HookManager.callHook(a.concrete, 'onRegister', this.publicContext, a.configuration);
24
- return a;
25
- }
26
- has(e) {
27
- return this.injectables.has(e);
28
- }
29
- require(e, t) {
30
- if (!this.injectables.has(e)) {
31
- throw new Error(`Class with identifier '${e.name}' has not been registered or is a circular dependency.`);
16
+ for (const e of t.events){
17
+ n.on(e, (...n)=>{
18
+ t.privateContext.emit(e, ...n);
19
+ });
32
20
  }
33
- const i = this.injectables.get(e);
34
- if (i.isSingleton) {
35
- return this.singletonStrategy.resolve(i, t);
36
- } else {
37
- return this.transientStrategy.resolve(i, t);
21
+ } else {
22
+ for (const e of t.events){
23
+ if (!t.privateContext.events.has(e)) t.privateContext.addChannels(e);
38
24
  }
39
25
  }
40
- concrete(e) {
41
- const t = this.injectables.get(e);
42
- if (t) return t.concrete;
43
- return;
44
- }
45
- tagged(...e) {
46
- const t = [];
47
- for (const i of e){
48
- for (const [e, s] of this.injectables){
49
- if (s.tags.includes(i)) t.push(s.build());
50
- }
26
+ };
27
+ const unregisterEvents = (t, n)=>{
28
+ const o = t.concrete !== undefined && t.concrete.prototype instanceof eventManager.EventManager;
29
+ if (o) {
30
+ const e = n;
31
+ for (const n of t.events){
32
+ e.off(n);
51
33
  }
52
- return t;
53
- }
54
- dispose() {
55
- for (const [e, t] of this.injectables){
56
- t.dispose();
34
+ e.removeChannels(...t.events);
35
+ t.privateContext.removeChannels(...t.events);
36
+ } else {
37
+ for (const e of t.events){
38
+ if (t.privateContext.events.has(e)) {
39
+ t.privateContext.removeChannels(e);
40
+ }
57
41
  }
58
42
  }
59
- get size() {
60
- return this.injectables.size;
61
- }
62
- constructor(){
63
- this.injectables = new Map();
64
- this.singletonStrategy = new resolutionStrategies.SingletonStrategy();
65
- this.transientStrategy = new resolutionStrategies.TransientStrategy();
66
- }
67
- }
43
+ };
68
44
 
69
- exports.InjectableManager = InjectableManager;
45
+ exports.registerEvents = registerEvents;
46
+ exports.unregisterEvents = unregisterEvents;
package/dist/index29.mjs CHANGED
@@ -1,65 +1,41 @@
1
- import { HookManager } from './index31.mjs';
2
- import { SingletonStrategy, TransientStrategy } from './index40.mjs';
3
- import { resolveInstanceInjectionTuple } from './index41.mjs';
4
- import { resolveInjectionTuple } from './index42.mjs';
5
- import { Injectable } from './index43.mjs';
1
+ import { EventManager } from './index6.mjs';
6
2
 
7
- class InjectableManager {
8
- setContexts(e, t) {
9
- this.privateContext = e;
10
- this.publicContext = t;
11
- }
12
- register(r, n = false) {
13
- const o = n === true ? resolveInstanceInjectionTuple(r) : resolveInjectionTuple(r);
14
- if (this.has(o.identifier)) {
15
- throw new Error(`An assemblage is already registered with identifier '${o.identifier.name}'.`);
3
+ const registerEvents = (t, n)=>{
4
+ const o = t.concrete !== undefined && t.concrete.prototype instanceof EventManager;
5
+ if (o) {
6
+ const e = n;
7
+ const o = e.channels;
8
+ for (const n of t.events){
9
+ if (!o.has(n)) e.addChannels(n);
10
+ if (!t.privateContext.events.has(n)) t.privateContext.addChannels(n);
16
11
  }
17
- const a = Injectable.of(o, this.privateContext, this.publicContext);
18
- this.injectables.set(a.identifier, a);
19
- HookManager.callHook(a.concrete, 'onRegister', this.publicContext, a.configuration);
20
- return a;
21
- }
22
- has(e) {
23
- return this.injectables.has(e);
24
- }
25
- require(e, t) {
26
- if (!this.injectables.has(e)) {
27
- throw new Error(`Class with identifier '${e.name}' has not been registered or is a circular dependency.`);
12
+ for (const e of t.events){
13
+ n.on(e, (...n)=>{
14
+ t.privateContext.emit(e, ...n);
15
+ });
28
16
  }
29
- const i = this.injectables.get(e);
30
- if (i.isSingleton) {
31
- return this.singletonStrategy.resolve(i, t);
32
- } else {
33
- return this.transientStrategy.resolve(i, t);
17
+ } else {
18
+ for (const e of t.events){
19
+ if (!t.privateContext.events.has(e)) t.privateContext.addChannels(e);
34
20
  }
35
21
  }
36
- concrete(e) {
37
- const t = this.injectables.get(e);
38
- if (t) return t.concrete;
39
- return;
40
- }
41
- tagged(...e) {
42
- const t = [];
43
- for (const i of e){
44
- for (const [e, s] of this.injectables){
45
- if (s.tags.includes(i)) t.push(s.build());
46
- }
22
+ };
23
+ const unregisterEvents = (t, n)=>{
24
+ const o = t.concrete !== undefined && t.concrete.prototype instanceof EventManager;
25
+ if (o) {
26
+ const e = n;
27
+ for (const n of t.events){
28
+ e.off(n);
47
29
  }
48
- return t;
49
- }
50
- dispose() {
51
- for (const [e, t] of this.injectables){
52
- t.dispose();
30
+ e.removeChannels(...t.events);
31
+ t.privateContext.removeChannels(...t.events);
32
+ } else {
33
+ for (const e of t.events){
34
+ if (t.privateContext.events.has(e)) {
35
+ t.privateContext.removeChannels(e);
36
+ }
53
37
  }
54
38
  }
55
- get size() {
56
- return this.injectables.size;
57
- }
58
- constructor(){
59
- this.injectables = new Map();
60
- this.singletonStrategy = new SingletonStrategy();
61
- this.transientStrategy = new TransientStrategy();
62
- }
63
- }
39
+ };
64
40
 
65
- export { InjectableManager };
41
+ export { registerEvents, unregisterEvents };
package/dist/index3.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const constants = require('./index28.js');
6
- const reflection = require('./index34.js');
6
+ const reflection = require('./index35.js');
7
7
 
8
8
  const isAssemblage = (s)=>{
9
9
  return reflection.getOwnCustomMetadata(constants.ReflectFlags.IsAssemblage, s) || false;
package/dist/index3.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ReflectFlags, ReflectValue } from './index28.mjs';
2
- import { getOwnCustomMetadata } from './index34.mjs';
2
+ import { getOwnCustomMetadata } from './index35.mjs';
3
3
 
4
4
  const isAssemblage = (s)=>{
5
5
  return getOwnCustomMetadata(ReflectFlags.IsAssemblage, s) || false;