assemblerjs 1.1.16 → 1.1.18

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 (80) hide show
  1. package/dist/index.d.ts +2 -1
  2. package/dist/index11.js +2 -2
  3. package/dist/index11.mjs +2 -2
  4. package/dist/index13.js +98 -83
  5. package/dist/index13.mjs +98 -83
  6. package/dist/index16.js +1 -1
  7. package/dist/index16.mjs +1 -1
  8. package/dist/index17.js +1 -1
  9. package/dist/index17.mjs +1 -1
  10. package/dist/index18.js +1 -1
  11. package/dist/index18.mjs +1 -1
  12. package/dist/index19.js +1 -1
  13. package/dist/index19.mjs +1 -1
  14. package/dist/index2.js +2 -2
  15. package/dist/index2.mjs +2 -2
  16. package/dist/index20.js +1 -1
  17. package/dist/index20.mjs +1 -1
  18. package/dist/index21.js +1 -1
  19. package/dist/index21.mjs +1 -1
  20. package/dist/index22.js +2 -2
  21. package/dist/index22.mjs +2 -2
  22. package/dist/index23.js +2 -2
  23. package/dist/index23.mjs +2 -2
  24. package/dist/index24.js +2 -2
  25. package/dist/index24.mjs +2 -2
  26. package/dist/index25.js +1 -1
  27. package/dist/index25.mjs +1 -1
  28. package/dist/index26.js +1 -1
  29. package/dist/index26.mjs +1 -1
  30. package/dist/index27.js +1 -1
  31. package/dist/index27.mjs +1 -1
  32. package/dist/index29.js +38 -15
  33. package/dist/index29.mjs +37 -12
  34. package/dist/index3.js +1 -1
  35. package/dist/index3.mjs +1 -1
  36. package/dist/index30.js +151 -100
  37. package/dist/index30.mjs +150 -98
  38. package/dist/index31.js +44 -34
  39. package/dist/index31.mjs +44 -33
  40. package/dist/index32.js +73 -16
  41. package/dist/index32.mjs +73 -16
  42. package/dist/index33.js +48 -98
  43. package/dist/index33.mjs +48 -98
  44. package/dist/index34.js +29 -26
  45. package/dist/index34.mjs +29 -26
  46. package/dist/index35.js +146 -138
  47. package/dist/index35.mjs +146 -137
  48. package/dist/index36.js +56 -43
  49. package/dist/index36.mjs +56 -43
  50. package/dist/index37.js +15 -77
  51. package/dist/index37.mjs +12 -77
  52. package/dist/index38.js +103 -51
  53. package/dist/index38.mjs +101 -51
  54. package/dist/index39.js +19 -28
  55. package/dist/index39.mjs +19 -28
  56. package/dist/index4.js +10 -10
  57. package/dist/index4.mjs +10 -10
  58. package/dist/index40.js +94 -151
  59. package/dist/index40.mjs +94 -151
  60. package/dist/index41.js +24 -59
  61. package/dist/index41.mjs +24 -59
  62. package/dist/index42.js +29 -49
  63. package/dist/index42.mjs +28 -49
  64. package/dist/index44.js +50 -943
  65. package/dist/index44.mjs +48 -941
  66. package/dist/index45.js +194 -2
  67. package/dist/index45.mjs +194 -2
  68. package/dist/index46.js +942 -2
  69. package/dist/index46.mjs +942 -2
  70. package/dist/index47.js +2 -29
  71. package/dist/index47.mjs +2 -28
  72. package/dist/index48.js +2 -194
  73. package/dist/index48.mjs +2 -194
  74. package/dist/index49.js +1 -1
  75. package/dist/index49.mjs +1 -1
  76. package/dist/index50.js +2 -2
  77. package/dist/index50.mjs +2 -2
  78. package/dist/index51.js +16 -13
  79. package/dist/index51.mjs +16 -13
  80. package/package.json +1 -1
package/dist/index45.js CHANGED
@@ -2,6 +2,198 @@
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
+ const core = require('@assemblerjs/core');
6
+ const constants = require('./index28.js');
7
+ const reflection = require('./index37.js');
8
+ const injectableBuilder = require('./index50.js');
9
+ const dependencies = require('./index51.js');
10
+ const helpers = require('./index29.js');
11
+ const hookManager = require('./index32.js');
12
+ const helpers$1 = require('./index3.js');
13
+ const use = require('./index43.js');
14
+ const schema = require('./index38.js');
15
+ const decorators = require('./index11.js');
16
+ const transversalManager = require('./index13.js');
6
17
 
7
- exports.commonjsGlobal = commonjsGlobal;
18
+ class Injectable {
19
+ static of(t, e, s) {
20
+ return new Injectable(t, e, s);
21
+ }
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
+ }
47
+ }
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
+ }
196
+ }
197
+ }
198
+
199
+ exports.Injectable = Injectable;
package/dist/index45.mjs CHANGED
@@ -1,3 +1,195 @@
1
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
1
+ import { isClass, clearInstance } from '@assemblerjs/core';
2
+ import { ReflectValue } from './index28.mjs';
3
+ import { defineCustomMetadata } from './index37.mjs';
4
+ import { InjectableBuilder } from './index50.mjs';
5
+ import { resolveDependencies } from './index51.mjs';
6
+ import { unregisterEvents } from './index29.mjs';
7
+ import { HookManager } from './index32.mjs';
8
+ import { isAssemblage } from './index3.mjs';
9
+ import { isFactory } from './index43.mjs';
10
+ import { getDefinition } from './index38.mjs';
11
+ import { isTransversal } from './index11.mjs';
12
+ import { TransversalManager } from './index13.mjs';
2
13
 
3
- export { commonjsGlobal };
14
+ class Injectable {
15
+ static of(t, e, s) {
16
+ return new Injectable(t, e, s);
17
+ }
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
+ }
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;
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
+ }
192
+ }
193
+ }
194
+
195
+ export { Injectable };