assemblerjs 1.1.14 → 1.1.16
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 +5 -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 +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 +35 -148
- package/dist/index31.mjs +34 -148
- package/dist/index32.js +16 -44
- package/dist/index32.mjs +16 -44
- package/dist/index33.js +97 -71
- package/dist/index33.mjs +97 -71
- package/dist/index34.js +26 -42
- package/dist/index34.mjs +26 -42
- package/dist/index35.js +157 -30
- package/dist/index35.mjs +156 -30
- package/dist/index36.js +41 -153
- package/dist/index36.mjs +41 -153
- package/dist/index37.js +73 -16
- package/dist/index37.mjs +73 -16
- package/dist/index38.js +51 -36
- package/dist/index38.mjs +51 -35
- package/dist/index39.js +28 -102
- package/dist/index39.mjs +28 -102
- package/dist/index4.js +13 -8
- package/dist/index4.mjs +13 -8
- package/dist/index40.js +156 -22
- package/dist/index40.mjs +156 -22
- package/dist/index41.js +61 -46
- package/dist/index41.mjs +61 -46
- package/dist/index42.js +44 -18
- package/dist/index42.mjs +44 -17
- package/dist/index43.js +22 -28
- package/dist/index43.mjs +21 -27
- package/dist/index44.js +940 -192
- package/dist/index44.mjs +940 -192
- package/dist/index45.js +2 -942
- package/dist/index45.mjs +2 -942
- package/dist/index46.js +2 -2
- package/dist/index46.mjs +2 -2
- package/dist/index47.js +29 -2
- package/dist/index47.mjs +28 -2
- package/dist/index48.js +189 -9
- package/dist/index48.mjs +189 -9
- package/dist/index49.js +9 -34
- package/dist/index49.mjs +9 -34
- package/dist/index50.js +32 -59
- package/dist/index50.mjs +32 -58
- package/dist/index51.js +71 -0
- package/dist/index51.mjs +66 -0
- package/package.json +1 -1
package/dist/index35.js
CHANGED
|
@@ -2,36 +2,163 @@
|
|
|
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
|
-
return
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
5
|
+
const hookManager = require('./index37.js');
|
|
6
|
+
const resolutionStrategies = require('./index47.js');
|
|
7
|
+
const debugLogger = require('./index40.js');
|
|
8
|
+
const core = require('@assemblerjs/core');
|
|
9
|
+
const use = require('./index43.js');
|
|
10
|
+
const inject = require('./index42.js');
|
|
11
|
+
const injectable = require('./index48.js');
|
|
12
|
+
|
|
13
|
+
function formatIdentifier(e) {
|
|
14
|
+
if (e === undefined) return 'undefined';
|
|
15
|
+
if (e === null) return 'null';
|
|
16
|
+
if (typeof e === 'function') {
|
|
17
|
+
if (e.name) return e.name;
|
|
18
|
+
if (e.constructor?.name && e.constructor.name !== 'Function') {
|
|
19
|
+
return e.constructor.name;
|
|
20
|
+
}
|
|
21
|
+
return 'AnonymousFunction';
|
|
22
|
+
}
|
|
23
|
+
if (typeof e === 'string') return e;
|
|
24
|
+
if (typeof e === 'symbol') return e.toString();
|
|
25
|
+
if (typeof e === 'number') return String(e);
|
|
26
|
+
if (typeof e === 'boolean') return String(e);
|
|
27
|
+
if (typeof e === 'object') {
|
|
28
|
+
if (e.name && typeof e.name === 'string') {
|
|
29
|
+
return e.name;
|
|
30
|
+
}
|
|
31
|
+
const t = e.constructor?.name;
|
|
32
|
+
if (t && t !== 'Object') {
|
|
33
|
+
return t;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const t = JSON.stringify(e);
|
|
37
|
+
if (t.length > 100) {
|
|
38
|
+
return t.substring(0, 100) + '...';
|
|
39
|
+
}
|
|
40
|
+
return t;
|
|
41
|
+
} catch {
|
|
42
|
+
return '[UnknownObject]';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return String(e);
|
|
46
|
+
}
|
|
47
|
+
function c(e) {
|
|
48
|
+
if (core.isClass(e)) {
|
|
49
|
+
const t = e.prototype && Object.getOwnPropertyNames(e.prototype).length > 1;
|
|
50
|
+
return t ? 'class' : 'class';
|
|
51
|
+
}
|
|
52
|
+
if (typeof e === 'function') return 'function';
|
|
53
|
+
if (typeof e === 'string') return 'string';
|
|
54
|
+
if (typeof e === 'symbol') return 'symbol';
|
|
55
|
+
if (typeof e === 'object' && e !== null) return 'object';
|
|
56
|
+
return 'unknown';
|
|
57
|
+
}
|
|
58
|
+
class InjectableManager {
|
|
59
|
+
setContexts(e, t) {
|
|
60
|
+
this.privateContext = e;
|
|
61
|
+
this.publicContext = t;
|
|
62
|
+
}
|
|
63
|
+
register(i, o = false) {
|
|
64
|
+
const a = debugLogger.DebugLogger.getInstance();
|
|
65
|
+
const c = o === true ? use.resolveInstanceInjectionTuple(i) : inject.resolveInjectionTuple(i);
|
|
66
|
+
if (this.has(c.identifier)) {
|
|
67
|
+
const e = `An assemblage is already registered with identifier '${c.identifier.name}'.`;
|
|
68
|
+
a.log('error', 'Duplicate registration', {
|
|
69
|
+
identifier: c.identifier.name,
|
|
70
|
+
error: e
|
|
71
|
+
});
|
|
72
|
+
throw new Error(e);
|
|
73
|
+
}
|
|
74
|
+
const f = injectable.Injectable.of(c, this.privateContext, this.publicContext);
|
|
75
|
+
a.logRegistration(f);
|
|
76
|
+
this.injectables.set(f.identifier, f);
|
|
77
|
+
if (f.concrete) {
|
|
78
|
+
hookManager.HookManager.callHook(f.concrete, 'onRegister', this.publicContext, f.configuration);
|
|
79
|
+
}
|
|
80
|
+
return f;
|
|
81
|
+
}
|
|
82
|
+
has(e) {
|
|
83
|
+
return this.injectables.has(e);
|
|
84
|
+
}
|
|
85
|
+
require(e, t, n) {
|
|
86
|
+
if (!this.injectables.has(e)) {
|
|
87
|
+
const r = this.resolvingStack.has(e);
|
|
88
|
+
const i = r ? 'Circular dependency detected' : 'Dependency not registered';
|
|
89
|
+
const o = formatIdentifier(e);
|
|
90
|
+
const a = c(e);
|
|
91
|
+
const f = t?.__paramIndex;
|
|
92
|
+
const u = t?.__paramCount;
|
|
93
|
+
const l = t?.__expectedType;
|
|
94
|
+
const g = r ? `Circular dependency detected: '${o}' is already being resolved.` : `Dependency '${o}' has not been registered (Class/Service not found in current assemblages).`;
|
|
95
|
+
const d = {
|
|
96
|
+
identifier: o,
|
|
97
|
+
caller: n ? formatIdentifier(n) : 'unknown',
|
|
98
|
+
type: a,
|
|
99
|
+
error: g
|
|
100
|
+
};
|
|
101
|
+
if (f !== undefined) {
|
|
102
|
+
d.paramIndex = f;
|
|
103
|
+
}
|
|
104
|
+
if (u !== undefined) {
|
|
105
|
+
d.paramCount = u;
|
|
106
|
+
}
|
|
107
|
+
if (l !== undefined) {
|
|
108
|
+
const e = l?.name || formatIdentifier(l);
|
|
109
|
+
d.expectedType = e;
|
|
110
|
+
}
|
|
111
|
+
debugLogger.DebugLogger.getInstance().log('error', i, d);
|
|
112
|
+
throw new Error(g);
|
|
113
|
+
}
|
|
114
|
+
const r = this.injectables.get(e);
|
|
115
|
+
this.resolvingStack.add(r.identifier);
|
|
116
|
+
try {
|
|
117
|
+
if (r.isSingleton) {
|
|
118
|
+
return this.singletonStrategy.resolve(r, t);
|
|
119
|
+
} else {
|
|
120
|
+
return this.transientStrategy.resolve(r, t);
|
|
121
|
+
}
|
|
122
|
+
} finally{
|
|
123
|
+
this.resolvingStack.delete(r.identifier);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
concrete(e) {
|
|
127
|
+
const t = this.injectables.get(e);
|
|
128
|
+
if (t) return t.concrete;
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
tagged(...e) {
|
|
132
|
+
const t = [];
|
|
133
|
+
for (const n of e){
|
|
134
|
+
for (const [e, r] of this.injectables){
|
|
135
|
+
if (r.tags.includes(n)) t.push(r.build());
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return t;
|
|
139
|
+
}
|
|
140
|
+
dispose() {
|
|
141
|
+
for (const [e, t] of this.injectables){
|
|
142
|
+
t.dispose();
|
|
143
|
+
}
|
|
144
|
+
this.resolvingStack.clear();
|
|
145
|
+
}
|
|
146
|
+
get size() {
|
|
147
|
+
return this.injectables.size;
|
|
148
|
+
}
|
|
149
|
+
getRegisteredIdentifiers() {
|
|
150
|
+
return Array.from(this.injectables.keys()).map((e)=>e?.name || String(e));
|
|
151
|
+
}
|
|
152
|
+
getInjectables() {
|
|
153
|
+
return this.injectables;
|
|
154
|
+
}
|
|
155
|
+
constructor(){
|
|
156
|
+
this.injectables = new Map();
|
|
157
|
+
this.resolvingStack = new Set();
|
|
158
|
+
this.singletonStrategy = new resolutionStrategies.SingletonStrategy();
|
|
159
|
+
this.transientStrategy = new resolutionStrategies.TransientStrategy();
|
|
34
160
|
}
|
|
35
161
|
}
|
|
36
162
|
|
|
37
|
-
exports.
|
|
163
|
+
exports.InjectableManager = InjectableManager;
|
|
164
|
+
exports.formatIdentifier = formatIdentifier;
|
package/dist/index35.mjs
CHANGED
|
@@ -1,33 +1,159 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
import { HookManager } from './index37.mjs';
|
|
2
|
+
import { SingletonStrategy, TransientStrategy } from './index47.mjs';
|
|
3
|
+
import { DebugLogger } from './index40.mjs';
|
|
4
|
+
import { isClass } from '@assemblerjs/core';
|
|
5
|
+
import { resolveInstanceInjectionTuple } from './index43.mjs';
|
|
6
|
+
import { resolveInjectionTuple } from './index42.mjs';
|
|
7
|
+
import { Injectable } from './index48.mjs';
|
|
8
|
+
|
|
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) + '...';
|
|
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';
|
|
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();
|
|
30
156
|
}
|
|
31
157
|
}
|
|
32
158
|
|
|
33
|
-
export {
|
|
159
|
+
export { InjectableManager, formatIdentifier };
|
package/dist/index36.js
CHANGED
|
@@ -2,167 +2,55 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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);
|
|
5
|
+
const debugLogger = require('./index40.js');
|
|
6
|
+
|
|
7
|
+
function t(e) {
|
|
8
|
+
return typeof e === 'symbol' ? 'symbol' : 'string';
|
|
26
9
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
};
|
|
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);
|
|
85
21
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
Object
|
|
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);
|
|
96
38
|
}
|
|
97
|
-
this.
|
|
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;
|
|
39
|
+
return this.objects.get(r);
|
|
112
40
|
}
|
|
113
|
-
|
|
114
|
-
if (this.
|
|
115
|
-
|
|
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
|
-
}
|
|
41
|
+
addGlobal(e, t) {
|
|
42
|
+
if (this.globals.has(e)) {
|
|
43
|
+
throw new Error(`Global value with key '${e}' has already been registered.`);
|
|
124
44
|
}
|
|
45
|
+
this.globals.set(e, t);
|
|
125
46
|
}
|
|
126
|
-
|
|
127
|
-
|
|
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}`;
|
|
47
|
+
global(e) {
|
|
48
|
+
return this.globals.get(e);
|
|
135
49
|
}
|
|
136
50
|
constructor(){
|
|
137
|
-
this.
|
|
138
|
-
|
|
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
|
-
};
|
|
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);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
static disable() {
|
|
163
|
-
DebugLogger.instance = new NoOpDebugLogger();
|
|
51
|
+
this.objects = new Map();
|
|
52
|
+
this.globals = new Map();
|
|
164
53
|
}
|
|
165
54
|
}
|
|
166
|
-
DebugLogger.instance = new NoOpDebugLogger();
|
|
167
55
|
|
|
168
|
-
exports.
|
|
56
|
+
exports.ObjectManager = ObjectManager;
|