assemblerjs 1.1.15 → 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 +38 -20
- package/dist/index31.mjs +37 -20
- package/dist/index32.js +16 -148
- package/dist/index32.mjs +16 -148
- package/dist/index33.js +99 -44
- package/dist/index33.mjs +99 -44
- package/dist/index34.js +23 -74
- package/dist/index34.mjs +23 -74
- package/dist/index35.js +156 -42
- package/dist/index35.mjs +155 -42
- package/dist/index36.js +47 -28
- package/dist/index36.mjs +47 -28
- package/dist/index37.js +66 -149
- package/dist/index37.mjs +66 -149
- package/dist/index38.js +48 -98
- package/dist/index38.mjs +48 -98
- package/dist/index39.js +29 -26
- package/dist/index39.mjs +29 -26
- package/dist/index4.js +13 -8
- package/dist/index4.mjs +13 -8
- package/dist/index40.js +153 -31
- package/dist/index40.mjs +153 -30
- 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/index.d.ts
CHANGED
|
@@ -395,6 +395,7 @@ export declare interface AssemblerDebugOptions {
|
|
|
395
395
|
logTimings?: boolean;
|
|
396
396
|
logDependencyTree?: boolean;
|
|
397
397
|
useColors?: boolean;
|
|
398
|
+
detectCycles?: boolean;
|
|
398
399
|
}
|
|
399
400
|
|
|
400
401
|
/**
|
|
@@ -849,6 +850,10 @@ declare class InjectableManager {
|
|
|
849
850
|
dispose(): void;
|
|
850
851
|
get size(): number;
|
|
851
852
|
getRegisteredIdentifiers(): string[];
|
|
853
|
+
/**
|
|
854
|
+
* Get the injectables map for cycle detection and other analysis
|
|
855
|
+
*/
|
|
856
|
+
getInjectables(): Map<Identifier, any>;
|
|
852
857
|
}
|
|
853
858
|
|
|
854
859
|
declare interface InjectableRegistrar {
|
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('./index34.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('./index32.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('./index32.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('./index32.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('./index32.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('./index32.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 './index32.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('./index32.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 './index32.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('./index32.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 './index32.mjs';
|
|
5
5
|
|
|
6
6
|
let OptionalResolver = class OptionalResolver {
|
|
7
7
|
resolve(o, t, n) {
|
package/dist/index27.js
CHANGED
package/dist/index27.mjs
CHANGED
package/dist/index31.js
CHANGED
|
@@ -2,27 +2,45 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
const eventManager = require('./index6.js');
|
|
6
|
+
|
|
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);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
for (const e of t.events){
|
|
23
|
+
if (!t.privateContext.events.has(e)) t.privateContext.addChannels(e);
|
|
13
24
|
}
|
|
14
|
-
return new r();
|
|
15
|
-
}
|
|
16
|
-
static hasResolver(e) {
|
|
17
|
-
return this.resolvers.has(e);
|
|
18
|
-
}
|
|
19
|
-
static getRegisteredTypes() {
|
|
20
|
-
return Array.from(this.resolvers.keys());
|
|
21
25
|
}
|
|
22
|
-
|
|
23
|
-
|
|
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);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
24
42
|
}
|
|
25
|
-
}
|
|
26
|
-
ResolverStore.resolvers = new Map();
|
|
43
|
+
};
|
|
27
44
|
|
|
28
|
-
exports.
|
|
45
|
+
exports.registerEvents = registerEvents;
|
|
46
|
+
exports.unregisterEvents = unregisterEvents;
|
package/dist/index31.mjs
CHANGED
|
@@ -1,24 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { EventManager } from './index6.mjs';
|
|
2
|
+
|
|
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);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
for (const e of t.events){
|
|
19
|
+
if (!t.privateContext.events.has(e)) t.privateContext.addChannels(e);
|
|
9
20
|
}
|
|
10
|
-
return new r();
|
|
11
|
-
}
|
|
12
|
-
static hasResolver(e) {
|
|
13
|
-
return this.resolvers.has(e);
|
|
14
|
-
}
|
|
15
|
-
static getRegisteredTypes() {
|
|
16
|
-
return Array.from(this.resolvers.keys());
|
|
17
21
|
}
|
|
18
|
-
|
|
19
|
-
|
|
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);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
20
38
|
}
|
|
21
|
-
}
|
|
22
|
-
ResolverStore.resolvers = new Map();
|
|
39
|
+
};
|
|
23
40
|
|
|
24
|
-
export {
|
|
41
|
+
export { registerEvents, unregisterEvents };
|
package/dist/index32.js
CHANGED
|
@@ -2,159 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const core = require('@assemblerjs/core');
|
|
9
|
-
const use = require('./index42.js');
|
|
10
|
-
const inject = require('./index41.js');
|
|
11
|
-
const injectable = require('./index44.js');
|
|
12
|
-
|
|
13
|
-
function a(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 f(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, s = false) {
|
|
64
|
-
const c = debugLogger.DebugLogger.getInstance();
|
|
65
|
-
const a = s === true ? use.resolveInstanceInjectionTuple(i) : inject.resolveInjectionTuple(i);
|
|
66
|
-
if (this.has(a.identifier)) {
|
|
67
|
-
const e = `An assemblage is already registered with identifier '${a.identifier.name}'.`;
|
|
68
|
-
c.log('error', 'Duplicate registration', {
|
|
69
|
-
identifier: a.identifier.name,
|
|
70
|
-
error: e
|
|
71
|
-
});
|
|
72
|
-
throw new Error(e);
|
|
73
|
-
}
|
|
74
|
-
const f = injectable.Injectable.of(a, this.privateContext, this.publicContext);
|
|
75
|
-
c.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 s = a(e);
|
|
90
|
-
const c = f(e);
|
|
91
|
-
const u = t?.__paramIndex;
|
|
92
|
-
const l = t?.__paramCount;
|
|
93
|
-
const g = t?.__expectedType;
|
|
94
|
-
const d = r ? `Circular dependency detected: '${s}' is already being resolved.` : `Dependency '${s}' has not been registered (Class/Service not found in current assemblages).`;
|
|
95
|
-
const p = {
|
|
96
|
-
identifier: s,
|
|
97
|
-
caller: n ? a(n) : 'unknown',
|
|
98
|
-
type: c,
|
|
99
|
-
error: d
|
|
100
|
-
};
|
|
101
|
-
if (u !== undefined) {
|
|
102
|
-
p.paramIndex = u;
|
|
103
|
-
}
|
|
104
|
-
if (l !== undefined) {
|
|
105
|
-
p.paramCount = l;
|
|
106
|
-
}
|
|
107
|
-
if (g !== undefined) {
|
|
108
|
-
const e = g?.name || a(g);
|
|
109
|
-
p.expectedType = e;
|
|
110
|
-
}
|
|
111
|
-
debugLogger.DebugLogger.getInstance().log('error', i, p);
|
|
112
|
-
throw new Error(d);
|
|
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;
|
|
5
|
+
class ResolverStore {
|
|
6
|
+
static register(e, r) {
|
|
7
|
+
this.resolvers.set(e, r);
|
|
139
8
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
9
|
+
static getResolver(e) {
|
|
10
|
+
const r = this.resolvers.get(e);
|
|
11
|
+
if (!r) {
|
|
12
|
+
throw new Error(`No resolver found for decorator type: ${e}`);
|
|
143
13
|
}
|
|
144
|
-
|
|
14
|
+
return new r();
|
|
145
15
|
}
|
|
146
|
-
|
|
147
|
-
return this.
|
|
16
|
+
static hasResolver(e) {
|
|
17
|
+
return this.resolvers.has(e);
|
|
148
18
|
}
|
|
149
|
-
|
|
150
|
-
return Array.from(this.
|
|
19
|
+
static getRegisteredTypes() {
|
|
20
|
+
return Array.from(this.resolvers.keys());
|
|
151
21
|
}
|
|
152
|
-
|
|
153
|
-
this.
|
|
154
|
-
this.resolvingStack = new Set();
|
|
155
|
-
this.singletonStrategy = new resolutionStrategies.SingletonStrategy();
|
|
156
|
-
this.transientStrategy = new resolutionStrategies.TransientStrategy();
|
|
22
|
+
static clear() {
|
|
23
|
+
this.resolvers.clear();
|
|
157
24
|
}
|
|
158
25
|
}
|
|
26
|
+
ResolverStore.resolvers = new Map();
|
|
159
27
|
|
|
160
|
-
exports.
|
|
28
|
+
exports.ResolverStore = ResolverStore;
|
package/dist/index32.mjs
CHANGED
|
@@ -1,156 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { isClass } from '@assemblerjs/core';
|
|
5
|
-
import { resolveInstanceInjectionTuple } from './index42.mjs';
|
|
6
|
-
import { resolveInjectionTuple } from './index41.mjs';
|
|
7
|
-
import { Injectable } from './index44.mjs';
|
|
8
|
-
|
|
9
|
-
function a(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 f(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, s = false) {
|
|
60
|
-
const c = DebugLogger.getInstance();
|
|
61
|
-
const a = s === true ? resolveInstanceInjectionTuple(i) : resolveInjectionTuple(i);
|
|
62
|
-
if (this.has(a.identifier)) {
|
|
63
|
-
const e = `An assemblage is already registered with identifier '${a.identifier.name}'.`;
|
|
64
|
-
c.log('error', 'Duplicate registration', {
|
|
65
|
-
identifier: a.identifier.name,
|
|
66
|
-
error: e
|
|
67
|
-
});
|
|
68
|
-
throw new Error(e);
|
|
69
|
-
}
|
|
70
|
-
const f = Injectable.of(a, this.privateContext, this.publicContext);
|
|
71
|
-
c.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 s = a(e);
|
|
86
|
-
const c = f(e);
|
|
87
|
-
const u = t?.__paramIndex;
|
|
88
|
-
const l = t?.__paramCount;
|
|
89
|
-
const g = t?.__expectedType;
|
|
90
|
-
const d = r ? `Circular dependency detected: '${s}' is already being resolved.` : `Dependency '${s}' has not been registered (Class/Service not found in current assemblages).`;
|
|
91
|
-
const p = {
|
|
92
|
-
identifier: s,
|
|
93
|
-
caller: n ? a(n) : 'unknown',
|
|
94
|
-
type: c,
|
|
95
|
-
error: d
|
|
96
|
-
};
|
|
97
|
-
if (u !== undefined) {
|
|
98
|
-
p.paramIndex = u;
|
|
99
|
-
}
|
|
100
|
-
if (l !== undefined) {
|
|
101
|
-
p.paramCount = l;
|
|
102
|
-
}
|
|
103
|
-
if (g !== undefined) {
|
|
104
|
-
const e = g?.name || a(g);
|
|
105
|
-
p.expectedType = e;
|
|
106
|
-
}
|
|
107
|
-
DebugLogger.getInstance().log('error', i, p);
|
|
108
|
-
throw new Error(d);
|
|
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;
|
|
1
|
+
class ResolverStore {
|
|
2
|
+
static register(e, r) {
|
|
3
|
+
this.resolvers.set(e, r);
|
|
135
4
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
5
|
+
static getResolver(e) {
|
|
6
|
+
const r = this.resolvers.get(e);
|
|
7
|
+
if (!r) {
|
|
8
|
+
throw new Error(`No resolver found for decorator type: ${e}`);
|
|
139
9
|
}
|
|
140
|
-
|
|
10
|
+
return new r();
|
|
141
11
|
}
|
|
142
|
-
|
|
143
|
-
return this.
|
|
12
|
+
static hasResolver(e) {
|
|
13
|
+
return this.resolvers.has(e);
|
|
144
14
|
}
|
|
145
|
-
|
|
146
|
-
return Array.from(this.
|
|
15
|
+
static getRegisteredTypes() {
|
|
16
|
+
return Array.from(this.resolvers.keys());
|
|
147
17
|
}
|
|
148
|
-
|
|
149
|
-
this.
|
|
150
|
-
this.resolvingStack = new Set();
|
|
151
|
-
this.singletonStrategy = new SingletonStrategy();
|
|
152
|
-
this.transientStrategy = new TransientStrategy();
|
|
18
|
+
static clear() {
|
|
19
|
+
this.resolvers.clear();
|
|
153
20
|
}
|
|
154
21
|
}
|
|
22
|
+
ResolverStore.resolvers = new Map();
|
|
155
23
|
|
|
156
|
-
export {
|
|
24
|
+
export { ResolverStore };
|