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/index34.js
CHANGED
|
@@ -2,60 +2,84 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const debugLogger = require('./
|
|
7
|
-
const cycleDetector = require('./index37.js');
|
|
8
|
-
const injectableManager = require('./index31.js');
|
|
9
|
-
const schema = require('./index30.js');
|
|
5
|
+
const core = require('@assemblerjs/core');
|
|
6
|
+
const debugLogger = require('./index37.js');
|
|
10
7
|
|
|
11
|
-
class
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const l = this.assembler.register([
|
|
17
|
-
n
|
|
18
|
-
]);
|
|
19
|
-
const c = this.assembler.injectableManager.getRegisteredIdentifiers();
|
|
20
|
-
i.logPhaseEnd('registration', undefined, {
|
|
21
|
-
registered: c
|
|
8
|
+
class HookManager {
|
|
9
|
+
prepareInitHook(o, t) {
|
|
10
|
+
this.initCache.push({
|
|
11
|
+
instance: o,
|
|
12
|
+
configuration: t
|
|
22
13
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
path: e.path
|
|
29
|
-
});
|
|
30
|
-
}
|
|
14
|
+
return this.initCache;
|
|
15
|
+
}
|
|
16
|
+
callInitHooks(o) {
|
|
17
|
+
for (const t of this.initCache){
|
|
18
|
+
HookManager.callHookImmediate(t.instance, 'onInit', o, t.configuration);
|
|
31
19
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
20
|
+
}
|
|
21
|
+
callInitedHooks(o) {
|
|
22
|
+
for (const t of [
|
|
23
|
+
...this.initCache
|
|
24
|
+
].reverse()){
|
|
25
|
+
HookManager.callHookImmediate(t.instance, 'onInited', o, t.configuration);
|
|
38
26
|
}
|
|
39
|
-
const b = this.assembler.hookManager.getCache().indexOf(m);
|
|
40
|
-
this.assembler.hookManager.getCache().splice(b, 1);
|
|
41
|
-
i.logPhaseStart('hooks:onInit');
|
|
42
|
-
this.assembler.hookManager.callInitHooks(this.assembler.publicContext);
|
|
43
|
-
const d = r ? {
|
|
44
|
-
...l.configuration,
|
|
45
|
-
...r
|
|
46
|
-
} : l.configuration;
|
|
47
|
-
hookManager.HookManager.callHookImmediate(g, 'onInit', this.assembler.publicContext, d);
|
|
48
|
-
i.logPhaseEnd('hooks:onInit');
|
|
49
|
-
i.logPhaseStart('hooks:onInited');
|
|
50
|
-
this.assembler.hookManager.callInitedHooks(this.assembler.publicContext);
|
|
51
|
-
hookManager.HookManager.callHookImmediate(g, 'onInited', this.assembler.publicContext, d);
|
|
52
|
-
i.logPhaseEnd('hooks:onInited');
|
|
53
|
-
this.assembler.hookManager.clearCache();
|
|
54
|
-
return g;
|
|
55
27
|
}
|
|
56
|
-
|
|
57
|
-
this.
|
|
28
|
+
clearCache() {
|
|
29
|
+
this.initCache.length = 0;
|
|
30
|
+
}
|
|
31
|
+
getCache() {
|
|
32
|
+
return this.initCache;
|
|
33
|
+
}
|
|
34
|
+
constructor(){
|
|
35
|
+
this.initCache = [];
|
|
58
36
|
}
|
|
59
37
|
}
|
|
38
|
+
HookManager.callHook = (e, i, n, a)=>{
|
|
39
|
+
const c = debugLogger.DebugLogger.getInstance();
|
|
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
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
if (r) r();
|
|
64
|
+
t();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
HookManager.callHookImmediate = (e, i, n, a)=>{
|
|
69
|
+
const c = debugLogger.DebugLogger.getInstance();
|
|
70
|
+
const r = c.logHook(i, e, a);
|
|
71
|
+
const s = e[i];
|
|
72
|
+
if (s) {
|
|
73
|
+
if (core.isAsync(s)) {
|
|
74
|
+
s.bind(e)(n, a).catch(()=>{});
|
|
75
|
+
if (r) r();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
s.bind(e)(n, a);
|
|
79
|
+
if (r) r();
|
|
80
|
+
} else {
|
|
81
|
+
if (r) r();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
60
84
|
|
|
61
|
-
exports.
|
|
85
|
+
exports.HookManager = HookManager;
|
package/dist/index34.mjs
CHANGED
|
@@ -1,57 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DebugLogger } from './
|
|
3
|
-
import { CycleDetector } from './index37.mjs';
|
|
4
|
-
import { formatIdentifier } from './index31.mjs';
|
|
5
|
-
import { setDefinitionValue } from './index30.mjs';
|
|
1
|
+
import { isAsync } from '@assemblerjs/core';
|
|
2
|
+
import { DebugLogger } from './index37.mjs';
|
|
6
3
|
|
|
7
|
-
class
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const l = this.assembler.register([
|
|
13
|
-
n
|
|
14
|
-
]);
|
|
15
|
-
const c = this.assembler.injectableManager.getRegisteredIdentifiers();
|
|
16
|
-
i.logPhaseEnd('registration', undefined, {
|
|
17
|
-
registered: c
|
|
4
|
+
class HookManager {
|
|
5
|
+
prepareInitHook(o, t) {
|
|
6
|
+
this.initCache.push({
|
|
7
|
+
instance: o,
|
|
8
|
+
configuration: t
|
|
18
9
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
path: e.path
|
|
25
|
-
});
|
|
26
|
-
}
|
|
10
|
+
return this.initCache;
|
|
11
|
+
}
|
|
12
|
+
callInitHooks(o) {
|
|
13
|
+
for (const t of this.initCache){
|
|
14
|
+
HookManager.callHookImmediate(t.instance, 'onInit', o, t.configuration);
|
|
27
15
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
16
|
+
}
|
|
17
|
+
callInitedHooks(o) {
|
|
18
|
+
for (const t of [
|
|
19
|
+
...this.initCache
|
|
20
|
+
].reverse()){
|
|
21
|
+
HookManager.callHookImmediate(t.instance, 'onInited', o, t.configuration);
|
|
34
22
|
}
|
|
35
|
-
const b = this.assembler.hookManager.getCache().indexOf(m);
|
|
36
|
-
this.assembler.hookManager.getCache().splice(b, 1);
|
|
37
|
-
i.logPhaseStart('hooks:onInit');
|
|
38
|
-
this.assembler.hookManager.callInitHooks(this.assembler.publicContext);
|
|
39
|
-
const d = r ? {
|
|
40
|
-
...l.configuration,
|
|
41
|
-
...r
|
|
42
|
-
} : l.configuration;
|
|
43
|
-
HookManager.callHookImmediate(g, 'onInit', this.assembler.publicContext, d);
|
|
44
|
-
i.logPhaseEnd('hooks:onInit');
|
|
45
|
-
i.logPhaseStart('hooks:onInited');
|
|
46
|
-
this.assembler.hookManager.callInitedHooks(this.assembler.publicContext);
|
|
47
|
-
HookManager.callHookImmediate(g, 'onInited', this.assembler.publicContext, d);
|
|
48
|
-
i.logPhaseEnd('hooks:onInited');
|
|
49
|
-
this.assembler.hookManager.clearCache();
|
|
50
|
-
return g;
|
|
51
23
|
}
|
|
52
|
-
|
|
53
|
-
this.
|
|
24
|
+
clearCache() {
|
|
25
|
+
this.initCache.length = 0;
|
|
26
|
+
}
|
|
27
|
+
getCache() {
|
|
28
|
+
return this.initCache;
|
|
29
|
+
}
|
|
30
|
+
constructor(){
|
|
31
|
+
this.initCache = [];
|
|
54
32
|
}
|
|
55
33
|
}
|
|
34
|
+
HookManager.callHook = (e, i, n, a)=>{
|
|
35
|
+
const c = DebugLogger.getInstance();
|
|
36
|
+
const r = c.logHook(i, e, a);
|
|
37
|
+
return new Promise((t, c)=>{
|
|
38
|
+
const s = e[i];
|
|
39
|
+
if (s) {
|
|
40
|
+
if (isAsync(s)) {
|
|
41
|
+
s.bind(e)(n, a).then(()=>{
|
|
42
|
+
if (r) r();
|
|
43
|
+
t();
|
|
44
|
+
}).catch((o)=>{
|
|
45
|
+
if (r) r();
|
|
46
|
+
c(o);
|
|
47
|
+
});
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
s.bind(e)(n, a);
|
|
52
|
+
if (r) r();
|
|
53
|
+
t();
|
|
54
|
+
} catch (o) {
|
|
55
|
+
if (r) r();
|
|
56
|
+
c(o);
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
if (r) r();
|
|
60
|
+
t();
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
HookManager.callHookImmediate = (e, i, n, a)=>{
|
|
65
|
+
const c = DebugLogger.getInstance();
|
|
66
|
+
const r = c.logHook(i, e, a);
|
|
67
|
+
const s = e[i];
|
|
68
|
+
if (s) {
|
|
69
|
+
if (isAsync(s)) {
|
|
70
|
+
s.bind(e)(n, a).catch(()=>{});
|
|
71
|
+
if (r) r();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
s.bind(e)(n, a);
|
|
75
|
+
if (r) r();
|
|
76
|
+
} else {
|
|
77
|
+
if (r) r();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
56
80
|
|
|
57
|
-
export {
|
|
81
|
+
export { HookManager };
|
package/dist/index35.js
CHANGED
|
@@ -2,36 +2,60 @@
|
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
5
|
+
const hookManager = require('./index34.js');
|
|
6
|
+
const debugLogger = require('./index37.js');
|
|
7
|
+
const cycleDetector = require('./index38.js');
|
|
8
|
+
const injectableManager = require('./index32.js');
|
|
9
|
+
const schema = require('./index30.js');
|
|
10
|
+
|
|
11
|
+
class AssemblerBuilder {
|
|
12
|
+
build(n, r) {
|
|
13
|
+
const i = debugLogger.DebugLogger.getInstance();
|
|
14
|
+
schema.setDefinitionValue('singleton', true, n);
|
|
15
|
+
i.logPhaseStart('registration');
|
|
16
|
+
const l = this.assembler.register([
|
|
17
|
+
n
|
|
18
|
+
]);
|
|
19
|
+
const c = this.assembler.injectableManager.getRegisteredIdentifiers();
|
|
20
|
+
i.logPhaseEnd('registration', undefined, {
|
|
21
|
+
registered: c
|
|
22
|
+
});
|
|
23
|
+
const h = cycleDetector.CycleDetector.getInstance().detect(this.assembler.injectableManager.getInjectables(), (e)=>injectableManager.formatIdentifier(e));
|
|
24
|
+
if (h.length > 0) {
|
|
25
|
+
for (const e of h){
|
|
26
|
+
i.log('error', 'Circular dependency detected', {
|
|
27
|
+
cycle: e.cycle,
|
|
28
|
+
path: e.path
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
i.logPhaseStart('resolution');
|
|
33
|
+
const g = this.assembler.require(l.identifier, r);
|
|
34
|
+
i.logPhaseEnd('resolution');
|
|
35
|
+
const m = this.assembler.hookManager.getCache().find((e)=>e.instance === g);
|
|
36
|
+
if (!m) {
|
|
37
|
+
throw new Error('Root instance not found in assemblages cache.');
|
|
38
|
+
}
|
|
39
|
+
const b = this.assembler.hookManager.getCache().indexOf(m);
|
|
40
|
+
this.assembler.hookManager.getCache().splice(b, 1);
|
|
41
|
+
i.logPhaseStart('hooks:onInit');
|
|
42
|
+
this.assembler.hookManager.callInitHooks(this.assembler.publicContext);
|
|
43
|
+
const d = r ? {
|
|
44
|
+
...l.configuration,
|
|
45
|
+
...r
|
|
46
|
+
} : l.configuration;
|
|
47
|
+
hookManager.HookManager.callHookImmediate(g, 'onInit', this.assembler.publicContext, d);
|
|
48
|
+
i.logPhaseEnd('hooks:onInit');
|
|
49
|
+
i.logPhaseStart('hooks:onInited');
|
|
50
|
+
this.assembler.hookManager.callInitedHooks(this.assembler.publicContext);
|
|
51
|
+
hookManager.HookManager.callHookImmediate(g, 'onInited', this.assembler.publicContext, d);
|
|
52
|
+
i.logPhaseEnd('hooks:onInited');
|
|
53
|
+
this.assembler.hookManager.clearCache();
|
|
54
|
+
return g;
|
|
31
55
|
}
|
|
32
|
-
constructor(
|
|
33
|
-
this.assembler =
|
|
56
|
+
constructor(e){
|
|
57
|
+
this.assembler = e;
|
|
34
58
|
}
|
|
35
59
|
}
|
|
36
60
|
|
|
37
|
-
exports.
|
|
61
|
+
exports.AssemblerBuilder = AssemblerBuilder;
|
package/dist/index35.mjs
CHANGED
|
@@ -1,33 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
import { HookManager } from './index34.mjs';
|
|
2
|
+
import { DebugLogger } from './index37.mjs';
|
|
3
|
+
import { CycleDetector } from './index38.mjs';
|
|
4
|
+
import { formatIdentifier } from './index32.mjs';
|
|
5
|
+
import { setDefinitionValue } from './index30.mjs';
|
|
6
|
+
|
|
7
|
+
class AssemblerBuilder {
|
|
8
|
+
build(n, r) {
|
|
9
|
+
const i = DebugLogger.getInstance();
|
|
10
|
+
setDefinitionValue('singleton', true, n);
|
|
11
|
+
i.logPhaseStart('registration');
|
|
12
|
+
const l = this.assembler.register([
|
|
13
|
+
n
|
|
14
|
+
]);
|
|
15
|
+
const c = this.assembler.injectableManager.getRegisteredIdentifiers();
|
|
16
|
+
i.logPhaseEnd('registration', undefined, {
|
|
17
|
+
registered: c
|
|
18
|
+
});
|
|
19
|
+
const h = CycleDetector.getInstance().detect(this.assembler.injectableManager.getInjectables(), (e)=>formatIdentifier(e));
|
|
20
|
+
if (h.length > 0) {
|
|
21
|
+
for (const e of h){
|
|
22
|
+
i.log('error', 'Circular dependency detected', {
|
|
23
|
+
cycle: e.cycle,
|
|
24
|
+
path: e.path
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
i.logPhaseStart('resolution');
|
|
29
|
+
const g = this.assembler.require(l.identifier, r);
|
|
30
|
+
i.logPhaseEnd('resolution');
|
|
31
|
+
const m = this.assembler.hookManager.getCache().find((e)=>e.instance === g);
|
|
32
|
+
if (!m) {
|
|
33
|
+
throw new Error('Root instance not found in assemblages cache.');
|
|
34
|
+
}
|
|
35
|
+
const b = this.assembler.hookManager.getCache().indexOf(m);
|
|
36
|
+
this.assembler.hookManager.getCache().splice(b, 1);
|
|
37
|
+
i.logPhaseStart('hooks:onInit');
|
|
38
|
+
this.assembler.hookManager.callInitHooks(this.assembler.publicContext);
|
|
39
|
+
const d = r ? {
|
|
40
|
+
...l.configuration,
|
|
41
|
+
...r
|
|
42
|
+
} : l.configuration;
|
|
43
|
+
HookManager.callHookImmediate(g, 'onInit', this.assembler.publicContext, d);
|
|
44
|
+
i.logPhaseEnd('hooks:onInit');
|
|
45
|
+
i.logPhaseStart('hooks:onInited');
|
|
46
|
+
this.assembler.hookManager.callInitedHooks(this.assembler.publicContext);
|
|
47
|
+
HookManager.callHookImmediate(g, 'onInited', this.assembler.publicContext, d);
|
|
48
|
+
i.logPhaseEnd('hooks:onInited');
|
|
49
|
+
this.assembler.hookManager.clearCache();
|
|
50
|
+
return g;
|
|
27
51
|
}
|
|
28
|
-
constructor(
|
|
29
|
-
this.assembler =
|
|
52
|
+
constructor(e){
|
|
53
|
+
this.assembler = e;
|
|
30
54
|
}
|
|
31
55
|
}
|
|
32
56
|
|
|
33
|
-
export {
|
|
57
|
+
export { AssemblerBuilder };
|
package/dist/index36.js
CHANGED
|
@@ -2,171 +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
|
-
return e;
|
|
19
|
-
}
|
|
20
|
-
if (o.name && typeof o.name === 'string') {
|
|
21
|
-
return o.name;
|
|
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
|
|
69
|
-
});
|
|
70
|
-
}
|
|
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
|
-
};
|
|
85
|
-
}
|
|
86
|
-
}
|
|
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);
|
|
96
|
-
}
|
|
97
|
-
this.log('info', `Phase: ${o} ended`, Object.keys(n).length > 0 ? n : undefined);
|
|
98
|
-
}
|
|
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
|
-
});
|
|
105
|
-
}
|
|
106
|
-
logConstruction(o) {
|
|
107
|
-
if (!this.shouldLog('construction')) return;
|
|
108
|
-
this.log('info', `Constructing: ${o}`);
|
|
109
|
-
}
|
|
110
|
-
shouldLog(o) {
|
|
111
|
-
return !this.options.logPhases || this.options.logPhases[o] !== false;
|
|
112
|
-
}
|
|
113
|
-
log(o, e, t) {
|
|
114
|
-
if (this.options.logger) {
|
|
115
|
-
this.options.logger(o, e, t);
|
|
116
|
-
} else {
|
|
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
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
colorize(o, e) {
|
|
127
|
-
const t = {
|
|
128
|
-
info: '\x1b[36m',
|
|
129
|
-
warn: '\x1b[33m',
|
|
130
|
-
error: '\x1b[31m',
|
|
131
|
-
reset: '\x1b[0m'
|
|
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
|
|
132
18
|
};
|
|
133
|
-
const n = t[o] || t.info;
|
|
134
|
-
return `${n}${e}${t.reset}`;
|
|
135
19
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
logTimings: false,
|
|
147
|
-
logDependencyTree: true,
|
|
148
|
-
useColors: true
|
|
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)
|
|
149
30
|
};
|
|
150
31
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
static getInstance() {
|
|
154
|
-
return DebugLogger.instance;
|
|
155
|
-
}
|
|
156
|
-
static enable(o) {
|
|
157
|
-
if (o?.enabled === false) {
|
|
158
|
-
DebugLogger.instance = new NoOpDebugLogger();
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
DebugLogger.instance = new ActiveDebugLogger();
|
|
162
|
-
if (o) {
|
|
163
|
-
DebugLogger.instance.configure(o);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
static disable() {
|
|
167
|
-
DebugLogger.instance = new NoOpDebugLogger();
|
|
32
|
+
constructor(s){
|
|
33
|
+
this.assembler = s;
|
|
168
34
|
}
|
|
169
35
|
}
|
|
170
|
-
DebugLogger.instance = new NoOpDebugLogger();
|
|
171
36
|
|
|
172
|
-
exports.
|
|
37
|
+
exports.ContextProvider = ContextProvider;
|