assemblerjs 1.1.27 → 1.2.0
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/README.md +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index13.js +1 -1
- package/dist/index13.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 +60 -47
- package/dist/index31.mjs +60 -47
- package/dist/index32.js +35 -158
- package/dist/index32.mjs +34 -157
- package/dist/index33.js +150 -37
- package/dist/index33.mjs +149 -37
- package/dist/index34.js +41 -70
- package/dist/index34.mjs +41 -70
- package/dist/index35.js +73 -49
- package/dist/index35.mjs +73 -49
- package/dist/index36.js +53 -29
- package/dist/index36.mjs +53 -29
- package/dist/index37.js +26 -208
- package/dist/index37.mjs +26 -208
- package/dist/index38.js +198 -48
- package/dist/index38.mjs +198 -48
- package/dist/index39.js +57 -24
- package/dist/index39.mjs +57 -24
- package/dist/index4.js +7 -7
- package/dist/index4.mjs +7 -7
- package/dist/index41.js +24 -36
- package/dist/index41.mjs +24 -35
- package/dist/index45.js +4 -4
- package/dist/index45.mjs +4 -4
- package/dist/index50.js +1 -1
- package/dist/index50.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -83,7 +83,7 @@ class Logger implements AbstractAssemblage {
|
|
|
83
83
|
|
|
84
84
|
// Define an application that depends on Logger
|
|
85
85
|
@Assemblage({
|
|
86
|
-
|
|
86
|
+
provide: [[Logger]], // Declare dependencies
|
|
87
87
|
})
|
|
88
88
|
class App implements AbstractAssemblage {
|
|
89
89
|
constructor(private logger: Logger) {}
|
package/dist/index.d.ts
CHANGED
|
@@ -299,7 +299,11 @@ export declare const Assemblage: <T>(definition?: AssemblageDefinition) => Class
|
|
|
299
299
|
export declare interface AssemblageDefinition {
|
|
300
300
|
singleton?: boolean;
|
|
301
301
|
events?: string[];
|
|
302
|
+
/**
|
|
303
|
+
* @deprecated Use 'provide' instead. This option will be removed in a future version.
|
|
304
|
+
*/
|
|
302
305
|
inject?: Injection<unknown>[];
|
|
306
|
+
provide?: Injection<unknown>[];
|
|
303
307
|
use?: InstanceInjection<unknown>[];
|
|
304
308
|
engage?: TransversalInjection<unknown>[];
|
|
305
309
|
tags?: string | string[];
|
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('./index31.js');
|
|
9
9
|
|
package/dist/index13.mjs
CHANGED
package/dist/index23.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const reflection = require('./index30.js');
|
|
6
|
-
const debugLogger = require('./
|
|
6
|
+
const debugLogger = require('./index38.js');
|
|
7
7
|
const parameterDecoratorFactory = require('./index18.js');
|
|
8
8
|
const helpers = require('./index26.js');
|
|
9
9
|
const resolverStore = require('./index40.js');
|
package/dist/index23.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getOwnCustomMetadata } from './index30.mjs';
|
|
2
|
-
import { DebugLogger } from './
|
|
2
|
+
import { DebugLogger } from './index38.mjs';
|
|
3
3
|
import { ParameterDecoratorFactory } from './index18.mjs';
|
|
4
4
|
import { getParamValueKey } from './index26.mjs';
|
|
5
5
|
import { ResolverStore } from './index40.mjs';
|
package/dist/index24.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const reflection = require('./index30.js');
|
|
6
|
-
const debugLogger = require('./
|
|
6
|
+
const debugLogger = require('./index38.js');
|
|
7
7
|
const parameterDecoratorFactory = require('./index18.js');
|
|
8
8
|
const helpers = require('./index26.js');
|
|
9
9
|
const resolverStore = require('./index40.js');
|
package/dist/index24.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getOwnCustomMetadata } from './index30.mjs';
|
|
2
|
-
import { DebugLogger } from './
|
|
2
|
+
import { DebugLogger } from './index38.mjs';
|
|
3
3
|
import { ParameterDecoratorFactory } from './index18.mjs';
|
|
4
4
|
import { getParamValueKey } from './index26.mjs';
|
|
5
5
|
import { ResolverStore } from './index40.mjs';
|
package/dist/index31.js
CHANGED
|
@@ -6,106 +6,119 @@ const constants = require('./index29.js');
|
|
|
6
6
|
const reflection = require('./index30.js');
|
|
7
7
|
const helpers = require('./index3.js');
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const o = {
|
|
10
10
|
singleton: {
|
|
11
|
-
test: (
|
|
11
|
+
test: (e)=>typeof e === 'boolean' || typeof e === 'undefined',
|
|
12
12
|
throw: ()=>{
|
|
13
13
|
throw new Error(`'singleton' property must be of type 'boolean' or 'undefined'.`);
|
|
14
14
|
},
|
|
15
|
-
transform: (
|
|
16
|
-
return typeof
|
|
15
|
+
transform: (e)=>{
|
|
16
|
+
return typeof e === 'undefined' ? true : e ? true : false;
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
events: {
|
|
20
|
-
test: (
|
|
20
|
+
test: (e)=>typeof e === 'undefined' || Array.isArray(e) && e.every((e)=>typeof e === 'string'),
|
|
21
21
|
throw: ()=>{
|
|
22
22
|
throw new Error(`'events' property must be an array of strings or 'undefined'.`);
|
|
23
23
|
},
|
|
24
|
-
transform: (
|
|
24
|
+
transform: (e)=>e
|
|
25
25
|
},
|
|
26
26
|
inject: {
|
|
27
|
-
test: (
|
|
27
|
+
test: (e)=>typeof e === 'undefined' || Array.isArray(e) && e.every((e)=>Array.isArray(e) && e.length >= 1 && e.length <= 3),
|
|
28
28
|
throw: ()=>{
|
|
29
29
|
throw new Error(`'inject' property must be an array of tuples of length 1, 2 or 3.`);
|
|
30
30
|
},
|
|
31
|
-
transform: (
|
|
31
|
+
transform: (e)=>e
|
|
32
|
+
},
|
|
33
|
+
provide: {
|
|
34
|
+
test: (e)=>typeof e === 'undefined' || Array.isArray(e) && e.every((e)=>Array.isArray(e) && e.length >= 1 && e.length <= 3),
|
|
35
|
+
throw: ()=>{
|
|
36
|
+
throw new Error(`'provide' property must be an array of tuples of length 1, 2 or 3.`);
|
|
37
|
+
},
|
|
38
|
+
transform: (e)=>e
|
|
32
39
|
},
|
|
33
40
|
use: {
|
|
34
|
-
test: (
|
|
35
|
-
if (!Array.isArray(
|
|
41
|
+
test: (e)=>typeof e === 'undefined' || Array.isArray(e) && e.every((e)=>{
|
|
42
|
+
if (!Array.isArray(e) || e.length !== 2) {
|
|
36
43
|
return false;
|
|
37
44
|
}
|
|
38
|
-
const
|
|
39
|
-
return typeof
|
|
45
|
+
const r = e[1];
|
|
46
|
+
return typeof r !== 'undefined';
|
|
40
47
|
}),
|
|
41
48
|
throw: ()=>{
|
|
42
49
|
throw new Error(`'use' property must be an array of tuples of length 2 with [identifier, instance | factory].`);
|
|
43
50
|
},
|
|
44
|
-
transform: (
|
|
51
|
+
transform: (e)=>e
|
|
45
52
|
},
|
|
46
53
|
engage: {
|
|
47
|
-
test: (
|
|
54
|
+
test: (e)=>typeof e === 'undefined' || Array.isArray(e) && e.every((e)=>Array.isArray(e) && e.length >= 1 && e.length <= 3),
|
|
48
55
|
throw: ()=>{
|
|
49
56
|
throw new Error(`'engage' property must be an array of tuples of length 1, 2 or 3.`);
|
|
50
57
|
},
|
|
51
|
-
transform: (
|
|
58
|
+
transform: (e)=>e
|
|
52
59
|
},
|
|
53
60
|
tags: {
|
|
54
|
-
test: (
|
|
61
|
+
test: (e)=>typeof e === 'undefined' || typeof e === 'string' || Array.isArray(e) && e.every((e)=>typeof e === 'string'),
|
|
55
62
|
throw: ()=>{
|
|
56
63
|
throw new Error(`'tags' property must be a string or an array of strings.`);
|
|
57
64
|
},
|
|
58
|
-
transform: (
|
|
59
|
-
|
|
60
|
-
] :
|
|
65
|
+
transform: (e)=>typeof e === 'string' ? [
|
|
66
|
+
e
|
|
67
|
+
] : e
|
|
61
68
|
},
|
|
62
69
|
metadata: {
|
|
63
|
-
test: (
|
|
70
|
+
test: (e)=>(typeof e === 'object' || typeof e === 'undefined') && !Array.isArray(e),
|
|
64
71
|
throw: ()=>{
|
|
65
72
|
throw new Error(`'metadata' property must be of type 'object' or 'undefined'.`);
|
|
66
73
|
},
|
|
67
|
-
transform: (
|
|
74
|
+
transform: (e)=>e
|
|
68
75
|
},
|
|
69
76
|
global: {
|
|
70
|
-
test: (
|
|
77
|
+
test: (e)=>(typeof e === 'object' || typeof e === 'undefined') && !Array.isArray(e),
|
|
71
78
|
throw: ()=>{
|
|
72
79
|
throw new Error(`'global' property must be of type 'object' or 'undefined'.`);
|
|
73
80
|
},
|
|
74
|
-
transform: (
|
|
81
|
+
transform: (e)=>e
|
|
75
82
|
}
|
|
76
83
|
};
|
|
77
|
-
const validateDefinition = (
|
|
78
|
-
const
|
|
79
|
-
...
|
|
84
|
+
const validateDefinition = (e)=>{
|
|
85
|
+
const r = {
|
|
86
|
+
...e
|
|
80
87
|
};
|
|
81
|
-
for(const
|
|
82
|
-
if (!Object.keys(
|
|
83
|
-
throw new Error(`Property '${
|
|
88
|
+
for(const e in r){
|
|
89
|
+
if (!Object.keys(o).includes(e)) {
|
|
90
|
+
throw new Error(`Property '${e}' is not a valid assemblage definition property.`);
|
|
84
91
|
}
|
|
85
92
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
if (r.inject !== undefined && r.provide === undefined) {
|
|
94
|
+
console.warn(`⚠️ Deprecation Warning: The 'inject' option is deprecated and will be removed in a future version. Please use 'provide' instead.`);
|
|
95
|
+
}
|
|
96
|
+
if (r.inject !== undefined && r.provide !== undefined) {
|
|
97
|
+
console.warn(`⚠️ Warning: Both 'inject' and 'provide' options found. Using 'provide' (inject is deprecated).`);
|
|
98
|
+
}
|
|
99
|
+
for(const e in o){
|
|
100
|
+
const t = o[e].test;
|
|
101
|
+
const n = o[e].throw;
|
|
102
|
+
const i = o[e].transform;
|
|
103
|
+
if (!t(r[e])) {
|
|
104
|
+
n();
|
|
92
105
|
}
|
|
93
|
-
e
|
|
106
|
+
r[e] = i(r[e]);
|
|
94
107
|
}
|
|
95
|
-
return
|
|
108
|
+
return r;
|
|
96
109
|
};
|
|
97
|
-
const getDefinition = (
|
|
98
|
-
if (!helpers.isAssemblage(
|
|
99
|
-
throw new Error(`Class '${
|
|
110
|
+
const getDefinition = (r)=>{
|
|
111
|
+
if (!helpers.isAssemblage(r)) {
|
|
112
|
+
throw new Error(`Class '${r.name}' is not an assemblage or transversal.`);
|
|
100
113
|
}
|
|
101
|
-
return reflection.getOwnCustomMetadata(constants.ReflectValue.AssemblageDefinition,
|
|
114
|
+
return reflection.getOwnCustomMetadata(constants.ReflectValue.AssemblageDefinition, r);
|
|
102
115
|
};
|
|
103
|
-
const setDefinitionValue = (t,
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
reflection.defineCustomMetadata(constants.ReflectValue.AssemblageDefinition,
|
|
108
|
-
return
|
|
116
|
+
const setDefinitionValue = (t, n, o)=>{
|
|
117
|
+
const i = getDefinition(o);
|
|
118
|
+
i[t] = n;
|
|
119
|
+
const s = validateDefinition(i);
|
|
120
|
+
reflection.defineCustomMetadata(constants.ReflectValue.AssemblageDefinition, s, o);
|
|
121
|
+
return s;
|
|
109
122
|
};
|
|
110
123
|
|
|
111
124
|
exports.getDefinition = getDefinition;
|
package/dist/index31.mjs
CHANGED
|
@@ -2,106 +2,119 @@ import { ReflectValue } from './index29.mjs';
|
|
|
2
2
|
import { getOwnCustomMetadata, defineCustomMetadata } from './index30.mjs';
|
|
3
3
|
import { isAssemblage } from './index3.mjs';
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const o = {
|
|
6
6
|
singleton: {
|
|
7
|
-
test: (
|
|
7
|
+
test: (e)=>typeof e === 'boolean' || typeof e === 'undefined',
|
|
8
8
|
throw: ()=>{
|
|
9
9
|
throw new Error(`'singleton' property must be of type 'boolean' or 'undefined'.`);
|
|
10
10
|
},
|
|
11
|
-
transform: (
|
|
12
|
-
return typeof
|
|
11
|
+
transform: (e)=>{
|
|
12
|
+
return typeof e === 'undefined' ? true : e ? true : false;
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
events: {
|
|
16
|
-
test: (
|
|
16
|
+
test: (e)=>typeof e === 'undefined' || Array.isArray(e) && e.every((e)=>typeof e === 'string'),
|
|
17
17
|
throw: ()=>{
|
|
18
18
|
throw new Error(`'events' property must be an array of strings or 'undefined'.`);
|
|
19
19
|
},
|
|
20
|
-
transform: (
|
|
20
|
+
transform: (e)=>e
|
|
21
21
|
},
|
|
22
22
|
inject: {
|
|
23
|
-
test: (
|
|
23
|
+
test: (e)=>typeof e === 'undefined' || Array.isArray(e) && e.every((e)=>Array.isArray(e) && e.length >= 1 && e.length <= 3),
|
|
24
24
|
throw: ()=>{
|
|
25
25
|
throw new Error(`'inject' property must be an array of tuples of length 1, 2 or 3.`);
|
|
26
26
|
},
|
|
27
|
-
transform: (
|
|
27
|
+
transform: (e)=>e
|
|
28
|
+
},
|
|
29
|
+
provide: {
|
|
30
|
+
test: (e)=>typeof e === 'undefined' || Array.isArray(e) && e.every((e)=>Array.isArray(e) && e.length >= 1 && e.length <= 3),
|
|
31
|
+
throw: ()=>{
|
|
32
|
+
throw new Error(`'provide' property must be an array of tuples of length 1, 2 or 3.`);
|
|
33
|
+
},
|
|
34
|
+
transform: (e)=>e
|
|
28
35
|
},
|
|
29
36
|
use: {
|
|
30
|
-
test: (
|
|
31
|
-
if (!Array.isArray(
|
|
37
|
+
test: (e)=>typeof e === 'undefined' || Array.isArray(e) && e.every((e)=>{
|
|
38
|
+
if (!Array.isArray(e) || e.length !== 2) {
|
|
32
39
|
return false;
|
|
33
40
|
}
|
|
34
|
-
const
|
|
35
|
-
return typeof
|
|
41
|
+
const r = e[1];
|
|
42
|
+
return typeof r !== 'undefined';
|
|
36
43
|
}),
|
|
37
44
|
throw: ()=>{
|
|
38
45
|
throw new Error(`'use' property must be an array of tuples of length 2 with [identifier, instance | factory].`);
|
|
39
46
|
},
|
|
40
|
-
transform: (
|
|
47
|
+
transform: (e)=>e
|
|
41
48
|
},
|
|
42
49
|
engage: {
|
|
43
|
-
test: (
|
|
50
|
+
test: (e)=>typeof e === 'undefined' || Array.isArray(e) && e.every((e)=>Array.isArray(e) && e.length >= 1 && e.length <= 3),
|
|
44
51
|
throw: ()=>{
|
|
45
52
|
throw new Error(`'engage' property must be an array of tuples of length 1, 2 or 3.`);
|
|
46
53
|
},
|
|
47
|
-
transform: (
|
|
54
|
+
transform: (e)=>e
|
|
48
55
|
},
|
|
49
56
|
tags: {
|
|
50
|
-
test: (
|
|
57
|
+
test: (e)=>typeof e === 'undefined' || typeof e === 'string' || Array.isArray(e) && e.every((e)=>typeof e === 'string'),
|
|
51
58
|
throw: ()=>{
|
|
52
59
|
throw new Error(`'tags' property must be a string or an array of strings.`);
|
|
53
60
|
},
|
|
54
|
-
transform: (
|
|
55
|
-
|
|
56
|
-
] :
|
|
61
|
+
transform: (e)=>typeof e === 'string' ? [
|
|
62
|
+
e
|
|
63
|
+
] : e
|
|
57
64
|
},
|
|
58
65
|
metadata: {
|
|
59
|
-
test: (
|
|
66
|
+
test: (e)=>(typeof e === 'object' || typeof e === 'undefined') && !Array.isArray(e),
|
|
60
67
|
throw: ()=>{
|
|
61
68
|
throw new Error(`'metadata' property must be of type 'object' or 'undefined'.`);
|
|
62
69
|
},
|
|
63
|
-
transform: (
|
|
70
|
+
transform: (e)=>e
|
|
64
71
|
},
|
|
65
72
|
global: {
|
|
66
|
-
test: (
|
|
73
|
+
test: (e)=>(typeof e === 'object' || typeof e === 'undefined') && !Array.isArray(e),
|
|
67
74
|
throw: ()=>{
|
|
68
75
|
throw new Error(`'global' property must be of type 'object' or 'undefined'.`);
|
|
69
76
|
},
|
|
70
|
-
transform: (
|
|
77
|
+
transform: (e)=>e
|
|
71
78
|
}
|
|
72
79
|
};
|
|
73
|
-
const validateDefinition = (
|
|
74
|
-
const
|
|
75
|
-
...
|
|
80
|
+
const validateDefinition = (e)=>{
|
|
81
|
+
const r = {
|
|
82
|
+
...e
|
|
76
83
|
};
|
|
77
|
-
for(const
|
|
78
|
-
if (!Object.keys(
|
|
79
|
-
throw new Error(`Property '${
|
|
84
|
+
for(const e in r){
|
|
85
|
+
if (!Object.keys(o).includes(e)) {
|
|
86
|
+
throw new Error(`Property '${e}' is not a valid assemblage definition property.`);
|
|
80
87
|
}
|
|
81
88
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
if (r.inject !== undefined && r.provide === undefined) {
|
|
90
|
+
console.warn(`⚠️ Deprecation Warning: The 'inject' option is deprecated and will be removed in a future version. Please use 'provide' instead.`);
|
|
91
|
+
}
|
|
92
|
+
if (r.inject !== undefined && r.provide !== undefined) {
|
|
93
|
+
console.warn(`⚠️ Warning: Both 'inject' and 'provide' options found. Using 'provide' (inject is deprecated).`);
|
|
94
|
+
}
|
|
95
|
+
for(const e in o){
|
|
96
|
+
const t = o[e].test;
|
|
97
|
+
const n = o[e].throw;
|
|
98
|
+
const i = o[e].transform;
|
|
99
|
+
if (!t(r[e])) {
|
|
100
|
+
n();
|
|
88
101
|
}
|
|
89
|
-
e
|
|
102
|
+
r[e] = i(r[e]);
|
|
90
103
|
}
|
|
91
|
-
return
|
|
104
|
+
return r;
|
|
92
105
|
};
|
|
93
|
-
const getDefinition = (
|
|
94
|
-
if (!isAssemblage(
|
|
95
|
-
throw new Error(`Class '${
|
|
106
|
+
const getDefinition = (r)=>{
|
|
107
|
+
if (!isAssemblage(r)) {
|
|
108
|
+
throw new Error(`Class '${r.name}' is not an assemblage or transversal.`);
|
|
96
109
|
}
|
|
97
|
-
return getOwnCustomMetadata(ReflectValue.AssemblageDefinition,
|
|
110
|
+
return getOwnCustomMetadata(ReflectValue.AssemblageDefinition, r);
|
|
98
111
|
};
|
|
99
|
-
const setDefinitionValue = (t,
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
defineCustomMetadata(ReflectValue.AssemblageDefinition,
|
|
104
|
-
return
|
|
112
|
+
const setDefinitionValue = (t, n, o)=>{
|
|
113
|
+
const i = getDefinition(o);
|
|
114
|
+
i[t] = n;
|
|
115
|
+
const s = validateDefinition(i);
|
|
116
|
+
defineCustomMetadata(ReflectValue.AssemblageDefinition, s, o);
|
|
117
|
+
return s;
|
|
105
118
|
};
|
|
106
119
|
|
|
107
120
|
export { getDefinition, setDefinitionValue, validateDefinition };
|
package/dist/index32.js
CHANGED
|
@@ -2,168 +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('./index37.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 a(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 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,
|
|
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(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
|
-
const r = debugLogger.DebugLogger.getInstance();
|
|
87
|
-
const i = formatIdentifier(e);
|
|
88
|
-
const o = n ? formatIdentifier(n) : undefined;
|
|
89
|
-
r.logDependencyStart(i, o);
|
|
90
|
-
if (!this.injectables.has(e)) {
|
|
91
|
-
const o = this.resolvingStack.has(e);
|
|
92
|
-
const s = o ? 'Circular dependency detected' : 'Dependency not registered';
|
|
93
|
-
const c = a(e);
|
|
94
|
-
const f = t?.__paramIndex;
|
|
95
|
-
const u = t?.__paramCount;
|
|
96
|
-
const l = t?.__expectedType;
|
|
97
|
-
const d = o ? `Circular dependency detected: '${i}' is already being resolved.` : `Dependency '${i}' has not been registered (Class/Service not found in current assemblages).`;
|
|
98
|
-
const g = {
|
|
99
|
-
identifier: i,
|
|
100
|
-
caller: n ? formatIdentifier(n) : 'unknown',
|
|
101
|
-
type: c,
|
|
102
|
-
error: d
|
|
103
|
-
};
|
|
104
|
-
if (f !== undefined) {
|
|
105
|
-
g.paramIndex = f;
|
|
106
|
-
}
|
|
107
|
-
if (u !== undefined) {
|
|
108
|
-
g.paramCount = u;
|
|
109
|
-
}
|
|
110
|
-
if (l !== undefined) {
|
|
111
|
-
const e = l?.name || formatIdentifier(l);
|
|
112
|
-
g.expectedType = e;
|
|
113
|
-
}
|
|
114
|
-
r.log('error', s, g);
|
|
115
|
-
r.logDependencyEnd(i);
|
|
116
|
-
throw new Error(d);
|
|
117
20
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const t = [];
|
|
138
|
-
for (const n of e){
|
|
139
|
-
for (const [e, r] of this.injectables){
|
|
140
|
-
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);
|
|
141
40
|
}
|
|
142
41
|
}
|
|
143
|
-
return t;
|
|
144
|
-
}
|
|
145
|
-
dispose() {
|
|
146
|
-
for (const [e, t] of this.injectables){
|
|
147
|
-
t.dispose();
|
|
148
|
-
}
|
|
149
|
-
this.resolvingStack.clear();
|
|
150
|
-
}
|
|
151
|
-
get size() {
|
|
152
|
-
return this.injectables.size;
|
|
153
|
-
}
|
|
154
|
-
getRegisteredIdentifiers() {
|
|
155
|
-
return Array.from(this.injectables.keys()).map((e)=>e?.name || String(e));
|
|
156
|
-
}
|
|
157
|
-
getInjectables() {
|
|
158
|
-
return this.injectables;
|
|
159
|
-
}
|
|
160
|
-
constructor(){
|
|
161
|
-
this.injectables = new Map();
|
|
162
|
-
this.resolvingStack = new Set();
|
|
163
|
-
this.singletonStrategy = new resolutionStrategies.SingletonStrategy();
|
|
164
|
-
this.transientStrategy = new resolutionStrategies.TransientStrategy();
|
|
165
42
|
}
|
|
166
|
-
}
|
|
43
|
+
};
|
|
167
44
|
|
|
168
|
-
exports.
|
|
169
|
-
exports.
|
|
45
|
+
exports.registerEvents = registerEvents;
|
|
46
|
+
exports.unregisterEvents = unregisterEvents;
|