assemblerjs 1.1.14 → 1.1.15

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/index38.js CHANGED
@@ -2,45 +2,110 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const eventManager = require('./index6.js');
5
+ const transversalManager = require('./index13.js');
6
+ const affect = require('./index12.js');
6
7
 
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);
8
+ class TransversalWeaver {
9
+ static weave(n, r, o) {
10
+ const c = transversalManager.TransversalManager.getInstance(o);
11
+ const s = c.getAspectsForTarget(r);
12
+ const a = Object.getPrototypeOf(n);
13
+ const f = Object.getOwnPropertyNames(a).some((t)=>{
14
+ if (t === 'constructor') return false;
15
+ const n = Object.getOwnPropertyDescriptor(a, t);
16
+ if (!n) return false;
17
+ const r = n.value && typeof n.value === 'function';
18
+ const o = n.get && typeof n.get === 'function';
19
+ if (!r && !o) return false;
20
+ const c = affect.getAffectedMethods(a, t);
21
+ return c.length > 0;
22
+ });
23
+ if (s.length === 0 && !f) {
24
+ return n;
24
25
  }
26
+ return new Proxy(n, {
27
+ get (t, e, n) {
28
+ const r = Reflect.get(t, e, n);
29
+ if (typeof r !== 'function') {
30
+ return r;
31
+ }
32
+ return function(...n) {
33
+ const o = String(e);
34
+ const a = {
35
+ target: t,
36
+ methodName: o,
37
+ args: n
38
+ };
39
+ const f = c.getAdvicesForJoinPoint(a, s, t, e);
40
+ return TransversalWeaver.executeAdviceChain(f, r, t, n, a);
41
+ };
42
+ }
43
+ });
25
44
  }
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);
45
+ static executeAdviceChain(t, e, n, r, o) {
46
+ const c = t.filter((t)=>t.type === 'before');
47
+ const s = t.filter((t)=>t.type === 'around');
48
+ const a = t.filter((t)=>t.type === 'after');
49
+ try {
50
+ for (const t of c){
51
+ const e = {
52
+ ...o,
53
+ config: t.config
54
+ };
55
+ t.method.call(t.transversalInstance, e);
56
+ }
57
+ let t;
58
+ if (s.length > 0) {
59
+ t = this.buildAroundChain(s, e, n, r, o);
60
+ } else {
61
+ t = e.apply(n, r);
40
62
  }
63
+ if (t instanceof Promise) {
64
+ return t.then((t)=>{
65
+ for (const e of a){
66
+ const n = {
67
+ ...o,
68
+ result: t
69
+ };
70
+ e.method.call(e.transversalInstance, n);
71
+ }
72
+ return t;
73
+ }).catch((t)=>{
74
+ o.error = t;
75
+ throw t;
76
+ });
77
+ }
78
+ for (const e of a){
79
+ const n = {
80
+ ...o,
81
+ result: t,
82
+ config: e.config
83
+ };
84
+ e.method.call(e.transversalInstance, n);
85
+ }
86
+ return t;
87
+ } catch (t) {
88
+ o.error = t;
89
+ throw t;
41
90
  }
42
91
  }
43
- };
92
+ static buildAroundChain(t, e, n, r, o) {
93
+ let c = 0;
94
+ const s = ()=>{
95
+ if (c < t.length) {
96
+ const e = t[c++];
97
+ const n = {
98
+ ...o,
99
+ proceed: s,
100
+ config: e.config
101
+ };
102
+ return e.method.call(e.transversalInstance, n);
103
+ } else {
104
+ return e.apply(n, r);
105
+ }
106
+ };
107
+ return s();
108
+ }
109
+ }
44
110
 
45
- exports.registerEvents = registerEvents;
46
- exports.unregisterEvents = unregisterEvents;
111
+ exports.TransversalWeaver = TransversalWeaver;
package/dist/index38.mjs CHANGED
@@ -1,41 +1,107 @@
1
- import { EventManager } from './index6.mjs';
1
+ import { TransversalManager } from './index13.mjs';
2
+ import { getAffectedMethods } from './index12.mjs';
2
3
 
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);
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;
20
21
  }
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
+ });
21
40
  }
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);
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);
36
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;
37
86
  }
38
87
  }
39
- };
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();
104
+ }
105
+ }
40
106
 
41
- export { registerEvents, unregisterEvents };
107
+ export { TransversalWeaver };
package/dist/index39.js CHANGED
@@ -2,110 +2,33 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const transversalManager = require('./index13.js');
6
- const affect = require('./index12.js');
7
-
8
- class TransversalWeaver {
9
- static weave(n, r, o) {
10
- const c = transversalManager.TransversalManager.getInstance(o);
11
- const s = c.getAspectsForTarget(r);
12
- const a = Object.getPrototypeOf(n);
13
- const f = Object.getOwnPropertyNames(a).some((t)=>{
14
- if (t === 'constructor') return false;
15
- const n = Object.getOwnPropertyDescriptor(a, t);
16
- if (!n) return false;
17
- const r = n.value && typeof n.value === 'function';
18
- const o = n.get && typeof n.get === 'function';
19
- if (!r && !o) return false;
20
- const c = affect.getAffectedMethods(a, t);
21
- return c.length > 0;
22
- });
23
- if (s.length === 0 && !f) {
24
- return n;
5
+ class PointcutMatcher {
6
+ static parse(t) {
7
+ const e = t.match(/^execution\(([^.]+)\.([^)]+)\)$/);
8
+ if (!e) {
9
+ throw new Error(`Invalid pointcut expression: ${t}`);
25
10
  }
26
- return new Proxy(n, {
27
- get (t, e, n) {
28
- const r = Reflect.get(t, e, n);
29
- if (typeof r !== 'function') {
30
- return r;
31
- }
32
- return function(...n) {
33
- const o = String(e);
34
- const a = {
35
- target: t,
36
- methodName: o,
37
- args: n
38
- };
39
- const f = c.getAdvicesForJoinPoint(a, s, t, e);
40
- return TransversalWeaver.executeAdviceChain(f, r, t, n, a);
41
- };
42
- }
43
- });
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);
44
20
  }
45
- static executeAdviceChain(t, e, n, r, o) {
46
- const c = t.filter((t)=>t.type === 'before');
47
- const s = t.filter((t)=>t.type === 'around');
48
- const a = t.filter((t)=>t.type === 'after');
49
- try {
50
- for (const t of c){
51
- const e = {
52
- ...o,
53
- config: t.config
54
- };
55
- t.method.call(t.transversalInstance, e);
56
- }
57
- let t;
58
- if (s.length > 0) {
59
- t = this.buildAroundChain(s, e, n, r, o);
60
- } else {
61
- t = e.apply(n, r);
62
- }
63
- if (t instanceof Promise) {
64
- return t.then((t)=>{
65
- for (const e of a){
66
- const n = {
67
- ...o,
68
- result: t
69
- };
70
- e.method.call(e.transversalInstance, n);
71
- }
72
- return t;
73
- }).catch((t)=>{
74
- o.error = t;
75
- throw t;
76
- });
77
- }
78
- for (const e of a){
79
- const n = {
80
- ...o,
81
- result: t,
82
- config: e.config
83
- };
84
- e.method.call(e.transversalInstance, n);
85
- }
86
- return t;
87
- } catch (t) {
88
- o.error = t;
89
- throw t;
21
+ patternToRegex(t) {
22
+ if (t === '*') {
23
+ return /.*/;
90
24
  }
25
+ const e = t.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
26
+ return new RegExp(`^${e}$`);
91
27
  }
92
- static buildAroundChain(t, e, n, r, o) {
93
- let c = 0;
94
- const s = ()=>{
95
- if (c < t.length) {
96
- const e = t[c++];
97
- const n = {
98
- ...o,
99
- proceed: s,
100
- config: e.config
101
- };
102
- return e.method.call(e.transversalInstance, n);
103
- } else {
104
- return e.apply(n, r);
105
- }
106
- };
107
- return s();
28
+ constructor(t, e){
29
+ this.classRegex = this.patternToRegex(t);
30
+ this.methodRegex = this.patternToRegex(e);
108
31
  }
109
- }
32
+ };
110
33
 
111
- exports.TransversalWeaver = TransversalWeaver;
34
+ exports.PointcutMatcher = PointcutMatcher;
package/dist/index39.mjs CHANGED
@@ -1,107 +1,30 @@
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;
1
+ class PointcutMatcher {
2
+ static parse(t) {
3
+ const e = t.match(/^execution\(([^.]+)\.([^)]+)\)$/);
4
+ if (!e) {
5
+ throw new Error(`Invalid pointcut expression: ${t}`);
21
6
  }
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
- });
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);
40
16
  }
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;
17
+ patternToRegex(t) {
18
+ if (t === '*') {
19
+ return /.*/;
86
20
  }
21
+ const e = t.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
22
+ return new RegExp(`^${e}$`);
87
23
  }
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();
24
+ constructor(t, e){
25
+ this.classRegex = this.patternToRegex(t);
26
+ this.methodRegex = this.patternToRegex(e);
104
27
  }
105
- }
28
+ };
106
29
 
107
- export { TransversalWeaver };
30
+ export { PointcutMatcher };
package/dist/index4.js CHANGED
@@ -3,12 +3,12 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const core = require('@assemblerjs/core');
6
- const injectableManager = require('./index31.js');
7
- const objectManager = require('./index32.js');
8
- const hookManager = require('./index33.js');
9
- const assemblerBuilder = require('./index34.js');
10
- const contextProvider = require('./index35.js');
11
- const debugLogger = require('./index36.js');
6
+ const injectableManager = require('./index32.js');
7
+ const objectManager = require('./index33.js');
8
+ const hookManager = require('./index34.js');
9
+ const assemblerBuilder = require('./index35.js');
10
+ const contextProvider = require('./index36.js');
11
+ const debugLogger = require('./index37.js');
12
12
  const eventManager = require('./index6.js');
13
13
 
14
14
  class Assembler extends eventManager.EventManager {
package/dist/index4.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import { clearInstance } from '@assemblerjs/core';
2
- import { InjectableManager } from './index31.mjs';
3
- import { ObjectManager } from './index32.mjs';
4
- import { HookManager } from './index33.mjs';
5
- import { AssemblerBuilder } from './index34.mjs';
6
- import { ContextProvider } from './index35.mjs';
7
- import { DebugLogger } from './index36.mjs';
2
+ import { InjectableManager } from './index32.mjs';
3
+ import { ObjectManager } from './index33.mjs';
4
+ import { HookManager } from './index34.mjs';
5
+ import { AssemblerBuilder } from './index35.mjs';
6
+ import { ContextProvider } from './index36.mjs';
7
+ import { DebugLogger } from './index37.mjs';
8
8
  import { EventManager } from './index6.mjs';
9
9
 
10
10
  class Assembler extends EventManager {
package/dist/index40.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;