assemblerjs 1.1.19 → 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 -100
- package/dist/index31.mjs +34 -100
- package/dist/index32.js +152 -22
- package/dist/index32.mjs +151 -22
- package/dist/index33.js +35 -143
- package/dist/index33.mjs +35 -142
- package/dist/index34.js +70 -41
- package/dist/index34.mjs +70 -41
- package/dist/index35.js +49 -73
- package/dist/index35.mjs +49 -73
- package/dist/index36.js +29 -53
- package/dist/index36.mjs +29 -53
- package/dist/index37.js +170 -26
- package/dist/index37.mjs +170 -26
- package/dist/index38.js +48 -151
- package/dist/index38.mjs +48 -151
- package/dist/index39.js +16 -57
- package/dist/index39.mjs +16 -57
- package/dist/index4.js +7 -7
- package/dist/index4.mjs +7 -7
- package/dist/index40.js +100 -35
- package/dist/index40.mjs +100 -34
- package/dist/index41.js +24 -18
- package/dist/index41.mjs +24 -18
- package/dist/index45.js +54 -22
- package/dist/index45.mjs +54 -22
- 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/index33.mjs
CHANGED
|
@@ -1,159 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SingletonStrategy, TransientStrategy } from './index44.mjs';
|
|
3
|
-
import { DebugLogger } from './index38.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';
|
|
1
|
+
import { DebugLogger } from './index37.mjs';
|
|
8
2
|
|
|
9
|
-
function
|
|
10
|
-
|
|
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) + '...';
|
|
35
|
-
}
|
|
36
|
-
return t;
|
|
37
|
-
} catch {
|
|
38
|
-
return '[UnknownObject]';
|
|
39
|
-
}
|
|
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';
|
|
3
|
+
function t(e) {
|
|
4
|
+
return typeof e === 'symbol' ? 'symbol' : 'string';
|
|
53
5
|
}
|
|
54
|
-
class
|
|
55
|
-
|
|
56
|
-
this.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
|
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
|
|
67
15
|
});
|
|
68
|
-
throw new Error(
|
|
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);
|
|
16
|
+
throw new Error(s);
|
|
75
17
|
}
|
|
76
|
-
|
|
18
|
+
this.objects.set(r, o);
|
|
19
|
+
return o;
|
|
77
20
|
}
|
|
78
21
|
has(e) {
|
|
79
|
-
return this.
|
|
22
|
+
return this.objects.has(e);
|
|
80
23
|
}
|
|
81
|
-
require(
|
|
82
|
-
if (!this.
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
|
|
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 = {
|
|
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', {
|
|
92
29
|
identifier: o,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
}
|
|
30
|
+
type: t(r),
|
|
31
|
+
error: s
|
|
32
|
+
});
|
|
33
|
+
throw new Error(s);
|
|
133
34
|
}
|
|
134
|
-
return
|
|
35
|
+
return this.objects.get(r);
|
|
135
36
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
37
|
+
addGlobal(e, t) {
|
|
38
|
+
if (this.globals.has(e)) {
|
|
39
|
+
throw new Error(`Global value with key '${e}' has already been registered.`);
|
|
139
40
|
}
|
|
140
|
-
this.
|
|
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));
|
|
41
|
+
this.globals.set(e, t);
|
|
147
42
|
}
|
|
148
|
-
|
|
149
|
-
return this.
|
|
43
|
+
global(e) {
|
|
44
|
+
return this.globals.get(e);
|
|
150
45
|
}
|
|
151
46
|
constructor(){
|
|
152
|
-
this.
|
|
153
|
-
this.
|
|
154
|
-
this.singletonStrategy = new SingletonStrategy();
|
|
155
|
-
this.transientStrategy = new TransientStrategy();
|
|
47
|
+
this.objects = new Map();
|
|
48
|
+
this.globals = new Map();
|
|
156
49
|
}
|
|
157
50
|
}
|
|
158
51
|
|
|
159
|
-
export {
|
|
52
|
+
export { ObjectManager };
|
package/dist/index34.js
CHANGED
|
@@ -2,55 +2,84 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const core = require('@assemblerjs/core');
|
|
6
|
+
const debugLogger = require('./index37.js');
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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;
|
|
8
|
+
class HookManager {
|
|
9
|
+
prepareInitHook(o, t) {
|
|
10
|
+
this.initCache.push({
|
|
11
|
+
instance: o,
|
|
12
|
+
configuration: t
|
|
13
|
+
});
|
|
14
|
+
return this.initCache;
|
|
24
15
|
}
|
|
25
|
-
|
|
26
|
-
|
|
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);
|
|
16
|
+
callInitHooks(o) {
|
|
17
|
+
for (const t of this.initCache){
|
|
18
|
+
HookManager.callHookImmediate(t.instance, 'onInit', o, t.configuration);
|
|
38
19
|
}
|
|
39
|
-
return this.objects.get(r);
|
|
40
20
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
21
|
+
callInitedHooks(o) {
|
|
22
|
+
for (const t of [
|
|
23
|
+
...this.initCache
|
|
24
|
+
].reverse()){
|
|
25
|
+
HookManager.callHookImmediate(t.instance, 'onInited', o, t.configuration);
|
|
44
26
|
}
|
|
45
|
-
this.globals.set(e, t);
|
|
46
27
|
}
|
|
47
|
-
|
|
48
|
-
|
|
28
|
+
clearCache() {
|
|
29
|
+
this.initCache.length = 0;
|
|
30
|
+
}
|
|
31
|
+
getCache() {
|
|
32
|
+
return this.initCache;
|
|
49
33
|
}
|
|
50
34
|
constructor(){
|
|
51
|
-
this.
|
|
52
|
-
this.globals = new Map();
|
|
35
|
+
this.initCache = [];
|
|
53
36
|
}
|
|
54
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
|
+
};
|
|
55
84
|
|
|
56
|
-
exports.
|
|
85
|
+
exports.HookManager = HookManager;
|
package/dist/index34.mjs
CHANGED
|
@@ -1,52 +1,81 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isAsync } from '@assemblerjs/core';
|
|
2
|
+
import { DebugLogger } from './index37.mjs';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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;
|
|
4
|
+
class HookManager {
|
|
5
|
+
prepareInitHook(o, t) {
|
|
6
|
+
this.initCache.push({
|
|
7
|
+
instance: o,
|
|
8
|
+
configuration: t
|
|
9
|
+
});
|
|
10
|
+
return this.initCache;
|
|
20
11
|
}
|
|
21
|
-
|
|
22
|
-
|
|
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);
|
|
12
|
+
callInitHooks(o) {
|
|
13
|
+
for (const t of this.initCache){
|
|
14
|
+
HookManager.callHookImmediate(t.instance, 'onInit', o, t.configuration);
|
|
34
15
|
}
|
|
35
|
-
return this.objects.get(r);
|
|
36
16
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
17
|
+
callInitedHooks(o) {
|
|
18
|
+
for (const t of [
|
|
19
|
+
...this.initCache
|
|
20
|
+
].reverse()){
|
|
21
|
+
HookManager.callHookImmediate(t.instance, 'onInited', o, t.configuration);
|
|
40
22
|
}
|
|
41
|
-
this.globals.set(e, t);
|
|
42
23
|
}
|
|
43
|
-
|
|
44
|
-
|
|
24
|
+
clearCache() {
|
|
25
|
+
this.initCache.length = 0;
|
|
26
|
+
}
|
|
27
|
+
getCache() {
|
|
28
|
+
return this.initCache;
|
|
45
29
|
}
|
|
46
30
|
constructor(){
|
|
47
|
-
this.
|
|
48
|
-
this.globals = new Map();
|
|
31
|
+
this.initCache = [];
|
|
49
32
|
}
|
|
50
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
|
+
};
|
|
51
80
|
|
|
52
|
-
export {
|
|
81
|
+
export { HookManager };
|
package/dist/index35.js
CHANGED
|
@@ -2,84 +2,60 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const debugLogger = require('./
|
|
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');
|
|
7
10
|
|
|
8
|
-
class
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
|
13
22
|
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
callInitedHooks(o) {
|
|
22
|
-
for (const t of [
|
|
23
|
-
...this.initCache
|
|
24
|
-
].reverse()){
|
|
25
|
-
HookManager.callHookImmediate(t.instance, 'onInited', o, t.configuration);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
clearCache() {
|
|
29
|
-
this.initCache.length = 0;
|
|
30
|
-
}
|
|
31
|
-
getCache() {
|
|
32
|
-
return this.initCache;
|
|
33
|
-
}
|
|
34
|
-
constructor(){
|
|
35
|
-
this.initCache = [];
|
|
36
|
-
}
|
|
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);
|
|
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
|
|
51
29
|
});
|
|
52
|
-
return;
|
|
53
30
|
}
|
|
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
31
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (s) {
|
|
73
|
-
if (core.isAsync(s)) {
|
|
74
|
-
s.bind(e)(n, a).catch(()=>{});
|
|
75
|
-
if (r) r();
|
|
76
|
-
return;
|
|
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.');
|
|
77
38
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
+
}
|
|
56
|
+
constructor(e){
|
|
57
|
+
this.assembler = e;
|
|
82
58
|
}
|
|
83
|
-
}
|
|
59
|
+
}
|
|
84
60
|
|
|
85
|
-
exports.
|
|
61
|
+
exports.AssemblerBuilder = AssemblerBuilder;
|