assemblerjs 1.1.6 → 1.1.8
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/index31.js +72 -23
- package/dist/index31.mjs +72 -23
- package/dist/index32.js +24 -17
- package/dist/index32.mjs +24 -17
- package/dist/index41.js +29 -49
- package/dist/index41.mjs +28 -49
- package/dist/index43.js +49 -29
- package/dist/index43.mjs +49 -28
- package/package.json +1 -1
package/dist/index31.js
CHANGED
|
@@ -3,50 +3,99 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const hookManager = require('./index33.js');
|
|
6
|
-
const resolutionStrategies = require('./
|
|
6
|
+
const resolutionStrategies = require('./index41.js');
|
|
7
7
|
const debugLogger = require('./index36.js');
|
|
8
|
+
const core = require('@assemblerjs/core');
|
|
8
9
|
const use = require('./index42.js');
|
|
9
|
-
const inject = require('./
|
|
10
|
+
const inject = require('./index43.js');
|
|
10
11
|
const injectable = require('./index44.js');
|
|
11
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
|
+
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
|
+
const t = e.constructor?.name;
|
|
39
|
+
if (t && t !== 'Object') {
|
|
40
|
+
return `[${t}]`;
|
|
41
|
+
}
|
|
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
|
+
}
|
|
12
58
|
class InjectableManager {
|
|
13
59
|
setContexts(e, t) {
|
|
14
60
|
this.privateContext = e;
|
|
15
61
|
this.publicContext = t;
|
|
16
62
|
}
|
|
17
|
-
register(
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
if (this.has(
|
|
21
|
-
const e = `An assemblage is already registered with identifier '${
|
|
22
|
-
|
|
23
|
-
identifier:
|
|
63
|
+
register(i, o = false) {
|
|
64
|
+
const c = debugLogger.DebugLogger.getInstance();
|
|
65
|
+
const a = o === 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,
|
|
24
70
|
error: e
|
|
25
71
|
});
|
|
26
72
|
throw new Error(e);
|
|
27
73
|
}
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
this.injectables.set(
|
|
31
|
-
if (
|
|
32
|
-
hookManager.HookManager.callHook(
|
|
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);
|
|
33
79
|
}
|
|
34
|
-
return
|
|
80
|
+
return f;
|
|
35
81
|
}
|
|
36
82
|
has(e) {
|
|
37
83
|
return this.injectables.has(e);
|
|
38
84
|
}
|
|
39
|
-
require(e, t,
|
|
85
|
+
require(e, t, n) {
|
|
40
86
|
if (!this.injectables.has(e)) {
|
|
41
87
|
const t = this.resolvingStack.has(e);
|
|
42
88
|
const r = t ? 'Circular dependency detected' : 'Dependency not registered';
|
|
43
|
-
const
|
|
89
|
+
const i = a(e);
|
|
90
|
+
const o = f(e);
|
|
91
|
+
const c = t ? `Circular dependency detected: '${i}' is already being resolved.` : `Dependency '${i}' has not been registered (Class/Service not found in current assemblies).`;
|
|
44
92
|
debugLogger.DebugLogger.getInstance().log('error', r, {
|
|
45
|
-
identifier:
|
|
46
|
-
caller:
|
|
47
|
-
|
|
93
|
+
identifier: i,
|
|
94
|
+
caller: n ? a(n) : 'unknown',
|
|
95
|
+
type: o,
|
|
96
|
+
error: c
|
|
48
97
|
});
|
|
49
|
-
throw new Error(
|
|
98
|
+
throw new Error(c);
|
|
50
99
|
}
|
|
51
100
|
const r = this.injectables.get(e);
|
|
52
101
|
this.resolvingStack.add(r.identifier);
|
|
@@ -67,9 +116,9 @@ class InjectableManager {
|
|
|
67
116
|
}
|
|
68
117
|
tagged(...e) {
|
|
69
118
|
const t = [];
|
|
70
|
-
for (const
|
|
119
|
+
for (const n of e){
|
|
71
120
|
for (const [e, r] of this.injectables){
|
|
72
|
-
if (r.tags.includes(
|
|
121
|
+
if (r.tags.includes(n)) t.push(r.build());
|
|
73
122
|
}
|
|
74
123
|
}
|
|
75
124
|
return t;
|
package/dist/index31.mjs
CHANGED
|
@@ -1,48 +1,97 @@
|
|
|
1
1
|
import { HookManager } from './index33.mjs';
|
|
2
|
-
import { SingletonStrategy, TransientStrategy } from './
|
|
2
|
+
import { SingletonStrategy, TransientStrategy } from './index41.mjs';
|
|
3
3
|
import { DebugLogger } from './index36.mjs';
|
|
4
|
+
import { isClass } from '@assemblerjs/core';
|
|
4
5
|
import { resolveInstanceInjectionTuple } from './index42.mjs';
|
|
5
|
-
import { resolveInjectionTuple } from './
|
|
6
|
+
import { resolveInjectionTuple } from './index43.mjs';
|
|
6
7
|
import { Injectable } from './index44.mjs';
|
|
7
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
|
+
try {
|
|
28
|
+
const t = JSON.stringify(e);
|
|
29
|
+
if (t.length > 100) {
|
|
30
|
+
return t.substring(0, 100) + '...';
|
|
31
|
+
}
|
|
32
|
+
return t;
|
|
33
|
+
} catch {
|
|
34
|
+
const t = e.constructor?.name;
|
|
35
|
+
if (t && t !== 'Object') {
|
|
36
|
+
return `[${t}]`;
|
|
37
|
+
}
|
|
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
|
+
}
|
|
8
54
|
class InjectableManager {
|
|
9
55
|
setContexts(e, t) {
|
|
10
56
|
this.privateContext = e;
|
|
11
57
|
this.publicContext = t;
|
|
12
58
|
}
|
|
13
|
-
register(
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
if (this.has(
|
|
17
|
-
const e = `An assemblage is already registered with identifier '${
|
|
18
|
-
|
|
19
|
-
identifier:
|
|
59
|
+
register(i, o = false) {
|
|
60
|
+
const c = DebugLogger.getInstance();
|
|
61
|
+
const a = o === 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,
|
|
20
66
|
error: e
|
|
21
67
|
});
|
|
22
68
|
throw new Error(e);
|
|
23
69
|
}
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
this.injectables.set(
|
|
27
|
-
if (
|
|
28
|
-
HookManager.callHook(
|
|
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);
|
|
29
75
|
}
|
|
30
|
-
return
|
|
76
|
+
return f;
|
|
31
77
|
}
|
|
32
78
|
has(e) {
|
|
33
79
|
return this.injectables.has(e);
|
|
34
80
|
}
|
|
35
|
-
require(e, t,
|
|
81
|
+
require(e, t, n) {
|
|
36
82
|
if (!this.injectables.has(e)) {
|
|
37
83
|
const t = this.resolvingStack.has(e);
|
|
38
84
|
const r = t ? 'Circular dependency detected' : 'Dependency not registered';
|
|
39
|
-
const
|
|
85
|
+
const i = a(e);
|
|
86
|
+
const o = f(e);
|
|
87
|
+
const c = t ? `Circular dependency detected: '${i}' is already being resolved.` : `Dependency '${i}' has not been registered (Class/Service not found in current assemblies).`;
|
|
40
88
|
DebugLogger.getInstance().log('error', r, {
|
|
41
|
-
identifier:
|
|
42
|
-
caller:
|
|
43
|
-
|
|
89
|
+
identifier: i,
|
|
90
|
+
caller: n ? a(n) : 'unknown',
|
|
91
|
+
type: o,
|
|
92
|
+
error: c
|
|
44
93
|
});
|
|
45
|
-
throw new Error(
|
|
94
|
+
throw new Error(c);
|
|
46
95
|
}
|
|
47
96
|
const r = this.injectables.get(e);
|
|
48
97
|
this.resolvingStack.add(r.identifier);
|
|
@@ -63,9 +112,9 @@ class InjectableManager {
|
|
|
63
112
|
}
|
|
64
113
|
tagged(...e) {
|
|
65
114
|
const t = [];
|
|
66
|
-
for (const
|
|
115
|
+
for (const n of e){
|
|
67
116
|
for (const [e, r] of this.injectables){
|
|
68
|
-
if (r.tags.includes(
|
|
117
|
+
if (r.tags.includes(n)) t.push(r.build());
|
|
69
118
|
}
|
|
70
119
|
}
|
|
71
120
|
return t;
|
package/dist/index32.js
CHANGED
|
@@ -4,32 +4,39 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
4
4
|
|
|
5
5
|
const debugLogger = require('./index36.js');
|
|
6
6
|
|
|
7
|
+
function t(e) {
|
|
8
|
+
return typeof e === 'symbol' ? 'symbol' : 'string';
|
|
9
|
+
}
|
|
7
10
|
class ObjectManager {
|
|
8
|
-
use(
|
|
9
|
-
if (this.has(
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
|
14
19
|
});
|
|
15
|
-
throw new Error(
|
|
20
|
+
throw new Error(s);
|
|
16
21
|
}
|
|
17
|
-
this.objects.set(
|
|
18
|
-
return
|
|
22
|
+
this.objects.set(r, o);
|
|
23
|
+
return o;
|
|
19
24
|
}
|
|
20
25
|
has(e) {
|
|
21
26
|
return this.objects.has(e);
|
|
22
27
|
}
|
|
23
|
-
require(
|
|
24
|
-
if (!this.objects.has(
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
|
29
36
|
});
|
|
30
|
-
throw new Error(
|
|
37
|
+
throw new Error(s);
|
|
31
38
|
}
|
|
32
|
-
return this.objects.get(
|
|
39
|
+
return this.objects.get(r);
|
|
33
40
|
}
|
|
34
41
|
addGlobal(e, t) {
|
|
35
42
|
if (this.globals.has(e)) {
|
package/dist/index32.mjs
CHANGED
|
@@ -1,31 +1,38 @@
|
|
|
1
1
|
import { DebugLogger } from './index36.mjs';
|
|
2
2
|
|
|
3
|
+
function t(e) {
|
|
4
|
+
return typeof e === 'symbol' ? 'symbol' : 'string';
|
|
5
|
+
}
|
|
3
6
|
class ObjectManager {
|
|
4
|
-
use(
|
|
5
|
-
if (this.has(
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
use(r, o) {
|
|
8
|
+
if (this.has(r)) {
|
|
9
|
+
const o = typeof r === 'symbol' ? r.toString() : String(r);
|
|
10
|
+
const s = `Object/value '${o}' is already registered (cannot register twice).`;
|
|
11
|
+
DebugLogger.getInstance().log('error', 'Duplicate object/value registration', {
|
|
12
|
+
identifier: o,
|
|
13
|
+
type: t(r),
|
|
14
|
+
error: s
|
|
10
15
|
});
|
|
11
|
-
throw new Error(
|
|
16
|
+
throw new Error(s);
|
|
12
17
|
}
|
|
13
|
-
this.objects.set(
|
|
14
|
-
return
|
|
18
|
+
this.objects.set(r, o);
|
|
19
|
+
return o;
|
|
15
20
|
}
|
|
16
21
|
has(e) {
|
|
17
22
|
return this.objects.has(e);
|
|
18
23
|
}
|
|
19
|
-
require(
|
|
20
|
-
if (!this.objects.has(
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
require(r) {
|
|
25
|
+
if (!this.objects.has(r)) {
|
|
26
|
+
const o = typeof r === 'symbol' ? r.toString() : String(r);
|
|
27
|
+
const s = `Object/value '${o}' has not been registered in the object store.`;
|
|
28
|
+
DebugLogger.getInstance().log('error', 'Object/value not found', {
|
|
29
|
+
identifier: o,
|
|
30
|
+
type: t(r),
|
|
31
|
+
error: s
|
|
25
32
|
});
|
|
26
|
-
throw new Error(
|
|
33
|
+
throw new Error(s);
|
|
27
34
|
}
|
|
28
|
-
return this.objects.get(
|
|
35
|
+
return this.objects.get(r);
|
|
29
36
|
}
|
|
30
37
|
addGlobal(e, t) {
|
|
31
38
|
if (this.globals.has(e)) {
|
package/dist/index41.js
CHANGED
|
@@ -2,53 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
class SingletonStrategy {
|
|
6
|
+
resolve(t, e) {
|
|
7
|
+
const n = t.identifier;
|
|
8
|
+
if (this.cache.has(n)) {
|
|
9
|
+
return this.cache.get(n);
|
|
10
|
+
}
|
|
11
|
+
const o = t.build(e);
|
|
12
|
+
const r = e ? {
|
|
13
|
+
...t.configuration,
|
|
14
|
+
...e
|
|
15
|
+
} : t.configuration;
|
|
16
|
+
t.setSingletonInstance(o, r);
|
|
17
|
+
this.cache.set(n, o);
|
|
18
|
+
t.privateContext.prepareInitHook(o, t.configuration);
|
|
19
|
+
return o;
|
|
20
|
+
}
|
|
21
|
+
constructor(){
|
|
22
|
+
this.cache = new Map();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
class TransientStrategy {
|
|
26
|
+
resolve(t, e) {
|
|
27
|
+
const n = t.build(e);
|
|
28
|
+
t.privateContext.prepareInitHook(n, t.configuration);
|
|
29
|
+
return n;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
6
32
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
identifier: e[0],
|
|
10
|
-
concrete: e[0],
|
|
11
|
-
configuration: {}
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
const c = (o)=>{
|
|
15
|
-
const i = ()=>core.isClass(o[0]) && core.isClass(o[1]);
|
|
16
|
-
const c = ()=>core.isClass(o[0]) && core.isObject(o[1]);
|
|
17
|
-
const s = ()=>core.pipe(core.conditionally({
|
|
18
|
-
if: ()=>i(),
|
|
19
|
-
then: ()=>{
|
|
20
|
-
return {
|
|
21
|
-
identifier: o[0],
|
|
22
|
-
concrete: o[1],
|
|
23
|
-
configuration: {}
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}), core.conditionally({
|
|
27
|
-
if: ()=>c(),
|
|
28
|
-
then: ()=>{
|
|
29
|
-
return {
|
|
30
|
-
identifier: o[0],
|
|
31
|
-
concrete: o[0],
|
|
32
|
-
configuration: o[1]
|
|
33
|
-
};
|
|
34
|
-
},
|
|
35
|
-
else: (e)=>e
|
|
36
|
-
}))();
|
|
37
|
-
return s();
|
|
38
|
-
};
|
|
39
|
-
const s = (e)=>{
|
|
40
|
-
return {
|
|
41
|
-
identifier: e[0],
|
|
42
|
-
concrete: e[1],
|
|
43
|
-
configuration: e[2]
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
const resolveInjectionTuple = (e)=>core.switchCase({
|
|
47
|
-
1: ()=>i(e),
|
|
48
|
-
2: ()=>c(e),
|
|
49
|
-
3: ()=>s(e)
|
|
50
|
-
}, ()=>{
|
|
51
|
-
throw new Error(`Injection tuple must be of length 1, 2 or 3.`);
|
|
52
|
-
})(e.length);
|
|
53
|
-
|
|
54
|
-
exports.resolveInjectionTuple = resolveInjectionTuple;
|
|
33
|
+
exports.SingletonStrategy = SingletonStrategy;
|
|
34
|
+
exports.TransientStrategy = TransientStrategy;
|
package/dist/index41.mjs
CHANGED
|
@@ -1,50 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
class SingletonStrategy {
|
|
2
|
+
resolve(t, e) {
|
|
3
|
+
const n = t.identifier;
|
|
4
|
+
if (this.cache.has(n)) {
|
|
5
|
+
return this.cache.get(n);
|
|
6
|
+
}
|
|
7
|
+
const o = t.build(e);
|
|
8
|
+
const r = e ? {
|
|
9
|
+
...t.configuration,
|
|
10
|
+
...e
|
|
11
|
+
} : t.configuration;
|
|
12
|
+
t.setSingletonInstance(o, r);
|
|
13
|
+
this.cache.set(n, o);
|
|
14
|
+
t.privateContext.prepareInitHook(o, t.configuration);
|
|
15
|
+
return o;
|
|
16
|
+
}
|
|
17
|
+
constructor(){
|
|
18
|
+
this.cache = new Map();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
class TransientStrategy {
|
|
22
|
+
resolve(t, e) {
|
|
23
|
+
const n = t.build(e);
|
|
24
|
+
t.privateContext.prepareInitHook(n, t.configuration);
|
|
25
|
+
return n;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
2
28
|
|
|
3
|
-
|
|
4
|
-
return {
|
|
5
|
-
identifier: e[0],
|
|
6
|
-
concrete: e[0],
|
|
7
|
-
configuration: {}
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
const c = (o)=>{
|
|
11
|
-
const i = ()=>isClass(o[0]) && isClass(o[1]);
|
|
12
|
-
const c = ()=>isClass(o[0]) && isObject(o[1]);
|
|
13
|
-
const s = ()=>pipe(conditionally({
|
|
14
|
-
if: ()=>i(),
|
|
15
|
-
then: ()=>{
|
|
16
|
-
return {
|
|
17
|
-
identifier: o[0],
|
|
18
|
-
concrete: o[1],
|
|
19
|
-
configuration: {}
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
}), conditionally({
|
|
23
|
-
if: ()=>c(),
|
|
24
|
-
then: ()=>{
|
|
25
|
-
return {
|
|
26
|
-
identifier: o[0],
|
|
27
|
-
concrete: o[0],
|
|
28
|
-
configuration: o[1]
|
|
29
|
-
};
|
|
30
|
-
},
|
|
31
|
-
else: (e)=>e
|
|
32
|
-
}))();
|
|
33
|
-
return s();
|
|
34
|
-
};
|
|
35
|
-
const s = (e)=>{
|
|
36
|
-
return {
|
|
37
|
-
identifier: e[0],
|
|
38
|
-
concrete: e[1],
|
|
39
|
-
configuration: e[2]
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
const resolveInjectionTuple = (e)=>switchCase({
|
|
43
|
-
1: ()=>i(e),
|
|
44
|
-
2: ()=>c(e),
|
|
45
|
-
3: ()=>s(e)
|
|
46
|
-
}, ()=>{
|
|
47
|
-
throw new Error(`Injection tuple must be of length 1, 2 or 3.`);
|
|
48
|
-
})(e.length);
|
|
49
|
-
|
|
50
|
-
export { resolveInjectionTuple };
|
|
29
|
+
export { SingletonStrategy, TransientStrategy };
|
package/dist/index43.js
CHANGED
|
@@ -2,33 +2,53 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
resolve(t, e) {
|
|
7
|
-
const n = t.identifier;
|
|
8
|
-
if (this.cache.has(n)) {
|
|
9
|
-
return this.cache.get(n);
|
|
10
|
-
}
|
|
11
|
-
const o = t.build(e);
|
|
12
|
-
const r = e ? {
|
|
13
|
-
...t.configuration,
|
|
14
|
-
...e
|
|
15
|
-
} : t.configuration;
|
|
16
|
-
t.setSingletonInstance(o, r);
|
|
17
|
-
this.cache.set(n, o);
|
|
18
|
-
t.privateContext.prepareInitHook(o, t.configuration);
|
|
19
|
-
return o;
|
|
20
|
-
}
|
|
21
|
-
constructor(){
|
|
22
|
-
this.cache = new Map();
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
class TransientStrategy {
|
|
26
|
-
resolve(t, e) {
|
|
27
|
-
const n = t.build(e);
|
|
28
|
-
t.privateContext.prepareInitHook(n, t.configuration);
|
|
29
|
-
return n;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
5
|
+
const core = require('@assemblerjs/core');
|
|
32
6
|
|
|
33
|
-
|
|
34
|
-
|
|
7
|
+
const i = (e)=>{
|
|
8
|
+
return {
|
|
9
|
+
identifier: e[0],
|
|
10
|
+
concrete: e[0],
|
|
11
|
+
configuration: {}
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
const c = (o)=>{
|
|
15
|
+
const i = ()=>core.isClass(o[0]) && core.isClass(o[1]);
|
|
16
|
+
const c = ()=>core.isClass(o[0]) && core.isObject(o[1]);
|
|
17
|
+
const s = ()=>core.pipe(core.conditionally({
|
|
18
|
+
if: ()=>i(),
|
|
19
|
+
then: ()=>{
|
|
20
|
+
return {
|
|
21
|
+
identifier: o[0],
|
|
22
|
+
concrete: o[1],
|
|
23
|
+
configuration: {}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}), core.conditionally({
|
|
27
|
+
if: ()=>c(),
|
|
28
|
+
then: ()=>{
|
|
29
|
+
return {
|
|
30
|
+
identifier: o[0],
|
|
31
|
+
concrete: o[0],
|
|
32
|
+
configuration: o[1]
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
else: (e)=>e
|
|
36
|
+
}))();
|
|
37
|
+
return s();
|
|
38
|
+
};
|
|
39
|
+
const s = (e)=>{
|
|
40
|
+
return {
|
|
41
|
+
identifier: e[0],
|
|
42
|
+
concrete: e[1],
|
|
43
|
+
configuration: e[2]
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
const resolveInjectionTuple = (e)=>core.switchCase({
|
|
47
|
+
1: ()=>i(e),
|
|
48
|
+
2: ()=>c(e),
|
|
49
|
+
3: ()=>s(e)
|
|
50
|
+
}, ()=>{
|
|
51
|
+
throw new Error(`Injection tuple must be of length 1, 2 or 3.`);
|
|
52
|
+
})(e.length);
|
|
53
|
+
|
|
54
|
+
exports.resolveInjectionTuple = resolveInjectionTuple;
|
package/dist/index43.mjs
CHANGED
|
@@ -1,29 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
resolve(t, e) {
|
|
3
|
-
const n = t.identifier;
|
|
4
|
-
if (this.cache.has(n)) {
|
|
5
|
-
return this.cache.get(n);
|
|
6
|
-
}
|
|
7
|
-
const o = t.build(e);
|
|
8
|
-
const r = e ? {
|
|
9
|
-
...t.configuration,
|
|
10
|
-
...e
|
|
11
|
-
} : t.configuration;
|
|
12
|
-
t.setSingletonInstance(o, r);
|
|
13
|
-
this.cache.set(n, o);
|
|
14
|
-
t.privateContext.prepareInitHook(o, t.configuration);
|
|
15
|
-
return o;
|
|
16
|
-
}
|
|
17
|
-
constructor(){
|
|
18
|
-
this.cache = new Map();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
class TransientStrategy {
|
|
22
|
-
resolve(t, e) {
|
|
23
|
-
const n = t.build(e);
|
|
24
|
-
t.privateContext.prepareInitHook(n, t.configuration);
|
|
25
|
-
return n;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
1
|
+
import { switchCase, pipe, conditionally, isClass, isObject } from '@assemblerjs/core';
|
|
28
2
|
|
|
29
|
-
|
|
3
|
+
const i = (e)=>{
|
|
4
|
+
return {
|
|
5
|
+
identifier: e[0],
|
|
6
|
+
concrete: e[0],
|
|
7
|
+
configuration: {}
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
const c = (o)=>{
|
|
11
|
+
const i = ()=>isClass(o[0]) && isClass(o[1]);
|
|
12
|
+
const c = ()=>isClass(o[0]) && isObject(o[1]);
|
|
13
|
+
const s = ()=>pipe(conditionally({
|
|
14
|
+
if: ()=>i(),
|
|
15
|
+
then: ()=>{
|
|
16
|
+
return {
|
|
17
|
+
identifier: o[0],
|
|
18
|
+
concrete: o[1],
|
|
19
|
+
configuration: {}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}), conditionally({
|
|
23
|
+
if: ()=>c(),
|
|
24
|
+
then: ()=>{
|
|
25
|
+
return {
|
|
26
|
+
identifier: o[0],
|
|
27
|
+
concrete: o[0],
|
|
28
|
+
configuration: o[1]
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
else: (e)=>e
|
|
32
|
+
}))();
|
|
33
|
+
return s();
|
|
34
|
+
};
|
|
35
|
+
const s = (e)=>{
|
|
36
|
+
return {
|
|
37
|
+
identifier: e[0],
|
|
38
|
+
concrete: e[1],
|
|
39
|
+
configuration: e[2]
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
const resolveInjectionTuple = (e)=>switchCase({
|
|
43
|
+
1: ()=>i(e),
|
|
44
|
+
2: ()=>c(e),
|
|
45
|
+
3: ()=>s(e)
|
|
46
|
+
}, ()=>{
|
|
47
|
+
throw new Error(`Injection tuple must be of length 1, 2 or 3.`);
|
|
48
|
+
})(e.length);
|
|
49
|
+
|
|
50
|
+
export { resolveInjectionTuple };
|
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.8",
|
|
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",
|