assemblerjs 1.1.24 → 1.1.26
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/README.md +1 -0
- package/dist/index.d.ts +142 -0
- package/dist/index.js +15 -13
- package/dist/index.mjs +14 -13
- package/dist/index11.js +3 -3
- package/dist/index11.mjs +3 -3
- package/dist/index12.js +2 -2
- package/dist/index12.mjs +2 -2
- package/dist/index13.js +1 -1
- package/dist/index13.mjs +1 -1
- package/dist/index14.js +168 -3
- package/dist/index14.mjs +168 -3
- package/dist/index15.js +4 -22
- package/dist/index15.mjs +4 -22
- package/dist/index16.js +20 -9
- package/dist/index16.mjs +20 -9
- package/dist/index17.js +9 -87
- package/dist/index17.mjs +9 -87
- package/dist/index18.js +88 -16
- package/dist/index18.mjs +88 -16
- package/dist/index19.js +10 -10
- package/dist/index19.mjs +10 -10
- package/dist/index2.js +3 -3
- package/dist/index2.mjs +3 -3
- package/dist/index20.js +10 -10
- package/dist/index20.mjs +10 -10
- package/dist/index21.js +10 -10
- package/dist/index21.mjs +10 -10
- package/dist/index22.js +11 -26
- package/dist/index22.mjs +11 -25
- package/dist/index23.js +22 -22
- package/dist/index23.mjs +21 -21
- package/dist/index24.js +25 -19
- package/dist/index24.mjs +24 -19
- package/dist/index25.js +23 -25
- package/dist/index25.mjs +23 -21
- package/dist/index26.js +26 -46
- package/dist/index26.mjs +22 -45
- package/dist/index27.js +50 -2
- package/dist/index27.mjs +47 -2
- package/dist/index28.js +2 -19
- package/dist/index28.mjs +2 -15
- package/dist/index29.js +17 -159
- package/dist/index29.mjs +15 -158
- package/dist/index3.js +2 -2
- package/dist/index3.mjs +2 -2
- package/dist/index30.js +17 -50
- package/dist/index30.mjs +14 -50
- package/dist/index31.js +99 -71
- package/dist/index31.mjs +97 -71
- package/dist/index32.js +154 -51
- package/dist/index32.mjs +153 -51
- package/dist/index33.js +47 -28
- package/dist/index33.mjs +47 -28
- package/dist/index34.js +65 -161
- package/dist/index34.mjs +65 -161
- package/dist/index35.js +50 -58
- package/dist/index35.mjs +50 -58
- package/dist/index36.js +32 -18
- package/dist/index36.mjs +32 -15
- package/dist/index37.js +169 -16
- package/dist/index37.mjs +169 -16
- package/dist/index38.js +56 -100
- package/dist/index38.mjs +56 -98
- package/dist/index4.js +7 -7
- package/dist/index4.mjs +7 -7
- package/dist/index40.js +17 -118
- package/dist/index40.mjs +17 -118
- package/dist/index42.js +49 -29
- package/dist/index42.mjs +49 -28
- package/dist/index44.js +29 -49
- package/dist/index44.mjs +28 -49
- package/dist/index45.js +5 -5
- package/dist/index45.mjs +5 -5
- package/dist/index49.js +1 -1
- package/dist/index49.mjs +1 -1
- package/dist/index50.js +1 -1
- package/dist/index50.mjs +1 -1
- package/dist/index51.js +2 -2
- package/dist/index51.mjs +2 -2
- package/package.json +1 -1
package/dist/index32.mjs
CHANGED
|
@@ -1,57 +1,159 @@
|
|
|
1
|
-
import { HookManager } from './
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { HookManager } from './index34.mjs';
|
|
2
|
+
import { SingletonStrategy, TransientStrategy } from './index44.mjs';
|
|
3
|
+
import { DebugLogger } from './index37.mjs';
|
|
4
|
+
import { isClass } from '@assemblerjs/core';
|
|
5
|
+
import { resolveInstanceInjectionTuple } from './index43.mjs';
|
|
6
|
+
import { resolveInjectionTuple } from './index42.mjs';
|
|
7
|
+
import { Injectable } from './index45.mjs';
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
function formatIdentifier(e) {
|
|
10
|
+
if (e === undefined) return 'undefined';
|
|
11
|
+
if (e === null) return 'null';
|
|
12
|
+
if (typeof e === 'function') {
|
|
13
|
+
if (e.name) return e.name;
|
|
14
|
+
if (e.constructor?.name && e.constructor.name !== 'Function') {
|
|
15
|
+
return e.constructor.name;
|
|
16
|
+
}
|
|
17
|
+
return 'AnonymousFunction';
|
|
18
|
+
}
|
|
19
|
+
if (typeof e === 'string') return e;
|
|
20
|
+
if (typeof e === 'symbol') return e.toString();
|
|
21
|
+
if (typeof e === 'number') return String(e);
|
|
22
|
+
if (typeof e === 'boolean') return String(e);
|
|
23
|
+
if (typeof e === 'object') {
|
|
24
|
+
if (e.name && typeof e.name === 'string') {
|
|
25
|
+
return e.name;
|
|
26
|
+
}
|
|
27
|
+
const t = e.constructor?.name;
|
|
28
|
+
if (t && t !== 'Object') {
|
|
29
|
+
return t;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
const t = JSON.stringify(e);
|
|
33
|
+
if (t.length > 100) {
|
|
34
|
+
return t.substring(0, 100) + '...';
|
|
26
35
|
}
|
|
36
|
+
return t;
|
|
37
|
+
} catch {
|
|
38
|
+
return '[UnknownObject]';
|
|
27
39
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
40
|
+
}
|
|
41
|
+
return String(e);
|
|
42
|
+
}
|
|
43
|
+
function c(e) {
|
|
44
|
+
if (isClass(e)) {
|
|
45
|
+
const t = e.prototype && Object.getOwnPropertyNames(e.prototype).length > 1;
|
|
46
|
+
return t ? 'class' : 'class';
|
|
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, o = false) {
|
|
60
|
+
const a = DebugLogger.getInstance();
|
|
61
|
+
const c = o === true ? resolveInstanceInjectionTuple(i) : resolveInjectionTuple(i);
|
|
62
|
+
if (this.has(c.identifier)) {
|
|
63
|
+
const e = `An assemblage is already registered with identifier '${c.identifier.name}'.`;
|
|
64
|
+
a.log('error', 'Duplicate registration', {
|
|
65
|
+
identifier: c.identifier.name,
|
|
66
|
+
error: e
|
|
67
|
+
});
|
|
68
|
+
throw new Error(e);
|
|
69
|
+
}
|
|
70
|
+
const f = Injectable.of(c, this.privateContext, this.publicContext);
|
|
71
|
+
a.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 r = this.resolvingStack.has(e);
|
|
84
|
+
const i = r ? 'Circular dependency detected' : 'Dependency not registered';
|
|
85
|
+
const o = formatIdentifier(e);
|
|
86
|
+
const a = c(e);
|
|
87
|
+
const f = t?.__paramIndex;
|
|
88
|
+
const u = t?.__paramCount;
|
|
89
|
+
const l = t?.__expectedType;
|
|
90
|
+
const g = r ? `Circular dependency detected: '${o}' is already being resolved.` : `Dependency '${o}' has not been registered (Class/Service not found in current assemblages).`;
|
|
91
|
+
const d = {
|
|
92
|
+
identifier: o,
|
|
93
|
+
caller: n ? formatIdentifier(n) : 'unknown',
|
|
94
|
+
type: a,
|
|
95
|
+
error: g
|
|
96
|
+
};
|
|
97
|
+
if (f !== undefined) {
|
|
98
|
+
d.paramIndex = f;
|
|
99
|
+
}
|
|
100
|
+
if (u !== undefined) {
|
|
101
|
+
d.paramCount = u;
|
|
102
|
+
}
|
|
103
|
+
if (l !== undefined) {
|
|
104
|
+
const e = l?.name || formatIdentifier(l);
|
|
105
|
+
d.expectedType = e;
|
|
106
|
+
}
|
|
107
|
+
DebugLogger.getInstance().log('error', i, d);
|
|
108
|
+
throw new Error(g);
|
|
109
|
+
}
|
|
110
|
+
const r = this.injectables.get(e);
|
|
111
|
+
this.resolvingStack.add(r.identifier);
|
|
112
|
+
try {
|
|
113
|
+
if (r.isSingleton) {
|
|
114
|
+
return this.singletonStrategy.resolve(r, t);
|
|
115
|
+
} else {
|
|
116
|
+
return this.transientStrategy.resolve(r, t);
|
|
117
|
+
}
|
|
118
|
+
} finally{
|
|
119
|
+
this.resolvingStack.delete(r.identifier);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
concrete(e) {
|
|
123
|
+
const t = this.injectables.get(e);
|
|
124
|
+
if (t) return t.concrete;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
tagged(...e) {
|
|
128
|
+
const t = [];
|
|
129
|
+
for (const n of e){
|
|
130
|
+
for (const [e, r] of this.injectables){
|
|
131
|
+
if (r.tags.includes(n)) t.push(r.build());
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return t;
|
|
135
|
+
}
|
|
136
|
+
dispose() {
|
|
137
|
+
for (const [e, t] of this.injectables){
|
|
138
|
+
t.dispose();
|
|
139
|
+
}
|
|
140
|
+
this.resolvingStack.clear();
|
|
141
|
+
}
|
|
142
|
+
get size() {
|
|
143
|
+
return this.injectables.size;
|
|
144
|
+
}
|
|
145
|
+
getRegisteredIdentifiers() {
|
|
146
|
+
return Array.from(this.injectables.keys()).map((e)=>e?.name || String(e));
|
|
147
|
+
}
|
|
148
|
+
getInjectables() {
|
|
149
|
+
return this.injectables;
|
|
150
|
+
}
|
|
151
|
+
constructor(){
|
|
152
|
+
this.injectables = new Map();
|
|
153
|
+
this.resolvingStack = new Set();
|
|
154
|
+
this.singletonStrategy = new SingletonStrategy();
|
|
155
|
+
this.transientStrategy = new TransientStrategy();
|
|
54
156
|
}
|
|
55
157
|
}
|
|
56
158
|
|
|
57
|
-
export {
|
|
159
|
+
export { InjectableManager, formatIdentifier };
|
package/dist/index33.js
CHANGED
|
@@ -2,36 +2,55 @@
|
|
|
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
|
-
|
|
5
|
+
const debugLogger = require('./index37.js');
|
|
6
|
+
|
|
7
|
+
function t(e) {
|
|
8
|
+
return typeof e === 'symbol' ? 'symbol' : 'string';
|
|
9
|
+
}
|
|
10
|
+
class ObjectManager {
|
|
11
|
+
use(r, o) {
|
|
12
|
+
if (this.has(r)) {
|
|
13
|
+
const o = typeof r === 'symbol' ? r.toString() : String(r);
|
|
14
|
+
const s = `Object/value '${o}' is already registered (cannot register twice).`;
|
|
15
|
+
debugLogger.DebugLogger.getInstance().log('error', 'Duplicate object/value registration', {
|
|
16
|
+
identifier: o,
|
|
17
|
+
type: t(r),
|
|
18
|
+
error: s
|
|
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);
|
|
19
46
|
}
|
|
20
|
-
|
|
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
|
-
};
|
|
47
|
+
global(e) {
|
|
48
|
+
return this.globals.get(e);
|
|
31
49
|
}
|
|
32
|
-
constructor(
|
|
33
|
-
this.
|
|
50
|
+
constructor(){
|
|
51
|
+
this.objects = new Map();
|
|
52
|
+
this.globals = new Map();
|
|
34
53
|
}
|
|
35
54
|
}
|
|
36
55
|
|
|
37
|
-
exports.
|
|
56
|
+
exports.ObjectManager = ObjectManager;
|
package/dist/index33.mjs
CHANGED
|
@@ -1,33 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { DebugLogger } from './index37.mjs';
|
|
2
|
+
|
|
3
|
+
function t(e) {
|
|
4
|
+
return typeof e === 'symbol' ? 'symbol' : 'string';
|
|
5
|
+
}
|
|
6
|
+
class ObjectManager {
|
|
7
|
+
use(r, o) {
|
|
8
|
+
if (this.has(r)) {
|
|
9
|
+
const o = typeof r === 'symbol' ? r.toString() : String(r);
|
|
10
|
+
const s = `Object/value '${o}' is already registered (cannot register twice).`;
|
|
11
|
+
DebugLogger.getInstance().log('error', 'Duplicate object/value registration', {
|
|
12
|
+
identifier: o,
|
|
13
|
+
type: t(r),
|
|
14
|
+
error: s
|
|
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);
|
|
15
42
|
}
|
|
16
|
-
|
|
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
|
-
};
|
|
43
|
+
global(e) {
|
|
44
|
+
return this.globals.get(e);
|
|
27
45
|
}
|
|
28
|
-
constructor(
|
|
29
|
-
this.
|
|
46
|
+
constructor(){
|
|
47
|
+
this.objects = new Map();
|
|
48
|
+
this.globals = new Map();
|
|
30
49
|
}
|
|
31
50
|
}
|
|
32
51
|
|
|
33
|
-
export {
|
|
52
|
+
export { ObjectManager };
|
package/dist/index34.js
CHANGED
|
@@ -2,180 +2,84 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return 'AnonymousFunction';
|
|
14
|
-
}
|
|
15
|
-
if (typeof e === 'object') {
|
|
16
|
-
const o = e.constructor?.name;
|
|
17
|
-
if (o && o !== 'Object') {
|
|
18
|
-
return o;
|
|
19
|
-
}
|
|
20
|
-
if (e.name && typeof e.name === 'string') {
|
|
21
|
-
return e.name;
|
|
22
|
-
}
|
|
23
|
-
return '[Object]';
|
|
24
|
-
}
|
|
25
|
-
return String(e);
|
|
26
|
-
}
|
|
27
|
-
let NoOpDebugLogger = class NoOpDebugLogger {
|
|
28
|
-
configure(e) {}
|
|
29
|
-
log(e, o, t) {}
|
|
30
|
-
logBuildStart(e) {}
|
|
31
|
-
logBuildEnd(e, o) {}
|
|
32
|
-
logRegistration(e) {}
|
|
33
|
-
logHook(e, o, t) {}
|
|
34
|
-
logPhaseStart(e, o) {}
|
|
35
|
-
logPhaseEnd(e, o, t) {}
|
|
36
|
-
logResolution(e, o, t) {}
|
|
37
|
-
logConstruction(e) {}
|
|
38
|
-
logInjection(e, o) {}
|
|
39
|
-
};
|
|
40
|
-
let ActiveDebugLogger = class ActiveDebugLogger {
|
|
41
|
-
configure(e) {
|
|
42
|
-
this.options = {
|
|
43
|
-
...this.options,
|
|
44
|
-
...e,
|
|
45
|
-
logPhases: {
|
|
46
|
-
...this.options.logPhases,
|
|
47
|
-
...e.logPhases || {}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
logBuildStart(e) {
|
|
52
|
-
this.log('info', 'Build started', {
|
|
53
|
-
entry: e.name
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
logBuildEnd(e, o) {
|
|
57
|
-
const t = {
|
|
58
|
-
entry: e.name
|
|
59
|
-
};
|
|
60
|
-
if (o !== undefined) t.duration = `${o.toFixed(2)}ms`;
|
|
61
|
-
this.log('info', 'Build completed', t);
|
|
62
|
-
}
|
|
63
|
-
logRegistration(o) {
|
|
64
|
-
if (!this.shouldLog('registration')) return;
|
|
65
|
-
this.log('info', 'Registration', {
|
|
66
|
-
identifier: e(o.identifier),
|
|
67
|
-
isSingleton: o.isSingleton,
|
|
68
|
-
dependencies: o.dependencies.map((o)=>e(o)),
|
|
69
|
-
tags: o.tags
|
|
5
|
+
const core = require('@assemblerjs/core');
|
|
6
|
+
const debugLogger = require('./index37.js');
|
|
7
|
+
|
|
8
|
+
class HookManager {
|
|
9
|
+
prepareInitHook(o, t) {
|
|
10
|
+
this.initCache.push({
|
|
11
|
+
instance: o,
|
|
12
|
+
configuration: t
|
|
70
13
|
});
|
|
14
|
+
return this.initCache;
|
|
71
15
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this.log('info', `Hook: ${o}`, {
|
|
76
|
-
target: e(t),
|
|
77
|
-
config: n
|
|
78
|
-
});
|
|
79
|
-
if (this.options.logTimings) {
|
|
80
|
-
return ()=>{
|
|
81
|
-
const e = performance.now() - i;
|
|
82
|
-
this.log('info', `Hook: ${o} completed`, {
|
|
83
|
-
duration: `${e.toFixed(2)}ms`
|
|
84
|
-
});
|
|
85
|
-
};
|
|
16
|
+
callInitHooks(o) {
|
|
17
|
+
for (const t of this.initCache){
|
|
18
|
+
HookManager.callHookImmediate(t.instance, 'onInit', o, t.configuration);
|
|
86
19
|
}
|
|
87
20
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
duration: `${o.toFixed(2)}ms`
|
|
94
|
-
} : {};
|
|
95
|
-
if (t) {
|
|
96
|
-
Object.assign(n, t);
|
|
21
|
+
callInitedHooks(o) {
|
|
22
|
+
for (const t of [
|
|
23
|
+
...this.initCache
|
|
24
|
+
].reverse()){
|
|
25
|
+
HookManager.callHookImmediate(t.instance, 'onInited', o, t.configuration);
|
|
97
26
|
}
|
|
98
|
-
this.log('info', `Phase: ${e} ended`, Object.keys(n).length > 0 ? n : undefined);
|
|
99
27
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
this.log('info', `Resolving: ${e}`, {
|
|
103
|
-
strategy: `${o} strategy`,
|
|
104
|
-
cache: t ? 'hit' : 'miss'
|
|
105
|
-
});
|
|
28
|
+
clearCache() {
|
|
29
|
+
this.initCache.length = 0;
|
|
106
30
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
this.log('info', `Constructing: ${e}`);
|
|
31
|
+
getCache() {
|
|
32
|
+
return this.initCache;
|
|
110
33
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
this.log('info', `Injecting: @${e === 'use' ? 'Use' : 'Global'}`, o);
|
|
114
|
-
}
|
|
115
|
-
shouldLog(e) {
|
|
116
|
-
return !this.options.logPhases || this.options.logPhases[e] !== false;
|
|
34
|
+
constructor(){
|
|
35
|
+
this.initCache = [];
|
|
117
36
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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);
|
|
128
61
|
}
|
|
62
|
+
} else {
|
|
63
|
+
if (r) r();
|
|
64
|
+
t();
|
|
129
65
|
}
|
|
130
|
-
}
|
|
131
|
-
colorize(e, o) {
|
|
132
|
-
const t = {
|
|
133
|
-
info: '\x1b[36m',
|
|
134
|
-
warn: '\x1b[33m',
|
|
135
|
-
error: '\x1b[31m',
|
|
136
|
-
reset: '\x1b[0m'
|
|
137
|
-
};
|
|
138
|
-
const n = t[e] || t.info;
|
|
139
|
-
return `${n}${o}${t.reset}`;
|
|
140
|
-
}
|
|
141
|
-
constructor(){
|
|
142
|
-
this.options = {
|
|
143
|
-
enabled: true,
|
|
144
|
-
logPhases: {
|
|
145
|
-
registration: true,
|
|
146
|
-
registrationUse: true,
|
|
147
|
-
registrationGlobals: true,
|
|
148
|
-
resolution: true,
|
|
149
|
-
construction: true,
|
|
150
|
-
hooks: true,
|
|
151
|
-
cache: true,
|
|
152
|
-
injectionUse: true,
|
|
153
|
-
injectionGlobal: true
|
|
154
|
-
},
|
|
155
|
-
logTimings: false,
|
|
156
|
-
logDependencyTree: true,
|
|
157
|
-
useColors: true
|
|
158
|
-
};
|
|
159
|
-
}
|
|
66
|
+
});
|
|
160
67
|
};
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if (
|
|
167
|
-
|
|
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();
|
|
168
76
|
return;
|
|
169
77
|
}
|
|
170
|
-
|
|
171
|
-
if (
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
static disable() {
|
|
176
|
-
DebugLogger.instance = new NoOpDebugLogger();
|
|
78
|
+
s.bind(e)(n, a);
|
|
79
|
+
if (r) r();
|
|
80
|
+
} else {
|
|
81
|
+
if (r) r();
|
|
177
82
|
}
|
|
178
|
-
}
|
|
179
|
-
DebugLogger.instance = new NoOpDebugLogger();
|
|
83
|
+
};
|
|
180
84
|
|
|
181
|
-
exports.
|
|
85
|
+
exports.HookManager = HookManager;
|