assemblerjs 1.0.1 → 1.1.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 +8 -5
- package/dist/index.d.ts +430 -9
- package/dist/index.js +24 -12
- package/dist/index.mjs +16 -12
- package/dist/index11.js +82 -20
- package/dist/index11.mjs +78 -20
- package/dist/index12.js +17 -8
- package/dist/index12.mjs +16 -8
- package/dist/index13.js +148 -73
- package/dist/index13.mjs +148 -73
- package/dist/index14.js +4 -17
- package/dist/index14.mjs +4 -17
- package/dist/index15.js +21 -16
- package/dist/index15.mjs +21 -16
- package/dist/index16.js +10 -16
- package/dist/index16.mjs +10 -16
- package/dist/index17.js +88 -16
- package/dist/index17.mjs +88 -16
- package/dist/index18.js +11 -20
- package/dist/index18.mjs +11 -19
- package/dist/index19.js +11 -20
- package/dist/index19.mjs +11 -19
- package/dist/index2.js +3 -3
- package/dist/index2.mjs +3 -3
- package/dist/index20.js +11 -20
- package/dist/index20.mjs +11 -20
- package/dist/index21.js +14 -25
- package/dist/index21.mjs +14 -21
- package/dist/index22.js +24 -46
- package/dist/index22.mjs +23 -45
- package/dist/index23.js +22 -37
- package/dist/index23.mjs +21 -36
- package/dist/index24.js +26 -15
- package/dist/index24.mjs +26 -13
- package/dist/index25.js +24 -10
- package/dist/index25.mjs +20 -8
- package/dist/index26.js +45 -92
- package/dist/index26.mjs +44 -90
- package/dist/index27.js +2 -66
- package/dist/index27.mjs +2 -64
- package/dist/index28.js +17 -32
- package/dist/index28.mjs +15 -32
- package/dist/index29.js +53 -55
- package/dist/index29.mjs +53 -55
- package/dist/index3.js +2 -2
- package/dist/index3.mjs +2 -2
- package/dist/index30.js +28 -28
- package/dist/index30.mjs +28 -28
- package/dist/index31.js +62 -28
- package/dist/index31.mjs +62 -28
- package/dist/index32.js +28 -19
- package/dist/index32.mjs +28 -19
- package/dist/index33.js +32 -49
- package/dist/index33.mjs +32 -49
- package/dist/index34.js +17 -8
- package/dist/index34.mjs +14 -8
- package/dist/index35.js +18 -24
- package/dist/index35.mjs +18 -23
- package/dist/index36.js +37 -108
- package/dist/index36.mjs +36 -108
- package/dist/index37.js +98 -10
- package/dist/index37.mjs +96 -10
- package/dist/index38.js +95 -20
- package/dist/index38.mjs +95 -20
- package/dist/index39.js +23 -44
- package/dist/index39.mjs +23 -43
- package/dist/index4.js +5 -5
- package/dist/index4.mjs +5 -5
- package/dist/index40.js +34 -0
- package/dist/index40.mjs +29 -0
- package/dist/index41.js +14 -0
- package/dist/index41.mjs +10 -0
- package/dist/index42.js +54 -0
- package/dist/index42.mjs +50 -0
- package/dist/index43.js +177 -0
- package/dist/index43.mjs +173 -0
- package/dist/index44.js +947 -0
- package/dist/index44.mjs +943 -0
- package/dist/index45.js +7 -0
- package/dist/index45.mjs +3 -0
- package/dist/index46.js +7 -0
- package/dist/index46.mjs +3 -0
- package/dist/index47.js +19 -0
- package/dist/index47.mjs +15 -0
- package/dist/index48.js +33 -0
- package/dist/index48.mjs +29 -0
- package/dist/index49.js +67 -0
- package/dist/index49.mjs +62 -0
- package/package.json +2 -2
package/dist/index45.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
6
|
+
|
|
7
|
+
exports.commonjsGlobal = commonjsGlobal;
|
package/dist/index45.mjs
ADDED
package/dist/index46.js
ADDED
package/dist/index46.mjs
ADDED
package/dist/index47.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const resolverStore = require('./index35.js');
|
|
6
|
+
|
|
7
|
+
class ParameterResolverFactory {
|
|
8
|
+
static getResolver(r) {
|
|
9
|
+
return resolverStore.ResolverStore.getResolver(r);
|
|
10
|
+
}
|
|
11
|
+
static registerResolver(r, s) {
|
|
12
|
+
resolverStore.ResolverStore.register(r, s);
|
|
13
|
+
}
|
|
14
|
+
static hasResolver(r) {
|
|
15
|
+
return resolverStore.ResolverStore.hasResolver(r);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.ParameterResolverFactory = ParameterResolverFactory;
|
package/dist/index47.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ResolverStore } from './index35.mjs';
|
|
2
|
+
|
|
3
|
+
class ParameterResolverFactory {
|
|
4
|
+
static getResolver(r) {
|
|
5
|
+
return ResolverStore.getResolver(r);
|
|
6
|
+
}
|
|
7
|
+
static registerResolver(r, s) {
|
|
8
|
+
ResolverStore.register(r, s);
|
|
9
|
+
}
|
|
10
|
+
static hasResolver(r) {
|
|
11
|
+
return ResolverStore.hasResolver(r);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { ParameterResolverFactory };
|
package/dist/index48.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const dependencies = require('./index49.js');
|
|
6
|
+
const transversalWeaver = require('./index38.js');
|
|
7
|
+
const helpers = require('./index36.js');
|
|
8
|
+
|
|
9
|
+
class InjectableBuilder {
|
|
10
|
+
build(i) {
|
|
11
|
+
const r = this.mergeConfiguration(i);
|
|
12
|
+
const c = dependencies.resolveInjectableParameters(this.injectable, r);
|
|
13
|
+
const o = new this.injectable.concrete(...c);
|
|
14
|
+
const s = transversalWeaver.TransversalWeaver.weave(o, this.injectable.concrete, this.injectable.publicContext, this.injectable.concrete.name);
|
|
15
|
+
helpers.registerEvents(this.injectable, s);
|
|
16
|
+
return s;
|
|
17
|
+
}
|
|
18
|
+
mergeConfiguration(e) {
|
|
19
|
+
const t = this.injectable.configuration || {};
|
|
20
|
+
if (e) {
|
|
21
|
+
return {
|
|
22
|
+
...t,
|
|
23
|
+
...e
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return t;
|
|
27
|
+
}
|
|
28
|
+
constructor(e){
|
|
29
|
+
this.injectable = e;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.InjectableBuilder = InjectableBuilder;
|
package/dist/index48.mjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { resolveInjectableParameters } from './index49.mjs';
|
|
2
|
+
import { TransversalWeaver } from './index38.mjs';
|
|
3
|
+
import { registerEvents } from './index36.mjs';
|
|
4
|
+
|
|
5
|
+
class InjectableBuilder {
|
|
6
|
+
build(i) {
|
|
7
|
+
const r = this.mergeConfiguration(i);
|
|
8
|
+
const c = resolveInjectableParameters(this.injectable, r);
|
|
9
|
+
const o = new this.injectable.concrete(...c);
|
|
10
|
+
const s = TransversalWeaver.weave(o, this.injectable.concrete, this.injectable.publicContext, this.injectable.concrete.name);
|
|
11
|
+
registerEvents(this.injectable, s);
|
|
12
|
+
return s;
|
|
13
|
+
}
|
|
14
|
+
mergeConfiguration(e) {
|
|
15
|
+
const t = this.injectable.configuration || {};
|
|
16
|
+
if (e) {
|
|
17
|
+
return {
|
|
18
|
+
...t,
|
|
19
|
+
...e
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
}
|
|
24
|
+
constructor(e){
|
|
25
|
+
this.injectable = e;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { InjectableBuilder };
|
package/dist/index49.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const reflection = require('./index34.js');
|
|
6
|
+
const helpers = require('./index25.js');
|
|
7
|
+
const parameterResolver_factory = require('./index47.js');
|
|
8
|
+
const decorators = require('./index11.js');
|
|
9
|
+
const transversalManager = require('./index13.js');
|
|
10
|
+
|
|
11
|
+
const n = new WeakMap();
|
|
12
|
+
const c = (e, t)=>{
|
|
13
|
+
for (const [r, s] of Object.entries(e)){
|
|
14
|
+
if (s.includes(t)) {
|
|
15
|
+
return r;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
};
|
|
20
|
+
const resolveInjectableParameters = (n, a)=>{
|
|
21
|
+
const i = [];
|
|
22
|
+
const l = reflection.getParamTypes(n.concrete);
|
|
23
|
+
const u = helpers.getDecoratedParametersIndexes(n.concrete);
|
|
24
|
+
for(let e = 0; e < l.length; e++){
|
|
25
|
+
const t = c(u, e);
|
|
26
|
+
if (t) {
|
|
27
|
+
const s = parameterResolver_factory.ParameterResolverFactory.getResolver(t);
|
|
28
|
+
i.push(s.resolve(e, n, n.concrete, a));
|
|
29
|
+
} else {
|
|
30
|
+
const t = l[e];
|
|
31
|
+
if (decorators.isTransversal(t)) {
|
|
32
|
+
const e = transversalManager.TransversalManager.getInstance(n.publicContext);
|
|
33
|
+
const r = e.getTransversalInstance(t.name);
|
|
34
|
+
if (!r) {
|
|
35
|
+
throw new Error(`Transversal ${t.name} is injected in constructor but not registered in transversals[]. ` + `Add it to transversals[] in @Assemblage decorator.`);
|
|
36
|
+
}
|
|
37
|
+
i.push(r);
|
|
38
|
+
} else {
|
|
39
|
+
i.push(n.privateContext.require(t));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return i;
|
|
44
|
+
};
|
|
45
|
+
const resolveDependencies = (r)=>{
|
|
46
|
+
if (n.has(r)) {
|
|
47
|
+
return n.get(r);
|
|
48
|
+
}
|
|
49
|
+
const s = [];
|
|
50
|
+
const o = reflection.getParamTypes(r);
|
|
51
|
+
const c = helpers.getDecoratedParametersIndexes(r);
|
|
52
|
+
let a = 0;
|
|
53
|
+
for (const e of o){
|
|
54
|
+
const t = Object.values(c).some((e)=>e.includes(a));
|
|
55
|
+
if (t) {
|
|
56
|
+
a++;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
s.push(e);
|
|
60
|
+
a++;
|
|
61
|
+
}
|
|
62
|
+
n.set(r, s);
|
|
63
|
+
return s;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
exports.resolveDependencies = resolveDependencies;
|
|
67
|
+
exports.resolveInjectableParameters = resolveInjectableParameters;
|
package/dist/index49.mjs
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { getParamTypes } from './index34.mjs';
|
|
2
|
+
import { getDecoratedParametersIndexes } from './index25.mjs';
|
|
3
|
+
import { ParameterResolverFactory } from './index47.mjs';
|
|
4
|
+
import { isTransversal } from './index11.mjs';
|
|
5
|
+
import { TransversalManager } from './index13.mjs';
|
|
6
|
+
|
|
7
|
+
const n = new WeakMap();
|
|
8
|
+
const c = (e, t)=>{
|
|
9
|
+
for (const [r, s] of Object.entries(e)){
|
|
10
|
+
if (s.includes(t)) {
|
|
11
|
+
return r;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
};
|
|
16
|
+
const resolveInjectableParameters = (n, a)=>{
|
|
17
|
+
const i = [];
|
|
18
|
+
const l = getParamTypes(n.concrete);
|
|
19
|
+
const u = getDecoratedParametersIndexes(n.concrete);
|
|
20
|
+
for(let e = 0; e < l.length; e++){
|
|
21
|
+
const t = c(u, e);
|
|
22
|
+
if (t) {
|
|
23
|
+
const s = ParameterResolverFactory.getResolver(t);
|
|
24
|
+
i.push(s.resolve(e, n, n.concrete, a));
|
|
25
|
+
} else {
|
|
26
|
+
const t = l[e];
|
|
27
|
+
if (isTransversal(t)) {
|
|
28
|
+
const e = TransversalManager.getInstance(n.publicContext);
|
|
29
|
+
const r = e.getTransversalInstance(t.name);
|
|
30
|
+
if (!r) {
|
|
31
|
+
throw new Error(`Transversal ${t.name} is injected in constructor but not registered in transversals[]. ` + `Add it to transversals[] in @Assemblage decorator.`);
|
|
32
|
+
}
|
|
33
|
+
i.push(r);
|
|
34
|
+
} else {
|
|
35
|
+
i.push(n.privateContext.require(t));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return i;
|
|
40
|
+
};
|
|
41
|
+
const resolveDependencies = (r)=>{
|
|
42
|
+
if (n.has(r)) {
|
|
43
|
+
return n.get(r);
|
|
44
|
+
}
|
|
45
|
+
const s = [];
|
|
46
|
+
const o = getParamTypes(r);
|
|
47
|
+
const c = getDecoratedParametersIndexes(r);
|
|
48
|
+
let a = 0;
|
|
49
|
+
for (const e of o){
|
|
50
|
+
const t = Object.values(c).some((e)=>e.includes(a));
|
|
51
|
+
if (t) {
|
|
52
|
+
a++;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
s.push(e);
|
|
56
|
+
a++;
|
|
57
|
+
}
|
|
58
|
+
n.set(r, s);
|
|
59
|
+
return s;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { resolveDependencies, resolveInjectableParameters };
|
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.0
|
|
4
|
+
"version": "1.1.0",
|
|
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",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"reflect-metadata": "0.2.2"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"istanbul-badges-readme": "^
|
|
59
|
+
"istanbul-badges-readme": "^1.9.0",
|
|
60
60
|
"vitest": "^3.0.0"
|
|
61
61
|
}
|
|
62
62
|
}
|