assemblerjs 1.1.13 → 1.1.15

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/index46.js CHANGED
@@ -2,33 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
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
- }
5
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
32
6
 
33
- exports.SingletonStrategy = SingletonStrategy;
34
- exports.TransientStrategy = TransientStrategy;
7
+ exports.commonjsGlobal = commonjsGlobal;
package/dist/index46.mjs CHANGED
@@ -1,29 +1,3 @@
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
- }
1
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
28
2
 
29
- export { SingletonStrategy, TransientStrategy };
3
+ export { commonjsGlobal };
package/dist/index47.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('./index40.js');
11
- const hookManager = require('./index36.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 _Reflect = {};
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.__exports = _Reflect;
package/dist/index47.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 './index40.mjs';
7
- import { HookManager } from './index36.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 _Reflect = {};
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 { _Reflect as __exports };
package/dist/index49.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const dependencies = require('./index50.js');
6
- const transversalWeaver = require('./index32.js');
6
+ const transversalWeaver = require('./index38.js');
7
7
  const helpers = require('./index40.js');
8
8
 
9
9
  class InjectableBuilder {
package/dist/index49.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { resolveInjectableParameters } from './index50.mjs';
2
- import { TransversalWeaver } from './index32.mjs';
2
+ import { TransversalWeaver } from './index38.mjs';
3
3
  import { registerEvents } from './index40.mjs';
4
4
 
5
5
  class InjectableBuilder {
package/dist/index50.js CHANGED
@@ -36,7 +36,11 @@ const resolveInjectableParameters = (o, a)=>{
36
36
  }
37
37
  i.push(r);
38
38
  } else {
39
- i.push(o.privateContext.require(t, undefined, o.identifier));
39
+ i.push(o.privateContext.require(t, {
40
+ __paramIndex: e,
41
+ __paramCount: l.length,
42
+ __expectedType: t
43
+ }, o.identifier));
40
44
  }
41
45
  }
42
46
  }
package/dist/index50.mjs CHANGED
@@ -32,7 +32,11 @@ const resolveInjectableParameters = (o, a)=>{
32
32
  }
33
33
  i.push(r);
34
34
  } else {
35
- i.push(o.privateContext.require(t, undefined, o.identifier));
35
+ i.push(o.privateContext.require(t, {
36
+ __paramIndex: e,
37
+ __paramCount: l.length,
38
+ __expectedType: t
39
+ }, o.identifier));
36
40
  }
37
41
  }
38
42
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "assemblerjs",
3
3
  "description": "A general purpose Dependency Injection library for node and browser.",
4
- "version": "1.1.13",
4
+ "version": "1.1.15",
5
5
  "author": "Benoît LAHOZ <info@benoitlahoz.io>",
6
6
  "bugs": "https://github.com/benoitlahoz/assemblerjs/issues",
7
7
  "homepage": "https://github.com/benoitlahoz/assemblerjs#README",