assemblerjs 1.1.13 → 1.1.14
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/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 +1 -1
- package/dist/index22.mjs +1 -1
- package/dist/index23.js +1 -1
- package/dist/index23.mjs +1 -1
- package/dist/index24.js +1 -1
- package/dist/index24.mjs +1 -1
- package/dist/index27.js +1 -1
- package/dist/index27.mjs +1 -1
- package/dist/index31.js +147 -16
- package/dist/index31.mjs +147 -16
- package/dist/index32.js +44 -99
- package/dist/index32.mjs +44 -99
- package/dist/index33.js +74 -23
- package/dist/index33.mjs +74 -23
- package/dist/index34.js +42 -138
- package/dist/index34.mjs +42 -138
- package/dist/index35.js +28 -47
- package/dist/index35.mjs +28 -47
- package/dist/index36.js +149 -66
- package/dist/index36.mjs +149 -66
- package/dist/index37.js +19 -41
- package/dist/index37.mjs +19 -41
- package/dist/index38.js +39 -30
- package/dist/index38.mjs +38 -30
- package/dist/index39.js +94 -151
- package/dist/index39.mjs +94 -151
- package/dist/index4.js +6 -6
- package/dist/index4.mjs +6 -6
- package/dist/index40.js +24 -36
- package/dist/index40.mjs +24 -35
- package/dist/index43.js +28 -941
- package/dist/index43.mjs +27 -941
- package/dist/index44.js +194 -2
- package/dist/index44.mjs +194 -2
- package/dist/index45.js +942 -2
- package/dist/index45.mjs +942 -2
- package/dist/index46.js +2 -29
- package/dist/index46.mjs +2 -28
- package/dist/index47.js +2 -194
- package/dist/index47.mjs +2 -194
- package/dist/index48.js +1 -1
- package/dist/index48.mjs +1 -1
- package/dist/index49.js +2 -2
- package/dist/index49.mjs +2 -2
- package/dist/index50.js +5 -1
- package/dist/index50.mjs +5 -1
- package/package.json +1 -1
package/dist/index34.mjs
CHANGED
|
@@ -1,142 +1,46 @@
|
|
|
1
|
-
import { HookManager } from './
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { isClass } from '@assemblerjs/core';
|
|
5
|
-
import { resolveInstanceInjectionTuple } from './index42.mjs';
|
|
6
|
-
import { resolveInjectionTuple } from './index41.mjs';
|
|
7
|
-
import { Injectable } from './index47.mjs';
|
|
1
|
+
import { HookManager } from './index33.mjs';
|
|
2
|
+
import { DebugLogger } from './index36.mjs';
|
|
3
|
+
import { setDefinitionValue } from './index30.mjs';
|
|
8
4
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
if (typeof e === 'function') return 'function';
|
|
49
|
-
if (typeof e === 'string') return 'string';
|
|
50
|
-
if (typeof e === 'symbol') return 'symbol';
|
|
51
|
-
if (typeof e === 'object' && e !== null) return 'object';
|
|
52
|
-
return 'unknown';
|
|
53
|
-
}
|
|
54
|
-
class InjectableManager {
|
|
55
|
-
setContexts(e, t) {
|
|
56
|
-
this.privateContext = e;
|
|
57
|
-
this.publicContext = t;
|
|
58
|
-
}
|
|
59
|
-
register(i, s = false) {
|
|
60
|
-
const c = DebugLogger.getInstance();
|
|
61
|
-
const a = s === true ? resolveInstanceInjectionTuple(i) : resolveInjectionTuple(i);
|
|
62
|
-
if (this.has(a.identifier)) {
|
|
63
|
-
const e = `An assemblage is already registered with identifier '${a.identifier.name}'.`;
|
|
64
|
-
c.log('error', 'Duplicate registration', {
|
|
65
|
-
identifier: a.identifier.name,
|
|
66
|
-
error: e
|
|
67
|
-
});
|
|
68
|
-
throw new Error(e);
|
|
69
|
-
}
|
|
70
|
-
const f = Injectable.of(a, this.privateContext, this.publicContext);
|
|
71
|
-
c.logRegistration(f);
|
|
72
|
-
this.injectables.set(f.identifier, f);
|
|
73
|
-
if (f.concrete) {
|
|
74
|
-
HookManager.callHook(f.concrete, 'onRegister', this.publicContext, f.configuration);
|
|
75
|
-
}
|
|
76
|
-
return f;
|
|
77
|
-
}
|
|
78
|
-
has(e) {
|
|
79
|
-
return this.injectables.has(e);
|
|
80
|
-
}
|
|
81
|
-
require(e, t, n) {
|
|
82
|
-
if (!this.injectables.has(e)) {
|
|
83
|
-
const t = this.resolvingStack.has(e);
|
|
84
|
-
const r = t ? 'Circular dependency detected' : 'Dependency not registered';
|
|
85
|
-
const i = a(e);
|
|
86
|
-
const s = f(e);
|
|
87
|
-
const c = t ? `Circular dependency detected: '${i}' is already being resolved.` : `Dependency '${i}' has not been registered (Class/Service not found in current assemblies).`;
|
|
88
|
-
DebugLogger.getInstance().log('error', r, {
|
|
89
|
-
identifier: i,
|
|
90
|
-
caller: n ? a(n) : 'unknown',
|
|
91
|
-
type: s,
|
|
92
|
-
error: c
|
|
93
|
-
});
|
|
94
|
-
throw new Error(c);
|
|
95
|
-
}
|
|
96
|
-
const r = this.injectables.get(e);
|
|
97
|
-
this.resolvingStack.add(r.identifier);
|
|
98
|
-
try {
|
|
99
|
-
if (r.isSingleton) {
|
|
100
|
-
return this.singletonStrategy.resolve(r, t);
|
|
101
|
-
} else {
|
|
102
|
-
return this.transientStrategy.resolve(r, t);
|
|
103
|
-
}
|
|
104
|
-
} finally{
|
|
105
|
-
this.resolvingStack.delete(r.identifier);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
concrete(e) {
|
|
109
|
-
const t = this.injectables.get(e);
|
|
110
|
-
if (t) return t.concrete;
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
tagged(...e) {
|
|
114
|
-
const t = [];
|
|
115
|
-
for (const n of e){
|
|
116
|
-
for (const [e, r] of this.injectables){
|
|
117
|
-
if (r.tags.includes(n)) t.push(r.build());
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return t;
|
|
121
|
-
}
|
|
122
|
-
dispose() {
|
|
123
|
-
for (const [e, t] of this.injectables){
|
|
124
|
-
t.dispose();
|
|
125
|
-
}
|
|
126
|
-
this.resolvingStack.clear();
|
|
127
|
-
}
|
|
128
|
-
get size() {
|
|
129
|
-
return this.injectables.size;
|
|
130
|
-
}
|
|
131
|
-
getRegisteredIdentifiers() {
|
|
132
|
-
return Array.from(this.injectables.keys()).map((e)=>e?.name || String(e));
|
|
133
|
-
}
|
|
134
|
-
constructor(){
|
|
135
|
-
this.injectables = new Map();
|
|
136
|
-
this.resolvingStack = new Set();
|
|
137
|
-
this.singletonStrategy = new SingletonStrategy();
|
|
138
|
-
this.transientStrategy = new TransientStrategy();
|
|
5
|
+
class AssemblerBuilder {
|
|
6
|
+
build(t, a) {
|
|
7
|
+
const n = DebugLogger.getInstance();
|
|
8
|
+
setDefinitionValue('singleton', true, t);
|
|
9
|
+
n.logPhaseStart('registration');
|
|
10
|
+
const r = this.assembler.register([
|
|
11
|
+
t
|
|
12
|
+
]);
|
|
13
|
+
const i = this.assembler.injectableManager.getRegisteredIdentifiers();
|
|
14
|
+
n.logPhaseEnd('registration', undefined, {
|
|
15
|
+
registered: i
|
|
16
|
+
});
|
|
17
|
+
n.logPhaseStart('resolution');
|
|
18
|
+
const l = this.assembler.require(r.identifier, a);
|
|
19
|
+
n.logPhaseEnd('resolution');
|
|
20
|
+
const h = this.assembler.hookManager.getCache().find((e)=>e.instance === l);
|
|
21
|
+
if (!h) {
|
|
22
|
+
throw new Error('Root instance not found in assemblages cache.');
|
|
23
|
+
}
|
|
24
|
+
const g = this.assembler.hookManager.getCache().indexOf(h);
|
|
25
|
+
this.assembler.hookManager.getCache().splice(g, 1);
|
|
26
|
+
n.logPhaseStart('hooks:onInit');
|
|
27
|
+
this.assembler.hookManager.callInitHooks(this.assembler.publicContext);
|
|
28
|
+
const c = a ? {
|
|
29
|
+
...r.configuration,
|
|
30
|
+
...a
|
|
31
|
+
} : r.configuration;
|
|
32
|
+
HookManager.callHookImmediate(l, 'onInit', this.assembler.publicContext, c);
|
|
33
|
+
n.logPhaseEnd('hooks:onInit');
|
|
34
|
+
n.logPhaseStart('hooks:onInited');
|
|
35
|
+
this.assembler.hookManager.callInitedHooks(this.assembler.publicContext);
|
|
36
|
+
HookManager.callHookImmediate(l, 'onInited', this.assembler.publicContext, c);
|
|
37
|
+
n.logPhaseEnd('hooks:onInited');
|
|
38
|
+
this.assembler.hookManager.clearCache();
|
|
39
|
+
return l;
|
|
40
|
+
}
|
|
41
|
+
constructor(e){
|
|
42
|
+
this.assembler = e;
|
|
139
43
|
}
|
|
140
44
|
}
|
|
141
45
|
|
|
142
|
-
export {
|
|
46
|
+
export { AssemblerBuilder };
|
package/dist/index35.js
CHANGED
|
@@ -2,55 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
20
|
-
throw new Error(s);
|
|
21
|
-
}
|
|
22
|
-
this.objects.set(r, o);
|
|
23
|
-
return o;
|
|
24
|
-
}
|
|
25
|
-
has(e) {
|
|
26
|
-
return this.objects.has(e);
|
|
27
|
-
}
|
|
28
|
-
require(r) {
|
|
29
|
-
if (!this.objects.has(r)) {
|
|
30
|
-
const o = typeof r === 'symbol' ? r.toString() : String(r);
|
|
31
|
-
const s = `Object/value '${o}' has not been registered in the object store.`;
|
|
32
|
-
debugLogger.DebugLogger.getInstance().log('error', 'Object/value not found', {
|
|
33
|
-
identifier: o,
|
|
34
|
-
type: t(r),
|
|
35
|
-
error: s
|
|
36
|
-
});
|
|
37
|
-
throw new Error(s);
|
|
38
|
-
}
|
|
39
|
-
return this.objects.get(r);
|
|
40
|
-
}
|
|
41
|
-
addGlobal(e, t) {
|
|
42
|
-
if (this.globals.has(e)) {
|
|
43
|
-
throw new Error(`Global value with key '${e}' has already been registered.`);
|
|
44
|
-
}
|
|
45
|
-
this.globals.set(e, t);
|
|
5
|
+
class ContextProvider {
|
|
6
|
+
createPublicContext() {
|
|
7
|
+
return {
|
|
8
|
+
has: this.assembler.has.bind(this.assembler),
|
|
9
|
+
require: this.assembler.require.bind(this.assembler),
|
|
10
|
+
concrete: this.assembler.concrete.bind(this.assembler),
|
|
11
|
+
tagged: this.assembler.tagged.bind(this.assembler),
|
|
12
|
+
dispose: this.assembler.dispose.bind(this.assembler),
|
|
13
|
+
global: this.assembler.global.bind(this.assembler),
|
|
14
|
+
on: this.assembler.on.bind(this.assembler),
|
|
15
|
+
once: this.assembler.once.bind(this.assembler),
|
|
16
|
+
off: this.assembler.off.bind(this.assembler),
|
|
17
|
+
events: this.assembler.channels
|
|
18
|
+
};
|
|
46
19
|
}
|
|
47
|
-
|
|
48
|
-
return
|
|
20
|
+
createPrivateContext(s) {
|
|
21
|
+
return {
|
|
22
|
+
...s,
|
|
23
|
+
register: this.assembler.register.bind(this.assembler),
|
|
24
|
+
use: this.assembler.use.bind(this.assembler),
|
|
25
|
+
addGlobal: this.assembler.addGlobal.bind(this.assembler),
|
|
26
|
+
prepareInitHook: this.assembler.prepareInitHook.bind(this.assembler),
|
|
27
|
+
emit: this.assembler.emit.bind(this.assembler),
|
|
28
|
+
addChannels: this.assembler.addChannels.bind(this.assembler),
|
|
29
|
+
removeChannels: this.assembler.removeChannels.bind(this.assembler)
|
|
30
|
+
};
|
|
49
31
|
}
|
|
50
|
-
constructor(){
|
|
51
|
-
this.
|
|
52
|
-
this.globals = new Map();
|
|
32
|
+
constructor(s){
|
|
33
|
+
this.assembler = s;
|
|
53
34
|
}
|
|
54
35
|
}
|
|
55
36
|
|
|
56
|
-
exports.
|
|
37
|
+
exports.ContextProvider = ContextProvider;
|
package/dist/index35.mjs
CHANGED
|
@@ -1,52 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
16
|
-
throw new Error(s);
|
|
17
|
-
}
|
|
18
|
-
this.objects.set(r, o);
|
|
19
|
-
return o;
|
|
20
|
-
}
|
|
21
|
-
has(e) {
|
|
22
|
-
return this.objects.has(e);
|
|
23
|
-
}
|
|
24
|
-
require(r) {
|
|
25
|
-
if (!this.objects.has(r)) {
|
|
26
|
-
const o = typeof r === 'symbol' ? r.toString() : String(r);
|
|
27
|
-
const s = `Object/value '${o}' has not been registered in the object store.`;
|
|
28
|
-
DebugLogger.getInstance().log('error', 'Object/value not found', {
|
|
29
|
-
identifier: o,
|
|
30
|
-
type: t(r),
|
|
31
|
-
error: s
|
|
32
|
-
});
|
|
33
|
-
throw new Error(s);
|
|
34
|
-
}
|
|
35
|
-
return this.objects.get(r);
|
|
36
|
-
}
|
|
37
|
-
addGlobal(e, t) {
|
|
38
|
-
if (this.globals.has(e)) {
|
|
39
|
-
throw new Error(`Global value with key '${e}' has already been registered.`);
|
|
40
|
-
}
|
|
41
|
-
this.globals.set(e, t);
|
|
1
|
+
class ContextProvider {
|
|
2
|
+
createPublicContext() {
|
|
3
|
+
return {
|
|
4
|
+
has: this.assembler.has.bind(this.assembler),
|
|
5
|
+
require: this.assembler.require.bind(this.assembler),
|
|
6
|
+
concrete: this.assembler.concrete.bind(this.assembler),
|
|
7
|
+
tagged: this.assembler.tagged.bind(this.assembler),
|
|
8
|
+
dispose: this.assembler.dispose.bind(this.assembler),
|
|
9
|
+
global: this.assembler.global.bind(this.assembler),
|
|
10
|
+
on: this.assembler.on.bind(this.assembler),
|
|
11
|
+
once: this.assembler.once.bind(this.assembler),
|
|
12
|
+
off: this.assembler.off.bind(this.assembler),
|
|
13
|
+
events: this.assembler.channels
|
|
14
|
+
};
|
|
42
15
|
}
|
|
43
|
-
|
|
44
|
-
return
|
|
16
|
+
createPrivateContext(s) {
|
|
17
|
+
return {
|
|
18
|
+
...s,
|
|
19
|
+
register: this.assembler.register.bind(this.assembler),
|
|
20
|
+
use: this.assembler.use.bind(this.assembler),
|
|
21
|
+
addGlobal: this.assembler.addGlobal.bind(this.assembler),
|
|
22
|
+
prepareInitHook: this.assembler.prepareInitHook.bind(this.assembler),
|
|
23
|
+
emit: this.assembler.emit.bind(this.assembler),
|
|
24
|
+
addChannels: this.assembler.addChannels.bind(this.assembler),
|
|
25
|
+
removeChannels: this.assembler.removeChannels.bind(this.assembler)
|
|
26
|
+
};
|
|
45
27
|
}
|
|
46
|
-
constructor(){
|
|
47
|
-
this.
|
|
48
|
-
this.globals = new Map();
|
|
28
|
+
constructor(s){
|
|
29
|
+
this.assembler = s;
|
|
49
30
|
}
|
|
50
31
|
}
|
|
51
32
|
|
|
52
|
-
export {
|
|
33
|
+
export { ContextProvider };
|
package/dist/index36.js
CHANGED
|
@@ -2,84 +2,167 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
function o(o) {
|
|
6
|
+
if (o === undefined) return 'undefined';
|
|
7
|
+
if (o === null) return 'null';
|
|
8
|
+
if (typeof o === 'function') {
|
|
9
|
+
if (o.name) return o.name;
|
|
10
|
+
if (o.constructor?.name && o.constructor.name !== 'Function') {
|
|
11
|
+
return o.constructor.name;
|
|
12
|
+
}
|
|
13
|
+
return 'AnonymousFunction';
|
|
14
|
+
}
|
|
15
|
+
if (typeof o === 'object') {
|
|
16
|
+
if (o.name && typeof o.name === 'string') {
|
|
17
|
+
return o.name;
|
|
18
|
+
}
|
|
19
|
+
const e = o.constructor?.name;
|
|
20
|
+
if (e && e !== 'Object') {
|
|
21
|
+
return e;
|
|
22
|
+
}
|
|
23
|
+
return '[Object]';
|
|
24
|
+
}
|
|
25
|
+
return String(o);
|
|
26
|
+
}
|
|
27
|
+
let NoOpDebugLogger = class NoOpDebugLogger {
|
|
28
|
+
configure(o) {}
|
|
29
|
+
log(o, e, t) {}
|
|
30
|
+
logBuildStart(o) {}
|
|
31
|
+
logBuildEnd(o, e) {}
|
|
32
|
+
logRegistration(o) {}
|
|
33
|
+
logHook(o, e, t) {}
|
|
34
|
+
logPhaseStart(o, e) {}
|
|
35
|
+
logPhaseEnd(o, e, t) {}
|
|
36
|
+
logResolution(o, e, t) {}
|
|
37
|
+
logConstruction(o) {}
|
|
38
|
+
};
|
|
39
|
+
let ActiveDebugLogger = class ActiveDebugLogger {
|
|
40
|
+
configure(o) {
|
|
41
|
+
this.options = {
|
|
42
|
+
...this.options,
|
|
43
|
+
...o,
|
|
44
|
+
logPhases: {
|
|
45
|
+
...this.options.logPhases,
|
|
46
|
+
...o.logPhases || {}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
logBuildStart(o) {
|
|
51
|
+
this.log('info', 'Build started', {
|
|
52
|
+
entry: o.name
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
logBuildEnd(o, e) {
|
|
56
|
+
const t = {
|
|
57
|
+
entry: o.name
|
|
58
|
+
};
|
|
59
|
+
if (e !== undefined) t.duration = `${e.toFixed(2)}ms`;
|
|
60
|
+
this.log('info', 'Build completed', t);
|
|
61
|
+
}
|
|
62
|
+
logRegistration(e) {
|
|
63
|
+
if (!this.shouldLog('registration')) return;
|
|
64
|
+
this.log('info', 'Registration', {
|
|
65
|
+
identifier: o(e.identifier),
|
|
66
|
+
isSingleton: e.isSingleton,
|
|
67
|
+
dependencies: e.dependencies.map((e)=>o(e)),
|
|
68
|
+
tags: e.tags
|
|
13
69
|
});
|
|
14
|
-
return this.initCache;
|
|
15
70
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
71
|
+
logHook(e, t, n) {
|
|
72
|
+
if (!this.shouldLog('hooks')) return;
|
|
73
|
+
const s = this.options.logTimings ? performance.now() : 0;
|
|
74
|
+
this.log('info', `Hook: ${e}`, {
|
|
75
|
+
target: o(t),
|
|
76
|
+
config: n
|
|
77
|
+
});
|
|
78
|
+
if (this.options.logTimings) {
|
|
79
|
+
return ()=>{
|
|
80
|
+
const o = performance.now() - s;
|
|
81
|
+
this.log('info', `Hook: ${e} completed`, {
|
|
82
|
+
duration: `${o.toFixed(2)}ms`
|
|
83
|
+
});
|
|
84
|
+
};
|
|
19
85
|
}
|
|
20
86
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
87
|
+
logPhaseStart(o, e) {
|
|
88
|
+
this.log('info', `Phase: ${o} started`, e);
|
|
89
|
+
}
|
|
90
|
+
logPhaseEnd(o, e, t) {
|
|
91
|
+
const n = e !== undefined ? {
|
|
92
|
+
duration: `${e.toFixed(2)}ms`
|
|
93
|
+
} : {};
|
|
94
|
+
if (t) {
|
|
95
|
+
Object.assign(n, t);
|
|
26
96
|
}
|
|
97
|
+
this.log('info', `Phase: ${o} ended`, Object.keys(n).length > 0 ? n : undefined);
|
|
27
98
|
}
|
|
28
|
-
|
|
29
|
-
this.
|
|
99
|
+
logResolution(o, e, t) {
|
|
100
|
+
if (!this.shouldLog('resolution')) return;
|
|
101
|
+
this.log('info', `Resolving: ${o}`, {
|
|
102
|
+
strategy: `${e} strategy`,
|
|
103
|
+
cache: t ? 'hit' : 'miss'
|
|
104
|
+
});
|
|
30
105
|
}
|
|
31
|
-
|
|
32
|
-
|
|
106
|
+
logConstruction(o) {
|
|
107
|
+
if (!this.shouldLog('construction')) return;
|
|
108
|
+
this.log('info', `Constructing: ${o}`);
|
|
33
109
|
}
|
|
34
|
-
|
|
35
|
-
this.
|
|
110
|
+
shouldLog(o) {
|
|
111
|
+
return !this.options.logPhases || this.options.logPhases[o] !== false;
|
|
36
112
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const r = c.logHook(i, e, a);
|
|
41
|
-
return new Promise((t, c)=>{
|
|
42
|
-
const s = e[i];
|
|
43
|
-
if (s) {
|
|
44
|
-
if (core.isAsync(s)) {
|
|
45
|
-
s.bind(e)(n, a).then(()=>{
|
|
46
|
-
if (r) r();
|
|
47
|
-
t();
|
|
48
|
-
}).catch((o)=>{
|
|
49
|
-
if (r) r();
|
|
50
|
-
c(o);
|
|
51
|
-
});
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
try {
|
|
55
|
-
s.bind(e)(n, a);
|
|
56
|
-
if (r) r();
|
|
57
|
-
t();
|
|
58
|
-
} catch (o) {
|
|
59
|
-
if (r) r();
|
|
60
|
-
c(o);
|
|
61
|
-
}
|
|
113
|
+
log(o, e, t) {
|
|
114
|
+
if (this.options.logger) {
|
|
115
|
+
this.options.logger(o, e, t);
|
|
62
116
|
} else {
|
|
63
|
-
|
|
64
|
-
|
|
117
|
+
const n = `[Assembler:${o}]`;
|
|
118
|
+
const s = this.options.useColors !== false ? this.colorize(o, n) : n;
|
|
119
|
+
if (t) {
|
|
120
|
+
console.log(`${s} ${e}`, t);
|
|
121
|
+
} else {
|
|
122
|
+
console.log(`${s} ${e}`);
|
|
123
|
+
}
|
|
65
124
|
}
|
|
66
|
-
}
|
|
125
|
+
}
|
|
126
|
+
colorize(o, e) {
|
|
127
|
+
const t = {
|
|
128
|
+
info: '\x1b[36m',
|
|
129
|
+
warn: '\x1b[33m',
|
|
130
|
+
error: '\x1b[31m',
|
|
131
|
+
reset: '\x1b[0m'
|
|
132
|
+
};
|
|
133
|
+
const n = t[o] || t.info;
|
|
134
|
+
return `${n}${e}${t.reset}`;
|
|
135
|
+
}
|
|
136
|
+
constructor(){
|
|
137
|
+
this.options = {
|
|
138
|
+
enabled: true,
|
|
139
|
+
logPhases: {
|
|
140
|
+
registration: true,
|
|
141
|
+
resolution: true,
|
|
142
|
+
construction: true,
|
|
143
|
+
hooks: true,
|
|
144
|
+
cache: true
|
|
145
|
+
},
|
|
146
|
+
logTimings: false,
|
|
147
|
+
logDependencyTree: true,
|
|
148
|
+
useColors: true
|
|
149
|
+
};
|
|
150
|
+
}
|
|
67
151
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return;
|
|
152
|
+
class DebugLogger {
|
|
153
|
+
static getInstance() {
|
|
154
|
+
return DebugLogger.instance;
|
|
155
|
+
}
|
|
156
|
+
static enable(o) {
|
|
157
|
+
DebugLogger.instance = new ActiveDebugLogger();
|
|
158
|
+
if (o) {
|
|
159
|
+
DebugLogger.instance.configure(o);
|
|
77
160
|
}
|
|
78
|
-
s.bind(e)(n, a);
|
|
79
|
-
if (r) r();
|
|
80
|
-
} else {
|
|
81
|
-
if (r) r();
|
|
82
161
|
}
|
|
83
|
-
|
|
162
|
+
static disable() {
|
|
163
|
+
DebugLogger.instance = new NoOpDebugLogger();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
DebugLogger.instance = new NoOpDebugLogger();
|
|
84
167
|
|
|
85
|
-
exports.
|
|
168
|
+
exports.DebugLogger = DebugLogger;
|