assemblerjs 1.1.20 → 1.1.21

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 (48) hide show
  1. package/dist/index.d.ts +4 -0
  2. package/dist/index13.js +1 -1
  3. package/dist/index13.mjs +1 -1
  4. package/dist/index18.js +1 -1
  5. package/dist/index18.mjs +1 -1
  6. package/dist/index19.js +1 -1
  7. package/dist/index19.mjs +1 -1
  8. package/dist/index20.js +1 -1
  9. package/dist/index20.mjs +1 -1
  10. package/dist/index21.js +1 -1
  11. package/dist/index21.mjs +1 -1
  12. package/dist/index22.js +11 -5
  13. package/dist/index22.mjs +11 -5
  14. package/dist/index23.js +13 -7
  15. package/dist/index23.mjs +13 -7
  16. package/dist/index24.js +1 -1
  17. package/dist/index24.mjs +1 -1
  18. package/dist/index31.js +35 -153
  19. package/dist/index31.mjs +34 -152
  20. package/dist/index32.js +143 -35
  21. package/dist/index32.mjs +142 -35
  22. package/dist/index33.js +41 -70
  23. package/dist/index33.mjs +41 -70
  24. package/dist/index34.js +73 -49
  25. package/dist/index34.mjs +73 -49
  26. package/dist/index35.js +53 -29
  27. package/dist/index35.mjs +53 -29
  28. package/dist/index36.js +26 -161
  29. package/dist/index36.mjs +26 -161
  30. package/dist/index37.js +160 -48
  31. package/dist/index37.mjs +160 -48
  32. package/dist/index38.js +57 -34
  33. package/dist/index38.mjs +57 -33
  34. package/dist/index39.js +18 -101
  35. package/dist/index39.mjs +18 -101
  36. package/dist/index4.js +7 -7
  37. package/dist/index4.mjs +7 -7
  38. package/dist/index40.js +101 -24
  39. package/dist/index40.mjs +101 -24
  40. package/dist/index41.js +24 -18
  41. package/dist/index41.mjs +24 -18
  42. package/dist/index45.js +16 -9
  43. package/dist/index45.mjs +16 -9
  44. package/dist/index49.js +1 -1
  45. package/dist/index49.mjs +1 -1
  46. package/dist/index50.js +2 -2
  47. package/dist/index50.mjs +2 -2
  48. package/package.json +1 -1
package/dist/index40.mjs CHANGED
@@ -1,30 +1,107 @@
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 { TransversalManager } from './index13.mjs';
2
+ import { getAffectedMethods } from './index12.mjs';
3
+
4
+ class TransversalWeaver {
5
+ static weave(n, r, o) {
6
+ const c = TransversalManager.getInstance(o);
7
+ const s = c.getAspectsForTarget(r);
8
+ const a = Object.getPrototypeOf(n);
9
+ const f = Object.getOwnPropertyNames(a).some((t)=>{
10
+ if (t === 'constructor') return false;
11
+ const n = Object.getOwnPropertyDescriptor(a, t);
12
+ if (!n) return false;
13
+ const r = n.value && typeof n.value === 'function';
14
+ const o = n.get && typeof n.get === 'function';
15
+ if (!r && !o) return false;
16
+ const c = getAffectedMethods(a, t);
17
+ return c.length > 0;
18
+ });
19
+ if (s.length === 0 && !f) {
20
+ return n;
6
21
  }
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);
22
+ return new Proxy(n, {
23
+ get (t, e, n) {
24
+ const r = Reflect.get(t, e, n);
25
+ if (typeof r !== 'function') {
26
+ return r;
27
+ }
28
+ return function(...n) {
29
+ const o = String(e);
30
+ const a = {
31
+ target: t,
32
+ methodName: o,
33
+ args: n
34
+ };
35
+ const f = c.getAdvicesForJoinPoint(a, s, t, e);
36
+ return TransversalWeaver.executeAdviceChain(f, r, t, n, a);
37
+ };
38
+ }
39
+ });
16
40
  }
17
- patternToRegex(t) {
18
- if (t === '*') {
19
- return /.*/;
41
+ static executeAdviceChain(t, e, n, r, o) {
42
+ const c = t.filter((t)=>t.type === 'before');
43
+ const s = t.filter((t)=>t.type === 'around');
44
+ const a = t.filter((t)=>t.type === 'after');
45
+ try {
46
+ for (const t of c){
47
+ const e = {
48
+ ...o,
49
+ config: t.config
50
+ };
51
+ t.method.call(t.transversalInstance, e);
52
+ }
53
+ let t;
54
+ if (s.length > 0) {
55
+ t = this.buildAroundChain(s, e, n, r, o);
56
+ } else {
57
+ t = e.apply(n, r);
58
+ }
59
+ if (t instanceof Promise) {
60
+ return t.then((t)=>{
61
+ for (const e of a){
62
+ const n = {
63
+ ...o,
64
+ result: t
65
+ };
66
+ e.method.call(e.transversalInstance, n);
67
+ }
68
+ return t;
69
+ }).catch((t)=>{
70
+ o.error = t;
71
+ throw t;
72
+ });
73
+ }
74
+ for (const e of a){
75
+ const n = {
76
+ ...o,
77
+ result: t,
78
+ config: e.config
79
+ };
80
+ e.method.call(e.transversalInstance, n);
81
+ }
82
+ return t;
83
+ } catch (t) {
84
+ o.error = t;
85
+ throw t;
20
86
  }
21
- const e = t.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
22
- return new RegExp(`^${e}$`);
23
87
  }
24
- constructor(t, e){
25
- this.classRegex = this.patternToRegex(t);
26
- this.methodRegex = this.patternToRegex(e);
88
+ static buildAroundChain(t, e, n, r, o) {
89
+ let c = 0;
90
+ const s = ()=>{
91
+ if (c < t.length) {
92
+ const e = t[c++];
93
+ const n = {
94
+ ...o,
95
+ proceed: s,
96
+ config: e.config
97
+ };
98
+ return e.method.call(e.transversalInstance, n);
99
+ } else {
100
+ return e.apply(n, r);
101
+ }
102
+ };
103
+ return s();
27
104
  }
28
- };
105
+ }
29
106
 
30
- export { PointcutMatcher };
107
+ export { TransversalWeaver };
package/dist/index41.js CHANGED
@@ -2,27 +2,33 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- class ResolverStore {
6
- static register(e, r) {
7
- this.resolvers.set(e, r);
8
- }
9
- static getResolver(e) {
10
- const r = this.resolvers.get(e);
11
- if (!r) {
12
- throw new Error(`No resolver found for decorator type: ${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}`);
13
10
  }
14
- return new r();
11
+ const [, c, r] = e;
12
+ return new ExecutionPointcutMatcher(c, r);
15
13
  }
16
- static hasResolver(e) {
17
- return this.resolvers.has(e);
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);
18
20
  }
19
- static getRegisteredTypes() {
20
- return Array.from(this.resolvers.keys());
21
+ patternToRegex(t) {
22
+ if (t === '*') {
23
+ return /.*/;
24
+ }
25
+ const e = t.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
26
+ return new RegExp(`^${e}$`);
21
27
  }
22
- static clear() {
23
- this.resolvers.clear();
28
+ constructor(t, e){
29
+ this.classRegex = this.patternToRegex(t);
30
+ this.methodRegex = this.patternToRegex(e);
24
31
  }
25
- }
26
- ResolverStore.resolvers = new Map();
32
+ };
27
33
 
28
- exports.ResolverStore = ResolverStore;
34
+ exports.PointcutMatcher = PointcutMatcher;
package/dist/index41.mjs CHANGED
@@ -1,24 +1,30 @@
1
- class ResolverStore {
2
- static register(e, r) {
3
- this.resolvers.set(e, r);
4
- }
5
- static getResolver(e) {
6
- const r = this.resolvers.get(e);
7
- if (!r) {
8
- throw new Error(`No resolver found for decorator type: ${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}`);
9
6
  }
10
- return new r();
7
+ const [, c, r] = e;
8
+ return new ExecutionPointcutMatcher(c, r);
11
9
  }
12
- static hasResolver(e) {
13
- return this.resolvers.has(e);
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);
14
16
  }
15
- static getRegisteredTypes() {
16
- return Array.from(this.resolvers.keys());
17
+ patternToRegex(t) {
18
+ if (t === '*') {
19
+ return /.*/;
20
+ }
21
+ const e = t.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
22
+ return new RegExp(`^${e}$`);
17
23
  }
18
- static clear() {
19
- this.resolvers.clear();
24
+ constructor(t, e){
25
+ this.classRegex = this.patternToRegex(t);
26
+ this.methodRegex = this.patternToRegex(e);
20
27
  }
21
- }
22
- ResolverStore.resolvers = new Map();
28
+ };
23
29
 
24
- export { ResolverStore };
30
+ export { PointcutMatcher };
package/dist/index45.js CHANGED
@@ -5,11 +5,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
5
  const core = require('@assemblerjs/core');
6
6
  const constants = require('./index28.js');
7
7
  const reflection = require('./index29.js');
8
- const debugLogger = require('./index36.js');
8
+ const debugLogger = require('./index37.js');
9
9
  const injectableBuilder = require('./index50.js');
10
10
  const dependencies = require('./index51.js');
11
- const helpers = require('./index38.js');
12
- const hookManager = require('./index33.js');
11
+ const helpers = require('./index31.js');
12
+ const hookManager = require('./index34.js');
13
13
  const helpers$1 = require('./index3.js');
14
14
  const use = require('./index43.js');
15
15
  const schema = require('./index30.js');
@@ -152,9 +152,15 @@ class Injectable {
152
152
  }
153
153
  }
154
154
  if (this.objects.length > 0) {
155
- t.logPhaseStart('registration:use', {
155
+ const e = this.objects.map(([t])=>{
156
+ if (typeof t === 'symbol') return t.toString();
157
+ if (typeof t === 'function') return t.name || t.toString();
158
+ return String(t);
159
+ });
160
+ t.logPhaseStart('registrationUse', {
156
161
  target: this.concrete?.name ?? String(this.identifier),
157
- count: this.objects.length
162
+ count: this.objects.length,
163
+ keys: e
158
164
  });
159
165
  }
160
166
  for (const t of this.objects){
@@ -176,7 +182,7 @@ class Injectable {
176
182
  }
177
183
  }
178
184
  if (this.objects.length > 0) {
179
- t.logPhaseEnd('registration:use', undefined, {
185
+ t.logPhaseEnd('registrationUse', undefined, {
180
186
  target: this.concrete?.name ?? String(this.identifier)
181
187
  });
182
188
  }
@@ -197,16 +203,17 @@ class Injectable {
197
203
  if (this.globals) {
198
204
  const e = Object.keys(this.globals);
199
205
  if (e.length > 0) {
200
- t.logPhaseStart('registration:globals', {
206
+ t.logPhaseStart('registrationGlobals', {
201
207
  target: this.concrete?.name ?? String(this.identifier),
202
- count: e.length
208
+ count: e.length,
209
+ keys: e
203
210
  });
204
211
  }
205
212
  for(const t in this.globals){
206
213
  this.privateContext.addGlobal(t, this.globals[t]);
207
214
  }
208
215
  if (e.length > 0) {
209
- t.logPhaseEnd('registration:globals', undefined, {
216
+ t.logPhaseEnd('registrationGlobals', undefined, {
210
217
  target: this.concrete?.name ?? String(this.identifier)
211
218
  });
212
219
  }
package/dist/index45.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  import { isClass, clearInstance } from '@assemblerjs/core';
2
2
  import { ReflectValue } from './index28.mjs';
3
3
  import { defineCustomMetadata } from './index29.mjs';
4
- import { DebugLogger } from './index36.mjs';
4
+ import { DebugLogger } from './index37.mjs';
5
5
  import { InjectableBuilder } from './index50.mjs';
6
6
  import { resolveDependencies } from './index51.mjs';
7
- import { unregisterEvents } from './index38.mjs';
8
- import { HookManager } from './index33.mjs';
7
+ import { unregisterEvents } from './index31.mjs';
8
+ import { HookManager } from './index34.mjs';
9
9
  import { isAssemblage } from './index3.mjs';
10
10
  import { isFactory } from './index43.mjs';
11
11
  import { getDefinition } from './index30.mjs';
@@ -148,9 +148,15 @@ class Injectable {
148
148
  }
149
149
  }
150
150
  if (this.objects.length > 0) {
151
- t.logPhaseStart('registration:use', {
151
+ const e = this.objects.map(([t])=>{
152
+ if (typeof t === 'symbol') return t.toString();
153
+ if (typeof t === 'function') return t.name || t.toString();
154
+ return String(t);
155
+ });
156
+ t.logPhaseStart('registrationUse', {
152
157
  target: this.concrete?.name ?? String(this.identifier),
153
- count: this.objects.length
158
+ count: this.objects.length,
159
+ keys: e
154
160
  });
155
161
  }
156
162
  for (const t of this.objects){
@@ -172,7 +178,7 @@ class Injectable {
172
178
  }
173
179
  }
174
180
  if (this.objects.length > 0) {
175
- t.logPhaseEnd('registration:use', undefined, {
181
+ t.logPhaseEnd('registrationUse', undefined, {
176
182
  target: this.concrete?.name ?? String(this.identifier)
177
183
  });
178
184
  }
@@ -193,16 +199,17 @@ class Injectable {
193
199
  if (this.globals) {
194
200
  const e = Object.keys(this.globals);
195
201
  if (e.length > 0) {
196
- t.logPhaseStart('registration:globals', {
202
+ t.logPhaseStart('registrationGlobals', {
197
203
  target: this.concrete?.name ?? String(this.identifier),
198
- count: e.length
204
+ count: e.length,
205
+ keys: e
199
206
  });
200
207
  }
201
208
  for(const t in this.globals){
202
209
  this.privateContext.addGlobal(t, this.globals[t]);
203
210
  }
204
211
  if (e.length > 0) {
205
- t.logPhaseEnd('registration:globals', undefined, {
212
+ t.logPhaseEnd('registrationGlobals', undefined, {
206
213
  target: this.concrete?.name ?? String(this.identifier)
207
214
  });
208
215
  }
package/dist/index49.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const resolverStore = require('./index41.js');
5
+ const resolverStore = require('./index39.js');
6
6
 
7
7
  class ParameterResolverFactory {
8
8
  static getResolver(r) {
package/dist/index49.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { ResolverStore } from './index41.mjs';
1
+ import { ResolverStore } from './index39.mjs';
2
2
 
3
3
  class ParameterResolverFactory {
4
4
  static getResolver(r) {
package/dist/index50.js CHANGED
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const dependencies = require('./index51.js');
6
- const transversalWeaver = require('./index39.js');
7
- const helpers = require('./index38.js');
6
+ const transversalWeaver = require('./index40.js');
7
+ const helpers = require('./index31.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
- import { TransversalWeaver } from './index39.mjs';
3
- import { registerEvents } from './index38.mjs';
2
+ import { TransversalWeaver } from './index40.mjs';
3
+ import { registerEvents } from './index31.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.20",
4
+ "version": "1.1.21",
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",