assemblerjs 1.1.3 → 1.1.5
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 +3 -3
- 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/index31.js +71 -32
- package/dist/index31.mjs +71 -31
- package/dist/index32.js +37 -16
- package/dist/index32.mjs +37 -16
- package/dist/index33.js +68 -57
- package/dist/index33.mjs +68 -57
- package/dist/index34.js +38 -28
- package/dist/index34.mjs +38 -28
- package/dist/index35.js +28 -76
- package/dist/index35.mjs +28 -76
- package/dist/index36.js +132 -39
- package/dist/index36.mjs +132 -39
- package/dist/index37.js +39 -30
- package/dist/index37.mjs +38 -30
- package/dist/index38.js +97 -125
- package/dist/index38.mjs +97 -125
- package/dist/index39.js +24 -101
- package/dist/index39.mjs +24 -101
- package/dist/index4.js +8 -8
- package/dist/index4.mjs +8 -8
- package/dist/index40.js +18 -24
- package/dist/index40.mjs +18 -24
- package/dist/index44.js +2 -2
- package/dist/index44.mjs +2 -2
- package/dist/index48.js +1 -1
- package/dist/index48.mjs +1 -1
- package/dist/index49.js +2 -2
- package/dist/index49.mjs +2 -2
- package/dist/index50.js +12 -12
- package/dist/index50.mjs +12 -12
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export declare abstract class AbstractAssembler extends AbstractEventManager imp
|
|
|
56
56
|
abstract prepareInitHook<T = AbstractAssemblage>(instance: T, configuration?: Record<string, any>): unknown[];
|
|
57
57
|
abstract addGlobal(key: string, value: any): void;
|
|
58
58
|
abstract has<T>(identifier: Identifier<T>): boolean;
|
|
59
|
-
abstract require<T>(identifier: Identifier<T> | string | symbol, configuration?: Record<string, any>): T;
|
|
59
|
+
abstract require<T>(identifier: Identifier<T> | string | symbol, configuration?: Record<string, any>, caller?: Identifier<any>): T;
|
|
60
60
|
abstract concrete<T>(identifier: Identifier<T>): Concrete<T> | undefined;
|
|
61
61
|
abstract tagged(...tags: string[]): any[];
|
|
62
62
|
abstract global(key: string): any | undefined;
|
|
@@ -345,7 +345,7 @@ export declare class Assembler extends EventManager implements AbstractAssembler
|
|
|
345
345
|
use<T>(identifier: string | symbol, object: T): T;
|
|
346
346
|
prepareInitHook<T = AbstractAssemblage>(instance: T, configuration?: Record<string, any>): unknown[];
|
|
347
347
|
has<T>(identifier: Identifier<T> | string | symbol): boolean;
|
|
348
|
-
require<T>(identifier: Identifier<T> | string | symbol, configuration?: Record<string, any>): T;
|
|
348
|
+
require<T>(identifier: Identifier<T> | string | symbol, configuration?: Record<string, any>, caller?: Identifier<any>): T;
|
|
349
349
|
concrete<T>(identifier: Identifier<T>): Concrete<T> | undefined;
|
|
350
350
|
tagged(...tags: string[]): unknown[];
|
|
351
351
|
addGlobal(key: string, value: any): void;
|
|
@@ -842,7 +842,7 @@ declare class InjectableManager {
|
|
|
842
842
|
setContexts(privateContext: AssemblerPrivateContext, publicContext: AssemblerContext): void;
|
|
843
843
|
register<T>(injection: Injection<T>, instance?: boolean): Injectable<T>;
|
|
844
844
|
has<T>(identifier: Identifier<T>): boolean;
|
|
845
|
-
require<T>(identifier: Identifier<T>, configuration?: Record<string, any>): T;
|
|
845
|
+
require<T>(identifier: Identifier<T>, configuration?: Record<string, any>, caller?: Identifier<any>): T;
|
|
846
846
|
concrete<T>(identifier: Identifier<T>): any | undefined;
|
|
847
847
|
tagged(...tags: string[]): unknown[];
|
|
848
848
|
dispose(): void;
|
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('./index39.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('./index40.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('./index40.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('./index40.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('./index40.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
|
@@ -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('./index40.js');
|
|
9
9
|
|
|
10
10
|
let UseResolver = class UseResolver {
|
|
11
11
|
resolve(r, o, t) {
|
package/dist/index22.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { 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 './index40.mjs';
|
|
5
5
|
|
|
6
6
|
let UseResolver = class UseResolver {
|
|
7
7
|
resolve(r, o, t) {
|
package/dist/index23.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('./index40.js');
|
|
9
9
|
|
|
10
10
|
let GlobalResolver = class GlobalResolver {
|
|
11
11
|
resolve(e, r, a) {
|
package/dist/index23.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { 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 './index40.mjs';
|
|
5
5
|
|
|
6
6
|
let GlobalResolver = class GlobalResolver {
|
|
7
7
|
resolve(e, r, a) {
|
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('./index40.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 './index40.mjs';
|
|
5
5
|
|
|
6
6
|
let OptionalResolver = class OptionalResolver {
|
|
7
7
|
resolve(o, t, n) {
|
package/dist/index31.js
CHANGED
|
@@ -2,45 +2,84 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const hookManager = require('./index33.js');
|
|
6
|
+
const resolutionStrategies = require('./index43.js');
|
|
7
|
+
const debugLogger = require('./index36.js');
|
|
8
|
+
const use = require('./index42.js');
|
|
9
|
+
const inject = require('./index41.js');
|
|
10
|
+
const injectable = require('./index44.js');
|
|
6
11
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
class InjectableManager {
|
|
13
|
+
setContexts(e, t) {
|
|
14
|
+
this.privateContext = e;
|
|
15
|
+
this.publicContext = t;
|
|
16
|
+
}
|
|
17
|
+
register(n, s = false) {
|
|
18
|
+
const a = debugLogger.DebugLogger.getInstance();
|
|
19
|
+
const c = s === true ? use.resolveInstanceInjectionTuple(n) : inject.resolveInjectionTuple(n);
|
|
20
|
+
if (this.has(c.identifier)) {
|
|
21
|
+
const e = `An assemblage is already registered with identifier '${c.identifier.name}'.`;
|
|
22
|
+
a.log('error', 'Duplicate registration', {
|
|
23
|
+
identifier: c.identifier.name,
|
|
24
|
+
error: e
|
|
19
25
|
});
|
|
26
|
+
throw new Error(e);
|
|
20
27
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
const l = injectable.Injectable.of(c, this.privateContext, this.publicContext);
|
|
29
|
+
a.logRegistration(l);
|
|
30
|
+
this.injectables.set(l.identifier, l);
|
|
31
|
+
if (l.concrete) {
|
|
32
|
+
hookManager.HookManager.callHook(l.concrete, 'onRegister', this.publicContext, l.configuration);
|
|
24
33
|
}
|
|
34
|
+
return l;
|
|
35
|
+
}
|
|
36
|
+
has(e) {
|
|
37
|
+
return this.injectables.has(e);
|
|
25
38
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
39
|
+
require(e, t, i) {
|
|
40
|
+
if (!this.injectables.has(e)) {
|
|
41
|
+
const t = `Class with identifier '${e.name}' has not been registered or is a circular dependency.`;
|
|
42
|
+
debugLogger.DebugLogger.getInstance().log('error', 'Resolution failed', {
|
|
43
|
+
identifier: e.name,
|
|
44
|
+
caller: i ? i?.name || String(i) : 'unknown',
|
|
45
|
+
error: t
|
|
46
|
+
});
|
|
47
|
+
throw new Error(t);
|
|
48
|
+
}
|
|
49
|
+
const r = this.injectables.get(e);
|
|
50
|
+
if (r.isSingleton) {
|
|
51
|
+
return this.singletonStrategy.resolve(r, t);
|
|
52
|
+
} else {
|
|
53
|
+
return this.transientStrategy.resolve(r, t);
|
|
33
54
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
55
|
+
}
|
|
56
|
+
concrete(e) {
|
|
57
|
+
const t = this.injectables.get(e);
|
|
58
|
+
if (t) return t.concrete;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
tagged(...e) {
|
|
62
|
+
const t = [];
|
|
63
|
+
for (const i of e){
|
|
64
|
+
for (const [e, r] of this.injectables){
|
|
65
|
+
if (r.tags.includes(i)) t.push(r.build());
|
|
40
66
|
}
|
|
41
67
|
}
|
|
68
|
+
return t;
|
|
69
|
+
}
|
|
70
|
+
dispose() {
|
|
71
|
+
for (const [e, t] of this.injectables){
|
|
72
|
+
t.dispose();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
get size() {
|
|
76
|
+
return this.injectables.size;
|
|
77
|
+
}
|
|
78
|
+
constructor(){
|
|
79
|
+
this.injectables = new Map();
|
|
80
|
+
this.singletonStrategy = new resolutionStrategies.SingletonStrategy();
|
|
81
|
+
this.transientStrategy = new resolutionStrategies.TransientStrategy();
|
|
42
82
|
}
|
|
43
|
-
}
|
|
83
|
+
}
|
|
44
84
|
|
|
45
|
-
exports.
|
|
46
|
-
exports.unregisterEvents = unregisterEvents;
|
|
85
|
+
exports.InjectableManager = InjectableManager;
|
package/dist/index31.mjs
CHANGED
|
@@ -1,41 +1,81 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HookManager } from './index33.mjs';
|
|
2
|
+
import { SingletonStrategy, TransientStrategy } from './index43.mjs';
|
|
3
|
+
import { DebugLogger } from './index36.mjs';
|
|
4
|
+
import { resolveInstanceInjectionTuple } from './index42.mjs';
|
|
5
|
+
import { resolveInjectionTuple } from './index41.mjs';
|
|
6
|
+
import { Injectable } from './index44.mjs';
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
class InjectableManager {
|
|
9
|
+
setContexts(e, t) {
|
|
10
|
+
this.privateContext = e;
|
|
11
|
+
this.publicContext = t;
|
|
12
|
+
}
|
|
13
|
+
register(n, s = false) {
|
|
14
|
+
const a = DebugLogger.getInstance();
|
|
15
|
+
const c = s === true ? resolveInstanceInjectionTuple(n) : resolveInjectionTuple(n);
|
|
16
|
+
if (this.has(c.identifier)) {
|
|
17
|
+
const e = `An assemblage is already registered with identifier '${c.identifier.name}'.`;
|
|
18
|
+
a.log('error', 'Duplicate registration', {
|
|
19
|
+
identifier: c.identifier.name,
|
|
20
|
+
error: e
|
|
15
21
|
});
|
|
22
|
+
throw new Error(e);
|
|
16
23
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
const l = Injectable.of(c, this.privateContext, this.publicContext);
|
|
25
|
+
a.logRegistration(l);
|
|
26
|
+
this.injectables.set(l.identifier, l);
|
|
27
|
+
if (l.concrete) {
|
|
28
|
+
HookManager.callHook(l.concrete, 'onRegister', this.publicContext, l.configuration);
|
|
20
29
|
}
|
|
30
|
+
return l;
|
|
31
|
+
}
|
|
32
|
+
has(e) {
|
|
33
|
+
return this.injectables.has(e);
|
|
21
34
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
35
|
+
require(e, t, i) {
|
|
36
|
+
if (!this.injectables.has(e)) {
|
|
37
|
+
const t = `Class with identifier '${e.name}' has not been registered or is a circular dependency.`;
|
|
38
|
+
DebugLogger.getInstance().log('error', 'Resolution failed', {
|
|
39
|
+
identifier: e.name,
|
|
40
|
+
caller: i ? i?.name || String(i) : 'unknown',
|
|
41
|
+
error: t
|
|
42
|
+
});
|
|
43
|
+
throw new Error(t);
|
|
44
|
+
}
|
|
45
|
+
const r = this.injectables.get(e);
|
|
46
|
+
if (r.isSingleton) {
|
|
47
|
+
return this.singletonStrategy.resolve(r, t);
|
|
48
|
+
} else {
|
|
49
|
+
return this.transientStrategy.resolve(r, t);
|
|
29
50
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
51
|
+
}
|
|
52
|
+
concrete(e) {
|
|
53
|
+
const t = this.injectables.get(e);
|
|
54
|
+
if (t) return t.concrete;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
tagged(...e) {
|
|
58
|
+
const t = [];
|
|
59
|
+
for (const i of e){
|
|
60
|
+
for (const [e, r] of this.injectables){
|
|
61
|
+
if (r.tags.includes(i)) t.push(r.build());
|
|
36
62
|
}
|
|
37
63
|
}
|
|
64
|
+
return t;
|
|
65
|
+
}
|
|
66
|
+
dispose() {
|
|
67
|
+
for (const [e, t] of this.injectables){
|
|
68
|
+
t.dispose();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
get size() {
|
|
72
|
+
return this.injectables.size;
|
|
73
|
+
}
|
|
74
|
+
constructor(){
|
|
75
|
+
this.injectables = new Map();
|
|
76
|
+
this.singletonStrategy = new SingletonStrategy();
|
|
77
|
+
this.transientStrategy = new TransientStrategy();
|
|
38
78
|
}
|
|
39
|
-
}
|
|
79
|
+
}
|
|
40
80
|
|
|
41
|
-
export {
|
|
81
|
+
export { InjectableManager };
|
package/dist/index32.js
CHANGED
|
@@ -2,27 +2,48 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const debugLogger = require('./index36.js');
|
|
6
|
+
|
|
7
|
+
class ObjectManager {
|
|
8
|
+
use(t, r) {
|
|
9
|
+
if (this.has(t)) {
|
|
10
|
+
const r = `A value is already registered with identifier '${String(t)}'.`;
|
|
11
|
+
debugLogger.DebugLogger.getInstance().log('error', 'Duplicate object registration', {
|
|
12
|
+
identifier: String(t),
|
|
13
|
+
error: r
|
|
14
|
+
});
|
|
15
|
+
throw new Error(r);
|
|
16
|
+
}
|
|
17
|
+
this.objects.set(t, r);
|
|
18
|
+
return r;
|
|
8
19
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
20
|
+
has(e) {
|
|
21
|
+
return this.objects.has(e);
|
|
22
|
+
}
|
|
23
|
+
require(t) {
|
|
24
|
+
if (!this.objects.has(t)) {
|
|
25
|
+
const r = `Injected object with identifier '${String(t)}' has not been registered.`;
|
|
26
|
+
debugLogger.DebugLogger.getInstance().log('error', 'Object not found', {
|
|
27
|
+
identifier: String(t),
|
|
28
|
+
error: r
|
|
29
|
+
});
|
|
30
|
+
throw new Error(r);
|
|
13
31
|
}
|
|
14
|
-
return
|
|
32
|
+
return this.objects.get(t);
|
|
15
33
|
}
|
|
16
|
-
|
|
17
|
-
|
|
34
|
+
addGlobal(e, t) {
|
|
35
|
+
if (this.globals.has(e)) {
|
|
36
|
+
throw new Error(`Global value with key '${e}' has already been registered.`);
|
|
37
|
+
}
|
|
38
|
+
this.globals.set(e, t);
|
|
18
39
|
}
|
|
19
|
-
|
|
20
|
-
return
|
|
40
|
+
global(e) {
|
|
41
|
+
return this.globals.get(e);
|
|
21
42
|
}
|
|
22
|
-
|
|
23
|
-
this.
|
|
43
|
+
constructor(){
|
|
44
|
+
this.objects = new Map();
|
|
45
|
+
this.globals = new Map();
|
|
24
46
|
}
|
|
25
47
|
}
|
|
26
|
-
ResolverStore.resolvers = new Map();
|
|
27
48
|
|
|
28
|
-
exports.
|
|
49
|
+
exports.ObjectManager = ObjectManager;
|
package/dist/index32.mjs
CHANGED
|
@@ -1,24 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { DebugLogger } from './index36.mjs';
|
|
2
|
+
|
|
3
|
+
class ObjectManager {
|
|
4
|
+
use(t, r) {
|
|
5
|
+
if (this.has(t)) {
|
|
6
|
+
const r = `A value is already registered with identifier '${String(t)}'.`;
|
|
7
|
+
DebugLogger.getInstance().log('error', 'Duplicate object registration', {
|
|
8
|
+
identifier: String(t),
|
|
9
|
+
error: r
|
|
10
|
+
});
|
|
11
|
+
throw new Error(r);
|
|
12
|
+
}
|
|
13
|
+
this.objects.set(t, r);
|
|
14
|
+
return r;
|
|
4
15
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
16
|
+
has(e) {
|
|
17
|
+
return this.objects.has(e);
|
|
18
|
+
}
|
|
19
|
+
require(t) {
|
|
20
|
+
if (!this.objects.has(t)) {
|
|
21
|
+
const r = `Injected object with identifier '${String(t)}' has not been registered.`;
|
|
22
|
+
DebugLogger.getInstance().log('error', 'Object not found', {
|
|
23
|
+
identifier: String(t),
|
|
24
|
+
error: r
|
|
25
|
+
});
|
|
26
|
+
throw new Error(r);
|
|
9
27
|
}
|
|
10
|
-
return
|
|
28
|
+
return this.objects.get(t);
|
|
11
29
|
}
|
|
12
|
-
|
|
13
|
-
|
|
30
|
+
addGlobal(e, t) {
|
|
31
|
+
if (this.globals.has(e)) {
|
|
32
|
+
throw new Error(`Global value with key '${e}' has already been registered.`);
|
|
33
|
+
}
|
|
34
|
+
this.globals.set(e, t);
|
|
14
35
|
}
|
|
15
|
-
|
|
16
|
-
return
|
|
36
|
+
global(e) {
|
|
37
|
+
return this.globals.get(e);
|
|
17
38
|
}
|
|
18
|
-
|
|
19
|
-
this.
|
|
39
|
+
constructor(){
|
|
40
|
+
this.objects = new Map();
|
|
41
|
+
this.globals = new Map();
|
|
20
42
|
}
|
|
21
43
|
}
|
|
22
|
-
ResolverStore.resolvers = new Map();
|
|
23
44
|
|
|
24
|
-
export {
|
|
45
|
+
export { ObjectManager };
|