assemblerjs 1.1.2 → 1.1.3
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/index.d.ts +26 -0
- package/dist/index11.js +2 -2
- package/dist/index11.mjs +2 -2
- package/dist/index13.js +2 -2
- package/dist/index13.mjs +2 -2
- package/dist/index16.js +1 -1
- package/dist/index16.mjs +1 -1
- package/dist/index17.js +1 -1
- package/dist/index17.mjs +1 -1
- package/dist/index18.js +1 -1
- package/dist/index18.mjs +1 -1
- package/dist/index19.js +1 -1
- package/dist/index19.mjs +1 -1
- package/dist/index2.js +2 -2
- package/dist/index2.mjs +2 -2
- package/dist/index20.js +1 -1
- package/dist/index20.mjs +1 -1
- package/dist/index21.js +1 -1
- package/dist/index21.mjs +1 -1
- package/dist/index22.js +2 -2
- package/dist/index22.mjs +2 -2
- package/dist/index23.js +2 -2
- package/dist/index23.mjs +2 -2
- package/dist/index24.js +2 -2
- package/dist/index24.mjs +2 -2
- package/dist/index25.js +1 -1
- package/dist/index25.mjs +1 -1
- package/dist/index26.js +1 -1
- package/dist/index26.mjs +1 -1
- package/dist/index27.js +1 -1
- package/dist/index27.mjs +1 -1
- package/dist/index29.js +15 -38
- package/dist/index29.mjs +12 -37
- package/dist/index3.js +1 -1
- package/dist/index3.mjs +1 -1
- package/dist/index30.js +100 -58
- package/dist/index30.mjs +98 -58
- package/dist/index31.js +36 -27
- package/dist/index31.mjs +35 -27
- package/dist/index32.js +16 -59
- package/dist/index32.mjs +16 -59
- package/dist/index33.js +65 -28
- package/dist/index33.mjs +65 -28
- package/dist/index34.js +28 -28
- package/dist/index34.mjs +28 -28
- package/dist/index35.js +77 -15
- package/dist/index35.mjs +77 -12
- package/dist/index36.js +38 -104
- package/dist/index36.mjs +38 -102
- package/dist/index37.js +28 -102
- package/dist/index37.mjs +28 -102
- package/dist/index38.js +128 -23
- package/dist/index38.mjs +128 -23
- package/dist/index39.js +101 -18
- package/dist/index39.mjs +101 -18
- package/dist/index4.js +21 -8
- package/dist/index4.mjs +21 -8
- package/dist/index40.js +25 -25
- package/dist/index40.mjs +25 -24
- package/dist/index41.js +44 -18
- package/dist/index41.mjs +44 -17
- package/dist/index42.js +18 -44
- package/dist/index42.mjs +17 -44
- package/dist/index43.js +26 -191
- package/dist/index43.mjs +25 -191
- package/dist/index44.js +192 -940
- package/dist/index44.mjs +192 -940
- package/dist/index45.js +942 -2
- package/dist/index45.mjs +942 -2
- package/dist/index46.js +2 -2
- package/dist/index46.mjs +2 -2
- package/dist/index47.js +2 -14
- package/dist/index47.mjs +2 -14
- package/dist/index48.js +9 -34
- package/dist/index48.mjs +9 -34
- package/dist/index49.js +32 -55
- package/dist/index49.mjs +32 -54
- package/dist/index50.js +67 -0
- package/dist/index50.mjs +62 -0
- package/package.json +1 -1
package/dist/index43.mjs
CHANGED
|
@@ -1,195 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (t.length === 1) {
|
|
20
|
-
return [
|
|
21
|
-
t[0]
|
|
22
|
-
];
|
|
23
|
-
} else if (t.length === 2) {
|
|
24
|
-
const s = t[1];
|
|
25
|
-
if (isClass(s)) {
|
|
26
|
-
return [
|
|
27
|
-
t[0],
|
|
28
|
-
t[1]
|
|
29
|
-
];
|
|
30
|
-
} else {
|
|
31
|
-
return [
|
|
32
|
-
t[0],
|
|
33
|
-
t[1]
|
|
34
|
-
];
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
return [
|
|
38
|
-
t[0],
|
|
39
|
-
t[1],
|
|
40
|
-
t[2]
|
|
41
|
-
];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
dispose() {
|
|
45
|
-
if (this.singletonInstance) {
|
|
46
|
-
unregisterEvents(this, this.singletonInstance);
|
|
47
|
-
HookManager.callHook(this.singletonInstance, 'onDispose', this.publicContext, this.mergedConfiguration || this.configuration);
|
|
48
|
-
clearInstance(this.singletonInstance, this.concrete);
|
|
49
|
-
}
|
|
50
|
-
clearInstance(this, Injectable);
|
|
51
|
-
}
|
|
52
|
-
build(t) {
|
|
53
|
-
return this.builder.build(t);
|
|
54
|
-
}
|
|
55
|
-
setSingletonInstance(t, e) {
|
|
56
|
-
this.singletonInstance = t;
|
|
57
|
-
if (e) {
|
|
58
|
-
this.mergedConfiguration = e;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
get definition() {
|
|
62
|
-
if (!this.cachedDefinition) {
|
|
63
|
-
if (!this.concrete) {
|
|
64
|
-
this.cachedDefinition = {};
|
|
65
|
-
} else {
|
|
66
|
-
this.cachedDefinition = getDefinition(this.concrete) || {};
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return this.cachedDefinition;
|
|
70
|
-
}
|
|
71
|
-
get isSingleton() {
|
|
72
|
-
return this.definition.singleton ?? false;
|
|
73
|
-
}
|
|
74
|
-
get dependencies() {
|
|
75
|
-
return this.dependenciesIds;
|
|
76
|
-
}
|
|
77
|
-
get singleton() {
|
|
78
|
-
return this.singletonInstance;
|
|
79
|
-
}
|
|
80
|
-
get injections() {
|
|
81
|
-
if (this.cachedInjections === undefined) {
|
|
82
|
-
this.cachedInjections = this.definition.inject || [];
|
|
83
|
-
}
|
|
84
|
-
return this.cachedInjections;
|
|
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();
|
|
85
19
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
get transversals() {
|
|
93
|
-
if (this.cachedTransversals === undefined) {
|
|
94
|
-
this.cachedTransversals = this.definition.engage || [];
|
|
95
|
-
}
|
|
96
|
-
return this.cachedTransversals;
|
|
97
|
-
}
|
|
98
|
-
get tags() {
|
|
99
|
-
if (this.cachedTags === undefined) {
|
|
100
|
-
this.cachedTags = this.definition.tags || [];
|
|
101
|
-
}
|
|
102
|
-
return Array.isArray(this.cachedTags) ? this.cachedTags : [
|
|
103
|
-
this.cachedTags
|
|
104
|
-
];
|
|
105
|
-
}
|
|
106
|
-
get globals() {
|
|
107
|
-
if (this.cachedGlobals === undefined) {
|
|
108
|
-
this.cachedGlobals = this.definition.global;
|
|
109
|
-
}
|
|
110
|
-
return this.cachedGlobals;
|
|
111
|
-
}
|
|
112
|
-
get events() {
|
|
113
|
-
if (this.cachedEvents === undefined) {
|
|
114
|
-
this.cachedEvents = this.definition.events || [];
|
|
115
|
-
}
|
|
116
|
-
return this.cachedEvents;
|
|
117
|
-
}
|
|
118
|
-
constructor(t, e, o){
|
|
119
|
-
this.privateContext = e;
|
|
120
|
-
this.publicContext = o;
|
|
121
|
-
this.dependenciesIds = [];
|
|
122
|
-
this.identifier = t.identifier;
|
|
123
|
-
this.concrete = t.concrete;
|
|
124
|
-
this.factory = t.factory;
|
|
125
|
-
this.configuration = t.configuration;
|
|
126
|
-
if (process.env.NODE_ENV !== 'production' && this.concrete && !isAssemblage(this.concrete)) {
|
|
127
|
-
throw new Error(`Class '${this.concrete.name}' is not an Assemblage.`);
|
|
128
|
-
}
|
|
129
|
-
this.builder = new InjectableBuilder(this);
|
|
130
|
-
if (this.concrete) {
|
|
131
|
-
defineCustomMetadata(ReflectValue.AssemblageContext, this.publicContext, this.concrete);
|
|
132
|
-
for (const t of this.transversals){
|
|
133
|
-
const e = this.resolveTransversalToInjection(t);
|
|
134
|
-
this.privateContext.register(e);
|
|
135
|
-
}
|
|
136
|
-
for (const t of this.injections){
|
|
137
|
-
const [e] = t;
|
|
138
|
-
if (isTransversal(e)) {
|
|
139
|
-
this.privateContext.register(t);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
for (const t of this.injections){
|
|
143
|
-
const [e] = t;
|
|
144
|
-
if (!isTransversal(e)) {
|
|
145
|
-
this.privateContext.register(t);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
for (const t of this.objects){
|
|
149
|
-
const [e, s] = t;
|
|
150
|
-
const i = isFactory(s);
|
|
151
|
-
if (typeof e === 'string' || typeof e === 'symbol') {
|
|
152
|
-
const t = i ? s() : s;
|
|
153
|
-
this.privateContext.use(e, t);
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
if (this.isSingleton && i) {
|
|
157
|
-
const t = s();
|
|
158
|
-
this.privateContext.register([
|
|
159
|
-
e,
|
|
160
|
-
t
|
|
161
|
-
], true);
|
|
162
|
-
} else {
|
|
163
|
-
this.privateContext.register(t, true);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
const t = TransversalManager.getInstance(this.publicContext);
|
|
167
|
-
for (const e of this.transversals){
|
|
168
|
-
t.registerTransversal(e, this.privateContext);
|
|
169
|
-
}
|
|
170
|
-
for (const e of this.injections){
|
|
171
|
-
const [s] = e;
|
|
172
|
-
if (isTransversal(s)) {
|
|
173
|
-
const i = e.length > 1 ? e : [
|
|
174
|
-
s
|
|
175
|
-
];
|
|
176
|
-
t.registerTransversal(i, this.privateContext);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
this.dependenciesIds = this.concrete ? resolveDependencies(this.concrete) : [];
|
|
180
|
-
if (this.globals) {
|
|
181
|
-
for(const t in this.globals){
|
|
182
|
-
this.privateContext.addGlobal(t, this.globals[t]);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
if (t.instance) {
|
|
187
|
-
this.singletonInstance = t.instance;
|
|
188
|
-
} else if (t.factory) {
|
|
189
|
-
const e = t.factory();
|
|
190
|
-
this.singletonInstance = e;
|
|
191
|
-
}
|
|
20
|
+
}
|
|
21
|
+
class TransientStrategy {
|
|
22
|
+
resolve(t, e) {
|
|
23
|
+
const n = t.build(e);
|
|
24
|
+
t.privateContext.prepareInitHook(n, t.configuration);
|
|
25
|
+
return n;
|
|
192
26
|
}
|
|
193
27
|
}
|
|
194
28
|
|
|
195
|
-
export {
|
|
29
|
+
export { SingletonStrategy, TransientStrategy };
|