assemblerjs 1.1.26 → 1.1.27

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/index13.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const core = require('@assemblerjs/core');
6
- const pointcutMatcher = require('./index41.js');
6
+ const pointcutMatcher = require('./index39.js');
7
7
  const affect = require('./index12.js');
8
8
  const schema = require('./index31.js');
9
9
 
package/dist/index13.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { isClass } from '@assemblerjs/core';
2
- import { PointcutMatcher } from './index41.mjs';
2
+ import { PointcutMatcher } from './index39.mjs';
3
3
  import { getAffectedMethods } from './index12.mjs';
4
4
  import { getDefinition } from './index31.mjs';
5
5
 
package/dist/index32.js CHANGED
@@ -44,7 +44,7 @@ function formatIdentifier(e) {
44
44
  }
45
45
  return String(e);
46
46
  }
47
- function c(e) {
47
+ function a(e) {
48
48
  if (core.isClass(e)) {
49
49
  const t = e.prototype && Object.getOwnPropertyNames(e.prototype).length > 1;
50
50
  return t ? 'class' : 'class';
@@ -61,18 +61,18 @@ class InjectableManager {
61
61
  this.publicContext = t;
62
62
  }
63
63
  register(i, o = false) {
64
- const a = debugLogger.DebugLogger.getInstance();
65
- const c = o === true ? use.resolveInstanceInjectionTuple(i) : inject.resolveInjectionTuple(i);
66
- if (this.has(c.identifier)) {
67
- const e = `An assemblage is already registered with identifier '${c.identifier.name}'.`;
68
- a.log('error', 'Duplicate registration', {
69
- identifier: c.identifier.name,
64
+ const c = debugLogger.DebugLogger.getInstance();
65
+ const a = o === true ? use.resolveInstanceInjectionTuple(i) : inject.resolveInjectionTuple(i);
66
+ if (this.has(a.identifier)) {
67
+ const e = `An assemblage is already registered with identifier '${a.identifier.name}'.`;
68
+ c.log('error', 'Duplicate registration', {
69
+ identifier: a.identifier.name,
70
70
  error: e
71
71
  });
72
72
  throw new Error(e);
73
73
  }
74
- const f = injectable.Injectable.of(c, this.privateContext, this.publicContext);
75
- a.logRegistration(f);
74
+ const f = injectable.Injectable.of(a, this.privateContext, this.publicContext);
75
+ c.logRegistration(f);
76
76
  this.injectables.set(f.identifier, f);
77
77
  if (f.concrete) {
78
78
  hookManager.HookManager.callHook(f.concrete, 'onRegister', this.publicContext, f.configuration);
@@ -83,44 +83,49 @@ class InjectableManager {
83
83
  return this.injectables.has(e);
84
84
  }
85
85
  require(e, t, n) {
86
+ const r = debugLogger.DebugLogger.getInstance();
87
+ const i = formatIdentifier(e);
88
+ const o = n ? formatIdentifier(n) : undefined;
89
+ r.logDependencyStart(i, o);
86
90
  if (!this.injectables.has(e)) {
87
- const r = this.resolvingStack.has(e);
88
- const i = r ? 'Circular dependency detected' : 'Dependency not registered';
89
- const o = formatIdentifier(e);
90
- const a = c(e);
91
+ const o = this.resolvingStack.has(e);
92
+ const s = o ? 'Circular dependency detected' : 'Dependency not registered';
93
+ const c = a(e);
91
94
  const f = t?.__paramIndex;
92
95
  const u = t?.__paramCount;
93
96
  const l = t?.__expectedType;
94
- const g = r ? `Circular dependency detected: '${o}' is already being resolved.` : `Dependency '${o}' has not been registered (Class/Service not found in current assemblages).`;
95
- const d = {
96
- identifier: o,
97
+ const d = o ? `Circular dependency detected: '${i}' is already being resolved.` : `Dependency '${i}' has not been registered (Class/Service not found in current assemblages).`;
98
+ const g = {
99
+ identifier: i,
97
100
  caller: n ? formatIdentifier(n) : 'unknown',
98
- type: a,
99
- error: g
101
+ type: c,
102
+ error: d
100
103
  };
101
104
  if (f !== undefined) {
102
- d.paramIndex = f;
105
+ g.paramIndex = f;
103
106
  }
104
107
  if (u !== undefined) {
105
- d.paramCount = u;
108
+ g.paramCount = u;
106
109
  }
107
110
  if (l !== undefined) {
108
111
  const e = l?.name || formatIdentifier(l);
109
- d.expectedType = e;
112
+ g.expectedType = e;
110
113
  }
111
- debugLogger.DebugLogger.getInstance().log('error', i, d);
112
- throw new Error(g);
114
+ r.log('error', s, g);
115
+ r.logDependencyEnd(i);
116
+ throw new Error(d);
113
117
  }
114
- const r = this.injectables.get(e);
115
- this.resolvingStack.add(r.identifier);
118
+ const c = this.injectables.get(e);
119
+ this.resolvingStack.add(c.identifier);
116
120
  try {
117
- if (r.isSingleton) {
118
- return this.singletonStrategy.resolve(r, t);
121
+ if (c.isSingleton) {
122
+ return this.singletonStrategy.resolve(c, t);
119
123
  } else {
120
- return this.transientStrategy.resolve(r, t);
124
+ return this.transientStrategy.resolve(c, t);
121
125
  }
122
126
  } finally{
123
- this.resolvingStack.delete(r.identifier);
127
+ this.resolvingStack.delete(c.identifier);
128
+ r.logDependencyEnd(i);
124
129
  }
125
130
  }
126
131
  concrete(e) {
package/dist/index32.mjs CHANGED
@@ -40,7 +40,7 @@ function formatIdentifier(e) {
40
40
  }
41
41
  return String(e);
42
42
  }
43
- function c(e) {
43
+ function a(e) {
44
44
  if (isClass(e)) {
45
45
  const t = e.prototype && Object.getOwnPropertyNames(e.prototype).length > 1;
46
46
  return t ? 'class' : 'class';
@@ -57,18 +57,18 @@ class InjectableManager {
57
57
  this.publicContext = t;
58
58
  }
59
59
  register(i, o = false) {
60
- const a = DebugLogger.getInstance();
61
- const c = o === true ? resolveInstanceInjectionTuple(i) : resolveInjectionTuple(i);
62
- if (this.has(c.identifier)) {
63
- const e = `An assemblage is already registered with identifier '${c.identifier.name}'.`;
64
- a.log('error', 'Duplicate registration', {
65
- identifier: c.identifier.name,
60
+ const c = DebugLogger.getInstance();
61
+ const a = o === true ? resolveInstanceInjectionTuple(i) : resolveInjectionTuple(i);
62
+ if (this.has(a.identifier)) {
63
+ const e = `An assemblage is already registered with identifier '${a.identifier.name}'.`;
64
+ c.log('error', 'Duplicate registration', {
65
+ identifier: a.identifier.name,
66
66
  error: e
67
67
  });
68
68
  throw new Error(e);
69
69
  }
70
- const f = Injectable.of(c, this.privateContext, this.publicContext);
71
- a.logRegistration(f);
70
+ const f = Injectable.of(a, this.privateContext, this.publicContext);
71
+ c.logRegistration(f);
72
72
  this.injectables.set(f.identifier, f);
73
73
  if (f.concrete) {
74
74
  HookManager.callHook(f.concrete, 'onRegister', this.publicContext, f.configuration);
@@ -79,44 +79,49 @@ class InjectableManager {
79
79
  return this.injectables.has(e);
80
80
  }
81
81
  require(e, t, n) {
82
+ const r = DebugLogger.getInstance();
83
+ const i = formatIdentifier(e);
84
+ const o = n ? formatIdentifier(n) : undefined;
85
+ r.logDependencyStart(i, o);
82
86
  if (!this.injectables.has(e)) {
83
- const r = this.resolvingStack.has(e);
84
- const i = r ? 'Circular dependency detected' : 'Dependency not registered';
85
- const o = formatIdentifier(e);
86
- const a = c(e);
87
+ const o = this.resolvingStack.has(e);
88
+ const s = o ? 'Circular dependency detected' : 'Dependency not registered';
89
+ const c = a(e);
87
90
  const f = t?.__paramIndex;
88
91
  const u = t?.__paramCount;
89
92
  const l = t?.__expectedType;
90
- const g = r ? `Circular dependency detected: '${o}' is already being resolved.` : `Dependency '${o}' has not been registered (Class/Service not found in current assemblages).`;
91
- const d = {
92
- identifier: o,
93
+ const d = o ? `Circular dependency detected: '${i}' is already being resolved.` : `Dependency '${i}' has not been registered (Class/Service not found in current assemblages).`;
94
+ const g = {
95
+ identifier: i,
93
96
  caller: n ? formatIdentifier(n) : 'unknown',
94
- type: a,
95
- error: g
97
+ type: c,
98
+ error: d
96
99
  };
97
100
  if (f !== undefined) {
98
- d.paramIndex = f;
101
+ g.paramIndex = f;
99
102
  }
100
103
  if (u !== undefined) {
101
- d.paramCount = u;
104
+ g.paramCount = u;
102
105
  }
103
106
  if (l !== undefined) {
104
107
  const e = l?.name || formatIdentifier(l);
105
- d.expectedType = e;
108
+ g.expectedType = e;
106
109
  }
107
- DebugLogger.getInstance().log('error', i, d);
108
- throw new Error(g);
110
+ r.log('error', s, g);
111
+ r.logDependencyEnd(i);
112
+ throw new Error(d);
109
113
  }
110
- const r = this.injectables.get(e);
111
- this.resolvingStack.add(r.identifier);
114
+ const c = this.injectables.get(e);
115
+ this.resolvingStack.add(c.identifier);
112
116
  try {
113
- if (r.isSingleton) {
114
- return this.singletonStrategy.resolve(r, t);
117
+ if (c.isSingleton) {
118
+ return this.singletonStrategy.resolve(c, t);
115
119
  } else {
116
- return this.transientStrategy.resolve(r, t);
120
+ return this.transientStrategy.resolve(c, t);
117
121
  }
118
122
  } finally{
119
- this.resolvingStack.delete(r.identifier);
123
+ this.resolvingStack.delete(c.identifier);
124
+ r.logDependencyEnd(i);
120
125
  }
121
126
  }
122
127
  concrete(e) {
package/dist/index37.js CHANGED
@@ -13,9 +13,9 @@ function e(e) {
13
13
  return 'AnonymousFunction';
14
14
  }
15
15
  if (typeof e === 'object') {
16
- const o = e.constructor?.name;
17
- if (o && o !== 'Object') {
18
- return o;
16
+ const t = e.constructor?.name;
17
+ if (t && t !== 'Object') {
18
+ return t;
19
19
  }
20
20
  if (e.name && typeof e.name === 'string') {
21
21
  return e.name;
@@ -26,16 +26,18 @@ function e(e) {
26
26
  }
27
27
  let NoOpDebugLogger = class NoOpDebugLogger {
28
28
  configure(e) {}
29
- log(e, o, t) {}
29
+ log(e, t, n) {}
30
30
  logBuildStart(e) {}
31
- logBuildEnd(e, o) {}
31
+ logBuildEnd(e, t) {}
32
32
  logRegistration(e) {}
33
- logHook(e, o, t) {}
34
- logPhaseStart(e, o) {}
35
- logPhaseEnd(e, o, t) {}
36
- logResolution(e, o, t) {}
33
+ logHook(e, t, n) {}
34
+ logPhaseStart(e, t) {}
35
+ logPhaseEnd(e, t, n) {}
36
+ logResolution(e, t, n) {}
37
37
  logConstruction(e) {}
38
- logInjection(e, o) {}
38
+ logInjection(e, t) {}
39
+ logDependencyStart(e, t) {}
40
+ logDependencyEnd(e) {}
39
41
  };
40
42
  let ActiveDebugLogger = class ActiveDebugLogger {
41
43
  configure(e) {
@@ -53,90 +55,124 @@ let ActiveDebugLogger = class ActiveDebugLogger {
53
55
  entry: e.name
54
56
  });
55
57
  }
56
- logBuildEnd(e, o) {
57
- const t = {
58
+ logBuildEnd(e, t) {
59
+ const n = {
58
60
  entry: e.name
59
61
  };
60
- if (o !== undefined) t.duration = `${o.toFixed(2)}ms`;
61
- this.log('info', 'Build completed', t);
62
+ if (t !== undefined) n.duration = `${t.toFixed(2)}ms`;
63
+ this.log('info', 'Build completed', n);
62
64
  }
63
- logRegistration(o) {
65
+ logRegistration(t) {
64
66
  if (!this.shouldLog('registration')) return;
65
67
  this.log('info', 'Registration', {
66
- identifier: e(o.identifier),
67
- isSingleton: o.isSingleton,
68
- dependencies: o.dependencies.map((o)=>e(o)),
69
- tags: o.tags
68
+ identifier: e(t.identifier),
69
+ isSingleton: t.isSingleton,
70
+ dependencies: t.dependencies.map((t)=>e(t)),
71
+ tags: t.tags
70
72
  });
71
73
  }
72
- logHook(o, t, n) {
74
+ logHook(t, n, o) {
73
75
  if (!this.shouldLog('hooks')) return;
74
76
  const i = this.options.logTimings ? performance.now() : 0;
75
- this.log('info', `Hook: ${o}`, {
76
- target: e(t),
77
- config: n
77
+ this.log('info', `Hook: ${t}`, {
78
+ target: e(n),
79
+ config: o
78
80
  });
79
81
  if (this.options.logTimings) {
80
82
  return ()=>{
81
83
  const e = performance.now() - i;
82
- this.log('info', `Hook: ${o} completed`, {
84
+ this.log('info', `Hook: ${t} completed`, {
83
85
  duration: `${e.toFixed(2)}ms`
84
86
  });
85
87
  };
86
88
  }
87
89
  }
88
- logPhaseStart(e, o) {
89
- this.log('info', `Phase: ${e} started`, o);
90
+ logPhaseStart(e, t) {
91
+ this.log('info', `Phase: ${e} started`, t);
90
92
  }
91
- logPhaseEnd(e, o, t) {
92
- const n = o !== undefined ? {
93
- duration: `${o.toFixed(2)}ms`
93
+ logPhaseEnd(e, t, n) {
94
+ const o = t !== undefined ? {
95
+ duration: `${t.toFixed(2)}ms`
94
96
  } : {};
95
- if (t) {
96
- Object.assign(n, t);
97
+ if (n) {
98
+ Object.assign(o, n);
97
99
  }
98
- this.log('info', `Phase: ${e} ended`, Object.keys(n).length > 0 ? n : undefined);
100
+ this.log('info', `Phase: ${e} ended`, Object.keys(o).length > 0 ? o : undefined);
99
101
  }
100
- logResolution(e, o, t) {
102
+ logResolution(e, t, n) {
101
103
  if (!this.shouldLog('resolution')) return;
102
104
  this.log('info', `Resolving: ${e}`, {
103
- strategy: `${o} strategy`,
104
- cache: t ? 'hit' : 'miss'
105
+ strategy: `${t} strategy`,
106
+ cache: n ? 'hit' : 'miss'
105
107
  });
106
108
  }
107
109
  logConstruction(e) {
108
110
  if (!this.shouldLog('construction')) return;
109
111
  this.log('info', `Constructing: ${e}`);
110
112
  }
111
- logInjection(e, o) {
113
+ logInjection(e, t) {
112
114
  if (!this.shouldLog(e === 'use' ? 'injectionUse' : 'injectionGlobal')) return;
113
- this.log('info', `Injecting: @${e === 'use' ? 'Use' : 'Global'}`, o);
115
+ this.log('info', `Injecting: @${e === 'use' ? 'Use' : 'Global'}`, t);
114
116
  }
115
117
  shouldLog(e) {
116
118
  return !this.options.logPhases || this.options.logPhases[e] !== false;
117
119
  }
118
- log(e, o, t) {
120
+ log(e, t, n) {
119
121
  if (this.options.logger) {
120
- this.options.logger(e, o, t);
122
+ this.options.logger(e, t, n);
121
123
  } else {
122
- const n = `[Assembler:${e}]`;
123
- const i = this.options.useColors !== false ? this.colorize(e, n) : n;
124
- if (t) {
125
- console.log(`${i} ${o}`, t);
124
+ const o = `[Assembler:${e}]`;
125
+ const i = this.options.useColors !== false ? this.colorize(e, o) : o;
126
+ if (n) {
127
+ console.log(`${i} ${t}`, n);
126
128
  } else {
127
- console.log(`${i} ${o}`);
129
+ console.log(`${i} ${t}`);
128
130
  }
129
131
  }
130
132
  }
131
- colorize(e, o) {
132
- const t = {
133
+ colorize(e, t) {
134
+ const n = {
133
135
  info: '\x1b[36m',
134
136
  warn: '\x1b[33m',
135
137
  error: '\x1b[31m',
136
138
  reset: '\x1b[0m'
137
139
  };
138
- const n = t[e] || t.info;
139
- return `${n}${o}${t.reset}`;
140
+ const o = n[e] || n.info;
141
+ return `${o}${t}${n.reset}`;
142
+ }
143
+ logDependencyStart(e, t) {
144
+ if (!this.options.logDependencyTree) return;
145
+ const n = this.dependencyStack.length;
146
+ const o = ' '.repeat(n);
147
+ const i = this.visitedDependencies.has(e);
148
+ this.dependencyStack.push({
149
+ identifier: e,
150
+ caller: t
151
+ });
152
+ if (i) {
153
+ this.log('warn', `${o}🔄 ${e} (CYCLE DETECTED)`, t ? {
154
+ caller: t
155
+ } : undefined);
156
+ } else {
157
+ this.visitedDependencies.add(e);
158
+ this.log('info', `${o}📦 ${e}`, t ? {
159
+ caller: t
160
+ } : undefined);
161
+ }
162
+ }
163
+ logDependencyEnd(e) {
164
+ if (!this.options.logDependencyTree) return;
165
+ const t = this.dependencyStack.pop();
166
+ if (t?.identifier !== e) {
167
+ this.log('error', 'Dependency stack corruption', {
168
+ expected: e,
169
+ actual: t?.identifier,
170
+ stackDepth: this.dependencyStack.length
171
+ });
172
+ }
173
+ if (this.dependencyStack.length === 0) {
174
+ this.visitedDependencies.clear();
175
+ }
140
176
  }
141
177
  constructor(){
142
178
  this.options = {
@@ -156,6 +192,8 @@ let ActiveDebugLogger = class ActiveDebugLogger {
156
192
  logDependencyTree: true,
157
193
  useColors: true
158
194
  };
195
+ this.dependencyStack = [];
196
+ this.visitedDependencies = new Set();
159
197
  }
160
198
  };
161
199
  class DebugLogger {
package/dist/index37.mjs CHANGED
@@ -9,9 +9,9 @@ function e(e) {
9
9
  return 'AnonymousFunction';
10
10
  }
11
11
  if (typeof e === 'object') {
12
- const o = e.constructor?.name;
13
- if (o && o !== 'Object') {
14
- return o;
12
+ const t = e.constructor?.name;
13
+ if (t && t !== 'Object') {
14
+ return t;
15
15
  }
16
16
  if (e.name && typeof e.name === 'string') {
17
17
  return e.name;
@@ -22,16 +22,18 @@ function e(e) {
22
22
  }
23
23
  let NoOpDebugLogger = class NoOpDebugLogger {
24
24
  configure(e) {}
25
- log(e, o, t) {}
25
+ log(e, t, n) {}
26
26
  logBuildStart(e) {}
27
- logBuildEnd(e, o) {}
27
+ logBuildEnd(e, t) {}
28
28
  logRegistration(e) {}
29
- logHook(e, o, t) {}
30
- logPhaseStart(e, o) {}
31
- logPhaseEnd(e, o, t) {}
32
- logResolution(e, o, t) {}
29
+ logHook(e, t, n) {}
30
+ logPhaseStart(e, t) {}
31
+ logPhaseEnd(e, t, n) {}
32
+ logResolution(e, t, n) {}
33
33
  logConstruction(e) {}
34
- logInjection(e, o) {}
34
+ logInjection(e, t) {}
35
+ logDependencyStart(e, t) {}
36
+ logDependencyEnd(e) {}
35
37
  };
36
38
  let ActiveDebugLogger = class ActiveDebugLogger {
37
39
  configure(e) {
@@ -49,90 +51,124 @@ let ActiveDebugLogger = class ActiveDebugLogger {
49
51
  entry: e.name
50
52
  });
51
53
  }
52
- logBuildEnd(e, o) {
53
- const t = {
54
+ logBuildEnd(e, t) {
55
+ const n = {
54
56
  entry: e.name
55
57
  };
56
- if (o !== undefined) t.duration = `${o.toFixed(2)}ms`;
57
- this.log('info', 'Build completed', t);
58
+ if (t !== undefined) n.duration = `${t.toFixed(2)}ms`;
59
+ this.log('info', 'Build completed', n);
58
60
  }
59
- logRegistration(o) {
61
+ logRegistration(t) {
60
62
  if (!this.shouldLog('registration')) return;
61
63
  this.log('info', 'Registration', {
62
- identifier: e(o.identifier),
63
- isSingleton: o.isSingleton,
64
- dependencies: o.dependencies.map((o)=>e(o)),
65
- tags: o.tags
64
+ identifier: e(t.identifier),
65
+ isSingleton: t.isSingleton,
66
+ dependencies: t.dependencies.map((t)=>e(t)),
67
+ tags: t.tags
66
68
  });
67
69
  }
68
- logHook(o, t, n) {
70
+ logHook(t, n, o) {
69
71
  if (!this.shouldLog('hooks')) return;
70
72
  const i = this.options.logTimings ? performance.now() : 0;
71
- this.log('info', `Hook: ${o}`, {
72
- target: e(t),
73
- config: n
73
+ this.log('info', `Hook: ${t}`, {
74
+ target: e(n),
75
+ config: o
74
76
  });
75
77
  if (this.options.logTimings) {
76
78
  return ()=>{
77
79
  const e = performance.now() - i;
78
- this.log('info', `Hook: ${o} completed`, {
80
+ this.log('info', `Hook: ${t} completed`, {
79
81
  duration: `${e.toFixed(2)}ms`
80
82
  });
81
83
  };
82
84
  }
83
85
  }
84
- logPhaseStart(e, o) {
85
- this.log('info', `Phase: ${e} started`, o);
86
+ logPhaseStart(e, t) {
87
+ this.log('info', `Phase: ${e} started`, t);
86
88
  }
87
- logPhaseEnd(e, o, t) {
88
- const n = o !== undefined ? {
89
- duration: `${o.toFixed(2)}ms`
89
+ logPhaseEnd(e, t, n) {
90
+ const o = t !== undefined ? {
91
+ duration: `${t.toFixed(2)}ms`
90
92
  } : {};
91
- if (t) {
92
- Object.assign(n, t);
93
+ if (n) {
94
+ Object.assign(o, n);
93
95
  }
94
- this.log('info', `Phase: ${e} ended`, Object.keys(n).length > 0 ? n : undefined);
96
+ this.log('info', `Phase: ${e} ended`, Object.keys(o).length > 0 ? o : undefined);
95
97
  }
96
- logResolution(e, o, t) {
98
+ logResolution(e, t, n) {
97
99
  if (!this.shouldLog('resolution')) return;
98
100
  this.log('info', `Resolving: ${e}`, {
99
- strategy: `${o} strategy`,
100
- cache: t ? 'hit' : 'miss'
101
+ strategy: `${t} strategy`,
102
+ cache: n ? 'hit' : 'miss'
101
103
  });
102
104
  }
103
105
  logConstruction(e) {
104
106
  if (!this.shouldLog('construction')) return;
105
107
  this.log('info', `Constructing: ${e}`);
106
108
  }
107
- logInjection(e, o) {
109
+ logInjection(e, t) {
108
110
  if (!this.shouldLog(e === 'use' ? 'injectionUse' : 'injectionGlobal')) return;
109
- this.log('info', `Injecting: @${e === 'use' ? 'Use' : 'Global'}`, o);
111
+ this.log('info', `Injecting: @${e === 'use' ? 'Use' : 'Global'}`, t);
110
112
  }
111
113
  shouldLog(e) {
112
114
  return !this.options.logPhases || this.options.logPhases[e] !== false;
113
115
  }
114
- log(e, o, t) {
116
+ log(e, t, n) {
115
117
  if (this.options.logger) {
116
- this.options.logger(e, o, t);
118
+ this.options.logger(e, t, n);
117
119
  } else {
118
- const n = `[Assembler:${e}]`;
119
- const i = this.options.useColors !== false ? this.colorize(e, n) : n;
120
- if (t) {
121
- console.log(`${i} ${o}`, t);
120
+ const o = `[Assembler:${e}]`;
121
+ const i = this.options.useColors !== false ? this.colorize(e, o) : o;
122
+ if (n) {
123
+ console.log(`${i} ${t}`, n);
122
124
  } else {
123
- console.log(`${i} ${o}`);
125
+ console.log(`${i} ${t}`);
124
126
  }
125
127
  }
126
128
  }
127
- colorize(e, o) {
128
- const t = {
129
+ colorize(e, t) {
130
+ const n = {
129
131
  info: '\x1b[36m',
130
132
  warn: '\x1b[33m',
131
133
  error: '\x1b[31m',
132
134
  reset: '\x1b[0m'
133
135
  };
134
- const n = t[e] || t.info;
135
- return `${n}${o}${t.reset}`;
136
+ const o = n[e] || n.info;
137
+ return `${o}${t}${n.reset}`;
138
+ }
139
+ logDependencyStart(e, t) {
140
+ if (!this.options.logDependencyTree) return;
141
+ const n = this.dependencyStack.length;
142
+ const o = ' '.repeat(n);
143
+ const i = this.visitedDependencies.has(e);
144
+ this.dependencyStack.push({
145
+ identifier: e,
146
+ caller: t
147
+ });
148
+ if (i) {
149
+ this.log('warn', `${o}🔄 ${e} (CYCLE DETECTED)`, t ? {
150
+ caller: t
151
+ } : undefined);
152
+ } else {
153
+ this.visitedDependencies.add(e);
154
+ this.log('info', `${o}📦 ${e}`, t ? {
155
+ caller: t
156
+ } : undefined);
157
+ }
158
+ }
159
+ logDependencyEnd(e) {
160
+ if (!this.options.logDependencyTree) return;
161
+ const t = this.dependencyStack.pop();
162
+ if (t?.identifier !== e) {
163
+ this.log('error', 'Dependency stack corruption', {
164
+ expected: e,
165
+ actual: t?.identifier,
166
+ stackDepth: this.dependencyStack.length
167
+ });
168
+ }
169
+ if (this.dependencyStack.length === 0) {
170
+ this.visitedDependencies.clear();
171
+ }
136
172
  }
137
173
  constructor(){
138
174
  this.options = {
@@ -152,6 +188,8 @@ let ActiveDebugLogger = class ActiveDebugLogger {
152
188
  logDependencyTree: true,
153
189
  useColors: true
154
190
  };
191
+ this.dependencyStack = [];
192
+ this.visitedDependencies = new Set();
155
193
  }
156
194
  };
157
195
  class DebugLogger {
package/dist/index39.js CHANGED
@@ -2,45 +2,33 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const eventManager = require('./index6.js');
6
-
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);
15
- }
16
- for (const e of t.events){
17
- n.on(e, (...n)=>{
18
- t.privateContext.emit(e, ...n);
19
- });
20
- }
21
- } else {
22
- for (const e of t.events){
23
- if (!t.privateContext.events.has(e)) t.privateContext.addChannels(e);
5
+ class PointcutMatcher {
6
+ static parse(t) {
7
+ const e = t.match(/^execution\(([^.]+)\.([^)]+)\)$/);
8
+ if (!e) {
9
+ throw new Error(`Invalid pointcut expression: ${t}`);
24
10
  }
11
+ const [, c, r] = e;
12
+ return new ExecutionPointcutMatcher(c, r);
25
13
  }
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);
33
- }
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
- }
14
+ }
15
+ let ExecutionPointcutMatcher = class ExecutionPointcutMatcher {
16
+ matches(t) {
17
+ const e = t.target.constructor.name;
18
+ const c = t.methodName;
19
+ return this.classRegex.test(e) && this.methodRegex.test(c);
20
+ }
21
+ patternToRegex(t) {
22
+ if (t === '*') {
23
+ return /.*/;
41
24
  }
25
+ const e = t.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
26
+ return new RegExp(`^${e}$`);
27
+ }
28
+ constructor(t, e){
29
+ this.classRegex = this.patternToRegex(t);
30
+ this.methodRegex = this.patternToRegex(e);
42
31
  }
43
32
  };
44
33
 
45
- exports.registerEvents = registerEvents;
46
- exports.unregisterEvents = unregisterEvents;
34
+ exports.PointcutMatcher = PointcutMatcher;
package/dist/index39.mjs CHANGED
@@ -1,41 +1,30 @@
1
- import { EventManager } from './index6.mjs';
2
-
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);
11
- }
12
- for (const e of t.events){
13
- n.on(e, (...n)=>{
14
- t.privateContext.emit(e, ...n);
15
- });
16
- }
17
- } else {
18
- for (const e of t.events){
19
- if (!t.privateContext.events.has(e)) t.privateContext.addChannels(e);
1
+ class PointcutMatcher {
2
+ static parse(t) {
3
+ const e = t.match(/^execution\(([^.]+)\.([^)]+)\)$/);
4
+ if (!e) {
5
+ throw new Error(`Invalid pointcut expression: ${t}`);
20
6
  }
7
+ const [, c, r] = e;
8
+ return new ExecutionPointcutMatcher(c, r);
21
9
  }
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);
29
- }
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
- }
10
+ }
11
+ let ExecutionPointcutMatcher = class ExecutionPointcutMatcher {
12
+ matches(t) {
13
+ const e = t.target.constructor.name;
14
+ const c = t.methodName;
15
+ return this.classRegex.test(e) && this.methodRegex.test(c);
16
+ }
17
+ patternToRegex(t) {
18
+ if (t === '*') {
19
+ return /.*/;
37
20
  }
21
+ const e = t.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
22
+ return new RegExp(`^${e}$`);
23
+ }
24
+ constructor(t, e){
25
+ this.classRegex = this.patternToRegex(t);
26
+ this.methodRegex = this.patternToRegex(e);
38
27
  }
39
28
  };
40
29
 
41
- export { registerEvents, unregisterEvents };
30
+ export { PointcutMatcher };
package/dist/index41.js CHANGED
@@ -2,33 +2,45 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- class PointcutMatcher {
6
- static parse(t) {
7
- const e = t.match(/^execution\(([^.]+)\.([^)]+)\)$/);
8
- if (!e) {
9
- throw new Error(`Invalid pointcut expression: ${t}`);
5
+ const eventManager = require('./index6.js');
6
+
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);
10
15
  }
11
- const [, c, r] = e;
12
- return new ExecutionPointcutMatcher(c, r);
13
- }
14
- }
15
- let ExecutionPointcutMatcher = class ExecutionPointcutMatcher {
16
- matches(t) {
17
- const e = t.target.constructor.name;
18
- const c = t.methodName;
19
- return this.classRegex.test(e) && this.methodRegex.test(c);
20
- }
21
- patternToRegex(t) {
22
- if (t === '*') {
23
- return /.*/;
16
+ for (const e of t.events){
17
+ n.on(e, (...n)=>{
18
+ t.privateContext.emit(e, ...n);
19
+ });
20
+ }
21
+ } else {
22
+ for (const e of t.events){
23
+ if (!t.privateContext.events.has(e)) t.privateContext.addChannels(e);
24
24
  }
25
- const e = t.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
26
- return new RegExp(`^${e}$`);
27
25
  }
28
- constructor(t, e){
29
- this.classRegex = this.patternToRegex(t);
30
- this.methodRegex = this.patternToRegex(e);
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);
33
+ }
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
+ }
41
+ }
31
42
  }
32
43
  };
33
44
 
34
- exports.PointcutMatcher = PointcutMatcher;
45
+ exports.registerEvents = registerEvents;
46
+ exports.unregisterEvents = unregisterEvents;
package/dist/index41.mjs CHANGED
@@ -1,30 +1,41 @@
1
- class PointcutMatcher {
2
- static parse(t) {
3
- const e = t.match(/^execution\(([^.]+)\.([^)]+)\)$/);
4
- if (!e) {
5
- throw new Error(`Invalid pointcut expression: ${t}`);
1
+ import { EventManager } from './index6.mjs';
2
+
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);
6
11
  }
7
- const [, c, r] = e;
8
- return new ExecutionPointcutMatcher(c, r);
9
- }
10
- }
11
- let ExecutionPointcutMatcher = class ExecutionPointcutMatcher {
12
- matches(t) {
13
- const e = t.target.constructor.name;
14
- const c = t.methodName;
15
- return this.classRegex.test(e) && this.methodRegex.test(c);
16
- }
17
- patternToRegex(t) {
18
- if (t === '*') {
19
- return /.*/;
12
+ for (const e of t.events){
13
+ n.on(e, (...n)=>{
14
+ t.privateContext.emit(e, ...n);
15
+ });
16
+ }
17
+ } else {
18
+ for (const e of t.events){
19
+ if (!t.privateContext.events.has(e)) t.privateContext.addChannels(e);
20
20
  }
21
- const e = t.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
22
- return new RegExp(`^${e}$`);
23
21
  }
24
- constructor(t, e){
25
- this.classRegex = this.patternToRegex(t);
26
- this.methodRegex = this.patternToRegex(e);
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);
29
+ }
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
+ }
37
+ }
27
38
  }
28
39
  };
29
40
 
30
- export { PointcutMatcher };
41
+ export { registerEvents, unregisterEvents };
package/dist/index45.js CHANGED
@@ -8,7 +8,7 @@ const reflection = require('./index30.js');
8
8
  const debugLogger = require('./index37.js');
9
9
  const injectableBuilder = require('./index50.js');
10
10
  const dependencies = require('./index51.js');
11
- const helpers = require('./index39.js');
11
+ const helpers = require('./index41.js');
12
12
  const hookManager = require('./index34.js');
13
13
  const helpers$1 = require('./index3.js');
14
14
  const use = require('./index43.js');
package/dist/index45.mjs CHANGED
@@ -4,7 +4,7 @@ import { defineCustomMetadata } from './index30.mjs';
4
4
  import { DebugLogger } from './index37.mjs';
5
5
  import { InjectableBuilder } from './index50.mjs';
6
6
  import { resolveDependencies } from './index51.mjs';
7
- import { unregisterEvents } from './index39.mjs';
7
+ import { unregisterEvents } from './index41.mjs';
8
8
  import { HookManager } from './index34.mjs';
9
9
  import { isAssemblage } from './index3.mjs';
10
10
  import { isFactory } from './index43.mjs';
package/dist/index50.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const dependencies = require('./index51.js');
6
6
  const transversalWeaver = require('./index14.js');
7
- const helpers = require('./index39.js');
7
+ const helpers = require('./index41.js');
8
8
 
9
9
  class InjectableBuilder {
10
10
  build(i) {
package/dist/index50.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { resolveInjectableParameters } from './index51.mjs';
2
2
  import { TransversalWeaver } from './index14.mjs';
3
- import { registerEvents } from './index39.mjs';
3
+ import { registerEvents } from './index41.mjs';
4
4
 
5
5
  class InjectableBuilder {
6
6
  build(i) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "assemblerjs",
3
3
  "description": "A general purpose Dependency Injection library for node and browser.",
4
- "version": "1.1.26",
4
+ "version": "1.1.27",
5
5
  "author": "Benoît LAHOZ <info@benoitlahoz.io>",
6
6
  "bugs": "https://github.com/benoitlahoz/assemblerjs/issues",
7
7
  "homepage": "https://github.com/benoitlahoz/assemblerjs#README",