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/index.d.ts
CHANGED
|
@@ -387,10 +387,14 @@ export declare interface AssemblerDebugOptions {
|
|
|
387
387
|
logger?: (level: 'info' | 'warn' | 'error', message: string, data?: any) => void;
|
|
388
388
|
logPhases?: {
|
|
389
389
|
registration?: boolean;
|
|
390
|
+
registrationUse?: boolean;
|
|
391
|
+
registrationGlobals?: boolean;
|
|
390
392
|
resolution?: boolean;
|
|
391
393
|
construction?: boolean;
|
|
392
394
|
hooks?: boolean;
|
|
393
395
|
cache?: boolean;
|
|
396
|
+
injectionUse?: boolean;
|
|
397
|
+
injectionGlobal?: boolean;
|
|
394
398
|
};
|
|
395
399
|
logTimings?: boolean;
|
|
396
400
|
logDependencyTree?: boolean;
|
package/dist/index13.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const core = require('@assemblerjs/core');
|
|
6
|
-
const pointcutMatcher = require('./
|
|
6
|
+
const pointcutMatcher = require('./index41.js');
|
|
7
7
|
const affect = require('./index12.js');
|
|
8
8
|
const schema = require('./index30.js');
|
|
9
9
|
|
package/dist/index13.mjs
CHANGED
package/dist/index18.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const parameterDecoratorFactory = require('./index17.js');
|
|
6
|
-
const resolverStore = require('./
|
|
6
|
+
const resolverStore = require('./index39.js');
|
|
7
7
|
|
|
8
8
|
let ContextResolver = class ContextResolver {
|
|
9
9
|
resolve(e, r, t) {
|
package/dist/index18.mjs
CHANGED
package/dist/index19.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const parameterDecoratorFactory = require('./index17.js');
|
|
6
|
-
const resolverStore = require('./
|
|
6
|
+
const resolverStore = require('./index39.js');
|
|
7
7
|
|
|
8
8
|
let ConfigurationResolver = class ConfigurationResolver {
|
|
9
9
|
resolve(r, o, e, n) {
|
package/dist/index19.mjs
CHANGED
package/dist/index20.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const parameterDecoratorFactory = require('./index17.js');
|
|
6
|
-
const resolverStore = require('./
|
|
6
|
+
const resolverStore = require('./index39.js');
|
|
7
7
|
|
|
8
8
|
let DefinitionResolver = class DefinitionResolver {
|
|
9
9
|
resolve(e, r) {
|
package/dist/index20.mjs
CHANGED
package/dist/index21.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const parameterDecoratorFactory = require('./index17.js');
|
|
6
|
-
const resolverStore = require('./
|
|
6
|
+
const resolverStore = require('./index39.js');
|
|
7
7
|
|
|
8
8
|
let DisposeResolver = class DisposeResolver {
|
|
9
9
|
resolve(e, r, s) {
|
package/dist/index21.mjs
CHANGED
package/dist/index22.js
CHANGED
|
@@ -3,15 +3,21 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const reflection = require('./index29.js');
|
|
6
|
+
const debugLogger = require('./index37.js');
|
|
6
7
|
const parameterDecoratorFactory = require('./index17.js');
|
|
7
8
|
const helpers = require('./index25.js');
|
|
8
|
-
const resolverStore = require('./
|
|
9
|
+
const resolverStore = require('./index39.js');
|
|
9
10
|
|
|
10
11
|
let UseResolver = class UseResolver {
|
|
11
|
-
resolve(
|
|
12
|
-
const
|
|
13
|
-
const m =
|
|
14
|
-
|
|
12
|
+
resolve(o, t, a) {
|
|
13
|
+
const n = reflection.getOwnCustomMetadata(helpers.getParamValueKey('Use'), a);
|
|
14
|
+
const m = n[o];
|
|
15
|
+
debugLogger.DebugLogger.getInstance().logInjection('use', {
|
|
16
|
+
target: a?.name,
|
|
17
|
+
index: o,
|
|
18
|
+
identifier: typeof m === 'symbol' ? m.toString() : m
|
|
19
|
+
});
|
|
20
|
+
return t.privateContext.require(m);
|
|
15
21
|
}
|
|
16
22
|
};
|
|
17
23
|
const decorateUse = (e, r, o)=>{
|
package/dist/index22.mjs
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { getOwnCustomMetadata } from './index29.mjs';
|
|
2
|
+
import { DebugLogger } from './index37.mjs';
|
|
2
3
|
import { ParameterDecoratorFactory } from './index17.mjs';
|
|
3
4
|
import { getParamValueKey } from './index25.mjs';
|
|
4
|
-
import { ResolverStore } from './
|
|
5
|
+
import { ResolverStore } from './index39.mjs';
|
|
5
6
|
|
|
6
7
|
let UseResolver = class UseResolver {
|
|
7
|
-
resolve(
|
|
8
|
-
const
|
|
9
|
-
const m =
|
|
10
|
-
|
|
8
|
+
resolve(o, t, a) {
|
|
9
|
+
const n = getOwnCustomMetadata(getParamValueKey('Use'), a);
|
|
10
|
+
const m = n[o];
|
|
11
|
+
DebugLogger.getInstance().logInjection('use', {
|
|
12
|
+
target: a?.name,
|
|
13
|
+
index: o,
|
|
14
|
+
identifier: typeof m === 'symbol' ? m.toString() : m
|
|
15
|
+
});
|
|
16
|
+
return t.privateContext.require(m);
|
|
11
17
|
}
|
|
12
18
|
};
|
|
13
19
|
const decorateUse = (e, r, o)=>{
|
package/dist/index23.js
CHANGED
|
@@ -3,19 +3,25 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const reflection = require('./index29.js');
|
|
6
|
+
const debugLogger = require('./index37.js');
|
|
6
7
|
const parameterDecoratorFactory = require('./index17.js');
|
|
7
8
|
const helpers = require('./index25.js');
|
|
8
|
-
const resolverStore = require('./
|
|
9
|
+
const resolverStore = require('./index39.js');
|
|
9
10
|
|
|
10
11
|
let GlobalResolver = class GlobalResolver {
|
|
11
|
-
resolve(
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
12
|
+
resolve(r, l, a) {
|
|
13
|
+
const s = reflection.getOwnCustomMetadata(helpers.getParamValueKey('Global'), a);
|
|
14
|
+
const n = s[r];
|
|
15
|
+
debugLogger.DebugLogger.getInstance().logInjection('global', {
|
|
16
|
+
target: a?.name,
|
|
17
|
+
index: r,
|
|
18
|
+
identifier: typeof n === 'symbol' ? n.toString() : n
|
|
19
|
+
});
|
|
20
|
+
return l.privateContext.global(n);
|
|
15
21
|
}
|
|
16
22
|
};
|
|
17
|
-
const decorateGlobal = (
|
|
18
|
-
Global(
|
|
23
|
+
const decorateGlobal = (e, o, r)=>{
|
|
24
|
+
Global(e)(o, undefined, r);
|
|
19
25
|
};
|
|
20
26
|
const Global = (()=>{
|
|
21
27
|
resolverStore.ResolverStore.register('Global', GlobalResolver);
|
package/dist/index23.mjs
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import { getOwnCustomMetadata } from './index29.mjs';
|
|
2
|
+
import { DebugLogger } from './index37.mjs';
|
|
2
3
|
import { ParameterDecoratorFactory } from './index17.mjs';
|
|
3
4
|
import { getParamValueKey } from './index25.mjs';
|
|
4
|
-
import { ResolverStore } from './
|
|
5
|
+
import { ResolverStore } from './index39.mjs';
|
|
5
6
|
|
|
6
7
|
let GlobalResolver = class GlobalResolver {
|
|
7
|
-
resolve(
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
8
|
+
resolve(r, l, a) {
|
|
9
|
+
const s = getOwnCustomMetadata(getParamValueKey('Global'), a);
|
|
10
|
+
const n = s[r];
|
|
11
|
+
DebugLogger.getInstance().logInjection('global', {
|
|
12
|
+
target: a?.name,
|
|
13
|
+
index: r,
|
|
14
|
+
identifier: typeof n === 'symbol' ? n.toString() : n
|
|
15
|
+
});
|
|
16
|
+
return l.privateContext.global(n);
|
|
11
17
|
}
|
|
12
18
|
};
|
|
13
|
-
const decorateGlobal = (
|
|
14
|
-
Global(
|
|
19
|
+
const decorateGlobal = (e, o, r)=>{
|
|
20
|
+
Global(e)(o, undefined, r);
|
|
15
21
|
};
|
|
16
22
|
const Global = (()=>{
|
|
17
23
|
ResolverStore.register('Global', GlobalResolver);
|
package/dist/index24.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
5
5
|
const reflection = require('./index29.js');
|
|
6
6
|
const parameterDecoratorFactory = require('./index17.js');
|
|
7
7
|
const helpers = require('./index25.js');
|
|
8
|
-
const resolverStore = require('./
|
|
8
|
+
const resolverStore = require('./index39.js');
|
|
9
9
|
|
|
10
10
|
let OptionalResolver = class OptionalResolver {
|
|
11
11
|
resolve(o, t, n) {
|
package/dist/index24.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getParamTypes, getOwnCustomMetadata } from './index29.mjs';
|
|
2
2
|
import { ParameterDecoratorFactory } from './index17.mjs';
|
|
3
3
|
import { getParamValueKey } from './index25.mjs';
|
|
4
|
-
import { ResolverStore } from './
|
|
4
|
+
import { ResolverStore } from './index39.mjs';
|
|
5
5
|
|
|
6
6
|
let OptionalResolver = class OptionalResolver {
|
|
7
7
|
resolve(o, t, n) {
|
package/dist/index31.js
CHANGED
|
@@ -2,163 +2,45 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const resolutionStrategies = require('./index44.js');
|
|
7
|
-
const debugLogger = require('./index36.js');
|
|
8
|
-
const core = require('@assemblerjs/core');
|
|
9
|
-
const use = require('./index43.js');
|
|
10
|
-
const inject = require('./index42.js');
|
|
11
|
-
const injectable = require('./index45.js');
|
|
5
|
+
const eventManager = require('./index6.js');
|
|
12
6
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
|
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);
|
|
15
|
+
}
|
|
16
|
+
for (const e of t.events){
|
|
17
|
+
n.on(e, (...n)=>{
|
|
18
|
+
t.privateContext.emit(e, ...n);
|
|
71
19
|
});
|
|
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
20
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
for (const n of e){
|
|
134
|
-
for (const [e, r] of this.injectables){
|
|
135
|
-
if (r.tags.includes(n)) t.push(r.build());
|
|
21
|
+
} else {
|
|
22
|
+
for (const e of t.events){
|
|
23
|
+
if (!t.privateContext.events.has(e)) t.privateContext.addChannels(e);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
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);
|
|
136
40
|
}
|
|
137
41
|
}
|
|
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();
|
|
160
42
|
}
|
|
161
|
-
}
|
|
43
|
+
};
|
|
162
44
|
|
|
163
|
-
exports.
|
|
164
|
-
exports.
|
|
45
|
+
exports.registerEvents = registerEvents;
|
|
46
|
+
exports.unregisterEvents = unregisterEvents;
|
package/dist/index31.mjs
CHANGED
|
@@ -1,159 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SingletonStrategy, TransientStrategy } from './index44.mjs';
|
|
3
|
-
import { DebugLogger } from './index36.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 { EventManager } from './index6.mjs';
|
|
8
2
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
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);
|
|
11
|
+
}
|
|
12
|
+
for (const e of t.events){
|
|
13
|
+
n.on(e, (...n)=>{
|
|
14
|
+
t.privateContext.emit(e, ...n);
|
|
67
15
|
});
|
|
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
16
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
for (const n of e){
|
|
130
|
-
for (const [e, r] of this.injectables){
|
|
131
|
-
if (r.tags.includes(n)) t.push(r.build());
|
|
17
|
+
} else {
|
|
18
|
+
for (const e of t.events){
|
|
19
|
+
if (!t.privateContext.events.has(e)) t.privateContext.addChannels(e);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
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);
|
|
132
36
|
}
|
|
133
37
|
}
|
|
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();
|
|
156
38
|
}
|
|
157
|
-
}
|
|
39
|
+
};
|
|
158
40
|
|
|
159
|
-
export {
|
|
41
|
+
export { registerEvents, unregisterEvents };
|