assemblerjs 1.1.2 → 1.1.3
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 +26 -0
- package/dist/index11.js +2 -2
- package/dist/index11.mjs +2 -2
- package/dist/index13.js +2 -2
- package/dist/index13.mjs +2 -2
- package/dist/index16.js +1 -1
- package/dist/index16.mjs +1 -1
- package/dist/index17.js +1 -1
- package/dist/index17.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/index2.js +2 -2
- package/dist/index2.mjs +2 -2
- 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 +2 -2
- package/dist/index22.mjs +2 -2
- package/dist/index23.js +2 -2
- package/dist/index23.mjs +2 -2
- package/dist/index24.js +2 -2
- package/dist/index24.mjs +2 -2
- package/dist/index25.js +1 -1
- package/dist/index25.mjs +1 -1
- package/dist/index26.js +1 -1
- package/dist/index26.mjs +1 -1
- package/dist/index27.js +1 -1
- package/dist/index27.mjs +1 -1
- package/dist/index29.js +15 -38
- package/dist/index29.mjs +12 -37
- package/dist/index3.js +1 -1
- package/dist/index3.mjs +1 -1
- package/dist/index30.js +100 -58
- package/dist/index30.mjs +98 -58
- package/dist/index31.js +36 -27
- package/dist/index31.mjs +35 -27
- package/dist/index32.js +16 -59
- package/dist/index32.mjs +16 -59
- package/dist/index33.js +65 -28
- package/dist/index33.mjs +65 -28
- package/dist/index34.js +28 -28
- package/dist/index34.mjs +28 -28
- package/dist/index35.js +77 -15
- package/dist/index35.mjs +77 -12
- package/dist/index36.js +38 -104
- package/dist/index36.mjs +38 -102
- package/dist/index37.js +28 -102
- package/dist/index37.mjs +28 -102
- package/dist/index38.js +128 -23
- package/dist/index38.mjs +128 -23
- package/dist/index39.js +101 -18
- package/dist/index39.mjs +101 -18
- package/dist/index4.js +21 -8
- package/dist/index4.mjs +21 -8
- package/dist/index40.js +25 -25
- package/dist/index40.mjs +25 -24
- package/dist/index41.js +44 -18
- package/dist/index41.mjs +44 -17
- package/dist/index42.js +18 -44
- package/dist/index42.mjs +17 -44
- package/dist/index43.js +26 -191
- package/dist/index43.mjs +25 -191
- package/dist/index44.js +192 -940
- package/dist/index44.mjs +192 -940
- package/dist/index45.js +942 -2
- package/dist/index45.mjs +942 -2
- package/dist/index46.js +2 -2
- package/dist/index46.mjs +2 -2
- package/dist/index47.js +2 -14
- package/dist/index47.mjs +2 -14
- package/dist/index48.js +9 -34
- package/dist/index48.mjs +9 -34
- package/dist/index49.js +32 -55
- package/dist/index49.mjs +32 -54
- package/dist/index50.js +67 -0
- package/dist/index50.mjs +62 -0
- package/package.json +1 -1
package/dist/index38.js
CHANGED
|
@@ -2,33 +2,138 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
class
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
let NoOpDebugLogger = class NoOpDebugLogger {
|
|
6
|
+
configure(o) {}
|
|
7
|
+
logBuildStart(o) {}
|
|
8
|
+
logBuildEnd(o, e) {}
|
|
9
|
+
logRegistration(o) {}
|
|
10
|
+
logHook(o, e, t) {}
|
|
11
|
+
logPhaseStart(o, e) {}
|
|
12
|
+
logPhaseEnd(o, e) {}
|
|
13
|
+
logResolution(o, e, t) {}
|
|
14
|
+
logConstruction(o) {}
|
|
15
|
+
};
|
|
16
|
+
let ActiveDebugLogger = class ActiveDebugLogger {
|
|
17
|
+
configure(o) {
|
|
18
|
+
this.options = {
|
|
19
|
+
...this.options,
|
|
20
|
+
...o,
|
|
21
|
+
logPhases: {
|
|
22
|
+
...this.options.logPhases,
|
|
23
|
+
...o.logPhases || {}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
logBuildStart(o) {
|
|
28
|
+
this.log('info', 'Build started', {
|
|
29
|
+
entry: o.name
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
logBuildEnd(o, e) {
|
|
33
|
+
const t = {
|
|
34
|
+
entry: o.name
|
|
35
|
+
};
|
|
36
|
+
if (e !== undefined) t.duration = `${e.toFixed(2)}ms`;
|
|
37
|
+
this.log('info', 'Build completed', t);
|
|
38
|
+
}
|
|
39
|
+
logRegistration(o) {
|
|
40
|
+
if (!this.shouldLog('registration')) return;
|
|
41
|
+
this.log('info', 'Registration', {
|
|
42
|
+
identifier: o.identifier?.name || String(o.identifier),
|
|
43
|
+
isSingleton: o.isSingleton,
|
|
44
|
+
dependencies: o.dependencies.map((o)=>o?.name || String(o)),
|
|
45
|
+
tags: o.tags
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
logHook(o, e, t) {
|
|
49
|
+
if (!this.shouldLog('hooks')) return;
|
|
50
|
+
const s = this.options.logTimings ? performance.now() : 0;
|
|
51
|
+
this.log('info', `Hook: ${o}`, {
|
|
52
|
+
target: e.constructor?.name || e.name,
|
|
53
|
+
config: t
|
|
54
|
+
});
|
|
55
|
+
if (this.options.logTimings) {
|
|
56
|
+
return ()=>{
|
|
57
|
+
const e = performance.now() - s;
|
|
58
|
+
this.log('info', `Hook: ${o} completed`, {
|
|
59
|
+
duration: `${e.toFixed(2)}ms`
|
|
60
|
+
});
|
|
61
|
+
};
|
|
10
62
|
}
|
|
11
|
-
const [, c, r] = e;
|
|
12
|
-
return new ExecutionPointcutMatcher(c, r);
|
|
13
63
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
64
|
+
logPhaseStart(o, e) {
|
|
65
|
+
this.log('info', `Phase: ${o} started`, e);
|
|
66
|
+
}
|
|
67
|
+
logPhaseEnd(o, e) {
|
|
68
|
+
const t = e !== undefined ? {
|
|
69
|
+
duration: `${e.toFixed(2)}ms`
|
|
70
|
+
} : undefined;
|
|
71
|
+
this.log('info', `Phase: ${o} ended`, t);
|
|
72
|
+
}
|
|
73
|
+
logResolution(o, e, t) {
|
|
74
|
+
if (!this.shouldLog('resolution')) return;
|
|
75
|
+
this.log('info', `Resolving: ${o}`, {
|
|
76
|
+
strategy: `${e} strategy`,
|
|
77
|
+
cache: t ? 'hit' : 'miss'
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
logConstruction(o) {
|
|
81
|
+
if (!this.shouldLog('construction')) return;
|
|
82
|
+
this.log('info', `Constructing: ${o}`);
|
|
83
|
+
}
|
|
84
|
+
shouldLog(o) {
|
|
85
|
+
return !this.options.logPhases || this.options.logPhases[o] !== false;
|
|
86
|
+
}
|
|
87
|
+
log(o, e, t) {
|
|
88
|
+
if (this.options.logger) {
|
|
89
|
+
this.options.logger(o, e, t);
|
|
90
|
+
} else {
|
|
91
|
+
const s = `[Assembler:${o}]`;
|
|
92
|
+
const i = this.options.useColors !== false ? this.colorize(o, s) : s;
|
|
93
|
+
const n = t ? ` ${JSON.stringify(t)}` : '';
|
|
94
|
+
console.log(`${i} ${e}${n}`);
|
|
24
95
|
}
|
|
25
|
-
const e = t.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
|
|
26
|
-
return new RegExp(`^${e}$`);
|
|
27
96
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
97
|
+
colorize(o, e) {
|
|
98
|
+
const t = {
|
|
99
|
+
info: '\x1b[36m',
|
|
100
|
+
warn: '\x1b[33m',
|
|
101
|
+
error: '\x1b[31m',
|
|
102
|
+
reset: '\x1b[0m'
|
|
103
|
+
};
|
|
104
|
+
const s = t[o] || t.info;
|
|
105
|
+
return `${s}${e}${t.reset}`;
|
|
106
|
+
}
|
|
107
|
+
constructor(){
|
|
108
|
+
this.options = {
|
|
109
|
+
enabled: true,
|
|
110
|
+
logPhases: {
|
|
111
|
+
registration: true,
|
|
112
|
+
resolution: true,
|
|
113
|
+
construction: true,
|
|
114
|
+
hooks: true,
|
|
115
|
+
cache: true
|
|
116
|
+
},
|
|
117
|
+
logTimings: false,
|
|
118
|
+
logDependencyTree: true,
|
|
119
|
+
useColors: true
|
|
120
|
+
};
|
|
31
121
|
}
|
|
32
122
|
};
|
|
123
|
+
class DebugLogger {
|
|
124
|
+
static getInstance() {
|
|
125
|
+
return DebugLogger.instance;
|
|
126
|
+
}
|
|
127
|
+
static enable(o) {
|
|
128
|
+
DebugLogger.instance = new ActiveDebugLogger();
|
|
129
|
+
if (o) {
|
|
130
|
+
DebugLogger.instance.configure(o);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
static disable() {
|
|
134
|
+
DebugLogger.instance = new NoOpDebugLogger();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
DebugLogger.instance = new NoOpDebugLogger();
|
|
33
138
|
|
|
34
|
-
exports.
|
|
139
|
+
exports.DebugLogger = DebugLogger;
|
package/dist/index38.mjs
CHANGED
|
@@ -1,30 +1,135 @@
|
|
|
1
|
-
class
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
let NoOpDebugLogger = class NoOpDebugLogger {
|
|
2
|
+
configure(o) {}
|
|
3
|
+
logBuildStart(o) {}
|
|
4
|
+
logBuildEnd(o, e) {}
|
|
5
|
+
logRegistration(o) {}
|
|
6
|
+
logHook(o, e, t) {}
|
|
7
|
+
logPhaseStart(o, e) {}
|
|
8
|
+
logPhaseEnd(o, e) {}
|
|
9
|
+
logResolution(o, e, t) {}
|
|
10
|
+
logConstruction(o) {}
|
|
11
|
+
};
|
|
12
|
+
let ActiveDebugLogger = class ActiveDebugLogger {
|
|
13
|
+
configure(o) {
|
|
14
|
+
this.options = {
|
|
15
|
+
...this.options,
|
|
16
|
+
...o,
|
|
17
|
+
logPhases: {
|
|
18
|
+
...this.options.logPhases,
|
|
19
|
+
...o.logPhases || {}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
logBuildStart(o) {
|
|
24
|
+
this.log('info', 'Build started', {
|
|
25
|
+
entry: o.name
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
logBuildEnd(o, e) {
|
|
29
|
+
const t = {
|
|
30
|
+
entry: o.name
|
|
31
|
+
};
|
|
32
|
+
if (e !== undefined) t.duration = `${e.toFixed(2)}ms`;
|
|
33
|
+
this.log('info', 'Build completed', t);
|
|
34
|
+
}
|
|
35
|
+
logRegistration(o) {
|
|
36
|
+
if (!this.shouldLog('registration')) return;
|
|
37
|
+
this.log('info', 'Registration', {
|
|
38
|
+
identifier: o.identifier?.name || String(o.identifier),
|
|
39
|
+
isSingleton: o.isSingleton,
|
|
40
|
+
dependencies: o.dependencies.map((o)=>o?.name || String(o)),
|
|
41
|
+
tags: o.tags
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
logHook(o, e, t) {
|
|
45
|
+
if (!this.shouldLog('hooks')) return;
|
|
46
|
+
const s = this.options.logTimings ? performance.now() : 0;
|
|
47
|
+
this.log('info', `Hook: ${o}`, {
|
|
48
|
+
target: e.constructor?.name || e.name,
|
|
49
|
+
config: t
|
|
50
|
+
});
|
|
51
|
+
if (this.options.logTimings) {
|
|
52
|
+
return ()=>{
|
|
53
|
+
const e = performance.now() - s;
|
|
54
|
+
this.log('info', `Hook: ${o} completed`, {
|
|
55
|
+
duration: `${e.toFixed(2)}ms`
|
|
56
|
+
});
|
|
57
|
+
};
|
|
6
58
|
}
|
|
7
|
-
const [, c, r] = e;
|
|
8
|
-
return new ExecutionPointcutMatcher(c, r);
|
|
9
59
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
60
|
+
logPhaseStart(o, e) {
|
|
61
|
+
this.log('info', `Phase: ${o} started`, e);
|
|
62
|
+
}
|
|
63
|
+
logPhaseEnd(o, e) {
|
|
64
|
+
const t = e !== undefined ? {
|
|
65
|
+
duration: `${e.toFixed(2)}ms`
|
|
66
|
+
} : undefined;
|
|
67
|
+
this.log('info', `Phase: ${o} ended`, t);
|
|
68
|
+
}
|
|
69
|
+
logResolution(o, e, t) {
|
|
70
|
+
if (!this.shouldLog('resolution')) return;
|
|
71
|
+
this.log('info', `Resolving: ${o}`, {
|
|
72
|
+
strategy: `${e} strategy`,
|
|
73
|
+
cache: t ? 'hit' : 'miss'
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
logConstruction(o) {
|
|
77
|
+
if (!this.shouldLog('construction')) return;
|
|
78
|
+
this.log('info', `Constructing: ${o}`);
|
|
79
|
+
}
|
|
80
|
+
shouldLog(o) {
|
|
81
|
+
return !this.options.logPhases || this.options.logPhases[o] !== false;
|
|
82
|
+
}
|
|
83
|
+
log(o, e, t) {
|
|
84
|
+
if (this.options.logger) {
|
|
85
|
+
this.options.logger(o, e, t);
|
|
86
|
+
} else {
|
|
87
|
+
const s = `[Assembler:${o}]`;
|
|
88
|
+
const i = this.options.useColors !== false ? this.colorize(o, s) : s;
|
|
89
|
+
const n = t ? ` ${JSON.stringify(t)}` : '';
|
|
90
|
+
console.log(`${i} ${e}${n}`);
|
|
20
91
|
}
|
|
21
|
-
const e = t.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
|
|
22
|
-
return new RegExp(`^${e}$`);
|
|
23
92
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
93
|
+
colorize(o, e) {
|
|
94
|
+
const t = {
|
|
95
|
+
info: '\x1b[36m',
|
|
96
|
+
warn: '\x1b[33m',
|
|
97
|
+
error: '\x1b[31m',
|
|
98
|
+
reset: '\x1b[0m'
|
|
99
|
+
};
|
|
100
|
+
const s = t[o] || t.info;
|
|
101
|
+
return `${s}${e}${t.reset}`;
|
|
102
|
+
}
|
|
103
|
+
constructor(){
|
|
104
|
+
this.options = {
|
|
105
|
+
enabled: true,
|
|
106
|
+
logPhases: {
|
|
107
|
+
registration: true,
|
|
108
|
+
resolution: true,
|
|
109
|
+
construction: true,
|
|
110
|
+
hooks: true,
|
|
111
|
+
cache: true
|
|
112
|
+
},
|
|
113
|
+
logTimings: false,
|
|
114
|
+
logDependencyTree: true,
|
|
115
|
+
useColors: true
|
|
116
|
+
};
|
|
27
117
|
}
|
|
28
118
|
};
|
|
119
|
+
class DebugLogger {
|
|
120
|
+
static getInstance() {
|
|
121
|
+
return DebugLogger.instance;
|
|
122
|
+
}
|
|
123
|
+
static enable(o) {
|
|
124
|
+
DebugLogger.instance = new ActiveDebugLogger();
|
|
125
|
+
if (o) {
|
|
126
|
+
DebugLogger.instance.configure(o);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
static disable() {
|
|
130
|
+
DebugLogger.instance = new NoOpDebugLogger();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
DebugLogger.instance = new NoOpDebugLogger();
|
|
29
134
|
|
|
30
|
-
export {
|
|
135
|
+
export { DebugLogger };
|
package/dist/index39.js
CHANGED
|
@@ -2,27 +2,110 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
static
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
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;
|
|
13
25
|
}
|
|
14
|
-
return new
|
|
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
|
+
});
|
|
15
44
|
}
|
|
16
|
-
static
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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;
|
|
90
|
+
}
|
|
21
91
|
}
|
|
22
|
-
static
|
|
23
|
-
|
|
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();
|
|
24
108
|
}
|
|
25
109
|
}
|
|
26
|
-
ResolverStore.resolvers = new Map();
|
|
27
110
|
|
|
28
|
-
exports.
|
|
111
|
+
exports.TransversalWeaver = TransversalWeaver;
|
package/dist/index39.mjs
CHANGED
|
@@ -1,24 +1,107 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
static
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
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;
|
|
9
21
|
}
|
|
10
|
-
return new
|
|
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
|
+
});
|
|
11
40
|
}
|
|
12
|
-
static
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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;
|
|
86
|
+
}
|
|
17
87
|
}
|
|
18
|
-
static
|
|
19
|
-
|
|
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();
|
|
20
104
|
}
|
|
21
105
|
}
|
|
22
|
-
ResolverStore.resolvers = new Map();
|
|
23
106
|
|
|
24
|
-
export {
|
|
107
|
+
export { TransversalWeaver };
|
package/dist/index4.js
CHANGED
|
@@ -3,18 +3,31 @@
|
|
|
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('./
|
|
6
|
+
const injectableManager = require('./index33.js');
|
|
7
|
+
const objectManager = require('./index34.js');
|
|
8
|
+
const hookManager = require('./index35.js');
|
|
9
|
+
const assemblerBuilder = require('./index36.js');
|
|
10
|
+
const contextProvider = require('./index37.js');
|
|
11
|
+
const debugLogger = require('./index38.js');
|
|
11
12
|
const eventManager = require('./index6.js');
|
|
12
13
|
|
|
13
14
|
class Assembler extends eventManager.EventManager {
|
|
15
|
+
static enableDebug(e) {
|
|
16
|
+
debugLogger.DebugLogger.enable(e);
|
|
17
|
+
}
|
|
18
|
+
static disableDebug() {
|
|
19
|
+
debugLogger.DebugLogger.disable();
|
|
20
|
+
}
|
|
14
21
|
static build(e, t) {
|
|
15
|
-
const r =
|
|
16
|
-
const a =
|
|
17
|
-
|
|
22
|
+
const r = debugLogger.DebugLogger.getInstance();
|
|
23
|
+
const a = performance.now();
|
|
24
|
+
r.logBuildStart(e);
|
|
25
|
+
const n = new Assembler();
|
|
26
|
+
const o = new assemblerBuilder.AssemblerBuilder(n);
|
|
27
|
+
const c = o.build(e, t);
|
|
28
|
+
const l = performance.now() - a;
|
|
29
|
+
r.logBuildEnd(e, l);
|
|
30
|
+
return c;
|
|
18
31
|
}
|
|
19
32
|
get hookManager() {
|
|
20
33
|
return this._hookManager;
|
package/dist/index4.mjs
CHANGED
|
@@ -1,16 +1,29 @@
|
|
|
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 './
|
|
2
|
+
import { InjectableManager } from './index33.mjs';
|
|
3
|
+
import { ObjectManager } from './index34.mjs';
|
|
4
|
+
import { HookManager } from './index35.mjs';
|
|
5
|
+
import { AssemblerBuilder } from './index36.mjs';
|
|
6
|
+
import { ContextProvider } from './index37.mjs';
|
|
7
|
+
import { DebugLogger } from './index38.mjs';
|
|
7
8
|
import { EventManager } from './index6.mjs';
|
|
8
9
|
|
|
9
10
|
class Assembler extends EventManager {
|
|
11
|
+
static enableDebug(e) {
|
|
12
|
+
DebugLogger.enable(e);
|
|
13
|
+
}
|
|
14
|
+
static disableDebug() {
|
|
15
|
+
DebugLogger.disable();
|
|
16
|
+
}
|
|
10
17
|
static build(e, t) {
|
|
11
|
-
const r =
|
|
12
|
-
const a =
|
|
13
|
-
|
|
18
|
+
const r = DebugLogger.getInstance();
|
|
19
|
+
const a = performance.now();
|
|
20
|
+
r.logBuildStart(e);
|
|
21
|
+
const n = new Assembler();
|
|
22
|
+
const o = new AssemblerBuilder(n);
|
|
23
|
+
const c = o.build(e, t);
|
|
24
|
+
const l = performance.now() - a;
|
|
25
|
+
r.logBuildEnd(e, l);
|
|
26
|
+
return c;
|
|
14
27
|
}
|
|
15
28
|
get hookManager() {
|
|
16
29
|
return this._hookManager;
|