assemblerjs 1.1.15 → 1.1.17

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