assemblerjs 1.1.17 → 1.1.19
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 +1 -0
- package/dist/index13.js +97 -82
- package/dist/index13.mjs +97 -82
- 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 +100 -35
- package/dist/index31.mjs +100 -34
- package/dist/index32.js +24 -101
- package/dist/index32.mjs +24 -101
- package/dist/index33.js +152 -22
- package/dist/index33.mjs +151 -22
- package/dist/index34.js +44 -16
- package/dist/index34.mjs +44 -16
- package/dist/index35.js +66 -145
- package/dist/index35.mjs +67 -145
- package/dist/index36.js +50 -45
- package/dist/index36.mjs +50 -45
- package/dist/index37.js +28 -76
- package/dist/index37.mjs +28 -76
- package/dist/index38.js +161 -50
- package/dist/index38.mjs +161 -50
- package/dist/index39.js +60 -28
- package/dist/index39.mjs +60 -28
- package/dist/index4.js +7 -7
- package/dist/index4.mjs +7 -7
- package/dist/index40.js +32 -158
- package/dist/index40.mjs +31 -158
- package/dist/index41.js +16 -57
- package/dist/index41.mjs +16 -57
- package/dist/index44.js +28 -941
- package/dist/index44.mjs +27 -941
- package/dist/index45.js +194 -2
- package/dist/index45.mjs +194 -2
- package/dist/index46.js +942 -2
- package/dist/index46.mjs +942 -2
- package/dist/index47.js +2 -29
- package/dist/index47.mjs +2 -28
- package/dist/index48.js +2 -194
- package/dist/index48.mjs +2 -194
- 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/index39.js
CHANGED
|
@@ -2,36 +2,68 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
class
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
};
|
|
5
|
+
let AbstractCycleDetector = class AbstractCycleDetector {
|
|
6
|
+
};
|
|
7
|
+
let NoOpCycleDetector = class NoOpCycleDetector extends AbstractCycleDetector {
|
|
8
|
+
detect() {
|
|
9
|
+
return [];
|
|
19
10
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
11
|
+
};
|
|
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
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return c;
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
c.delete(e);
|
|
52
|
+
s.add(e);
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
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();
|
|
34
65
|
}
|
|
35
66
|
}
|
|
67
|
+
CycleDetector.instance = new NoOpCycleDetector();
|
|
36
68
|
|
|
37
|
-
exports.
|
|
69
|
+
exports.CycleDetector = CycleDetector;
|
package/dist/index39.mjs
CHANGED
|
@@ -1,33 +1,65 @@
|
|
|
1
|
-
class
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
};
|
|
1
|
+
let AbstractCycleDetector = class AbstractCycleDetector {
|
|
2
|
+
};
|
|
3
|
+
let NoOpCycleDetector = class NoOpCycleDetector extends AbstractCycleDetector {
|
|
4
|
+
detect() {
|
|
5
|
+
return [];
|
|
15
6
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
7
|
+
};
|
|
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
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return c;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
|
|
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
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
c.delete(e);
|
|
48
|
+
s.add(e);
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
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();
|
|
30
61
|
}
|
|
31
62
|
}
|
|
63
|
+
CycleDetector.instance = new NoOpCycleDetector();
|
|
32
64
|
|
|
33
|
-
export {
|
|
65
|
+
export { CycleDetector };
|
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('./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');
|
|
12
|
+
const cycleDetector = require('./index39.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 './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';
|
|
8
|
+
import { CycleDetector } from './index39.mjs';
|
|
9
9
|
import { EventManager } from './index6.mjs';
|
|
10
10
|
|
|
11
11
|
class Assembler extends EventManager {
|
package/dist/index40.js
CHANGED
|
@@ -2,171 +2,45 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
const eventManager = require('./index6.js');
|
|
6
|
+
|
|
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);
|
|
12
15
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return o.name;
|
|
16
|
+
for (const e of t.events){
|
|
17
|
+
n.on(e, (...n)=>{
|
|
18
|
+
t.privateContext.emit(e, ...n);
|
|
19
|
+
});
|
|
18
20
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
} else {
|
|
22
|
+
for (const e of t.events){
|
|
23
|
+
if (!t.privateContext.events.has(e)) t.privateContext.addChannels(e);
|
|
22
24
|
}
|
|
23
|
-
return '[Object]';
|
|
24
25
|
}
|
|
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
26
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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}`);
|
|
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);
|
|
123
40
|
}
|
|
124
41
|
}
|
|
125
42
|
}
|
|
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
|
-
}
|
|
151
43
|
};
|
|
152
|
-
class DebugLogger {
|
|
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();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
DebugLogger.instance = new NoOpDebugLogger();
|
|
171
44
|
|
|
172
|
-
exports.
|
|
45
|
+
exports.registerEvents = registerEvents;
|
|
46
|
+
exports.unregisterEvents = unregisterEvents;
|
package/dist/index40.mjs
CHANGED
|
@@ -1,168 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { EventManager } from './index6.mjs';
|
|
2
|
+
|
|
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);
|
|
8
11
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return o.name;
|
|
12
|
+
for (const e of t.events){
|
|
13
|
+
n.on(e, (...n)=>{
|
|
14
|
+
t.privateContext.emit(e, ...n);
|
|
15
|
+
});
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
} else {
|
|
18
|
+
for (const e of t.events){
|
|
19
|
+
if (!t.privateContext.events.has(e)) t.privateContext.addChannels(e);
|
|
18
20
|
}
|
|
19
|
-
return '[Object]';
|
|
20
21
|
}
|
|
21
|
-
return String(o);
|
|
22
|
-
}
|
|
23
|
-
let NoOpDebugLogger = class NoOpDebugLogger {
|
|
24
|
-
configure(o) {}
|
|
25
|
-
log(o, e, t) {}
|
|
26
|
-
logBuildStart(o) {}
|
|
27
|
-
logBuildEnd(o, e) {}
|
|
28
|
-
logRegistration(o) {}
|
|
29
|
-
logHook(o, e, t) {}
|
|
30
|
-
logPhaseStart(o, e) {}
|
|
31
|
-
logPhaseEnd(o, e, t) {}
|
|
32
|
-
logResolution(o, e, t) {}
|
|
33
|
-
logConstruction(o) {}
|
|
34
22
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
entry: o.name
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
logBuildEnd(o, e) {
|
|
52
|
-
const t = {
|
|
53
|
-
entry: o.name
|
|
54
|
-
};
|
|
55
|
-
if (e !== undefined) t.duration = `${e.toFixed(2)}ms`;
|
|
56
|
-
this.log('info', 'Build completed', t);
|
|
57
|
-
}
|
|
58
|
-
logRegistration(e) {
|
|
59
|
-
if (!this.shouldLog('registration')) return;
|
|
60
|
-
this.log('info', 'Registration', {
|
|
61
|
-
identifier: o(e.identifier),
|
|
62
|
-
isSingleton: e.isSingleton,
|
|
63
|
-
dependencies: e.dependencies.map((e)=>o(e)),
|
|
64
|
-
tags: e.tags
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
logHook(e, t, n) {
|
|
68
|
-
if (!this.shouldLog('hooks')) return;
|
|
69
|
-
const s = this.options.logTimings ? performance.now() : 0;
|
|
70
|
-
this.log('info', `Hook: ${e}`, {
|
|
71
|
-
target: o(t),
|
|
72
|
-
config: n
|
|
73
|
-
});
|
|
74
|
-
if (this.options.logTimings) {
|
|
75
|
-
return ()=>{
|
|
76
|
-
const o = performance.now() - s;
|
|
77
|
-
this.log('info', `Hook: ${e} completed`, {
|
|
78
|
-
duration: `${o.toFixed(2)}ms`
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
logPhaseStart(o, e) {
|
|
84
|
-
this.log('info', `Phase: ${o} started`, e);
|
|
85
|
-
}
|
|
86
|
-
logPhaseEnd(o, e, t) {
|
|
87
|
-
const n = e !== undefined ? {
|
|
88
|
-
duration: `${e.toFixed(2)}ms`
|
|
89
|
-
} : {};
|
|
90
|
-
if (t) {
|
|
91
|
-
Object.assign(n, t);
|
|
92
|
-
}
|
|
93
|
-
this.log('info', `Phase: ${o} ended`, Object.keys(n).length > 0 ? n : undefined);
|
|
94
|
-
}
|
|
95
|
-
logResolution(o, e, t) {
|
|
96
|
-
if (!this.shouldLog('resolution')) return;
|
|
97
|
-
this.log('info', `Resolving: ${o}`, {
|
|
98
|
-
strategy: `${e} strategy`,
|
|
99
|
-
cache: t ? 'hit' : 'miss'
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
logConstruction(o) {
|
|
103
|
-
if (!this.shouldLog('construction')) return;
|
|
104
|
-
this.log('info', `Constructing: ${o}`);
|
|
105
|
-
}
|
|
106
|
-
shouldLog(o) {
|
|
107
|
-
return !this.options.logPhases || this.options.logPhases[o] !== false;
|
|
108
|
-
}
|
|
109
|
-
log(o, e, t) {
|
|
110
|
-
if (this.options.logger) {
|
|
111
|
-
this.options.logger(o, e, t);
|
|
112
|
-
} else {
|
|
113
|
-
const n = `[Assembler:${o}]`;
|
|
114
|
-
const s = this.options.useColors !== false ? this.colorize(o, n) : n;
|
|
115
|
-
if (t) {
|
|
116
|
-
console.log(`${s} ${e}`, t);
|
|
117
|
-
} else {
|
|
118
|
-
console.log(`${s} ${e}`);
|
|
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);
|
|
119
36
|
}
|
|
120
37
|
}
|
|
121
38
|
}
|
|
122
|
-
colorize(o, e) {
|
|
123
|
-
const t = {
|
|
124
|
-
info: '\x1b[36m',
|
|
125
|
-
warn: '\x1b[33m',
|
|
126
|
-
error: '\x1b[31m',
|
|
127
|
-
reset: '\x1b[0m'
|
|
128
|
-
};
|
|
129
|
-
const n = t[o] || t.info;
|
|
130
|
-
return `${n}${e}${t.reset}`;
|
|
131
|
-
}
|
|
132
|
-
constructor(){
|
|
133
|
-
this.options = {
|
|
134
|
-
enabled: true,
|
|
135
|
-
logPhases: {
|
|
136
|
-
registration: true,
|
|
137
|
-
resolution: true,
|
|
138
|
-
construction: true,
|
|
139
|
-
hooks: true,
|
|
140
|
-
cache: true
|
|
141
|
-
},
|
|
142
|
-
logTimings: false,
|
|
143
|
-
logDependencyTree: true,
|
|
144
|
-
useColors: true
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
39
|
};
|
|
148
|
-
class DebugLogger {
|
|
149
|
-
static getInstance() {
|
|
150
|
-
return DebugLogger.instance;
|
|
151
|
-
}
|
|
152
|
-
static enable(o) {
|
|
153
|
-
if (o?.enabled === false) {
|
|
154
|
-
DebugLogger.instance = new NoOpDebugLogger();
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
DebugLogger.instance = new ActiveDebugLogger();
|
|
158
|
-
if (o) {
|
|
159
|
-
DebugLogger.instance.configure(o);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
static disable() {
|
|
163
|
-
DebugLogger.instance = new NoOpDebugLogger();
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
DebugLogger.instance = new NoOpDebugLogger();
|
|
167
40
|
|
|
168
|
-
export {
|
|
41
|
+
export { registerEvents, unregisterEvents };
|