assemblerjs 1.1.23 → 1.1.24
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/index.d.ts +4 -0
- package/dist/index13.js +1 -1
- package/dist/index13.mjs +1 -1
- package/dist/index39.js +35 -100
- package/dist/index39.mjs +34 -100
- package/dist/index40.js +119 -24
- package/dist/index40.mjs +119 -24
- package/dist/index41.js +24 -36
- package/dist/index41.mjs +24 -35
- package/dist/index45.js +1 -1
- package/dist/index45.mjs +1 -1
- package/dist/index50.js +2 -2
- package/dist/index50.mjs +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -914,6 +914,10 @@ export declare interface JoinPoint {
|
|
|
914
914
|
result?: any;
|
|
915
915
|
/** The error thrown by the method (if any) */
|
|
916
916
|
error?: any;
|
|
917
|
+
/** The name of the calling assemblage class (if available) */
|
|
918
|
+
caller?: string;
|
|
919
|
+
/** The identifier of the calling assemblage (if available) */
|
|
920
|
+
callerIdentifier?: string | symbol;
|
|
917
921
|
}
|
|
918
922
|
|
|
919
923
|
declare interface LifecycleManager {
|
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('./
|
|
6
|
+
const pointcutMatcher = require('./index41.js');
|
|
7
7
|
const affect = require('./index12.js');
|
|
8
8
|
const schema = require('./index38.js');
|
|
9
9
|
|
package/dist/index13.mjs
CHANGED
package/dist/index39.js
CHANGED
|
@@ -2,110 +2,45 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const affect = require('./index12.js');
|
|
5
|
+
const eventManager = require('./index6.js');
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
if (
|
|
15
|
-
|
|
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;
|
|
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);
|
|
25
15
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
});
|
|
44
|
-
}
|
|
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;
|
|
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);
|
|
90
24
|
}
|
|
91
25
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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);
|
|
105
40
|
}
|
|
106
|
-
}
|
|
107
|
-
return s();
|
|
41
|
+
}
|
|
108
42
|
}
|
|
109
|
-
}
|
|
43
|
+
};
|
|
110
44
|
|
|
111
|
-
exports.
|
|
45
|
+
exports.registerEvents = registerEvents;
|
|
46
|
+
exports.unregisterEvents = unregisterEvents;
|
package/dist/index39.mjs
CHANGED
|
@@ -1,107 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getAffectedMethods } from './index12.mjs';
|
|
1
|
+
import { EventManager } from './index6.mjs';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
if (
|
|
11
|
-
|
|
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;
|
|
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);
|
|
21
11
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
});
|
|
40
|
-
}
|
|
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;
|
|
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);
|
|
86
20
|
}
|
|
87
21
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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);
|
|
101
36
|
}
|
|
102
|
-
}
|
|
103
|
-
return s();
|
|
37
|
+
}
|
|
104
38
|
}
|
|
105
|
-
}
|
|
39
|
+
};
|
|
106
40
|
|
|
107
|
-
export {
|
|
41
|
+
export { registerEvents, unregisterEvents };
|
package/dist/index40.js
CHANGED
|
@@ -2,33 +2,128 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
const transversalManager = require('./index13.js');
|
|
6
|
+
const affect = require('./index12.js');
|
|
7
|
+
|
|
8
|
+
class TransversalWeaver {
|
|
9
|
+
static registerCaller(e, t, r) {
|
|
10
|
+
this.callerRegistry.set(e, {
|
|
11
|
+
className: t,
|
|
12
|
+
identifier: r
|
|
13
|
+
});
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
|
|
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);
|
|
15
|
+
static getCallerMetadata(e) {
|
|
16
|
+
return this.callerRegistry.get(e);
|
|
20
17
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
static weave(r, n, s) {
|
|
19
|
+
const a = transversalManager.TransversalManager.getInstance(s);
|
|
20
|
+
const c = a.getAspectsForTarget(n);
|
|
21
|
+
const o = Object.getPrototypeOf(r);
|
|
22
|
+
const i = Object.getOwnPropertyNames(o).some((e)=>{
|
|
23
|
+
if (e === 'constructor') return false;
|
|
24
|
+
const r = Object.getOwnPropertyDescriptor(o, e);
|
|
25
|
+
if (!r) return false;
|
|
26
|
+
const n = r.value && typeof r.value === 'function';
|
|
27
|
+
const s = r.get && typeof r.get === 'function';
|
|
28
|
+
if (!n && !s) return false;
|
|
29
|
+
const a = affect.getAffectedMethods(o, e);
|
|
30
|
+
return a.length > 0;
|
|
31
|
+
});
|
|
32
|
+
if (c.length === 0 && !i) {
|
|
33
|
+
return r;
|
|
24
34
|
}
|
|
25
|
-
const
|
|
26
|
-
|
|
35
|
+
const l = new Proxy(r, {
|
|
36
|
+
get (e, t, r) {
|
|
37
|
+
const n = Reflect.get(e, t, r);
|
|
38
|
+
if (typeof n !== 'function') {
|
|
39
|
+
return n;
|
|
40
|
+
}
|
|
41
|
+
return function(...r) {
|
|
42
|
+
const s = String(t);
|
|
43
|
+
const o = TransversalWeaver.callerRegistry.get(this);
|
|
44
|
+
const i = {
|
|
45
|
+
target: e,
|
|
46
|
+
methodName: s,
|
|
47
|
+
args: r,
|
|
48
|
+
caller: o?.className,
|
|
49
|
+
callerIdentifier: o?.identifier
|
|
50
|
+
};
|
|
51
|
+
const l = a.getAdvicesForJoinPoint(i, c, e, t);
|
|
52
|
+
return TransversalWeaver.executeAdviceChain(l, n, e, r, i);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
TransversalWeaver.callerRegistry.set(l, {
|
|
57
|
+
className: n.name,
|
|
58
|
+
identifier: n.name
|
|
59
|
+
});
|
|
60
|
+
return l;
|
|
27
61
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
62
|
+
static executeAdviceChain(e, t, r, n, s) {
|
|
63
|
+
const a = e.filter((e)=>e.type === 'before');
|
|
64
|
+
const c = e.filter((e)=>e.type === 'around');
|
|
65
|
+
const o = e.filter((e)=>e.type === 'after');
|
|
66
|
+
try {
|
|
67
|
+
for (const e of a){
|
|
68
|
+
const t = {
|
|
69
|
+
...s,
|
|
70
|
+
config: e.config
|
|
71
|
+
};
|
|
72
|
+
e.method.call(e.transversalInstance, t);
|
|
73
|
+
}
|
|
74
|
+
let e;
|
|
75
|
+
if (c.length > 0) {
|
|
76
|
+
e = this.buildAroundChain(c, t, r, n, s);
|
|
77
|
+
} else {
|
|
78
|
+
e = t.apply(r, n);
|
|
79
|
+
}
|
|
80
|
+
if (e instanceof Promise) {
|
|
81
|
+
return e.then((e)=>{
|
|
82
|
+
for (const t of o){
|
|
83
|
+
const r = {
|
|
84
|
+
...s,
|
|
85
|
+
result: e
|
|
86
|
+
};
|
|
87
|
+
t.method.call(t.transversalInstance, r);
|
|
88
|
+
}
|
|
89
|
+
return e;
|
|
90
|
+
}).catch((e)=>{
|
|
91
|
+
s.error = e;
|
|
92
|
+
throw e;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
for (const t of o){
|
|
96
|
+
const r = {
|
|
97
|
+
...s,
|
|
98
|
+
result: e,
|
|
99
|
+
config: t.config
|
|
100
|
+
};
|
|
101
|
+
t.method.call(t.transversalInstance, r);
|
|
102
|
+
}
|
|
103
|
+
return e;
|
|
104
|
+
} catch (e) {
|
|
105
|
+
s.error = e;
|
|
106
|
+
throw e;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
static buildAroundChain(e, t, r, n, s) {
|
|
110
|
+
let a = 0;
|
|
111
|
+
const c = ()=>{
|
|
112
|
+
if (a < e.length) {
|
|
113
|
+
const t = e[a++];
|
|
114
|
+
const r = {
|
|
115
|
+
...s,
|
|
116
|
+
proceed: c,
|
|
117
|
+
config: t.config
|
|
118
|
+
};
|
|
119
|
+
return t.method.call(t.transversalInstance, r);
|
|
120
|
+
} else {
|
|
121
|
+
return t.apply(r, n);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
return c();
|
|
31
125
|
}
|
|
32
|
-
}
|
|
126
|
+
}
|
|
127
|
+
TransversalWeaver.callerRegistry = new WeakMap();
|
|
33
128
|
|
|
34
|
-
exports.
|
|
129
|
+
exports.TransversalWeaver = TransversalWeaver;
|
package/dist/index40.mjs
CHANGED
|
@@ -1,30 +1,125 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { TransversalManager } from './index13.mjs';
|
|
2
|
+
import { getAffectedMethods } from './index12.mjs';
|
|
3
|
+
|
|
4
|
+
class TransversalWeaver {
|
|
5
|
+
static registerCaller(e, t, r) {
|
|
6
|
+
this.callerRegistry.set(e, {
|
|
7
|
+
className: t,
|
|
8
|
+
identifier: r
|
|
9
|
+
});
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
|
|
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);
|
|
11
|
+
static getCallerMetadata(e) {
|
|
12
|
+
return this.callerRegistry.get(e);
|
|
16
13
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
static weave(r, n, s) {
|
|
15
|
+
const a = TransversalManager.getInstance(s);
|
|
16
|
+
const c = a.getAspectsForTarget(n);
|
|
17
|
+
const o = Object.getPrototypeOf(r);
|
|
18
|
+
const i = Object.getOwnPropertyNames(o).some((e)=>{
|
|
19
|
+
if (e === 'constructor') return false;
|
|
20
|
+
const r = Object.getOwnPropertyDescriptor(o, e);
|
|
21
|
+
if (!r) return false;
|
|
22
|
+
const n = r.value && typeof r.value === 'function';
|
|
23
|
+
const s = r.get && typeof r.get === 'function';
|
|
24
|
+
if (!n && !s) return false;
|
|
25
|
+
const a = getAffectedMethods(o, e);
|
|
26
|
+
return a.length > 0;
|
|
27
|
+
});
|
|
28
|
+
if (c.length === 0 && !i) {
|
|
29
|
+
return r;
|
|
20
30
|
}
|
|
21
|
-
const
|
|
22
|
-
|
|
31
|
+
const l = new Proxy(r, {
|
|
32
|
+
get (e, t, r) {
|
|
33
|
+
const n = Reflect.get(e, t, r);
|
|
34
|
+
if (typeof n !== 'function') {
|
|
35
|
+
return n;
|
|
36
|
+
}
|
|
37
|
+
return function(...r) {
|
|
38
|
+
const s = String(t);
|
|
39
|
+
const o = TransversalWeaver.callerRegistry.get(this);
|
|
40
|
+
const i = {
|
|
41
|
+
target: e,
|
|
42
|
+
methodName: s,
|
|
43
|
+
args: r,
|
|
44
|
+
caller: o?.className,
|
|
45
|
+
callerIdentifier: o?.identifier
|
|
46
|
+
};
|
|
47
|
+
const l = a.getAdvicesForJoinPoint(i, c, e, t);
|
|
48
|
+
return TransversalWeaver.executeAdviceChain(l, n, e, r, i);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
TransversalWeaver.callerRegistry.set(l, {
|
|
53
|
+
className: n.name,
|
|
54
|
+
identifier: n.name
|
|
55
|
+
});
|
|
56
|
+
return l;
|
|
23
57
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
58
|
+
static executeAdviceChain(e, t, r, n, s) {
|
|
59
|
+
const a = e.filter((e)=>e.type === 'before');
|
|
60
|
+
const c = e.filter((e)=>e.type === 'around');
|
|
61
|
+
const o = e.filter((e)=>e.type === 'after');
|
|
62
|
+
try {
|
|
63
|
+
for (const e of a){
|
|
64
|
+
const t = {
|
|
65
|
+
...s,
|
|
66
|
+
config: e.config
|
|
67
|
+
};
|
|
68
|
+
e.method.call(e.transversalInstance, t);
|
|
69
|
+
}
|
|
70
|
+
let e;
|
|
71
|
+
if (c.length > 0) {
|
|
72
|
+
e = this.buildAroundChain(c, t, r, n, s);
|
|
73
|
+
} else {
|
|
74
|
+
e = t.apply(r, n);
|
|
75
|
+
}
|
|
76
|
+
if (e instanceof Promise) {
|
|
77
|
+
return e.then((e)=>{
|
|
78
|
+
for (const t of o){
|
|
79
|
+
const r = {
|
|
80
|
+
...s,
|
|
81
|
+
result: e
|
|
82
|
+
};
|
|
83
|
+
t.method.call(t.transversalInstance, r);
|
|
84
|
+
}
|
|
85
|
+
return e;
|
|
86
|
+
}).catch((e)=>{
|
|
87
|
+
s.error = e;
|
|
88
|
+
throw e;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
for (const t of o){
|
|
92
|
+
const r = {
|
|
93
|
+
...s,
|
|
94
|
+
result: e,
|
|
95
|
+
config: t.config
|
|
96
|
+
};
|
|
97
|
+
t.method.call(t.transversalInstance, r);
|
|
98
|
+
}
|
|
99
|
+
return e;
|
|
100
|
+
} catch (e) {
|
|
101
|
+
s.error = e;
|
|
102
|
+
throw e;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
static buildAroundChain(e, t, r, n, s) {
|
|
106
|
+
let a = 0;
|
|
107
|
+
const c = ()=>{
|
|
108
|
+
if (a < e.length) {
|
|
109
|
+
const t = e[a++];
|
|
110
|
+
const r = {
|
|
111
|
+
...s,
|
|
112
|
+
proceed: c,
|
|
113
|
+
config: t.config
|
|
114
|
+
};
|
|
115
|
+
return t.method.call(t.transversalInstance, r);
|
|
116
|
+
} else {
|
|
117
|
+
return t.apply(r, n);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
return c();
|
|
27
121
|
}
|
|
28
|
-
}
|
|
122
|
+
}
|
|
123
|
+
TransversalWeaver.callerRegistry = new WeakMap();
|
|
29
124
|
|
|
30
|
-
export {
|
|
125
|
+
export { TransversalWeaver };
|
package/dist/index41.js
CHANGED
|
@@ -2,45 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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.
|
|
46
|
-
exports.unregisterEvents = unregisterEvents;
|
|
34
|
+
exports.PointcutMatcher = PointcutMatcher;
|
package/dist/index41.mjs
CHANGED
|
@@ -1,41 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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 {
|
|
30
|
+
export { PointcutMatcher };
|
package/dist/index45.js
CHANGED
|
@@ -8,7 +8,7 @@ const reflection = require('./index36.js');
|
|
|
8
8
|
const debugLogger = require('./index34.js');
|
|
9
9
|
const injectableBuilder = require('./index50.js');
|
|
10
10
|
const dependencies = require('./index51.js');
|
|
11
|
-
const helpers = require('./
|
|
11
|
+
const helpers = require('./index39.js');
|
|
12
12
|
const hookManager = require('./index31.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 './index36.mjs';
|
|
|
4
4
|
import { DebugLogger } from './index34.mjs';
|
|
5
5
|
import { InjectableBuilder } from './index50.mjs';
|
|
6
6
|
import { resolveDependencies } from './index51.mjs';
|
|
7
|
-
import { unregisterEvents } from './
|
|
7
|
+
import { unregisterEvents } from './index39.mjs';
|
|
8
8
|
import { HookManager } from './index31.mjs';
|
|
9
9
|
import { isAssemblage } from './index3.mjs';
|
|
10
10
|
import { isFactory } from './index43.mjs';
|
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('./
|
|
7
|
-
const helpers = require('./
|
|
6
|
+
const transversalWeaver = require('./index40.js');
|
|
7
|
+
const helpers = require('./index39.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 './
|
|
3
|
-
import { registerEvents } from './
|
|
2
|
+
import { TransversalWeaver } from './index40.mjs';
|
|
3
|
+
import { registerEvents } from './index39.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.
|
|
4
|
+
"version": "1.1.24",
|
|
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",
|