assemblerjs 1.1.18 → 1.1.19

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 (71) hide show
  1. package/dist/index11.js +2 -2
  2. package/dist/index11.mjs +2 -2
  3. package/dist/index13.js +2 -2
  4. package/dist/index13.mjs +2 -2
  5. package/dist/index16.js +1 -1
  6. package/dist/index16.mjs +1 -1
  7. package/dist/index17.js +1 -1
  8. package/dist/index17.mjs +1 -1
  9. package/dist/index18.js +1 -1
  10. package/dist/index18.mjs +1 -1
  11. package/dist/index19.js +1 -1
  12. package/dist/index19.mjs +1 -1
  13. package/dist/index2.js +2 -2
  14. package/dist/index2.mjs +2 -2
  15. package/dist/index20.js +1 -1
  16. package/dist/index20.mjs +1 -1
  17. package/dist/index21.js +1 -1
  18. package/dist/index21.mjs +1 -1
  19. package/dist/index22.js +2 -2
  20. package/dist/index22.mjs +2 -2
  21. package/dist/index23.js +2 -2
  22. package/dist/index23.mjs +2 -2
  23. package/dist/index24.js +2 -2
  24. package/dist/index24.mjs +2 -2
  25. package/dist/index25.js +1 -1
  26. package/dist/index25.mjs +1 -1
  27. package/dist/index26.js +1 -1
  28. package/dist/index26.mjs +1 -1
  29. package/dist/index29.js +15 -38
  30. package/dist/index29.mjs +12 -37
  31. package/dist/index3.js +1 -1
  32. package/dist/index3.mjs +1 -1
  33. package/dist/index30.js +100 -151
  34. package/dist/index30.mjs +98 -150
  35. package/dist/index31.js +99 -44
  36. package/dist/index31.mjs +99 -44
  37. package/dist/index32.js +23 -74
  38. package/dist/index32.mjs +23 -74
  39. package/dist/index33.js +154 -51
  40. package/dist/index33.mjs +153 -51
  41. package/dist/index34.js +47 -28
  42. package/dist/index34.mjs +47 -28
  43. package/dist/index35.js +65 -152
  44. package/dist/index35.mjs +65 -152
  45. package/dist/index36.js +50 -58
  46. package/dist/index36.mjs +50 -58
  47. package/dist/index37.js +32 -18
  48. package/dist/index37.mjs +32 -15
  49. package/dist/index38.js +158 -99
  50. package/dist/index38.mjs +158 -97
  51. package/dist/index39.js +57 -16
  52. package/dist/index39.mjs +57 -16
  53. package/dist/index4.js +7 -7
  54. package/dist/index4.mjs +7 -7
  55. package/dist/index40.js +35 -100
  56. package/dist/index40.mjs +34 -100
  57. package/dist/index41.js +18 -24
  58. package/dist/index41.mjs +18 -24
  59. package/dist/index42.js +49 -29
  60. package/dist/index42.mjs +49 -28
  61. package/dist/index44.js +29 -49
  62. package/dist/index44.mjs +28 -49
  63. package/dist/index45.js +4 -4
  64. package/dist/index45.mjs +4 -4
  65. package/dist/index49.js +1 -1
  66. package/dist/index49.mjs +1 -1
  67. package/dist/index50.js +2 -2
  68. package/dist/index50.mjs +2 -2
  69. package/dist/index51.js +1 -1
  70. package/dist/index51.mjs +1 -1
  71. package/package.json +1 -1
package/dist/index39.mjs CHANGED
@@ -1,24 +1,65 @@
1
- class ResolverStore {
2
- static register(e, r) {
3
- this.resolvers.set(e, r);
1
+ let AbstractCycleDetector = class AbstractCycleDetector {
2
+ };
3
+ let NoOpCycleDetector = class NoOpCycleDetector extends AbstractCycleDetector {
4
+ detect() {
5
+ return [];
4
6
  }
5
- static getResolver(e) {
6
- const r = this.resolvers.get(e);
7
- if (!r) {
8
- throw new Error(`No resolver found for decorator type: ${e}`);
7
+ };
8
+ let ActiveCycleDetector = class ActiveCycleDetector extends AbstractCycleDetector {
9
+ detect(e, t) {
10
+ const c = [];
11
+ const s = new Set();
12
+ for (const [n] of e){
13
+ if (s.has(n)) continue;
14
+ const r = [];
15
+ const o = new Set();
16
+ if (this.hasCycleDFS(n, r, o, s, e)) {
17
+ const e = r.findIndex((e)=>e === n);
18
+ if (e >= 0) {
19
+ const s = r.slice(e).map((e)=>t(e));
20
+ c.push({
21
+ cycle: s,
22
+ path: s.join(' → ')
23
+ });
24
+ }
25
+ }
9
26
  }
10
- return new r();
27
+ return c;
11
28
  }
12
- static hasResolver(e) {
13
- return this.resolvers.has(e);
29
+ hasCycleDFS(e, t, c, s, n) {
30
+ if (c.has(e)) {
31
+ t.push(e);
32
+ return true;
33
+ }
34
+ if (s.has(e)) {
35
+ return false;
36
+ }
37
+ t.push(e);
38
+ c.add(e);
39
+ const r = n.get(e);
40
+ if (r?.dependencies && r.dependencies.length > 0) {
41
+ for (const e of r.dependencies){
42
+ if (this.hasCycleDFS(e, t, c, s, n)) {
43
+ return true;
44
+ }
45
+ }
46
+ }
47
+ c.delete(e);
48
+ s.add(e);
49
+ return false;
50
+ }
51
+ };
52
+ class CycleDetector {
53
+ static getInstance() {
54
+ return CycleDetector.instance;
14
55
  }
15
- static getRegisteredTypes() {
16
- return Array.from(this.resolvers.keys());
56
+ static enable() {
57
+ CycleDetector.instance = new ActiveCycleDetector();
17
58
  }
18
- static clear() {
19
- this.resolvers.clear();
59
+ static disable() {
60
+ CycleDetector.instance = new NoOpCycleDetector();
20
61
  }
21
62
  }
22
- ResolverStore.resolvers = new Map();
63
+ CycleDetector.instance = new NoOpCycleDetector();
23
64
 
24
- export { ResolverStore };
65
+ export { CycleDetector };
package/dist/index4.js CHANGED
@@ -3,13 +3,13 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const core = require('@assemblerjs/core');
6
- const injectableManager = require('./index30.js');
7
- const objectManager = require('./index31.js');
8
- const hookManager = require('./index32.js');
9
- const assemblerBuilder = require('./index33.js');
10
- const contextProvider = require('./index34.js');
11
- const debugLogger = require('./index35.js');
12
- const cycleDetector = require('./index36.js');
6
+ const injectableManager = require('./index33.js');
7
+ const objectManager = require('./index34.js');
8
+ const hookManager = require('./index35.js');
9
+ const assemblerBuilder = require('./index36.js');
10
+ const contextProvider = require('./index37.js');
11
+ const debugLogger = require('./index38.js');
12
+ const cycleDetector = require('./index39.js');
13
13
  const eventManager = require('./index6.js');
14
14
 
15
15
  class Assembler extends eventManager.EventManager {
package/dist/index4.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  import { clearInstance } from '@assemblerjs/core';
2
- import { InjectableManager } from './index30.mjs';
3
- import { ObjectManager } from './index31.mjs';
4
- import { HookManager } from './index32.mjs';
5
- import { AssemblerBuilder } from './index33.mjs';
6
- import { ContextProvider } from './index34.mjs';
7
- import { DebugLogger } from './index35.mjs';
8
- import { CycleDetector } from './index36.mjs';
2
+ import { InjectableManager } from './index33.mjs';
3
+ import { ObjectManager } from './index34.mjs';
4
+ import { HookManager } from './index35.mjs';
5
+ import { AssemblerBuilder } from './index36.mjs';
6
+ import { ContextProvider } from './index37.mjs';
7
+ import { DebugLogger } from './index38.mjs';
8
+ import { CycleDetector } from './index39.mjs';
9
9
  import { EventManager } from './index6.mjs';
10
10
 
11
11
  class Assembler extends EventManager {
package/dist/index40.js CHANGED
@@ -2,110 +2,45 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const transversalManager = require('./index13.js');
6
- const affect = require('./index12.js');
5
+ const eventManager = require('./index6.js');
7
6
 
8
- class TransversalWeaver {
9
- static weave(n, r, o) {
10
- const c = transversalManager.TransversalManager.getInstance(o);
11
- const s = c.getAspectsForTarget(r);
12
- const a = Object.getPrototypeOf(n);
13
- const f = Object.getOwnPropertyNames(a).some((t)=>{
14
- if (t === 'constructor') return false;
15
- const n = Object.getOwnPropertyDescriptor(a, t);
16
- if (!n) return false;
17
- const r = n.value && typeof n.value === 'function';
18
- const o = n.get && typeof n.get === 'function';
19
- if (!r && !o) return false;
20
- const c = affect.getAffectedMethods(a, t);
21
- return c.length > 0;
22
- });
23
- if (s.length === 0 && !f) {
24
- return n;
7
+ const registerEvents = (t, n)=>{
8
+ const o = t.concrete !== undefined && t.concrete.prototype instanceof eventManager.EventManager;
9
+ if (o) {
10
+ const e = n;
11
+ const o = e.channels;
12
+ for (const n of t.events){
13
+ if (!o.has(n)) e.addChannels(n);
14
+ if (!t.privateContext.events.has(n)) t.privateContext.addChannels(n);
25
15
  }
26
- return new Proxy(n, {
27
- get (t, e, n) {
28
- const r = Reflect.get(t, e, n);
29
- if (typeof r !== 'function') {
30
- return r;
31
- }
32
- return function(...n) {
33
- const o = String(e);
34
- const a = {
35
- target: t,
36
- methodName: o,
37
- args: n
38
- };
39
- const f = c.getAdvicesForJoinPoint(a, s, t, e);
40
- return TransversalWeaver.executeAdviceChain(f, r, t, n, a);
41
- };
42
- }
43
- });
44
- }
45
- static executeAdviceChain(t, e, n, r, o) {
46
- const c = t.filter((t)=>t.type === 'before');
47
- const s = t.filter((t)=>t.type === 'around');
48
- const a = t.filter((t)=>t.type === 'after');
49
- try {
50
- for (const t of c){
51
- const e = {
52
- ...o,
53
- config: t.config
54
- };
55
- t.method.call(t.transversalInstance, e);
56
- }
57
- let t;
58
- if (s.length > 0) {
59
- t = this.buildAroundChain(s, e, n, r, o);
60
- } else {
61
- t = e.apply(n, r);
62
- }
63
- if (t instanceof Promise) {
64
- return t.then((t)=>{
65
- for (const e of a){
66
- const n = {
67
- ...o,
68
- result: t
69
- };
70
- e.method.call(e.transversalInstance, n);
71
- }
72
- return t;
73
- }).catch((t)=>{
74
- o.error = t;
75
- throw t;
76
- });
77
- }
78
- for (const e of a){
79
- const n = {
80
- ...o,
81
- result: t,
82
- config: e.config
83
- };
84
- e.method.call(e.transversalInstance, n);
85
- }
86
- return t;
87
- } catch (t) {
88
- o.error = t;
89
- throw t;
16
+ for (const e of t.events){
17
+ n.on(e, (...n)=>{
18
+ t.privateContext.emit(e, ...n);
19
+ });
20
+ }
21
+ } else {
22
+ for (const e of t.events){
23
+ if (!t.privateContext.events.has(e)) t.privateContext.addChannels(e);
90
24
  }
91
25
  }
92
- static buildAroundChain(t, e, n, r, o) {
93
- let c = 0;
94
- const s = ()=>{
95
- if (c < t.length) {
96
- const e = t[c++];
97
- const n = {
98
- ...o,
99
- proceed: s,
100
- config: e.config
101
- };
102
- return e.method.call(e.transversalInstance, n);
103
- } else {
104
- return e.apply(n, r);
26
+ };
27
+ const unregisterEvents = (t, n)=>{
28
+ const o = t.concrete !== undefined && t.concrete.prototype instanceof eventManager.EventManager;
29
+ if (o) {
30
+ const e = n;
31
+ for (const n of t.events){
32
+ e.off(n);
33
+ }
34
+ e.removeChannels(...t.events);
35
+ t.privateContext.removeChannels(...t.events);
36
+ } else {
37
+ for (const e of t.events){
38
+ if (t.privateContext.events.has(e)) {
39
+ t.privateContext.removeChannels(e);
105
40
  }
106
- };
107
- return s();
41
+ }
108
42
  }
109
- }
43
+ };
110
44
 
111
- exports.TransversalWeaver = TransversalWeaver;
45
+ exports.registerEvents = registerEvents;
46
+ exports.unregisterEvents = unregisterEvents;
package/dist/index40.mjs CHANGED
@@ -1,107 +1,41 @@
1
- import { TransversalManager } from './index13.mjs';
2
- import { getAffectedMethods } from './index12.mjs';
1
+ import { EventManager } from './index6.mjs';
3
2
 
4
- class TransversalWeaver {
5
- static weave(n, r, o) {
6
- const c = TransversalManager.getInstance(o);
7
- const s = c.getAspectsForTarget(r);
8
- const a = Object.getPrototypeOf(n);
9
- const f = Object.getOwnPropertyNames(a).some((t)=>{
10
- if (t === 'constructor') return false;
11
- const n = Object.getOwnPropertyDescriptor(a, t);
12
- if (!n) return false;
13
- const r = n.value && typeof n.value === 'function';
14
- const o = n.get && typeof n.get === 'function';
15
- if (!r && !o) return false;
16
- const c = getAffectedMethods(a, t);
17
- return c.length > 0;
18
- });
19
- if (s.length === 0 && !f) {
20
- return n;
3
+ const registerEvents = (t, n)=>{
4
+ const o = t.concrete !== undefined && t.concrete.prototype instanceof EventManager;
5
+ if (o) {
6
+ const e = n;
7
+ const o = e.channels;
8
+ for (const n of t.events){
9
+ if (!o.has(n)) e.addChannels(n);
10
+ if (!t.privateContext.events.has(n)) t.privateContext.addChannels(n);
21
11
  }
22
- return new Proxy(n, {
23
- get (t, e, n) {
24
- const r = Reflect.get(t, e, n);
25
- if (typeof r !== 'function') {
26
- return r;
27
- }
28
- return function(...n) {
29
- const o = String(e);
30
- const a = {
31
- target: t,
32
- methodName: o,
33
- args: n
34
- };
35
- const f = c.getAdvicesForJoinPoint(a, s, t, e);
36
- return TransversalWeaver.executeAdviceChain(f, r, t, n, a);
37
- };
38
- }
39
- });
40
- }
41
- static executeAdviceChain(t, e, n, r, o) {
42
- const c = t.filter((t)=>t.type === 'before');
43
- const s = t.filter((t)=>t.type === 'around');
44
- const a = t.filter((t)=>t.type === 'after');
45
- try {
46
- for (const t of c){
47
- const e = {
48
- ...o,
49
- config: t.config
50
- };
51
- t.method.call(t.transversalInstance, e);
52
- }
53
- let t;
54
- if (s.length > 0) {
55
- t = this.buildAroundChain(s, e, n, r, o);
56
- } else {
57
- t = e.apply(n, r);
58
- }
59
- if (t instanceof Promise) {
60
- return t.then((t)=>{
61
- for (const e of a){
62
- const n = {
63
- ...o,
64
- result: t
65
- };
66
- e.method.call(e.transversalInstance, n);
67
- }
68
- return t;
69
- }).catch((t)=>{
70
- o.error = t;
71
- throw t;
72
- });
73
- }
74
- for (const e of a){
75
- const n = {
76
- ...o,
77
- result: t,
78
- config: e.config
79
- };
80
- e.method.call(e.transversalInstance, n);
81
- }
82
- return t;
83
- } catch (t) {
84
- o.error = t;
85
- throw t;
12
+ for (const e of t.events){
13
+ n.on(e, (...n)=>{
14
+ t.privateContext.emit(e, ...n);
15
+ });
16
+ }
17
+ } else {
18
+ for (const e of t.events){
19
+ if (!t.privateContext.events.has(e)) t.privateContext.addChannels(e);
86
20
  }
87
21
  }
88
- static buildAroundChain(t, e, n, r, o) {
89
- let c = 0;
90
- const s = ()=>{
91
- if (c < t.length) {
92
- const e = t[c++];
93
- const n = {
94
- ...o,
95
- proceed: s,
96
- config: e.config
97
- };
98
- return e.method.call(e.transversalInstance, n);
99
- } else {
100
- return e.apply(n, r);
22
+ };
23
+ const unregisterEvents = (t, n)=>{
24
+ const o = t.concrete !== undefined && t.concrete.prototype instanceof EventManager;
25
+ if (o) {
26
+ const e = n;
27
+ for (const n of t.events){
28
+ e.off(n);
29
+ }
30
+ e.removeChannels(...t.events);
31
+ t.privateContext.removeChannels(...t.events);
32
+ } else {
33
+ for (const e of t.events){
34
+ if (t.privateContext.events.has(e)) {
35
+ t.privateContext.removeChannels(e);
101
36
  }
102
- };
103
- return s();
37
+ }
104
38
  }
105
- }
39
+ };
106
40
 
107
- export { TransversalWeaver };
41
+ export { registerEvents, unregisterEvents };
package/dist/index41.js CHANGED
@@ -2,33 +2,27 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- class PointcutMatcher {
6
- static parse(t) {
7
- const e = t.match(/^execution\(([^.]+)\.([^)]+)\)$/);
8
- if (!e) {
9
- throw new Error(`Invalid pointcut expression: ${t}`);
5
+ class ResolverStore {
6
+ static register(e, r) {
7
+ this.resolvers.set(e, r);
8
+ }
9
+ static getResolver(e) {
10
+ const r = this.resolvers.get(e);
11
+ if (!r) {
12
+ throw new Error(`No resolver found for decorator type: ${e}`);
10
13
  }
11
- const [, c, r] = e;
12
- return new ExecutionPointcutMatcher(c, r);
14
+ return new r();
13
15
  }
14
- }
15
- let ExecutionPointcutMatcher = class ExecutionPointcutMatcher {
16
- matches(t) {
17
- const e = t.target.constructor.name;
18
- const c = t.methodName;
19
- return this.classRegex.test(e) && this.methodRegex.test(c);
16
+ static hasResolver(e) {
17
+ return this.resolvers.has(e);
20
18
  }
21
- patternToRegex(t) {
22
- if (t === '*') {
23
- return /.*/;
24
- }
25
- const e = t.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
26
- return new RegExp(`^${e}$`);
19
+ static getRegisteredTypes() {
20
+ return Array.from(this.resolvers.keys());
27
21
  }
28
- constructor(t, e){
29
- this.classRegex = this.patternToRegex(t);
30
- this.methodRegex = this.patternToRegex(e);
22
+ static clear() {
23
+ this.resolvers.clear();
31
24
  }
32
- };
25
+ }
26
+ ResolverStore.resolvers = new Map();
33
27
 
34
- exports.PointcutMatcher = PointcutMatcher;
28
+ exports.ResolverStore = ResolverStore;
package/dist/index41.mjs CHANGED
@@ -1,30 +1,24 @@
1
- class PointcutMatcher {
2
- static parse(t) {
3
- const e = t.match(/^execution\(([^.]+)\.([^)]+)\)$/);
4
- if (!e) {
5
- throw new Error(`Invalid pointcut expression: ${t}`);
1
+ class ResolverStore {
2
+ static register(e, r) {
3
+ this.resolvers.set(e, r);
4
+ }
5
+ static getResolver(e) {
6
+ const r = this.resolvers.get(e);
7
+ if (!r) {
8
+ throw new Error(`No resolver found for decorator type: ${e}`);
6
9
  }
7
- const [, c, r] = e;
8
- return new ExecutionPointcutMatcher(c, r);
10
+ return new r();
9
11
  }
10
- }
11
- let ExecutionPointcutMatcher = class ExecutionPointcutMatcher {
12
- matches(t) {
13
- const e = t.target.constructor.name;
14
- const c = t.methodName;
15
- return this.classRegex.test(e) && this.methodRegex.test(c);
12
+ static hasResolver(e) {
13
+ return this.resolvers.has(e);
16
14
  }
17
- patternToRegex(t) {
18
- if (t === '*') {
19
- return /.*/;
20
- }
21
- const e = t.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
22
- return new RegExp(`^${e}$`);
15
+ static getRegisteredTypes() {
16
+ return Array.from(this.resolvers.keys());
23
17
  }
24
- constructor(t, e){
25
- this.classRegex = this.patternToRegex(t);
26
- this.methodRegex = this.patternToRegex(e);
18
+ static clear() {
19
+ this.resolvers.clear();
27
20
  }
28
- };
21
+ }
22
+ ResolverStore.resolvers = new Map();
29
23
 
30
- export { PointcutMatcher };
24
+ export { ResolverStore };
package/dist/index42.js CHANGED
@@ -2,33 +2,53 @@
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
+ const core = require('@assemblerjs/core');
32
6
 
33
- exports.SingletonStrategy = SingletonStrategy;
34
- exports.TransientStrategy = TransientStrategy;
7
+ const i = (e)=>{
8
+ return {
9
+ identifier: e[0],
10
+ concrete: e[0],
11
+ configuration: {}
12
+ };
13
+ };
14
+ const c = (o)=>{
15
+ const i = ()=>core.isClass(o[0]) && core.isClass(o[1]);
16
+ const c = ()=>core.isClass(o[0]) && core.isObject(o[1]);
17
+ const s = ()=>core.pipe(core.conditionally({
18
+ if: ()=>i(),
19
+ then: ()=>{
20
+ return {
21
+ identifier: o[0],
22
+ concrete: o[1],
23
+ configuration: {}
24
+ };
25
+ }
26
+ }), core.conditionally({
27
+ if: ()=>c(),
28
+ then: ()=>{
29
+ return {
30
+ identifier: o[0],
31
+ concrete: o[0],
32
+ configuration: o[1]
33
+ };
34
+ },
35
+ else: (e)=>e
36
+ }))();
37
+ return s();
38
+ };
39
+ const s = (e)=>{
40
+ return {
41
+ identifier: e[0],
42
+ concrete: e[1],
43
+ configuration: e[2]
44
+ };
45
+ };
46
+ const resolveInjectionTuple = (e)=>core.switchCase({
47
+ 1: ()=>i(e),
48
+ 2: ()=>c(e),
49
+ 3: ()=>s(e)
50
+ }, ()=>{
51
+ throw new Error(`Injection tuple must be of length 1, 2 or 3.`);
52
+ })(e.length);
53
+
54
+ exports.resolveInjectionTuple = resolveInjectionTuple;
package/dist/index42.mjs CHANGED
@@ -1,29 +1,50 @@
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
+ import { switchCase, pipe, conditionally, isClass, isObject } from '@assemblerjs/core';
28
2
 
29
- export { SingletonStrategy, TransientStrategy };
3
+ const i = (e)=>{
4
+ return {
5
+ identifier: e[0],
6
+ concrete: e[0],
7
+ configuration: {}
8
+ };
9
+ };
10
+ const c = (o)=>{
11
+ const i = ()=>isClass(o[0]) && isClass(o[1]);
12
+ const c = ()=>isClass(o[0]) && isObject(o[1]);
13
+ const s = ()=>pipe(conditionally({
14
+ if: ()=>i(),
15
+ then: ()=>{
16
+ return {
17
+ identifier: o[0],
18
+ concrete: o[1],
19
+ configuration: {}
20
+ };
21
+ }
22
+ }), conditionally({
23
+ if: ()=>c(),
24
+ then: ()=>{
25
+ return {
26
+ identifier: o[0],
27
+ concrete: o[0],
28
+ configuration: o[1]
29
+ };
30
+ },
31
+ else: (e)=>e
32
+ }))();
33
+ return s();
34
+ };
35
+ const s = (e)=>{
36
+ return {
37
+ identifier: e[0],
38
+ concrete: e[1],
39
+ configuration: e[2]
40
+ };
41
+ };
42
+ const resolveInjectionTuple = (e)=>switchCase({
43
+ 1: ()=>i(e),
44
+ 2: ()=>c(e),
45
+ 3: ()=>s(e)
46
+ }, ()=>{
47
+ throw new Error(`Injection tuple must be of length 1, 2 or 3.`);
48
+ })(e.length);
49
+
50
+ export { resolveInjectionTuple };