assemblerjs 1.1.12 → 1.1.13

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 (55) hide show
  1. package/dist/index13.js +1 -1
  2. package/dist/index13.mjs +1 -1
  3. package/dist/index18.js +1 -1
  4. package/dist/index18.mjs +1 -1
  5. package/dist/index19.js +1 -1
  6. package/dist/index19.mjs +1 -1
  7. package/dist/index20.js +1 -1
  8. package/dist/index20.mjs +1 -1
  9. package/dist/index21.js +1 -1
  10. package/dist/index21.mjs +1 -1
  11. package/dist/index22.js +1 -1
  12. package/dist/index22.mjs +1 -1
  13. package/dist/index23.js +1 -1
  14. package/dist/index23.mjs +1 -1
  15. package/dist/index24.js +1 -1
  16. package/dist/index24.mjs +1 -1
  17. package/dist/index27.js +1 -1
  18. package/dist/index27.mjs +1 -1
  19. package/dist/index31.js +16 -134
  20. package/dist/index31.mjs +16 -134
  21. package/dist/index32.js +99 -44
  22. package/dist/index32.mjs +99 -44
  23. package/dist/index33.js +23 -74
  24. package/dist/index33.mjs +23 -74
  25. package/dist/index34.js +138 -42
  26. package/dist/index34.mjs +138 -42
  27. package/dist/index35.js +47 -28
  28. package/dist/index35.mjs +47 -28
  29. package/dist/index36.js +66 -149
  30. package/dist/index36.mjs +66 -149
  31. package/dist/index37.js +41 -19
  32. package/dist/index37.mjs +41 -19
  33. package/dist/index38.js +30 -39
  34. package/dist/index38.mjs +30 -38
  35. package/dist/index39.js +151 -94
  36. package/dist/index39.mjs +151 -94
  37. package/dist/index4.js +6 -6
  38. package/dist/index4.mjs +6 -6
  39. package/dist/index40.js +36 -24
  40. package/dist/index40.mjs +35 -24
  41. package/dist/index43.js +941 -28
  42. package/dist/index43.mjs +941 -27
  43. package/dist/index44.js +2 -194
  44. package/dist/index44.mjs +2 -194
  45. package/dist/index45.js +2 -942
  46. package/dist/index45.mjs +2 -942
  47. package/dist/index46.js +29 -2
  48. package/dist/index46.mjs +28 -2
  49. package/dist/index47.js +194 -2
  50. package/dist/index47.mjs +194 -2
  51. package/dist/index48.js +1 -1
  52. package/dist/index48.mjs +1 -1
  53. package/dist/index49.js +2 -2
  54. package/dist/index49.mjs +2 -2
  55. package/package.json +1 -1
package/dist/index44.js CHANGED
@@ -2,198 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const core = require('@assemblerjs/core');
6
- const constants = require('./index28.js');
7
- const reflection = require('./index29.js');
8
- const injectableBuilder = require('./index49.js');
9
- const dependencies = require('./index50.js');
10
- const helpers = require('./index38.js');
11
- const hookManager = require('./index33.js');
12
- const helpers$1 = require('./index3.js');
13
- const use = require('./index42.js');
14
- const schema = require('./index30.js');
15
- const decorators = require('./index11.js');
16
- const transversalManager = require('./index13.js');
5
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
17
6
 
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;
7
+ exports.commonjsGlobal = commonjsGlobal;
package/dist/index44.mjs CHANGED
@@ -1,195 +1,3 @@
1
- import { isClass, clearInstance } from '@assemblerjs/core';
2
- import { ReflectValue } from './index28.mjs';
3
- import { defineCustomMetadata } from './index29.mjs';
4
- import { InjectableBuilder } from './index49.mjs';
5
- import { resolveDependencies } from './index50.mjs';
6
- import { unregisterEvents } from './index38.mjs';
7
- import { HookManager } from './index33.mjs';
8
- import { isAssemblage } from './index3.mjs';
9
- import { isFactory } from './index42.mjs';
10
- import { getDefinition } from './index30.mjs';
11
- import { isTransversal } from './index11.mjs';
12
- import { TransversalManager } from './index13.mjs';
1
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
13
2
 
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 };
3
+ export { commonjsGlobal };