assemblerjs 0.9.7 → 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 +700 -465
- package/dist/index.js +59 -1
- package/dist/index.mjs +21 -919
- 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/index36.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const core = require('@assemblerjs/core');
|
|
6
|
+
const constants = require('./index29.js');
|
|
7
|
+
const reflection = require('./index30.js');
|
|
8
|
+
const injectableBuilder = require('./index38.js');
|
|
9
|
+
const dependencies = require('./index39.js');
|
|
10
|
+
const helpers = require('./index28.js');
|
|
11
|
+
const hookManager = require('./index25.js');
|
|
12
|
+
const schema = require('./index31.js');
|
|
13
|
+
const helpers$1 = require('./index3.js');
|
|
14
|
+
|
|
15
|
+
class Injectable {
|
|
16
|
+
static of(e, t, i) {
|
|
17
|
+
return new Injectable(e, t, i);
|
|
18
|
+
}
|
|
19
|
+
dispose() {
|
|
20
|
+
if (this.singletonInstance) {
|
|
21
|
+
helpers.unregisterEvents(this, this.singletonInstance);
|
|
22
|
+
hookManager.HookManager.callHook(this.singletonInstance, 'onDispose', this.publicContext, this.mergedConfiguration || this.configuration);
|
|
23
|
+
core.clearInstance(this.singletonInstance, this.concrete);
|
|
24
|
+
}
|
|
25
|
+
core.clearInstance(this, Injectable);
|
|
26
|
+
}
|
|
27
|
+
build(e) {
|
|
28
|
+
return this.builder.build(e);
|
|
29
|
+
}
|
|
30
|
+
setSingletonInstance(e, t) {
|
|
31
|
+
this.singletonInstance = e;
|
|
32
|
+
if (t) {
|
|
33
|
+
this.mergedConfiguration = t;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
get definition() {
|
|
37
|
+
if (!this.cachedDefinition) {
|
|
38
|
+
this.cachedDefinition = schema.getDefinition(this.concrete) || {};
|
|
39
|
+
}
|
|
40
|
+
return this.cachedDefinition;
|
|
41
|
+
}
|
|
42
|
+
get isSingleton() {
|
|
43
|
+
return this.definition.singleton ?? false;
|
|
44
|
+
}
|
|
45
|
+
get dependencies() {
|
|
46
|
+
return this.dependenciesIds;
|
|
47
|
+
}
|
|
48
|
+
get singleton() {
|
|
49
|
+
return this.singletonInstance;
|
|
50
|
+
}
|
|
51
|
+
get injections() {
|
|
52
|
+
if (this.cachedInjections === undefined) {
|
|
53
|
+
this.cachedInjections = this.definition.inject || [];
|
|
54
|
+
}
|
|
55
|
+
return this.cachedInjections;
|
|
56
|
+
}
|
|
57
|
+
get objects() {
|
|
58
|
+
if (this.cachedObjects === undefined) {
|
|
59
|
+
this.cachedObjects = this.definition.use || [];
|
|
60
|
+
}
|
|
61
|
+
return this.cachedObjects;
|
|
62
|
+
}
|
|
63
|
+
get tags() {
|
|
64
|
+
if (this.cachedTags === undefined) {
|
|
65
|
+
this.cachedTags = this.definition.tags || [];
|
|
66
|
+
}
|
|
67
|
+
return Array.isArray(this.cachedTags) ? this.cachedTags : [
|
|
68
|
+
this.cachedTags
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
get globals() {
|
|
72
|
+
if (this.cachedGlobals === undefined) {
|
|
73
|
+
this.cachedGlobals = this.definition.global;
|
|
74
|
+
}
|
|
75
|
+
return this.cachedGlobals;
|
|
76
|
+
}
|
|
77
|
+
get events() {
|
|
78
|
+
if (this.cachedEvents === undefined) {
|
|
79
|
+
this.cachedEvents = this.definition.events || [];
|
|
80
|
+
}
|
|
81
|
+
return this.cachedEvents;
|
|
82
|
+
}
|
|
83
|
+
constructor(e, n, o){
|
|
84
|
+
this.privateContext = n;
|
|
85
|
+
this.publicContext = o;
|
|
86
|
+
this.dependenciesIds = [];
|
|
87
|
+
this.identifier = e.identifier;
|
|
88
|
+
this.concrete = e.concrete;
|
|
89
|
+
this.configuration = e.configuration;
|
|
90
|
+
if (process.env.NODE_ENV !== 'production' && !helpers$1.isAssemblage(this.concrete)) {
|
|
91
|
+
throw new Error(`Class '${this.concrete.name}' is not an Assemblage.`);
|
|
92
|
+
}
|
|
93
|
+
this.builder = new injectableBuilder.InjectableBuilder(this);
|
|
94
|
+
reflection.defineCustomMetadata(constants.ReflectValue.AssemblageContext, this.publicContext, this.concrete);
|
|
95
|
+
for (const e of this.injections){
|
|
96
|
+
this.privateContext.register(e);
|
|
97
|
+
}
|
|
98
|
+
for (const e of this.objects){
|
|
99
|
+
if (typeof e[0] === 'string' || typeof e[0] === 'symbol') {
|
|
100
|
+
this.privateContext.use(e[0], e[1]);
|
|
101
|
+
} else {
|
|
102
|
+
this.privateContext.register(e, true);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
this.dependenciesIds = dependencies.resolveDependencies(this.concrete);
|
|
106
|
+
if (this.globals) {
|
|
107
|
+
for(const e in this.globals){
|
|
108
|
+
this.privateContext.addGlobal(e, this.globals[e]);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (e.instance) {
|
|
112
|
+
this.singletonInstance = e.instance;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
exports.Injectable = Injectable;
|
package/dist/index36.mjs
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { clearInstance } from '@assemblerjs/core';
|
|
2
|
+
import { ReflectValue } from './index29.mjs';
|
|
3
|
+
import { defineCustomMetadata } from './index30.mjs';
|
|
4
|
+
import { InjectableBuilder } from './index38.mjs';
|
|
5
|
+
import { resolveDependencies } from './index39.mjs';
|
|
6
|
+
import { unregisterEvents } from './index28.mjs';
|
|
7
|
+
import { HookManager } from './index25.mjs';
|
|
8
|
+
import { getDefinition } from './index31.mjs';
|
|
9
|
+
import { isAssemblage } from './index3.mjs';
|
|
10
|
+
|
|
11
|
+
class Injectable {
|
|
12
|
+
static of(e, t, i) {
|
|
13
|
+
return new Injectable(e, t, i);
|
|
14
|
+
}
|
|
15
|
+
dispose() {
|
|
16
|
+
if (this.singletonInstance) {
|
|
17
|
+
unregisterEvents(this, this.singletonInstance);
|
|
18
|
+
HookManager.callHook(this.singletonInstance, 'onDispose', this.publicContext, this.mergedConfiguration || this.configuration);
|
|
19
|
+
clearInstance(this.singletonInstance, this.concrete);
|
|
20
|
+
}
|
|
21
|
+
clearInstance(this, Injectable);
|
|
22
|
+
}
|
|
23
|
+
build(e) {
|
|
24
|
+
return this.builder.build(e);
|
|
25
|
+
}
|
|
26
|
+
setSingletonInstance(e, t) {
|
|
27
|
+
this.singletonInstance = e;
|
|
28
|
+
if (t) {
|
|
29
|
+
this.mergedConfiguration = t;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
get definition() {
|
|
33
|
+
if (!this.cachedDefinition) {
|
|
34
|
+
this.cachedDefinition = getDefinition(this.concrete) || {};
|
|
35
|
+
}
|
|
36
|
+
return this.cachedDefinition;
|
|
37
|
+
}
|
|
38
|
+
get isSingleton() {
|
|
39
|
+
return this.definition.singleton ?? false;
|
|
40
|
+
}
|
|
41
|
+
get dependencies() {
|
|
42
|
+
return this.dependenciesIds;
|
|
43
|
+
}
|
|
44
|
+
get singleton() {
|
|
45
|
+
return this.singletonInstance;
|
|
46
|
+
}
|
|
47
|
+
get injections() {
|
|
48
|
+
if (this.cachedInjections === undefined) {
|
|
49
|
+
this.cachedInjections = this.definition.inject || [];
|
|
50
|
+
}
|
|
51
|
+
return this.cachedInjections;
|
|
52
|
+
}
|
|
53
|
+
get objects() {
|
|
54
|
+
if (this.cachedObjects === undefined) {
|
|
55
|
+
this.cachedObjects = this.definition.use || [];
|
|
56
|
+
}
|
|
57
|
+
return this.cachedObjects;
|
|
58
|
+
}
|
|
59
|
+
get tags() {
|
|
60
|
+
if (this.cachedTags === undefined) {
|
|
61
|
+
this.cachedTags = this.definition.tags || [];
|
|
62
|
+
}
|
|
63
|
+
return Array.isArray(this.cachedTags) ? this.cachedTags : [
|
|
64
|
+
this.cachedTags
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
get globals() {
|
|
68
|
+
if (this.cachedGlobals === undefined) {
|
|
69
|
+
this.cachedGlobals = this.definition.global;
|
|
70
|
+
}
|
|
71
|
+
return this.cachedGlobals;
|
|
72
|
+
}
|
|
73
|
+
get events() {
|
|
74
|
+
if (this.cachedEvents === undefined) {
|
|
75
|
+
this.cachedEvents = this.definition.events || [];
|
|
76
|
+
}
|
|
77
|
+
return this.cachedEvents;
|
|
78
|
+
}
|
|
79
|
+
constructor(e, n, o){
|
|
80
|
+
this.privateContext = n;
|
|
81
|
+
this.publicContext = o;
|
|
82
|
+
this.dependenciesIds = [];
|
|
83
|
+
this.identifier = e.identifier;
|
|
84
|
+
this.concrete = e.concrete;
|
|
85
|
+
this.configuration = e.configuration;
|
|
86
|
+
if (process.env.NODE_ENV !== 'production' && !isAssemblage(this.concrete)) {
|
|
87
|
+
throw new Error(`Class '${this.concrete.name}' is not an Assemblage.`);
|
|
88
|
+
}
|
|
89
|
+
this.builder = new InjectableBuilder(this);
|
|
90
|
+
defineCustomMetadata(ReflectValue.AssemblageContext, this.publicContext, this.concrete);
|
|
91
|
+
for (const e of this.injections){
|
|
92
|
+
this.privateContext.register(e);
|
|
93
|
+
}
|
|
94
|
+
for (const e of this.objects){
|
|
95
|
+
if (typeof e[0] === 'string' || typeof e[0] === 'symbol') {
|
|
96
|
+
this.privateContext.use(e[0], e[1]);
|
|
97
|
+
} else {
|
|
98
|
+
this.privateContext.register(e, true);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
this.dependenciesIds = resolveDependencies(this.concrete);
|
|
102
|
+
if (this.globals) {
|
|
103
|
+
for(const e in this.globals){
|
|
104
|
+
this.privateContext.addGlobal(e, this.globals[e]);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (e.instance) {
|
|
108
|
+
this.singletonInstance = e.instance;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export { Injectable };
|
package/dist/index37.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const resolverStore = require('./index32.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/index37.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ResolverStore } from './index32.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/index38.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const dependencies = require('./index39.js');
|
|
6
|
+
const helpers = require('./index28.js');
|
|
7
|
+
|
|
8
|
+
class InjectableBuilder {
|
|
9
|
+
build(n) {
|
|
10
|
+
const i = this.mergeConfiguration(n);
|
|
11
|
+
const r = dependencies.resolveInjectableParameters(this.injectable, i);
|
|
12
|
+
const o = new this.injectable.concrete(...r);
|
|
13
|
+
helpers.registerEvents(this.injectable, o);
|
|
14
|
+
return o;
|
|
15
|
+
}
|
|
16
|
+
mergeConfiguration(e) {
|
|
17
|
+
const t = this.injectable.configuration || {};
|
|
18
|
+
if (e) {
|
|
19
|
+
return {
|
|
20
|
+
...t,
|
|
21
|
+
...e
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
}
|
|
26
|
+
constructor(e){
|
|
27
|
+
this.injectable = e;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
exports.InjectableBuilder = InjectableBuilder;
|
package/dist/index38.mjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { resolveInjectableParameters } from './index39.mjs';
|
|
2
|
+
import { registerEvents } from './index28.mjs';
|
|
3
|
+
|
|
4
|
+
class InjectableBuilder {
|
|
5
|
+
build(n) {
|
|
6
|
+
const i = this.mergeConfiguration(n);
|
|
7
|
+
const r = resolveInjectableParameters(this.injectable, i);
|
|
8
|
+
const o = new this.injectable.concrete(...r);
|
|
9
|
+
registerEvents(this.injectable, o);
|
|
10
|
+
return o;
|
|
11
|
+
}
|
|
12
|
+
mergeConfiguration(e) {
|
|
13
|
+
const t = this.injectable.configuration || {};
|
|
14
|
+
if (e) {
|
|
15
|
+
return {
|
|
16
|
+
...t,
|
|
17
|
+
...e
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
}
|
|
22
|
+
constructor(e){
|
|
23
|
+
this.injectable = e;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { InjectableBuilder };
|
package/dist/index39.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const reflection = require('./index30.js');
|
|
6
|
+
const helpers = require('./index21.js');
|
|
7
|
+
const parameterResolver_factory = require('./index37.js');
|
|
8
|
+
|
|
9
|
+
const r = new WeakMap();
|
|
10
|
+
const s = (e, o)=>{
|
|
11
|
+
for (const [t, r] of Object.entries(e)){
|
|
12
|
+
if (r.includes(o)) {
|
|
13
|
+
return t;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
};
|
|
18
|
+
const resolveInjectableParameters = (r, n)=>{
|
|
19
|
+
const c = [];
|
|
20
|
+
const l = reflection.getParamTypes(r.concrete);
|
|
21
|
+
const i = helpers.getDecoratedParametersIndexes(r.concrete);
|
|
22
|
+
for(let e = 0; e < l.length; e++){
|
|
23
|
+
const o = s(i, e);
|
|
24
|
+
if (o) {
|
|
25
|
+
const s = parameterResolver_factory.ParameterResolverFactory.getResolver(o);
|
|
26
|
+
c.push(s.resolve(e, r, r.concrete, n));
|
|
27
|
+
} else {
|
|
28
|
+
c.push(r.privateContext.require(l[e]));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return c;
|
|
32
|
+
};
|
|
33
|
+
const resolveDependencies = (t)=>{
|
|
34
|
+
if (r.has(t)) {
|
|
35
|
+
return r.get(t);
|
|
36
|
+
}
|
|
37
|
+
const s = [];
|
|
38
|
+
const n = reflection.getParamTypes(t);
|
|
39
|
+
const c = helpers.getDecoratedParametersIndexes(t);
|
|
40
|
+
let l = 0;
|
|
41
|
+
for (const e of n){
|
|
42
|
+
const o = Object.values(c).some((e)=>e.includes(l));
|
|
43
|
+
if (o) {
|
|
44
|
+
l++;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
s.push(e);
|
|
48
|
+
l++;
|
|
49
|
+
}
|
|
50
|
+
r.set(t, s);
|
|
51
|
+
return s;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
exports.resolveDependencies = resolveDependencies;
|
|
55
|
+
exports.resolveInjectableParameters = resolveInjectableParameters;
|
package/dist/index39.mjs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { getParamTypes } from './index30.mjs';
|
|
2
|
+
import { getDecoratedParametersIndexes } from './index21.mjs';
|
|
3
|
+
import { ParameterResolverFactory } from './index37.mjs';
|
|
4
|
+
|
|
5
|
+
const r = new WeakMap();
|
|
6
|
+
const s = (e, o)=>{
|
|
7
|
+
for (const [t, r] of Object.entries(e)){
|
|
8
|
+
if (r.includes(o)) {
|
|
9
|
+
return t;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return null;
|
|
13
|
+
};
|
|
14
|
+
const resolveInjectableParameters = (r, n)=>{
|
|
15
|
+
const c = [];
|
|
16
|
+
const l = getParamTypes(r.concrete);
|
|
17
|
+
const i = getDecoratedParametersIndexes(r.concrete);
|
|
18
|
+
for(let e = 0; e < l.length; e++){
|
|
19
|
+
const o = s(i, e);
|
|
20
|
+
if (o) {
|
|
21
|
+
const s = ParameterResolverFactory.getResolver(o);
|
|
22
|
+
c.push(s.resolve(e, r, r.concrete, n));
|
|
23
|
+
} else {
|
|
24
|
+
c.push(r.privateContext.require(l[e]));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return c;
|
|
28
|
+
};
|
|
29
|
+
const resolveDependencies = (t)=>{
|
|
30
|
+
if (r.has(t)) {
|
|
31
|
+
return r.get(t);
|
|
32
|
+
}
|
|
33
|
+
const s = [];
|
|
34
|
+
const n = getParamTypes(t);
|
|
35
|
+
const c = getDecoratedParametersIndexes(t);
|
|
36
|
+
let l = 0;
|
|
37
|
+
for (const e of n){
|
|
38
|
+
const o = Object.values(c).some((e)=>e.includes(l));
|
|
39
|
+
if (o) {
|
|
40
|
+
l++;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
s.push(e);
|
|
44
|
+
l++;
|
|
45
|
+
}
|
|
46
|
+
r.set(t, s);
|
|
47
|
+
return s;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export { resolveDependencies, resolveInjectableParameters };
|
package/dist/index4.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const core = require('@assemblerjs/core');
|
|
6
|
+
const injectableManager = require('./index23.js');
|
|
7
|
+
const objectManager = require('./index24.js');
|
|
8
|
+
const hookManager = require('./index25.js');
|
|
9
|
+
const assemblerBuilder = require('./index26.js');
|
|
10
|
+
const contextProvider = require('./index27.js');
|
|
11
|
+
const eventManager = require('./index6.js');
|
|
12
|
+
|
|
13
|
+
class Assembler extends eventManager.EventManager {
|
|
14
|
+
static build(e, t) {
|
|
15
|
+
const r = new Assembler();
|
|
16
|
+
const a = new assemblerBuilder.AssemblerBuilder(r);
|
|
17
|
+
return a.build(e, t);
|
|
18
|
+
}
|
|
19
|
+
get hookManager() {
|
|
20
|
+
return this._hookManager;
|
|
21
|
+
}
|
|
22
|
+
dispose() {
|
|
23
|
+
this.injectableManager.dispose();
|
|
24
|
+
core.clearInstance(this, Assembler);
|
|
25
|
+
}
|
|
26
|
+
register(e, t = false) {
|
|
27
|
+
return this.injectableManager.register(e, t);
|
|
28
|
+
}
|
|
29
|
+
use(e, t) {
|
|
30
|
+
return this.objectManager.use(e, t);
|
|
31
|
+
}
|
|
32
|
+
prepareInitHook(e, t) {
|
|
33
|
+
return this.hookManager.prepareInitHook(e, t);
|
|
34
|
+
}
|
|
35
|
+
has(e) {
|
|
36
|
+
if (typeof e === 'string' || typeof e === 'symbol') {
|
|
37
|
+
return this.objectManager.has(e);
|
|
38
|
+
}
|
|
39
|
+
return this.injectableManager.has(e);
|
|
40
|
+
}
|
|
41
|
+
require(e, t) {
|
|
42
|
+
switch(typeof e){
|
|
43
|
+
case 'string':
|
|
44
|
+
case 'symbol':
|
|
45
|
+
{
|
|
46
|
+
return this.objectManager.require(e);
|
|
47
|
+
}
|
|
48
|
+
default:
|
|
49
|
+
{
|
|
50
|
+
return this.injectableManager.require(e, t);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
concrete(e) {
|
|
55
|
+
return this.injectableManager.concrete(e);
|
|
56
|
+
}
|
|
57
|
+
tagged(...e) {
|
|
58
|
+
return this.injectableManager.tagged(...e);
|
|
59
|
+
}
|
|
60
|
+
addGlobal(e, t) {
|
|
61
|
+
this.objectManager.addGlobal(e, t);
|
|
62
|
+
}
|
|
63
|
+
global(e) {
|
|
64
|
+
return this.objectManager.global(e);
|
|
65
|
+
}
|
|
66
|
+
get size() {
|
|
67
|
+
return this.injectableManager.size;
|
|
68
|
+
}
|
|
69
|
+
constructor(){
|
|
70
|
+
super();
|
|
71
|
+
this.injectableManager = new injectableManager.InjectableManager();
|
|
72
|
+
this.objectManager = new objectManager.ObjectManager();
|
|
73
|
+
this._hookManager = new hookManager.HookManager();
|
|
74
|
+
const e = new contextProvider.ContextProvider(this);
|
|
75
|
+
this.publicContext = e.createPublicContext();
|
|
76
|
+
this.privateContext = e.createPrivateContext(this.publicContext);
|
|
77
|
+
this.injectableManager.setContexts(this.privateContext, this.publicContext);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
exports.Assembler = Assembler;
|
package/dist/index4.mjs
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { clearInstance } from '@assemblerjs/core';
|
|
2
|
+
import { InjectableManager } from './index23.mjs';
|
|
3
|
+
import { ObjectManager } from './index24.mjs';
|
|
4
|
+
import { HookManager } from './index25.mjs';
|
|
5
|
+
import { AssemblerBuilder } from './index26.mjs';
|
|
6
|
+
import { ContextProvider } from './index27.mjs';
|
|
7
|
+
import { EventManager } from './index6.mjs';
|
|
8
|
+
|
|
9
|
+
class Assembler extends EventManager {
|
|
10
|
+
static build(e, t) {
|
|
11
|
+
const r = new Assembler();
|
|
12
|
+
const a = new AssemblerBuilder(r);
|
|
13
|
+
return a.build(e, t);
|
|
14
|
+
}
|
|
15
|
+
get hookManager() {
|
|
16
|
+
return this._hookManager;
|
|
17
|
+
}
|
|
18
|
+
dispose() {
|
|
19
|
+
this.injectableManager.dispose();
|
|
20
|
+
clearInstance(this, Assembler);
|
|
21
|
+
}
|
|
22
|
+
register(e, t = false) {
|
|
23
|
+
return this.injectableManager.register(e, t);
|
|
24
|
+
}
|
|
25
|
+
use(e, t) {
|
|
26
|
+
return this.objectManager.use(e, t);
|
|
27
|
+
}
|
|
28
|
+
prepareInitHook(e, t) {
|
|
29
|
+
return this.hookManager.prepareInitHook(e, t);
|
|
30
|
+
}
|
|
31
|
+
has(e) {
|
|
32
|
+
if (typeof e === 'string' || typeof e === 'symbol') {
|
|
33
|
+
return this.objectManager.has(e);
|
|
34
|
+
}
|
|
35
|
+
return this.injectableManager.has(e);
|
|
36
|
+
}
|
|
37
|
+
require(e, t) {
|
|
38
|
+
switch(typeof e){
|
|
39
|
+
case 'string':
|
|
40
|
+
case 'symbol':
|
|
41
|
+
{
|
|
42
|
+
return this.objectManager.require(e);
|
|
43
|
+
}
|
|
44
|
+
default:
|
|
45
|
+
{
|
|
46
|
+
return this.injectableManager.require(e, t);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
concrete(e) {
|
|
51
|
+
return this.injectableManager.concrete(e);
|
|
52
|
+
}
|
|
53
|
+
tagged(...e) {
|
|
54
|
+
return this.injectableManager.tagged(...e);
|
|
55
|
+
}
|
|
56
|
+
addGlobal(e, t) {
|
|
57
|
+
this.objectManager.addGlobal(e, t);
|
|
58
|
+
}
|
|
59
|
+
global(e) {
|
|
60
|
+
return this.objectManager.global(e);
|
|
61
|
+
}
|
|
62
|
+
get size() {
|
|
63
|
+
return this.injectableManager.size;
|
|
64
|
+
}
|
|
65
|
+
constructor(){
|
|
66
|
+
super();
|
|
67
|
+
this.injectableManager = new InjectableManager();
|
|
68
|
+
this.objectManager = new ObjectManager();
|
|
69
|
+
this._hookManager = new HookManager();
|
|
70
|
+
const e = new ContextProvider(this);
|
|
71
|
+
this.publicContext = e.createPublicContext();
|
|
72
|
+
this.privateContext = e.createPrivateContext(this.publicContext);
|
|
73
|
+
this.injectableManager.setContexts(this.privateContext, this.publicContext);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { Assembler };
|
package/dist/index5.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const core = require('@assemblerjs/core');
|
|
6
|
+
|
|
7
|
+
class ListenerCollection {
|
|
8
|
+
dispose() {
|
|
9
|
+
core.clearInstance(this, ListenerCollection);
|
|
10
|
+
}
|
|
11
|
+
add(...t) {
|
|
12
|
+
let e;
|
|
13
|
+
let l;
|
|
14
|
+
if (t.length === 2) {
|
|
15
|
+
e = t[0];
|
|
16
|
+
l = t[1];
|
|
17
|
+
} else {
|
|
18
|
+
const i = t[0];
|
|
19
|
+
e = i[0];
|
|
20
|
+
l = i[1];
|
|
21
|
+
}
|
|
22
|
+
if (!this.collection[e]) {
|
|
23
|
+
this.collection[e] = [];
|
|
24
|
+
}
|
|
25
|
+
this.collection[e].push(l);
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
remove(t, l) {
|
|
29
|
+
const i = (e)=>this.collection[t].splice(e, 1);
|
|
30
|
+
const n = core.conditionally({
|
|
31
|
+
if: ()=>this.collection[t] && this.collection[t].length === 0,
|
|
32
|
+
then: ()=>delete this.collection[t]
|
|
33
|
+
});
|
|
34
|
+
const s = core.conditionally({
|
|
35
|
+
if: ()=>core.isDefined(l),
|
|
36
|
+
then: ()=>i(this.collection[t].indexOf(l)),
|
|
37
|
+
else: ()=>delete this.collection[t]
|
|
38
|
+
});
|
|
39
|
+
const r = core.conditionally({
|
|
40
|
+
if: (t)=>this.has(t),
|
|
41
|
+
then: (t)=>this.collection[t]
|
|
42
|
+
});
|
|
43
|
+
core.pipe(r, s, n)();
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
has(...t) {
|
|
47
|
+
if (core.isOfType('string')(t[0])) {
|
|
48
|
+
return Object.keys(this.collection).includes(t[0]);
|
|
49
|
+
} else if (core.isOfType('function')(t[0])) {
|
|
50
|
+
return Object.values(this.collection).flat().includes(t[0]);
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
get(...t) {
|
|
55
|
+
if (core.isOfType('string')(t[0])) {
|
|
56
|
+
return this.collection[t[0]];
|
|
57
|
+
} else if (core.isOfType('function')(t[0])) {
|
|
58
|
+
return Object.values(this.collection).flat().filter((e)=>e === t[0]);
|
|
59
|
+
}
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
clear() {
|
|
63
|
+
const t = core.forIn(this.collection);
|
|
64
|
+
const e = (t)=>core.forOf(this.collection[t])((e)=>this.remove(t, e));
|
|
65
|
+
t((t)=>e(t));
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
get listeners() {
|
|
69
|
+
return Object.values(this.collection).flat();
|
|
70
|
+
}
|
|
71
|
+
get channels() {
|
|
72
|
+
return Object.keys(this.collection);
|
|
73
|
+
}
|
|
74
|
+
get length() {
|
|
75
|
+
return Object.values(this.collection).flat().length;
|
|
76
|
+
}
|
|
77
|
+
[Symbol.iterator]() {
|
|
78
|
+
let t = -1;
|
|
79
|
+
const e = this.collection ? Object.keys(this.collection) : [];
|
|
80
|
+
return {
|
|
81
|
+
next: ()=>({
|
|
82
|
+
value: e[++t],
|
|
83
|
+
done: !(t in e)
|
|
84
|
+
})
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
constructor(){
|
|
88
|
+
this.collection = {};
|
|
89
|
+
const t = core.proxifyIterable(this, ListenerCollection);
|
|
90
|
+
return t;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
exports.ListenerCollection = ListenerCollection;
|