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.
- package/dist/index.d.ts +2 -1
- package/dist/index11.js +2 -2
- package/dist/index11.mjs +2 -2
- package/dist/index13.js +98 -83
- package/dist/index13.mjs +98 -83
- package/dist/index16.js +1 -1
- package/dist/index16.mjs +1 -1
- package/dist/index17.js +1 -1
- package/dist/index17.mjs +1 -1
- package/dist/index18.js +1 -1
- package/dist/index18.mjs +1 -1
- package/dist/index19.js +1 -1
- package/dist/index19.mjs +1 -1
- package/dist/index2.js +2 -2
- package/dist/index2.mjs +2 -2
- package/dist/index20.js +1 -1
- package/dist/index20.mjs +1 -1
- package/dist/index21.js +1 -1
- package/dist/index21.mjs +1 -1
- package/dist/index22.js +2 -2
- package/dist/index22.mjs +2 -2
- package/dist/index23.js +2 -2
- package/dist/index23.mjs +2 -2
- package/dist/index24.js +2 -2
- package/dist/index24.mjs +2 -2
- package/dist/index25.js +1 -1
- package/dist/index25.mjs +1 -1
- package/dist/index26.js +1 -1
- package/dist/index26.mjs +1 -1
- package/dist/index27.js +1 -1
- package/dist/index27.mjs +1 -1
- package/dist/index29.js +38 -15
- package/dist/index29.mjs +37 -12
- package/dist/index3.js +1 -1
- package/dist/index3.mjs +1 -1
- package/dist/index30.js +151 -100
- package/dist/index30.mjs +150 -98
- package/dist/index31.js +44 -34
- package/dist/index31.mjs +44 -33
- package/dist/index32.js +73 -16
- package/dist/index32.mjs +73 -16
- package/dist/index33.js +48 -98
- package/dist/index33.mjs +48 -98
- package/dist/index34.js +29 -26
- package/dist/index34.mjs +29 -26
- package/dist/index35.js +146 -138
- package/dist/index35.mjs +146 -137
- package/dist/index36.js +56 -43
- package/dist/index36.mjs +56 -43
- package/dist/index37.js +15 -77
- package/dist/index37.mjs +12 -77
- package/dist/index38.js +103 -51
- package/dist/index38.mjs +101 -51
- package/dist/index39.js +19 -28
- package/dist/index39.mjs +19 -28
- package/dist/index4.js +10 -10
- package/dist/index4.mjs +10 -10
- package/dist/index40.js +94 -151
- package/dist/index40.mjs +94 -151
- package/dist/index41.js +24 -59
- package/dist/index41.mjs +24 -59
- package/dist/index42.js +29 -49
- package/dist/index42.mjs +28 -49
- package/dist/index44.js +50 -943
- package/dist/index44.mjs +48 -941
- package/dist/index45.js +194 -2
- package/dist/index45.mjs +194 -2
- package/dist/index46.js +942 -2
- package/dist/index46.mjs +942 -2
- package/dist/index47.js +2 -29
- package/dist/index47.mjs +2 -28
- package/dist/index48.js +2 -194
- package/dist/index48.mjs +2 -194
- package/dist/index49.js +1 -1
- package/dist/index49.mjs +1 -1
- package/dist/index50.js +2 -2
- package/dist/index50.mjs +2 -2
- package/dist/index51.js +16 -13
- package/dist/index51.mjs +16 -13
- package/package.json +1 -1
package/dist/index40.mjs
CHANGED
|
@@ -1,164 +1,107 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return
|
|
1
|
+
import { TransversalManager } from './index13.mjs';
|
|
2
|
+
import { getAffectedMethods } from './index12.mjs';
|
|
3
|
+
|
|
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;
|
|
18
21
|
}
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
let ActiveDebugLogger = class ActiveDebugLogger {
|
|
36
|
-
configure(o) {
|
|
37
|
-
this.options = {
|
|
38
|
-
...this.options,
|
|
39
|
-
...o,
|
|
40
|
-
logPhases: {
|
|
41
|
-
...this.options.logPhases,
|
|
42
|
-
...o.logPhases || {}
|
|
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
|
+
};
|
|
43
38
|
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
logBuildStart(o) {
|
|
47
|
-
this.log('info', 'Build started', {
|
|
48
|
-
entry: o.name
|
|
49
39
|
});
|
|
50
40
|
}
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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;
|
|
79
72
|
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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;
|
|
92
86
|
}
|
|
93
|
-
this.log('info', `Phase: ${o} ended`, Object.keys(n).length > 0 ? n : undefined);
|
|
94
|
-
}
|
|
95
|
-
logResolution(o, e, t) {
|
|
96
|
-
if (!this.shouldLog('resolution')) return;
|
|
97
|
-
this.log('info', `Resolving: ${o}`, {
|
|
98
|
-
strategy: `${e} strategy`,
|
|
99
|
-
cache: t ? 'hit' : 'miss'
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
logConstruction(o) {
|
|
103
|
-
if (!this.shouldLog('construction')) return;
|
|
104
|
-
this.log('info', `Constructing: ${o}`);
|
|
105
|
-
}
|
|
106
|
-
shouldLog(o) {
|
|
107
|
-
return !this.options.logPhases || this.options.logPhases[o] !== false;
|
|
108
87
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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);
|
|
117
99
|
} else {
|
|
118
|
-
|
|
100
|
+
return e.apply(n, r);
|
|
119
101
|
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
colorize(o, e) {
|
|
123
|
-
const t = {
|
|
124
|
-
info: '\x1b[36m',
|
|
125
|
-
warn: '\x1b[33m',
|
|
126
|
-
error: '\x1b[31m',
|
|
127
|
-
reset: '\x1b[0m'
|
|
128
|
-
};
|
|
129
|
-
const n = t[o] || t.info;
|
|
130
|
-
return `${n}${e}${t.reset}`;
|
|
131
|
-
}
|
|
132
|
-
constructor(){
|
|
133
|
-
this.options = {
|
|
134
|
-
enabled: true,
|
|
135
|
-
logPhases: {
|
|
136
|
-
registration: true,
|
|
137
|
-
resolution: true,
|
|
138
|
-
construction: true,
|
|
139
|
-
hooks: true,
|
|
140
|
-
cache: true
|
|
141
|
-
},
|
|
142
|
-
logTimings: false,
|
|
143
|
-
logDependencyTree: true,
|
|
144
|
-
useColors: true
|
|
145
102
|
};
|
|
146
|
-
|
|
147
|
-
};
|
|
148
|
-
class DebugLogger {
|
|
149
|
-
static getInstance() {
|
|
150
|
-
return DebugLogger.instance;
|
|
151
|
-
}
|
|
152
|
-
static enable(o) {
|
|
153
|
-
DebugLogger.instance = new ActiveDebugLogger();
|
|
154
|
-
if (o) {
|
|
155
|
-
DebugLogger.instance.configure(o);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
static disable() {
|
|
159
|
-
DebugLogger.instance = new NoOpDebugLogger();
|
|
103
|
+
return s();
|
|
160
104
|
}
|
|
161
105
|
}
|
|
162
|
-
DebugLogger.instance = new NoOpDebugLogger();
|
|
163
106
|
|
|
164
|
-
export {
|
|
107
|
+
export { TransversalWeaver };
|
package/dist/index41.js
CHANGED
|
@@ -2,68 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
let ActiveCycleDetector = class ActiveCycleDetector extends AbstractCycleDetector {
|
|
13
|
-
detect(e, t) {
|
|
14
|
-
const c = [];
|
|
15
|
-
const s = new Set();
|
|
16
|
-
for (const [n] of e){
|
|
17
|
-
if (s.has(n)) continue;
|
|
18
|
-
const r = [];
|
|
19
|
-
const o = new Set();
|
|
20
|
-
if (this.hasCycleDFS(n, r, o, s, e)) {
|
|
21
|
-
const e = r.findIndex((e)=>e === n);
|
|
22
|
-
if (e >= 0) {
|
|
23
|
-
const s = r.slice(e).map((e)=>t(e));
|
|
24
|
-
c.push({
|
|
25
|
-
cycle: s,
|
|
26
|
-
path: s.join(' → ')
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return c;
|
|
32
|
-
}
|
|
33
|
-
hasCycleDFS(e, t, c, s, n) {
|
|
34
|
-
if (c.has(e)) {
|
|
35
|
-
t.push(e);
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
if (s.has(e)) {
|
|
39
|
-
return false;
|
|
5
|
+
class PointcutMatcher {
|
|
6
|
+
static parse(t) {
|
|
7
|
+
const e = t.match(/^execution\(([^.]+)\.([^)]+)\)$/);
|
|
8
|
+
if (!e) {
|
|
9
|
+
throw new Error(`Invalid pointcut expression: ${t}`);
|
|
40
10
|
}
|
|
41
|
-
|
|
42
|
-
c
|
|
43
|
-
const r = n.get(e);
|
|
44
|
-
if (r?.dependencies && r.dependencies.length > 0) {
|
|
45
|
-
for (const e of r.dependencies){
|
|
46
|
-
if (this.hasCycleDFS(e, t, c, s, n)) {
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
c.delete(e);
|
|
52
|
-
s.add(e);
|
|
53
|
-
return false;
|
|
11
|
+
const [, c, r] = e;
|
|
12
|
+
return new ExecutionPointcutMatcher(c, r);
|
|
54
13
|
}
|
|
55
|
-
}
|
|
56
|
-
class
|
|
57
|
-
|
|
58
|
-
|
|
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);
|
|
59
20
|
}
|
|
60
|
-
|
|
61
|
-
|
|
21
|
+
patternToRegex(t) {
|
|
22
|
+
if (t === '*') {
|
|
23
|
+
return /.*/;
|
|
24
|
+
}
|
|
25
|
+
const e = t.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
|
|
26
|
+
return new RegExp(`^${e}$`);
|
|
62
27
|
}
|
|
63
|
-
|
|
64
|
-
|
|
28
|
+
constructor(t, e){
|
|
29
|
+
this.classRegex = this.patternToRegex(t);
|
|
30
|
+
this.methodRegex = this.patternToRegex(e);
|
|
65
31
|
}
|
|
66
|
-
}
|
|
67
|
-
CycleDetector.instance = new NoOpCycleDetector();
|
|
32
|
+
};
|
|
68
33
|
|
|
69
|
-
exports.
|
|
34
|
+
exports.PointcutMatcher = PointcutMatcher;
|
package/dist/index41.mjs
CHANGED
|
@@ -1,65 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
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
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return c;
|
|
28
|
-
}
|
|
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;
|
|
1
|
+
class PointcutMatcher {
|
|
2
|
+
static parse(t) {
|
|
3
|
+
const e = t.match(/^execution\(([^.]+)\.([^)]+)\)$/);
|
|
4
|
+
if (!e) {
|
|
5
|
+
throw new Error(`Invalid pointcut expression: ${t}`);
|
|
36
6
|
}
|
|
37
|
-
|
|
38
|
-
c
|
|
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;
|
|
7
|
+
const [, c, r] = e;
|
|
8
|
+
return new ExecutionPointcutMatcher(c, r);
|
|
50
9
|
}
|
|
51
|
-
}
|
|
52
|
-
class
|
|
53
|
-
|
|
54
|
-
|
|
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);
|
|
55
16
|
}
|
|
56
|
-
|
|
57
|
-
|
|
17
|
+
patternToRegex(t) {
|
|
18
|
+
if (t === '*') {
|
|
19
|
+
return /.*/;
|
|
20
|
+
}
|
|
21
|
+
const e = t.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
|
|
22
|
+
return new RegExp(`^${e}$`);
|
|
58
23
|
}
|
|
59
|
-
|
|
60
|
-
|
|
24
|
+
constructor(t, e){
|
|
25
|
+
this.classRegex = this.patternToRegex(t);
|
|
26
|
+
this.methodRegex = this.patternToRegex(e);
|
|
61
27
|
}
|
|
62
|
-
}
|
|
63
|
-
CycleDetector.instance = new NoOpCycleDetector();
|
|
28
|
+
};
|
|
64
29
|
|
|
65
|
-
export {
|
|
30
|
+
export { PointcutMatcher };
|
package/dist/index42.js
CHANGED
|
@@ -2,53 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
|
|
8
|
-
|
|
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;
|
|
33
|
+
exports.SingletonStrategy = SingletonStrategy;
|
|
34
|
+
exports.TransientStrategy = TransientStrategy;
|
package/dist/index42.mjs
CHANGED
|
@@ -1,50 +1,29 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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 };
|
|
29
|
+
export { SingletonStrategy, TransientStrategy };
|