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.
- package/dist/index.d.ts +4 -0
- package/dist/index13.js +1 -1
- package/dist/index13.mjs +1 -1
- package/dist/index18.js +1 -1
- package/dist/index18.mjs +1 -1
- package/dist/index19.js +1 -1
- package/dist/index19.mjs +1 -1
- package/dist/index20.js +1 -1
- package/dist/index20.mjs +1 -1
- package/dist/index21.js +1 -1
- package/dist/index21.mjs +1 -1
- package/dist/index22.js +11 -5
- package/dist/index22.mjs +11 -5
- package/dist/index23.js +13 -7
- package/dist/index23.mjs +13 -7
- package/dist/index24.js +1 -1
- package/dist/index24.mjs +1 -1
- package/dist/index31.js +35 -153
- package/dist/index31.mjs +34 -152
- package/dist/index32.js +143 -35
- package/dist/index32.mjs +142 -35
- package/dist/index33.js +41 -70
- package/dist/index33.mjs +41 -70
- package/dist/index34.js +73 -49
- package/dist/index34.mjs +73 -49
- package/dist/index35.js +53 -29
- package/dist/index35.mjs +53 -29
- package/dist/index36.js +26 -161
- package/dist/index36.mjs +26 -161
- package/dist/index37.js +160 -48
- package/dist/index37.mjs +160 -48
- package/dist/index38.js +57 -34
- package/dist/index38.mjs +57 -33
- package/dist/index39.js +18 -101
- package/dist/index39.mjs +18 -101
- package/dist/index4.js +7 -7
- package/dist/index4.mjs +7 -7
- package/dist/index40.js +101 -24
- package/dist/index40.mjs +101 -24
- package/dist/index41.js +24 -18
- package/dist/index41.mjs +24 -18
- package/dist/index45.js +16 -9
- package/dist/index45.mjs +16 -9
- package/dist/index49.js +1 -1
- package/dist/index49.mjs +1 -1
- package/dist/index50.js +2 -2
- package/dist/index50.mjs +2 -2
- package/package.json +1 -1
package/dist/index38.js
CHANGED
|
@@ -2,45 +2,68 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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);
|
|
24
|
-
}
|
|
5
|
+
let AbstractCycleDetector = class AbstractCycleDetector {
|
|
6
|
+
};
|
|
7
|
+
let NoOpCycleDetector = class NoOpCycleDetector extends AbstractCycleDetector {
|
|
8
|
+
detect() {
|
|
9
|
+
return [];
|
|
25
10
|
}
|
|
26
11
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
for (const n of
|
|
32
|
-
|
|
12
|
+
let ActiveCycleDetector = class ActiveCycleDetector extends AbstractCycleDetector {
|
|
13
|
+
detect(e, t) {
|
|
14
|
+
const c = [];
|
|
15
|
+
const s = new Set();
|
|
16
|
+
for (const [n] of e){
|
|
17
|
+
if (s.has(n)) continue;
|
|
18
|
+
const r = [];
|
|
19
|
+
const o = new Set();
|
|
20
|
+
if (this.hasCycleDFS(n, r, o, s, e)) {
|
|
21
|
+
const e = r.findIndex((e)=>e === n);
|
|
22
|
+
if (e >= 0) {
|
|
23
|
+
const s = r.slice(e).map((e)=>t(e));
|
|
24
|
+
c.push({
|
|
25
|
+
cycle: s,
|
|
26
|
+
path: s.join(' → ')
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
33
30
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
return c;
|
|
32
|
+
}
|
|
33
|
+
hasCycleDFS(e, t, c, s, n) {
|
|
34
|
+
if (c.has(e)) {
|
|
35
|
+
t.push(e);
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
if (s.has(e)) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
t.push(e);
|
|
42
|
+
c.add(e);
|
|
43
|
+
const r = n.get(e);
|
|
44
|
+
if (r?.dependencies && r.dependencies.length > 0) {
|
|
45
|
+
for (const e of r.dependencies){
|
|
46
|
+
if (this.hasCycleDFS(e, t, c, s, n)) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
40
49
|
}
|
|
41
50
|
}
|
|
51
|
+
c.delete(e);
|
|
52
|
+
s.add(e);
|
|
53
|
+
return false;
|
|
42
54
|
}
|
|
43
55
|
};
|
|
56
|
+
class CycleDetector {
|
|
57
|
+
static getInstance() {
|
|
58
|
+
return CycleDetector.instance;
|
|
59
|
+
}
|
|
60
|
+
static enable() {
|
|
61
|
+
CycleDetector.instance = new ActiveCycleDetector();
|
|
62
|
+
}
|
|
63
|
+
static disable() {
|
|
64
|
+
CycleDetector.instance = new NoOpCycleDetector();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
CycleDetector.instance = new NoOpCycleDetector();
|
|
44
68
|
|
|
45
|
-
exports.
|
|
46
|
-
exports.unregisterEvents = unregisterEvents;
|
|
69
|
+
exports.CycleDetector = CycleDetector;
|
package/dist/index38.mjs
CHANGED
|
@@ -1,41 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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);
|
|
20
|
-
}
|
|
1
|
+
let AbstractCycleDetector = class AbstractCycleDetector {
|
|
2
|
+
};
|
|
3
|
+
let NoOpCycleDetector = class NoOpCycleDetector extends AbstractCycleDetector {
|
|
4
|
+
detect() {
|
|
5
|
+
return [];
|
|
21
6
|
}
|
|
22
7
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
for (const n of
|
|
28
|
-
|
|
8
|
+
let ActiveCycleDetector = class ActiveCycleDetector extends AbstractCycleDetector {
|
|
9
|
+
detect(e, t) {
|
|
10
|
+
const c = [];
|
|
11
|
+
const s = new Set();
|
|
12
|
+
for (const [n] of e){
|
|
13
|
+
if (s.has(n)) continue;
|
|
14
|
+
const r = [];
|
|
15
|
+
const o = new Set();
|
|
16
|
+
if (this.hasCycleDFS(n, r, o, s, e)) {
|
|
17
|
+
const e = r.findIndex((e)=>e === n);
|
|
18
|
+
if (e >= 0) {
|
|
19
|
+
const s = r.slice(e).map((e)=>t(e));
|
|
20
|
+
c.push({
|
|
21
|
+
cycle: s,
|
|
22
|
+
path: s.join(' → ')
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
29
26
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
return c;
|
|
28
|
+
}
|
|
29
|
+
hasCycleDFS(e, t, c, s, n) {
|
|
30
|
+
if (c.has(e)) {
|
|
31
|
+
t.push(e);
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
if (s.has(e)) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
t.push(e);
|
|
38
|
+
c.add(e);
|
|
39
|
+
const r = n.get(e);
|
|
40
|
+
if (r?.dependencies && r.dependencies.length > 0) {
|
|
41
|
+
for (const e of r.dependencies){
|
|
42
|
+
if (this.hasCycleDFS(e, t, c, s, n)) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
36
45
|
}
|
|
37
46
|
}
|
|
47
|
+
c.delete(e);
|
|
48
|
+
s.add(e);
|
|
49
|
+
return false;
|
|
38
50
|
}
|
|
39
51
|
};
|
|
52
|
+
class CycleDetector {
|
|
53
|
+
static getInstance() {
|
|
54
|
+
return CycleDetector.instance;
|
|
55
|
+
}
|
|
56
|
+
static enable() {
|
|
57
|
+
CycleDetector.instance = new ActiveCycleDetector();
|
|
58
|
+
}
|
|
59
|
+
static disable() {
|
|
60
|
+
CycleDetector.instance = new NoOpCycleDetector();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
CycleDetector.instance = new NoOpCycleDetector();
|
|
40
64
|
|
|
41
|
-
export {
|
|
65
|
+
export { CycleDetector };
|
package/dist/index39.js
CHANGED
|
@@ -2,110 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
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;
|
|
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
|
-
});
|
|
5
|
+
class ResolverStore {
|
|
6
|
+
static register(e, r) {
|
|
7
|
+
this.resolvers.set(e, r);
|
|
44
8
|
}
|
|
45
|
-
static
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
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;
|
|
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}`);
|
|
90
13
|
}
|
|
14
|
+
return new r();
|
|
15
|
+
}
|
|
16
|
+
static hasResolver(e) {
|
|
17
|
+
return this.resolvers.has(e);
|
|
18
|
+
}
|
|
19
|
+
static getRegisteredTypes() {
|
|
20
|
+
return Array.from(this.resolvers.keys());
|
|
91
21
|
}
|
|
92
|
-
static
|
|
93
|
-
|
|
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();
|
|
22
|
+
static clear() {
|
|
23
|
+
this.resolvers.clear();
|
|
108
24
|
}
|
|
109
25
|
}
|
|
26
|
+
ResolverStore.resolvers = new Map();
|
|
110
27
|
|
|
111
|
-
exports.
|
|
28
|
+
exports.ResolverStore = ResolverStore;
|
package/dist/index39.mjs
CHANGED
|
@@ -1,107 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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;
|
|
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
|
-
});
|
|
1
|
+
class ResolverStore {
|
|
2
|
+
static register(e, r) {
|
|
3
|
+
this.resolvers.set(e, r);
|
|
40
4
|
}
|
|
41
|
-
static
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
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;
|
|
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}`);
|
|
86
9
|
}
|
|
10
|
+
return new r();
|
|
11
|
+
}
|
|
12
|
+
static hasResolver(e) {
|
|
13
|
+
return this.resolvers.has(e);
|
|
14
|
+
}
|
|
15
|
+
static getRegisteredTypes() {
|
|
16
|
+
return Array.from(this.resolvers.keys());
|
|
87
17
|
}
|
|
88
|
-
static
|
|
89
|
-
|
|
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();
|
|
18
|
+
static clear() {
|
|
19
|
+
this.resolvers.clear();
|
|
104
20
|
}
|
|
105
21
|
}
|
|
22
|
+
ResolverStore.resolvers = new Map();
|
|
106
23
|
|
|
107
|
-
export {
|
|
24
|
+
export { ResolverStore };
|
package/dist/index4.js
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const core = require('@assemblerjs/core');
|
|
6
|
-
const injectableManager = require('./
|
|
7
|
-
const objectManager = require('./
|
|
8
|
-
const hookManager = require('./
|
|
9
|
-
const assemblerBuilder = require('./
|
|
10
|
-
const contextProvider = require('./
|
|
11
|
-
const debugLogger = require('./
|
|
12
|
-
const cycleDetector = require('./
|
|
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
|
+
const cycleDetector = require('./index38.js');
|
|
13
13
|
const eventManager = require('./index6.js');
|
|
14
14
|
|
|
15
15
|
class Assembler extends eventManager.EventManager {
|
package/dist/index4.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { clearInstance } from '@assemblerjs/core';
|
|
2
|
-
import { InjectableManager } from './
|
|
3
|
-
import { ObjectManager } from './
|
|
4
|
-
import { HookManager } from './
|
|
5
|
-
import { AssemblerBuilder } from './
|
|
6
|
-
import { ContextProvider } from './
|
|
7
|
-
import { DebugLogger } from './
|
|
8
|
-
import { CycleDetector } from './
|
|
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
|
+
import { CycleDetector } from './index38.mjs';
|
|
9
9
|
import { EventManager } from './index6.mjs';
|
|
10
10
|
|
|
11
11
|
class Assembler extends EventManager {
|
package/dist/index40.js
CHANGED
|
@@ -2,33 +2,110 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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;
|
|
10
25
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
});
|
|
20
44
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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;
|
|
24
90
|
}
|
|
25
|
-
const e = t.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
|
|
26
|
-
return new RegExp(`^${e}$`);
|
|
27
91
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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();
|
|
31
108
|
}
|
|
32
|
-
}
|
|
109
|
+
}
|
|
33
110
|
|
|
34
|
-
exports.
|
|
111
|
+
exports.TransversalWeaver = TransversalWeaver;
|