assemblerjs 0.9.6 → 1.0.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 +220 -56
- package/dist/index.d.ts +701 -464
- package/dist/index.js +59 -1
- package/dist/index.mjs +21 -916
- package/dist/index10.js +8 -0
- package/dist/index10.mjs +4 -0
- package/dist/index11.js +27 -0
- package/dist/index11.mjs +23 -0
- package/dist/index12.js +16 -0
- package/dist/index12.mjs +12 -0
- package/dist/index13.js +94 -0
- package/dist/index13.mjs +90 -0
- package/dist/index14.js +22 -0
- package/dist/index14.mjs +18 -0
- package/dist/index15.js +22 -0
- package/dist/index15.mjs +18 -0
- package/dist/index16.js +22 -0
- package/dist/index16.mjs +18 -0
- package/dist/index17.js +22 -0
- package/dist/index17.mjs +18 -0
- package/dist/index18.js +31 -0
- package/dist/index18.mjs +26 -0
- package/dist/index19.js +31 -0
- package/dist/index19.mjs +26 -0
- package/dist/index2.js +22 -0
- package/dist/index2.mjs +17 -0
- package/dist/index20.js +31 -0
- package/dist/index20.mjs +27 -0
- package/dist/index21.js +33 -0
- package/dist/index21.mjs +25 -0
- package/dist/index22.js +53 -0
- package/dist/index22.mjs +48 -0
- package/dist/index23.js +69 -0
- package/dist/index23.mjs +65 -0
- package/dist/index24.js +37 -0
- package/dist/index24.mjs +33 -0
- package/dist/index25.js +71 -0
- package/dist/index25.mjs +67 -0
- package/dist/index26.js +37 -0
- package/dist/index26.mjs +33 -0
- package/dist/index27.js +37 -0
- package/dist/index27.mjs +33 -0
- package/dist/index28.js +46 -0
- package/dist/index28.mjs +41 -0
- package/dist/index29.js +20 -0
- package/dist/index29.mjs +14 -0
- package/dist/index3.js +20 -0
- package/dist/index3.mjs +14 -0
- package/dist/index30.js +19 -0
- package/dist/index30.mjs +13 -0
- package/dist/index31.js +100 -0
- package/dist/index31.mjs +94 -0
- package/dist/index32.js +28 -0
- package/dist/index32.mjs +24 -0
- package/dist/index33.js +34 -0
- package/dist/index33.mjs +29 -0
- package/dist/index34.js +14 -0
- package/dist/index34.mjs +10 -0
- package/dist/index35.js +54 -0
- package/dist/index35.mjs +50 -0
- package/dist/index36.js +117 -0
- package/dist/index36.mjs +113 -0
- package/dist/index37.js +19 -0
- package/dist/index37.mjs +15 -0
- package/dist/index38.js +31 -0
- package/dist/index38.mjs +27 -0
- package/dist/index39.js +55 -0
- package/dist/index39.mjs +50 -0
- package/dist/index4.js +81 -0
- package/dist/index4.mjs +77 -0
- package/dist/index5.js +94 -0
- package/dist/index5.mjs +90 -0
- package/dist/index6.js +114 -0
- package/dist/index6.mjs +110 -0
- package/dist/index7.js +9 -0
- package/dist/index7.mjs +5 -0
- package/dist/index8.js +10 -0
- package/dist/index8.mjs +6 -0
- package/dist/index9.js +8 -0
- package/dist/index9.mjs +4 -0
- package/package.json +8 -5
package/dist/index28.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const eventManager = require('./index6.js');
|
|
6
|
+
|
|
7
|
+
const registerEvents = (t, n)=>{
|
|
8
|
+
const o = 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);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const unregisterEvents = (t, n)=>{
|
|
28
|
+
const o = 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
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
exports.registerEvents = registerEvents;
|
|
46
|
+
exports.unregisterEvents = unregisterEvents;
|
package/dist/index28.mjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { EventManager } from './index6.mjs';
|
|
2
|
+
|
|
3
|
+
const registerEvents = (t, n)=>{
|
|
4
|
+
const o = 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);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const unregisterEvents = (t, n)=>{
|
|
24
|
+
const o = 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
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { registerEvents, unregisterEvents };
|
package/dist/index29.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const ReflectParamTypes = 'design:paramtypes';
|
|
6
|
+
const ReflectPrefix = '__';
|
|
7
|
+
const ReflectSuffix = '__';
|
|
8
|
+
exports.ReflectFlags = void 0;
|
|
9
|
+
(function(e) {
|
|
10
|
+
e["IsAssemblage"] = "is_assemblage";
|
|
11
|
+
})(exports.ReflectFlags || (exports.ReflectFlags = {}));
|
|
12
|
+
exports.ReflectValue = void 0;
|
|
13
|
+
(function(e) {
|
|
14
|
+
e["AssemblageDefinition"] = "assemblage:definition.value";
|
|
15
|
+
e["AssemblageContext"] = "assemblage:context.value";
|
|
16
|
+
})(exports.ReflectValue || (exports.ReflectValue = {}));
|
|
17
|
+
|
|
18
|
+
exports.ReflectParamTypes = ReflectParamTypes;
|
|
19
|
+
exports.ReflectPrefix = ReflectPrefix;
|
|
20
|
+
exports.ReflectSuffix = ReflectSuffix;
|
package/dist/index29.mjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const ReflectParamTypes = 'design:paramtypes';
|
|
2
|
+
const ReflectPrefix = '__';
|
|
3
|
+
const ReflectSuffix = '__';
|
|
4
|
+
var ReflectFlags;
|
|
5
|
+
(function(e) {
|
|
6
|
+
e["IsAssemblage"] = "is_assemblage";
|
|
7
|
+
})(ReflectFlags || (ReflectFlags = {}));
|
|
8
|
+
var ReflectValue;
|
|
9
|
+
(function(e) {
|
|
10
|
+
e["AssemblageDefinition"] = "assemblage:definition.value";
|
|
11
|
+
e["AssemblageContext"] = "assemblage:context.value";
|
|
12
|
+
})(ReflectValue || (ReflectValue = {}));
|
|
13
|
+
|
|
14
|
+
export { ReflectFlags, ReflectParamTypes, ReflectPrefix, ReflectSuffix, ReflectValue };
|
package/dist/index3.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const constants = require('./index29.js');
|
|
6
|
+
const reflection = require('./index30.js');
|
|
7
|
+
|
|
8
|
+
const isAssemblage = (s)=>{
|
|
9
|
+
return reflection.getOwnCustomMetadata(constants.ReflectFlags.IsAssemblage, s) || false;
|
|
10
|
+
};
|
|
11
|
+
const getAssemblageDefinition = (e)=>{
|
|
12
|
+
return reflection.getOwnCustomMetadata(constants.ReflectValue.AssemblageDefinition, e);
|
|
13
|
+
};
|
|
14
|
+
const getAssemblageContext = (e)=>{
|
|
15
|
+
return reflection.getOwnCustomMetadata(constants.ReflectValue.AssemblageContext, e);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.getAssemblageContext = getAssemblageContext;
|
|
19
|
+
exports.getAssemblageDefinition = getAssemblageDefinition;
|
|
20
|
+
exports.isAssemblage = isAssemblage;
|
package/dist/index3.mjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ReflectFlags, ReflectValue } from './index29.mjs';
|
|
2
|
+
import { getOwnCustomMetadata } from './index30.mjs';
|
|
3
|
+
|
|
4
|
+
const isAssemblage = (s)=>{
|
|
5
|
+
return getOwnCustomMetadata(ReflectFlags.IsAssemblage, s) || false;
|
|
6
|
+
};
|
|
7
|
+
const getAssemblageDefinition = (e)=>{
|
|
8
|
+
return getOwnCustomMetadata(ReflectValue.AssemblageDefinition, e);
|
|
9
|
+
};
|
|
10
|
+
const getAssemblageContext = (e)=>{
|
|
11
|
+
return getOwnCustomMetadata(ReflectValue.AssemblageContext, e);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { getAssemblageContext, getAssemblageDefinition, isAssemblage };
|
package/dist/index30.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const constants = require('./index29.js');
|
|
6
|
+
|
|
7
|
+
const defineCustomMetadata = (t, o, n)=>{
|
|
8
|
+
Reflect.defineMetadata(`${constants.ReflectPrefix}${t}${constants.ReflectSuffix}`, o, n);
|
|
9
|
+
};
|
|
10
|
+
const getOwnCustomMetadata = (t, o)=>{
|
|
11
|
+
return Reflect.getOwnMetadata(`${constants.ReflectPrefix}${t}${constants.ReflectSuffix}`, o);
|
|
12
|
+
};
|
|
13
|
+
const getParamTypes = (e)=>{
|
|
14
|
+
return Reflect.getMetadata(constants.ReflectParamTypes, e) || [];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
exports.defineCustomMetadata = defineCustomMetadata;
|
|
18
|
+
exports.getOwnCustomMetadata = getOwnCustomMetadata;
|
|
19
|
+
exports.getParamTypes = getParamTypes;
|
package/dist/index30.mjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReflectPrefix, ReflectSuffix, ReflectParamTypes } from './index29.mjs';
|
|
2
|
+
|
|
3
|
+
const defineCustomMetadata = (t, o, n)=>{
|
|
4
|
+
Reflect.defineMetadata(`${ReflectPrefix}${t}${ReflectSuffix}`, o, n);
|
|
5
|
+
};
|
|
6
|
+
const getOwnCustomMetadata = (t, o)=>{
|
|
7
|
+
return Reflect.getOwnMetadata(`${ReflectPrefix}${t}${ReflectSuffix}`, o);
|
|
8
|
+
};
|
|
9
|
+
const getParamTypes = (e)=>{
|
|
10
|
+
return Reflect.getMetadata(ReflectParamTypes, e) || [];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { defineCustomMetadata, getOwnCustomMetadata, getParamTypes };
|
package/dist/index31.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const constants = require('./index29.js');
|
|
6
|
+
const reflection = require('./index30.js');
|
|
7
|
+
const helpers = require('./index3.js');
|
|
8
|
+
|
|
9
|
+
const n = {
|
|
10
|
+
singleton: {
|
|
11
|
+
test: (r)=>typeof r === 'boolean' || typeof r === 'undefined',
|
|
12
|
+
throw: ()=>{
|
|
13
|
+
throw new Error(`'singleton' property must be of type 'boolean' or 'undefined'.`);
|
|
14
|
+
},
|
|
15
|
+
transform: (r)=>{
|
|
16
|
+
return typeof r === 'undefined' ? true : r ? true : false;
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
events: {
|
|
20
|
+
test: (r)=>typeof r === 'undefined' || Array.isArray(r) && r.every((r)=>typeof r === 'string'),
|
|
21
|
+
throw: ()=>{
|
|
22
|
+
throw new Error(`'events' property must be an array of strings or 'undefined'.`);
|
|
23
|
+
},
|
|
24
|
+
transform: (r)=>r
|
|
25
|
+
},
|
|
26
|
+
inject: {
|
|
27
|
+
test: (r)=>typeof r === 'undefined' || Array.isArray(r) && r.every((r)=>Array.isArray(r) && r.length >= 1 && r.length <= 3),
|
|
28
|
+
throw: ()=>{
|
|
29
|
+
throw new Error(`'inject' property must be an array of tuples of length 1, 2 or 3.`);
|
|
30
|
+
},
|
|
31
|
+
transform: (r)=>r
|
|
32
|
+
},
|
|
33
|
+
use: {
|
|
34
|
+
test: (r)=>typeof r === 'undefined' || Array.isArray(r) && r.every((r)=>Array.isArray(r) && r.length == 2),
|
|
35
|
+
throw: ()=>{
|
|
36
|
+
throw new Error(`'use' property must be an array of tuples of length 2.`);
|
|
37
|
+
},
|
|
38
|
+
transform: (r)=>r
|
|
39
|
+
},
|
|
40
|
+
tags: {
|
|
41
|
+
test: (r)=>typeof r === 'undefined' || typeof r === 'string' || Array.isArray(r) && r.every((r)=>typeof r === 'string'),
|
|
42
|
+
throw: ()=>{
|
|
43
|
+
throw new Error(`'tags' property must be a string or an array of strings.`);
|
|
44
|
+
},
|
|
45
|
+
transform: (r)=>typeof r === 'string' ? [
|
|
46
|
+
r
|
|
47
|
+
] : r
|
|
48
|
+
},
|
|
49
|
+
metadata: {
|
|
50
|
+
test: (r)=>(typeof r === 'object' || typeof r === 'undefined') && !Array.isArray(r),
|
|
51
|
+
throw: ()=>{
|
|
52
|
+
throw new Error(`'metadata' property must be of type 'object' or 'undefined'.`);
|
|
53
|
+
},
|
|
54
|
+
transform: (r)=>r
|
|
55
|
+
},
|
|
56
|
+
global: {
|
|
57
|
+
test: (r)=>(typeof r === 'object' || typeof r === 'undefined') && !Array.isArray(r),
|
|
58
|
+
throw: ()=>{
|
|
59
|
+
throw new Error(`'global' property must be of type 'object' or 'undefined'.`);
|
|
60
|
+
},
|
|
61
|
+
transform: (r)=>r
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const validateDefinition = (r)=>{
|
|
65
|
+
const e = {
|
|
66
|
+
...r
|
|
67
|
+
};
|
|
68
|
+
for(const r in e){
|
|
69
|
+
if (!Object.keys(n).includes(r)) {
|
|
70
|
+
throw new Error(`Property '${r}' is not a valid assemblage definition property.`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
for(const r in n){
|
|
74
|
+
const t = n[r].test;
|
|
75
|
+
const o = n[r].throw;
|
|
76
|
+
const s = n[r].transform;
|
|
77
|
+
if (!t(e[r])) {
|
|
78
|
+
o();
|
|
79
|
+
}
|
|
80
|
+
e[r] = s(e[r]);
|
|
81
|
+
}
|
|
82
|
+
return e;
|
|
83
|
+
};
|
|
84
|
+
const getDefinition = (e)=>{
|
|
85
|
+
if (!helpers.isAssemblage(e)) {
|
|
86
|
+
throw new Error(`Class '${e.name}' is not an assemblage.`);
|
|
87
|
+
}
|
|
88
|
+
return reflection.getOwnCustomMetadata(constants.ReflectValue.AssemblageDefinition, e);
|
|
89
|
+
};
|
|
90
|
+
const setDefinitionValue = (t, o, n)=>{
|
|
91
|
+
const s = getDefinition(n);
|
|
92
|
+
s[t] = o;
|
|
93
|
+
const i = validateDefinition(s);
|
|
94
|
+
reflection.defineCustomMetadata(constants.ReflectValue.AssemblageDefinition, i, n);
|
|
95
|
+
return i;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
exports.getDefinition = getDefinition;
|
|
99
|
+
exports.setDefinitionValue = setDefinitionValue;
|
|
100
|
+
exports.validateDefinition = validateDefinition;
|
package/dist/index31.mjs
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { ReflectValue } from './index29.mjs';
|
|
2
|
+
import { defineCustomMetadata, getOwnCustomMetadata } from './index30.mjs';
|
|
3
|
+
import { isAssemblage } from './index3.mjs';
|
|
4
|
+
|
|
5
|
+
const n = {
|
|
6
|
+
singleton: {
|
|
7
|
+
test: (r)=>typeof r === 'boolean' || typeof r === 'undefined',
|
|
8
|
+
throw: ()=>{
|
|
9
|
+
throw new Error(`'singleton' property must be of type 'boolean' or 'undefined'.`);
|
|
10
|
+
},
|
|
11
|
+
transform: (r)=>{
|
|
12
|
+
return typeof r === 'undefined' ? true : r ? true : false;
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
events: {
|
|
16
|
+
test: (r)=>typeof r === 'undefined' || Array.isArray(r) && r.every((r)=>typeof r === 'string'),
|
|
17
|
+
throw: ()=>{
|
|
18
|
+
throw new Error(`'events' property must be an array of strings or 'undefined'.`);
|
|
19
|
+
},
|
|
20
|
+
transform: (r)=>r
|
|
21
|
+
},
|
|
22
|
+
inject: {
|
|
23
|
+
test: (r)=>typeof r === 'undefined' || Array.isArray(r) && r.every((r)=>Array.isArray(r) && r.length >= 1 && r.length <= 3),
|
|
24
|
+
throw: ()=>{
|
|
25
|
+
throw new Error(`'inject' property must be an array of tuples of length 1, 2 or 3.`);
|
|
26
|
+
},
|
|
27
|
+
transform: (r)=>r
|
|
28
|
+
},
|
|
29
|
+
use: {
|
|
30
|
+
test: (r)=>typeof r === 'undefined' || Array.isArray(r) && r.every((r)=>Array.isArray(r) && r.length == 2),
|
|
31
|
+
throw: ()=>{
|
|
32
|
+
throw new Error(`'use' property must be an array of tuples of length 2.`);
|
|
33
|
+
},
|
|
34
|
+
transform: (r)=>r
|
|
35
|
+
},
|
|
36
|
+
tags: {
|
|
37
|
+
test: (r)=>typeof r === 'undefined' || typeof r === 'string' || Array.isArray(r) && r.every((r)=>typeof r === 'string'),
|
|
38
|
+
throw: ()=>{
|
|
39
|
+
throw new Error(`'tags' property must be a string or an array of strings.`);
|
|
40
|
+
},
|
|
41
|
+
transform: (r)=>typeof r === 'string' ? [
|
|
42
|
+
r
|
|
43
|
+
] : r
|
|
44
|
+
},
|
|
45
|
+
metadata: {
|
|
46
|
+
test: (r)=>(typeof r === 'object' || typeof r === 'undefined') && !Array.isArray(r),
|
|
47
|
+
throw: ()=>{
|
|
48
|
+
throw new Error(`'metadata' property must be of type 'object' or 'undefined'.`);
|
|
49
|
+
},
|
|
50
|
+
transform: (r)=>r
|
|
51
|
+
},
|
|
52
|
+
global: {
|
|
53
|
+
test: (r)=>(typeof r === 'object' || typeof r === 'undefined') && !Array.isArray(r),
|
|
54
|
+
throw: ()=>{
|
|
55
|
+
throw new Error(`'global' property must be of type 'object' or 'undefined'.`);
|
|
56
|
+
},
|
|
57
|
+
transform: (r)=>r
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const validateDefinition = (r)=>{
|
|
61
|
+
const e = {
|
|
62
|
+
...r
|
|
63
|
+
};
|
|
64
|
+
for(const r in e){
|
|
65
|
+
if (!Object.keys(n).includes(r)) {
|
|
66
|
+
throw new Error(`Property '${r}' is not a valid assemblage definition property.`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
for(const r in n){
|
|
70
|
+
const t = n[r].test;
|
|
71
|
+
const o = n[r].throw;
|
|
72
|
+
const s = n[r].transform;
|
|
73
|
+
if (!t(e[r])) {
|
|
74
|
+
o();
|
|
75
|
+
}
|
|
76
|
+
e[r] = s(e[r]);
|
|
77
|
+
}
|
|
78
|
+
return e;
|
|
79
|
+
};
|
|
80
|
+
const getDefinition = (e)=>{
|
|
81
|
+
if (!isAssemblage(e)) {
|
|
82
|
+
throw new Error(`Class '${e.name}' is not an assemblage.`);
|
|
83
|
+
}
|
|
84
|
+
return getOwnCustomMetadata(ReflectValue.AssemblageDefinition, e);
|
|
85
|
+
};
|
|
86
|
+
const setDefinitionValue = (t, o, n)=>{
|
|
87
|
+
const s = getDefinition(n);
|
|
88
|
+
s[t] = o;
|
|
89
|
+
const i = validateDefinition(s);
|
|
90
|
+
defineCustomMetadata(ReflectValue.AssemblageDefinition, i, n);
|
|
91
|
+
return i;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export { getDefinition, setDefinitionValue, validateDefinition };
|
package/dist/index32.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
class ResolverStore {
|
|
6
|
+
static register(e, r) {
|
|
7
|
+
this.resolvers.set(e, r);
|
|
8
|
+
}
|
|
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}`);
|
|
13
|
+
}
|
|
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
|
+
}
|
|
22
|
+
static clear() {
|
|
23
|
+
this.resolvers.clear();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
ResolverStore.resolvers = new Map();
|
|
27
|
+
|
|
28
|
+
exports.ResolverStore = ResolverStore;
|
package/dist/index32.mjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
class ResolverStore {
|
|
2
|
+
static register(e, r) {
|
|
3
|
+
this.resolvers.set(e, r);
|
|
4
|
+
}
|
|
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}`);
|
|
9
|
+
}
|
|
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
|
+
}
|
|
18
|
+
static clear() {
|
|
19
|
+
this.resolvers.clear();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
ResolverStore.resolvers = new Map();
|
|
23
|
+
|
|
24
|
+
export { ResolverStore };
|
package/dist/index33.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
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
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.SingletonStrategy = SingletonStrategy;
|
|
34
|
+
exports.TransientStrategy = TransientStrategy;
|
package/dist/index33.mjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
}
|
|
28
|
+
|
|
29
|
+
export { SingletonStrategy, TransientStrategy };
|
package/dist/index34.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const resolveInstanceInjectionTuple = (e)=>{
|
|
6
|
+
return {
|
|
7
|
+
identifier: e[0],
|
|
8
|
+
concrete: e[0],
|
|
9
|
+
instance: e[1],
|
|
10
|
+
configuration: {}
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.resolveInstanceInjectionTuple = resolveInstanceInjectionTuple;
|
package/dist/index34.mjs
ADDED
package/dist/index35.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const core = require('@assemblerjs/core');
|
|
6
|
+
|
|
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/index35.mjs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { switchCase, pipe, conditionally, isClass, isObject } from '@assemblerjs/core';
|
|
2
|
+
|
|
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 };
|