assemblerjs 1.0.0 → 1.1.0

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 (89) hide show
  1. package/README.md +29 -53
  2. package/dist/index.d.ts +430 -9
  3. package/dist/index.js +24 -12
  4. package/dist/index.mjs +16 -12
  5. package/dist/index11.js +82 -20
  6. package/dist/index11.mjs +78 -20
  7. package/dist/index12.js +17 -8
  8. package/dist/index12.mjs +16 -8
  9. package/dist/index13.js +148 -73
  10. package/dist/index13.mjs +148 -73
  11. package/dist/index14.js +4 -17
  12. package/dist/index14.mjs +4 -17
  13. package/dist/index15.js +21 -16
  14. package/dist/index15.mjs +21 -16
  15. package/dist/index16.js +10 -16
  16. package/dist/index16.mjs +10 -16
  17. package/dist/index17.js +88 -16
  18. package/dist/index17.mjs +88 -16
  19. package/dist/index18.js +11 -20
  20. package/dist/index18.mjs +11 -19
  21. package/dist/index19.js +11 -20
  22. package/dist/index19.mjs +11 -19
  23. package/dist/index2.js +3 -3
  24. package/dist/index2.mjs +3 -3
  25. package/dist/index20.js +11 -20
  26. package/dist/index20.mjs +11 -20
  27. package/dist/index21.js +14 -25
  28. package/dist/index21.mjs +14 -21
  29. package/dist/index22.js +24 -46
  30. package/dist/index22.mjs +23 -45
  31. package/dist/index23.js +25 -63
  32. package/dist/index23.mjs +24 -63
  33. package/dist/index24.js +24 -30
  34. package/dist/index24.mjs +24 -30
  35. package/dist/index25.js +24 -62
  36. package/dist/index25.mjs +20 -62
  37. package/dist/index26.js +46 -30
  38. package/dist/index26.mjs +45 -30
  39. package/dist/index27.js +2 -34
  40. package/dist/index27.mjs +2 -32
  41. package/dist/index28.js +17 -41
  42. package/dist/index28.mjs +15 -40
  43. package/dist/index29.js +64 -15
  44. package/dist/index29.mjs +64 -13
  45. package/dist/index3.js +2 -2
  46. package/dist/index3.mjs +2 -2
  47. package/dist/index30.js +32 -14
  48. package/dist/index30.mjs +32 -12
  49. package/dist/index31.js +57 -86
  50. package/dist/index31.mjs +57 -84
  51. package/dist/index32.js +28 -19
  52. package/dist/index32.mjs +28 -19
  53. package/dist/index33.js +28 -25
  54. package/dist/index33.mjs +28 -24
  55. package/dist/index34.js +17 -8
  56. package/dist/index34.mjs +14 -8
  57. package/dist/index35.js +23 -49
  58. package/dist/index35.mjs +23 -49
  59. package/dist/index36.js +37 -108
  60. package/dist/index36.mjs +36 -108
  61. package/dist/index37.js +98 -10
  62. package/dist/index37.mjs +96 -10
  63. package/dist/index38.js +95 -20
  64. package/dist/index38.mjs +95 -20
  65. package/dist/index39.js +23 -44
  66. package/dist/index39.mjs +23 -43
  67. package/dist/index4.js +5 -5
  68. package/dist/index4.mjs +5 -5
  69. package/dist/index40.js +34 -0
  70. package/dist/index40.mjs +29 -0
  71. package/dist/index41.js +14 -0
  72. package/dist/index41.mjs +10 -0
  73. package/dist/index42.js +54 -0
  74. package/dist/index42.mjs +50 -0
  75. package/dist/index43.js +177 -0
  76. package/dist/index43.mjs +173 -0
  77. package/dist/index44.js +947 -0
  78. package/dist/index44.mjs +943 -0
  79. package/dist/index45.js +7 -0
  80. package/dist/index45.mjs +3 -0
  81. package/dist/index46.js +7 -0
  82. package/dist/index46.mjs +3 -0
  83. package/dist/index47.js +19 -0
  84. package/dist/index47.mjs +15 -0
  85. package/dist/index48.js +33 -0
  86. package/dist/index48.mjs +29 -0
  87. package/dist/index49.js +67 -0
  88. package/dist/index49.mjs +62 -0
  89. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -11,18 +11,22 @@ const abstract = require('./index7.js');
11
11
  const types = require('./index8.js');
12
12
  const listenerCollection_abstract = require('./index9.js');
13
13
  const eventManager_abstract = require('./index10.js');
14
- const _await = require('./index11.js');
15
- const indexFactory = require('./index12.js');
16
- const parameterDecoratorFactory = require('./index13.js');
17
- const context = require('./index14.js');
18
- const configuration = require('./index15.js');
19
- const definition = require('./index16.js');
20
- const dispose = require('./index17.js');
21
- const use = require('./index18.js');
22
- const global = require('./index19.js');
23
- const optional = require('./index20.js');
24
- const helpers$1 = require('./index21.js');
25
- const constructorDecorator = require('./index22.js');
14
+ const decorators = require('./index11.js');
15
+ const affect = require('./index12.js');
16
+ const transversalManager = require('./index13.js');
17
+ const abstract$1 = require('./index14.js');
18
+ const _await = require('./index15.js');
19
+ const indexFactory = require('./index16.js');
20
+ const parameterDecoratorFactory = require('./index17.js');
21
+ const context = require('./index18.js');
22
+ const configuration = require('./index19.js');
23
+ const definition = require('./index20.js');
24
+ const dispose = require('./index21.js');
25
+ const use = require('./index22.js');
26
+ const global = require('./index23.js');
27
+ const optional = require('./index24.js');
28
+ const helpers$1 = require('./index25.js');
29
+ const constructorDecorator = require('./index26.js');
26
30
 
27
31
 
28
32
 
@@ -38,6 +42,14 @@ exports.AbstractAssemblage = abstract.AbstractAssemblage;
38
42
  exports.AbstractAssembler = types.AbstractAssembler;
39
43
  exports.AbstractListenerCollection = listenerCollection_abstract.AbstractListenerCollection;
40
44
  exports.AbstractEventManager = eventManager_abstract.AbstractEventManager;
45
+ exports.After = decorators.After;
46
+ exports.Around = decorators.Around;
47
+ exports.Before = decorators.Before;
48
+ exports.Transversal = decorators.Transversal;
49
+ exports.isTransversal = decorators.isTransversal;
50
+ exports.Affect = affect.Affect;
51
+ exports.TransversalManager = transversalManager.TransversalManager;
52
+ exports.AbstractTransversal = abstract$1.AbstractTransversal;
41
53
  exports.Await = _await.Await;
42
54
  exports.createParamIndexDecorator = indexFactory.createParamIndexDecorator;
43
55
  exports.ParameterDecoratorFactory = parameterDecoratorFactory.ParameterDecoratorFactory;
package/dist/index.mjs CHANGED
@@ -7,15 +7,19 @@ export { AbstractAssemblage } from './index7.mjs';
7
7
  export { AbstractAssembler } from './index8.mjs';
8
8
  export { AbstractListenerCollection } from './index9.mjs';
9
9
  export { AbstractEventManager } from './index10.mjs';
10
- export { Await } from './index11.mjs';
11
- export { createParamIndexDecorator } from './index12.mjs';
12
- export { ParameterDecoratorFactory } from './index13.mjs';
13
- export { Context } from './index14.mjs';
14
- export { Configuration } from './index15.mjs';
15
- export { Definition } from './index16.mjs';
16
- export { Dispose } from './index17.mjs';
17
- export { Use, decorateUse } from './index18.mjs';
18
- export { Global, decorateGlobal } from './index19.mjs';
19
- export { Optional } from './index20.mjs';
20
- export { getDecoratedParametersIndexes, getParamIndexKey, getParamValueKey, getParameterIndexes, getParameterValues } from './index21.mjs';
21
- export { ConstructorDecorator, createConstructorDecorator } from './index22.mjs';
10
+ export { After, Around, Before, Transversal, isTransversal } from './index11.mjs';
11
+ export { Affect } from './index12.mjs';
12
+ export { TransversalManager } from './index13.mjs';
13
+ export { AbstractTransversal } from './index14.mjs';
14
+ export { Await } from './index15.mjs';
15
+ export { createParamIndexDecorator } from './index16.mjs';
16
+ export { ParameterDecoratorFactory } from './index17.mjs';
17
+ export { Context } from './index18.mjs';
18
+ export { Configuration } from './index19.mjs';
19
+ export { Definition } from './index20.mjs';
20
+ export { Dispose } from './index21.mjs';
21
+ export { Use, decorateUse } from './index22.mjs';
22
+ export { Global, decorateGlobal } from './index23.mjs';
23
+ export { Optional } from './index24.mjs';
24
+ export { getDecoratedParametersIndexes, getParamIndexKey, getParamValueKey, getParameterIndexes, getParameterValues } from './index25.mjs';
25
+ export { ConstructorDecorator, createConstructorDecorator } from './index26.mjs';
package/dist/index11.js CHANGED
@@ -2,26 +2,88 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const Await = (t, e = 25)=>{
6
- return (n, s, a)=>{
7
- const i = a.value;
8
- a.value = async function() {
9
- return new Promise((n)=>{
10
- if (this[t]) {
11
- i.apply(this);
12
- n();
13
- } else {
14
- const s = setInterval(()=>{
15
- if (this[t]) {
16
- clearInterval(s);
17
- i.apply(this);
18
- n();
19
- }
20
- }, e);
21
- }
22
- });
5
+ const constants = require('./index28.js');
6
+ const reflection = require('./index34.js');
7
+ const decorator = require('./index2.js');
8
+ const schema = require('./index37.js');
9
+
10
+ function isTransversal(e) {
11
+ try {
12
+ const t = schema.getDefinition(e);
13
+ return t?.metadata?.isTransversal === true;
14
+ } catch {
15
+ return false;
16
+ }
17
+ }
18
+ function Transversal(t) {
19
+ return function(a) {
20
+ if (t) {
21
+ if ('inject' in t || 'use' in t) {
22
+ throw new Error(`@Transversal on class ${a.name} cannot have inject or use properties. ` + `Aspects receive dependencies through constructor parameters resolved from parent context.`);
23
+ }
24
+ }
25
+ const s = reflection.getCustomMetadata(constants.ReflectValue.TransversalAdvices, a) || [];
26
+ const o = {
27
+ singleton: true,
28
+ ...t,
29
+ inject: [],
30
+ use: [],
31
+ metadata: {
32
+ ...t?.metadata,
33
+ isTransversal: true,
34
+ advices: s
35
+ }
23
36
  };
37
+ return decorator.Assemblage(o)(a);
38
+ };
39
+ }
40
+ function Before(e, t = 0) {
41
+ return function(r, n, a) {
42
+ s(r.constructor, {
43
+ type: 'before',
44
+ pointcut: e,
45
+ methodName: n,
46
+ priority: t,
47
+ enabled: true
48
+ });
49
+ };
50
+ }
51
+ function After(e, t = 0) {
52
+ return function(r, n, a) {
53
+ s(r.constructor, {
54
+ type: 'after',
55
+ pointcut: e,
56
+ methodName: n,
57
+ priority: t,
58
+ enabled: true
59
+ });
60
+ };
61
+ }
62
+ function Around(e, t = 0) {
63
+ return function(r, n, a) {
64
+ s(r.constructor, {
65
+ type: 'around',
66
+ pointcut: e,
67
+ methodName: n,
68
+ priority: t,
69
+ enabled: true
70
+ });
24
71
  };
25
- };
72
+ }
73
+ function s(e, a) {
74
+ const s = reflection.getCustomMetadata(constants.ReflectValue.TransversalAdvices, e) || [];
75
+ s.push(a);
76
+ reflection.defineCustomMetadata(constants.ReflectValue.TransversalAdvices, s, e);
77
+ const o = reflection.getCustomMetadata('assemblage:definition.value', e) || {};
78
+ if (!o.metadata) {
79
+ o.metadata = {};
80
+ }
81
+ o.metadata.advices = s;
82
+ reflection.defineCustomMetadata('assemblage:definition.value', o, e);
83
+ }
26
84
 
27
- exports.Await = Await;
85
+ exports.After = After;
86
+ exports.Around = Around;
87
+ exports.Before = Before;
88
+ exports.Transversal = Transversal;
89
+ exports.isTransversal = isTransversal;
package/dist/index11.mjs CHANGED
@@ -1,23 +1,81 @@
1
- const Await = (t, e = 25)=>{
2
- return (n, s, a)=>{
3
- const i = a.value;
4
- a.value = async function() {
5
- return new Promise((n)=>{
6
- if (this[t]) {
7
- i.apply(this);
8
- n();
9
- } else {
10
- const s = setInterval(()=>{
11
- if (this[t]) {
12
- clearInterval(s);
13
- i.apply(this);
14
- n();
15
- }
16
- }, e);
17
- }
18
- });
1
+ import { ReflectValue } from './index28.mjs';
2
+ import { getCustomMetadata, defineCustomMetadata } from './index34.mjs';
3
+ import { Assemblage } from './index2.mjs';
4
+ import { getDefinition } from './index37.mjs';
5
+
6
+ function isTransversal(e) {
7
+ try {
8
+ const t = getDefinition(e);
9
+ return t?.metadata?.isTransversal === true;
10
+ } catch {
11
+ return false;
12
+ }
13
+ }
14
+ function Transversal(t) {
15
+ return function(a) {
16
+ if (t) {
17
+ if ('inject' in t || 'use' in t) {
18
+ throw new Error(`@Transversal on class ${a.name} cannot have inject or use properties. ` + `Aspects receive dependencies through constructor parameters resolved from parent context.`);
19
+ }
20
+ }
21
+ const s = getCustomMetadata(ReflectValue.TransversalAdvices, a) || [];
22
+ const o = {
23
+ singleton: true,
24
+ ...t,
25
+ inject: [],
26
+ use: [],
27
+ metadata: {
28
+ ...t?.metadata,
29
+ isTransversal: true,
30
+ advices: s
31
+ }
19
32
  };
33
+ return Assemblage(o)(a);
34
+ };
35
+ }
36
+ function Before(e, t = 0) {
37
+ return function(r, n, a) {
38
+ s(r.constructor, {
39
+ type: 'before',
40
+ pointcut: e,
41
+ methodName: n,
42
+ priority: t,
43
+ enabled: true
44
+ });
45
+ };
46
+ }
47
+ function After(e, t = 0) {
48
+ return function(r, n, a) {
49
+ s(r.constructor, {
50
+ type: 'after',
51
+ pointcut: e,
52
+ methodName: n,
53
+ priority: t,
54
+ enabled: true
55
+ });
56
+ };
57
+ }
58
+ function Around(e, t = 0) {
59
+ return function(r, n, a) {
60
+ s(r.constructor, {
61
+ type: 'around',
62
+ pointcut: e,
63
+ methodName: n,
64
+ priority: t,
65
+ enabled: true
66
+ });
20
67
  };
21
- };
68
+ }
69
+ function s(e, a) {
70
+ const s = getCustomMetadata(ReflectValue.TransversalAdvices, e) || [];
71
+ s.push(a);
72
+ defineCustomMetadata(ReflectValue.TransversalAdvices, s, e);
73
+ const o = getCustomMetadata('assemblage:definition.value', e) || {};
74
+ if (!o.metadata) {
75
+ o.metadata = {};
76
+ }
77
+ o.metadata.advices = s;
78
+ defineCustomMetadata('assemblage:definition.value', o, e);
79
+ }
22
80
 
23
- export { Await };
81
+ export { After, Around, Before, Transversal, isTransversal };
package/dist/index12.js CHANGED
@@ -2,15 +2,24 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const reflection = require('./index30.js');
5
+ require('./index27.js');
6
+ const constants = require('./index28.js');
6
7
 
7
- const t = (t)=>()=>{
8
- return (e, c, n)=>{
9
- const a = reflection.getOwnCustomMetadata(t, e) || [];
10
- a.push(n);
11
- reflection.defineCustomMetadata(t, a, e);
8
+ function Affect(t, f) {
9
+ return function(o, c, n) {
10
+ const d = {
11
+ transversal: t,
12
+ config: f
12
13
  };
14
+ const a = Reflect.getOwnMetadata(constants.ReflectValue.AffectedMethods, o, c) || [];
15
+ a.push(d);
16
+ Reflect.defineMetadata(constants.ReflectValue.AffectedMethods, a, o, c);
17
+ return n;
13
18
  };
14
- const createParamIndexDecorator = t;
19
+ }
20
+ function getAffectedMethods(t, f) {
21
+ return Reflect.getOwnMetadata(constants.ReflectValue.AffectedMethods, t, f) || [];
22
+ }
15
23
 
16
- exports.createParamIndexDecorator = createParamIndexDecorator;
24
+ exports.Affect = Affect;
25
+ exports.getAffectedMethods = getAffectedMethods;
package/dist/index12.mjs CHANGED
@@ -1,12 +1,20 @@
1
- import { getOwnCustomMetadata, defineCustomMetadata } from './index30.mjs';
1
+ import './index27.mjs';
2
+ import { ReflectValue } from './index28.mjs';
2
3
 
3
- const t = (t)=>()=>{
4
- return (e, c, n)=>{
5
- const a = getOwnCustomMetadata(t, e) || [];
6
- a.push(n);
7
- defineCustomMetadata(t, a, e);
4
+ function Affect(t, f) {
5
+ return function(o, c, n) {
6
+ const d = {
7
+ transversal: t,
8
+ config: f
8
9
  };
10
+ const a = Reflect.getOwnMetadata(ReflectValue.AffectedMethods, o, c) || [];
11
+ a.push(d);
12
+ Reflect.defineMetadata(ReflectValue.AffectedMethods, a, o, c);
13
+ return n;
9
14
  };
10
- const createParamIndexDecorator = t;
15
+ }
16
+ function getAffectedMethods(t, f) {
17
+ return Reflect.getOwnMetadata(ReflectValue.AffectedMethods, t, f) || [];
18
+ }
11
19
 
12
- export { createParamIndexDecorator };
20
+ export { Affect, getAffectedMethods };
package/dist/index13.js CHANGED
@@ -2,93 +2,168 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const reflection = require('./index30.js');
5
+ const core = require('@assemblerjs/core');
6
+ const pointcutMatcher = require('./index39.js');
7
+ const affect = require('./index12.js');
8
+ const schema = require('./index37.js');
6
9
 
7
- class ParameterDecoratorFactory {
8
- static create(e) {
9
- const { name: r, valueType: t = 'single', handler: a } = e;
10
- if (this.registeredDecorators.has(r)) {
11
- throw new Error(`Decorator ${r} already exists`);
10
+ class TransversalManager {
11
+ static getInstance(e) {
12
+ let t = this.instances.get(e);
13
+ if (!t) {
14
+ t = new TransversalManager(e);
15
+ this.instances.set(e, t);
12
16
  }
13
- const s = `assemblage:${r.toLowerCase()}.param.index`;
14
- const o = `assemblage:${r.toLowerCase()}.param.value`;
15
- const c = this.createDecoratorFunction(s, o, t);
16
- this.registeredDecorators.set(r, {
17
- name: r,
18
- valueType: t,
19
- handler: a
20
- });
21
- return c;
17
+ return t;
22
18
  }
23
- static createDecoratorFunction(e, r, t) {
24
- return (a)=>{
25
- return (s, o, c)=>{
26
- this.storeParameterData(a, s, c, e, r, t);
27
- };
28
- };
19
+ getTransversalInstance(e) {
20
+ return TransversalManager.transversalInstances.get(e);
21
+ }
22
+ static resetGlobalState() {
23
+ TransversalManager.transversalInstances.clear();
24
+ TransversalManager.transversalMetadata.clear();
25
+ TransversalManager.instances = new WeakMap();
29
26
  }
30
- static validateSingleDecoratorPerParameter(r, t, a) {
31
- for (const s of this.registeredDecorators.keys()){
32
- const o = `assemblage:${s.toLowerCase()}.param.index`;
33
- if (o === a) {
34
- continue;
27
+ registerTransversal(t, n) {
28
+ let s;
29
+ let r;
30
+ let o;
31
+ if (t.length === 1) {
32
+ s = t[0];
33
+ r = t[0];
34
+ o = undefined;
35
+ } else if (t.length === 2) {
36
+ const a = t[1];
37
+ if (core.isClass(a)) {
38
+ s = t[0];
39
+ r = a;
40
+ o = undefined;
41
+ } else {
42
+ s = t[0];
43
+ r = t[0];
44
+ o = a;
35
45
  }
36
- const c = reflection.getOwnCustomMetadata(o, r) || [];
37
- if (c.includes(t)) {
38
- throw new Error(`Parameter at index ${t} already has decorator @${s}. ` + `Multiple decorators per parameter are not allowed.`);
46
+ } else {
47
+ s = t[0];
48
+ r = t[1];
49
+ o = t[2];
50
+ }
51
+ const c = r.name;
52
+ if (!TransversalManager.transversalInstances.has(c)) {
53
+ const e = n || this.context;
54
+ const t = e.require(s, o);
55
+ const i = schema.getDefinition(r);
56
+ if (!i) {
57
+ throw new Error(`Transversal ${c} must be decorated with @Transversal`);
39
58
  }
59
+ TransversalManager.transversalInstances.set(c, t);
60
+ const l = {
61
+ definition: i,
62
+ advices: this.extractAdvices(r, t),
63
+ instance: t
64
+ };
65
+ TransversalManager.transversalMetadata.set(c, l);
40
66
  }
41
67
  }
42
- static storeParameterData(t, a, s, o, c, i) {
43
- this.validateSingleDecoratorPerParameter(a, s, o);
44
- const n = reflection.getOwnCustomMetadata(o, a) || [];
45
- n.push(s);
46
- reflection.defineCustomMetadata(o, n, a);
47
- switch(i){
48
- case 'single':
49
- {
50
- reflection.defineCustomMetadata(c, t, a);
51
- break;
52
- }
53
- case 'array':
54
- {
55
- const o = reflection.getOwnCustomMetadata(c, a) || [];
56
- o[s] = t;
57
- reflection.defineCustomMetadata(c, o, a);
58
- break;
59
- }
60
- case 'map':
61
- {
62
- const o = reflection.getOwnCustomMetadata(c, a) || {};
63
- o[s] = t;
64
- reflection.defineCustomMetadata(c, o, a);
65
- break;
66
- }
68
+ extractAdvices(e, t) {
69
+ const n = schema.getDefinition(e);
70
+ const s = [];
71
+ const r = n?.metadata?.advices || [];
72
+ for (const a of r){
73
+ const n = t[a.methodName];
74
+ if (typeof n !== 'function') {
75
+ throw new Error(`Advice method ${a.methodName} not found in ${e.name}`);
76
+ }
77
+ const r = a.pointcut.startsWith('execution(') ? undefined : a.pointcut;
78
+ s.push({
79
+ type: a.type,
80
+ pointcut: a.pointcut,
81
+ method: n,
82
+ transversalInstance: t,
83
+ priority: a.priority || 0,
84
+ enabled: a.enabled ?? true,
85
+ role: r
86
+ });
67
87
  }
88
+ return s;
68
89
  }
69
- static createParameterIndexGetter(r) {
70
- return (t)=>{
71
- return reflection.getOwnCustomMetadata(r, t) || [];
72
- };
73
- }
74
- static createParameterValueGetter(r, t) {
75
- return (t)=>{
76
- return reflection.getOwnCustomMetadata(r, t);
77
- };
90
+ getAspectsForTarget(e) {
91
+ const t = [];
92
+ for (const a of TransversalManager.transversalMetadata.values()){
93
+ if (this.hasMatchingAdviceForClass(a, e)) {
94
+ t.push(a);
95
+ }
96
+ }
97
+ return t;
78
98
  }
79
- static getRegisteredDecorators() {
80
- return Array.from(this.registeredDecorators.keys());
99
+ hasMatchingAdviceForClass(e, t) {
100
+ return e.advices.some((e)=>{
101
+ if (!e.enabled) return false;
102
+ const a = e.pointcut.match(/execution\(([^.]+)\.[^)]+\)/);
103
+ if (a) {
104
+ const e = a[1];
105
+ const n = this.patternToRegex(e);
106
+ return n.test(t.name);
107
+ }
108
+ return false;
109
+ });
81
110
  }
82
- static isRegistered(e) {
83
- return this.registeredDecorators.has(e);
111
+ patternToRegex(e) {
112
+ if (e === '*') {
113
+ return /.*/;
114
+ }
115
+ const t = e.replace(/[.+?^${}()|[\]\\]/g, '\\$&');
116
+ const a = t.replace(/\*/g, '.*');
117
+ return new RegExp(`^${a}$`);
84
118
  }
85
- static getDecoratorMetadata(e) {
86
- return this.registeredDecorators.get(e);
119
+ getAdvicesForJoinPoint(e, a, s, r) {
120
+ const o = [];
121
+ for (const n of a){
122
+ for (const a of n.advices){
123
+ if (!a.enabled) continue;
124
+ const n = pointcutMatcher.PointcutMatcher.parse(a.pointcut);
125
+ if (n.matches(e)) {
126
+ o.push(a);
127
+ }
128
+ }
129
+ }
130
+ if (s && r) {
131
+ const e = s.constructor.prototype;
132
+ const t = affect.getAffectedMethods(e, r);
133
+ for (const e of t){
134
+ const t = e.transversal;
135
+ const a = typeof t === 'function' ? t.name : String(t);
136
+ let n = TransversalManager.transversalMetadata.get(a);
137
+ if (!n && typeof t === 'function') {
138
+ const e = Object.getPrototypeOf(t);
139
+ if (e && e.name) {
140
+ n = TransversalManager.transversalMetadata.get(e.name);
141
+ }
142
+ }
143
+ if (!n) {
144
+ console.warn(`@Affect: Transversal ${a} not found. Make sure it's registered in transversals[].`);
145
+ continue;
146
+ }
147
+ for (const t of n.advices){
148
+ if (!t.enabled) continue;
149
+ if (e.role && t.role !== e.role) {
150
+ continue;
151
+ }
152
+ o.push({
153
+ ...t,
154
+ config: e.config
155
+ });
156
+ }
157
+ }
158
+ }
159
+ return o.sort((e, t)=>t.priority - e.priority);
87
160
  }
88
- static getDecoratorHandler(e) {
89
- return this.registeredDecorators.get(e)?.handler;
161
+ constructor(e){
162
+ this.context = e;
90
163
  }
91
164
  }
92
- ParameterDecoratorFactory.registeredDecorators = new Map();
165
+ TransversalManager.instances = new WeakMap();
166
+ TransversalManager.transversalInstances = new Map();
167
+ TransversalManager.transversalMetadata = new Map();
93
168
 
94
- exports.ParameterDecoratorFactory = ParameterDecoratorFactory;
169
+ exports.TransversalManager = TransversalManager;