assemblerjs 1.1.4 → 1.1.6
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 +1 -0
- package/dist/index31.js +25 -11
- package/dist/index31.mjs +25 -11
- package/dist/index32.js +21 -9
- package/dist/index32.mjs +21 -9
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index31.js
CHANGED
|
@@ -14,11 +14,16 @@ class InjectableManager {
|
|
|
14
14
|
this.privateContext = e;
|
|
15
15
|
this.publicContext = t;
|
|
16
16
|
}
|
|
17
|
-
register(
|
|
17
|
+
register(n, s = false) {
|
|
18
18
|
const a = debugLogger.DebugLogger.getInstance();
|
|
19
|
-
const c =
|
|
19
|
+
const c = s === true ? use.resolveInstanceInjectionTuple(n) : inject.resolveInjectionTuple(n);
|
|
20
20
|
if (this.has(c.identifier)) {
|
|
21
|
-
|
|
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
|
|
25
|
+
});
|
|
26
|
+
throw new Error(e);
|
|
22
27
|
}
|
|
23
28
|
const l = injectable.Injectable.of(c, this.privateContext, this.publicContext);
|
|
24
29
|
a.logRegistration(l);
|
|
@@ -33,19 +38,26 @@ class InjectableManager {
|
|
|
33
38
|
}
|
|
34
39
|
require(e, t, i) {
|
|
35
40
|
if (!this.injectables.has(e)) {
|
|
36
|
-
const t =
|
|
37
|
-
|
|
41
|
+
const t = this.resolvingStack.has(e);
|
|
42
|
+
const r = t ? 'Circular dependency detected' : 'Dependency not registered';
|
|
43
|
+
const n = t ? `Circular dependency detected: '${e.name}' is already being resolved.` : `Class with identifier '${e.name}' has not been registered.`;
|
|
44
|
+
debugLogger.DebugLogger.getInstance().log('error', r, {
|
|
38
45
|
identifier: e.name,
|
|
39
46
|
caller: i ? i?.name || String(i) : 'unknown',
|
|
40
|
-
error:
|
|
47
|
+
error: n
|
|
41
48
|
});
|
|
42
|
-
throw new Error(
|
|
49
|
+
throw new Error(n);
|
|
43
50
|
}
|
|
44
51
|
const r = this.injectables.get(e);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
this.resolvingStack.add(r.identifier);
|
|
53
|
+
try {
|
|
54
|
+
if (r.isSingleton) {
|
|
55
|
+
return this.singletonStrategy.resolve(r, t);
|
|
56
|
+
} else {
|
|
57
|
+
return this.transientStrategy.resolve(r, t);
|
|
58
|
+
}
|
|
59
|
+
} finally{
|
|
60
|
+
this.resolvingStack.delete(r.identifier);
|
|
49
61
|
}
|
|
50
62
|
}
|
|
51
63
|
concrete(e) {
|
|
@@ -66,12 +78,14 @@ class InjectableManager {
|
|
|
66
78
|
for (const [e, t] of this.injectables){
|
|
67
79
|
t.dispose();
|
|
68
80
|
}
|
|
81
|
+
this.resolvingStack.clear();
|
|
69
82
|
}
|
|
70
83
|
get size() {
|
|
71
84
|
return this.injectables.size;
|
|
72
85
|
}
|
|
73
86
|
constructor(){
|
|
74
87
|
this.injectables = new Map();
|
|
88
|
+
this.resolvingStack = new Set();
|
|
75
89
|
this.singletonStrategy = new resolutionStrategies.SingletonStrategy();
|
|
76
90
|
this.transientStrategy = new resolutionStrategies.TransientStrategy();
|
|
77
91
|
}
|
package/dist/index31.mjs
CHANGED
|
@@ -10,11 +10,16 @@ class InjectableManager {
|
|
|
10
10
|
this.privateContext = e;
|
|
11
11
|
this.publicContext = t;
|
|
12
12
|
}
|
|
13
|
-
register(
|
|
13
|
+
register(n, s = false) {
|
|
14
14
|
const a = DebugLogger.getInstance();
|
|
15
|
-
const c =
|
|
15
|
+
const c = s === true ? resolveInstanceInjectionTuple(n) : resolveInjectionTuple(n);
|
|
16
16
|
if (this.has(c.identifier)) {
|
|
17
|
-
|
|
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
|
|
21
|
+
});
|
|
22
|
+
throw new Error(e);
|
|
18
23
|
}
|
|
19
24
|
const l = Injectable.of(c, this.privateContext, this.publicContext);
|
|
20
25
|
a.logRegistration(l);
|
|
@@ -29,19 +34,26 @@ class InjectableManager {
|
|
|
29
34
|
}
|
|
30
35
|
require(e, t, i) {
|
|
31
36
|
if (!this.injectables.has(e)) {
|
|
32
|
-
const t =
|
|
33
|
-
|
|
37
|
+
const t = this.resolvingStack.has(e);
|
|
38
|
+
const r = t ? 'Circular dependency detected' : 'Dependency not registered';
|
|
39
|
+
const n = t ? `Circular dependency detected: '${e.name}' is already being resolved.` : `Class with identifier '${e.name}' has not been registered.`;
|
|
40
|
+
DebugLogger.getInstance().log('error', r, {
|
|
34
41
|
identifier: e.name,
|
|
35
42
|
caller: i ? i?.name || String(i) : 'unknown',
|
|
36
|
-
error:
|
|
43
|
+
error: n
|
|
37
44
|
});
|
|
38
|
-
throw new Error(
|
|
45
|
+
throw new Error(n);
|
|
39
46
|
}
|
|
40
47
|
const r = this.injectables.get(e);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
this.resolvingStack.add(r.identifier);
|
|
49
|
+
try {
|
|
50
|
+
if (r.isSingleton) {
|
|
51
|
+
return this.singletonStrategy.resolve(r, t);
|
|
52
|
+
} else {
|
|
53
|
+
return this.transientStrategy.resolve(r, t);
|
|
54
|
+
}
|
|
55
|
+
} finally{
|
|
56
|
+
this.resolvingStack.delete(r.identifier);
|
|
45
57
|
}
|
|
46
58
|
}
|
|
47
59
|
concrete(e) {
|
|
@@ -62,12 +74,14 @@ class InjectableManager {
|
|
|
62
74
|
for (const [e, t] of this.injectables){
|
|
63
75
|
t.dispose();
|
|
64
76
|
}
|
|
77
|
+
this.resolvingStack.clear();
|
|
65
78
|
}
|
|
66
79
|
get size() {
|
|
67
80
|
return this.injectables.size;
|
|
68
81
|
}
|
|
69
82
|
constructor(){
|
|
70
83
|
this.injectables = new Map();
|
|
84
|
+
this.resolvingStack = new Set();
|
|
71
85
|
this.singletonStrategy = new SingletonStrategy();
|
|
72
86
|
this.transientStrategy = new TransientStrategy();
|
|
73
87
|
}
|
package/dist/index32.js
CHANGED
|
@@ -2,22 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
+
const debugLogger = require('./index36.js');
|
|
6
|
+
|
|
5
7
|
class ObjectManager {
|
|
6
|
-
use(
|
|
7
|
-
if (this.has(
|
|
8
|
-
|
|
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);
|
|
9
16
|
}
|
|
10
|
-
this.objects.set(
|
|
11
|
-
return
|
|
17
|
+
this.objects.set(t, r);
|
|
18
|
+
return r;
|
|
12
19
|
}
|
|
13
20
|
has(e) {
|
|
14
21
|
return this.objects.has(e);
|
|
15
22
|
}
|
|
16
|
-
require(
|
|
17
|
-
if (!this.objects.has(
|
|
18
|
-
|
|
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);
|
|
19
31
|
}
|
|
20
|
-
return this.objects.get(
|
|
32
|
+
return this.objects.get(t);
|
|
21
33
|
}
|
|
22
34
|
addGlobal(e, t) {
|
|
23
35
|
if (this.globals.has(e)) {
|
package/dist/index32.mjs
CHANGED
|
@@ -1,19 +1,31 @@
|
|
|
1
|
+
import { DebugLogger } from './index36.mjs';
|
|
2
|
+
|
|
1
3
|
class ObjectManager {
|
|
2
|
-
use(
|
|
3
|
-
if (this.has(
|
|
4
|
-
|
|
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);
|
|
5
12
|
}
|
|
6
|
-
this.objects.set(
|
|
7
|
-
return
|
|
13
|
+
this.objects.set(t, r);
|
|
14
|
+
return r;
|
|
8
15
|
}
|
|
9
16
|
has(e) {
|
|
10
17
|
return this.objects.has(e);
|
|
11
18
|
}
|
|
12
|
-
require(
|
|
13
|
-
if (!this.objects.has(
|
|
14
|
-
|
|
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);
|
|
15
27
|
}
|
|
16
|
-
return this.objects.get(
|
|
28
|
+
return this.objects.get(t);
|
|
17
29
|
}
|
|
18
30
|
addGlobal(e, t) {
|
|
19
31
|
if (this.globals.has(e)) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "assemblerjs",
|
|
3
3
|
"description": "A general purpose Dependency Injection library for node and browser.",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.6",
|
|
5
5
|
"author": "Benoît LAHOZ <info@benoitlahoz.io>",
|
|
6
6
|
"bugs": "https://github.com/benoitlahoz/assemblerjs/issues",
|
|
7
7
|
"homepage": "https://github.com/benoitlahoz/assemblerjs#README",
|