assemblerjs 1.1.5 → 1.1.6
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 +1 -0
- package/dist/index13.js +1 -1
- package/dist/index13.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/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 +1 -1
- package/dist/index22.mjs +1 -1
- package/dist/index23.js +1 -1
- package/dist/index23.mjs +1 -1
- package/dist/index24.js +1 -1
- package/dist/index24.mjs +1 -1
- package/dist/index31.js +17 -8
- package/dist/index31.mjs +17 -8
- package/dist/index38.js +18 -101
- package/dist/index38.mjs +18 -101
- package/dist/index39.js +101 -24
- package/dist/index39.mjs +101 -24
- package/dist/index40.js +24 -18
- package/dist/index40.mjs +24 -18
- package/dist/index48.js +1 -1
- package/dist/index48.mjs +1 -1
- package/dist/index49.js +1 -1
- package/dist/index49.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index13.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const core = require('@assemblerjs/core');
|
|
6
|
-
const pointcutMatcher = require('./
|
|
6
|
+
const pointcutMatcher = require('./index40.js');
|
|
7
7
|
const affect = require('./index12.js');
|
|
8
8
|
const schema = require('./index30.js');
|
|
9
9
|
|
package/dist/index13.mjs
CHANGED
package/dist/index18.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const parameterDecoratorFactory = require('./index17.js');
|
|
6
|
-
const resolverStore = require('./
|
|
6
|
+
const resolverStore = require('./index38.js');
|
|
7
7
|
|
|
8
8
|
let ContextResolver = class ContextResolver {
|
|
9
9
|
resolve(e, r, t) {
|
package/dist/index18.mjs
CHANGED
package/dist/index19.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const parameterDecoratorFactory = require('./index17.js');
|
|
6
|
-
const resolverStore = require('./
|
|
6
|
+
const resolverStore = require('./index38.js');
|
|
7
7
|
|
|
8
8
|
let ConfigurationResolver = class ConfigurationResolver {
|
|
9
9
|
resolve(r, o, e, n) {
|
package/dist/index19.mjs
CHANGED
package/dist/index20.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const parameterDecoratorFactory = require('./index17.js');
|
|
6
|
-
const resolverStore = require('./
|
|
6
|
+
const resolverStore = require('./index38.js');
|
|
7
7
|
|
|
8
8
|
let DefinitionResolver = class DefinitionResolver {
|
|
9
9
|
resolve(e, r) {
|
package/dist/index20.mjs
CHANGED
package/dist/index21.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const parameterDecoratorFactory = require('./index17.js');
|
|
6
|
-
const resolverStore = require('./
|
|
6
|
+
const resolverStore = require('./index38.js');
|
|
7
7
|
|
|
8
8
|
let DisposeResolver = class DisposeResolver {
|
|
9
9
|
resolve(e, r, s) {
|
package/dist/index21.mjs
CHANGED
package/dist/index22.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
5
5
|
const reflection = require('./index29.js');
|
|
6
6
|
const parameterDecoratorFactory = require('./index17.js');
|
|
7
7
|
const helpers = require('./index25.js');
|
|
8
|
-
const resolverStore = require('./
|
|
8
|
+
const resolverStore = require('./index38.js');
|
|
9
9
|
|
|
10
10
|
let UseResolver = class UseResolver {
|
|
11
11
|
resolve(r, o, t) {
|
package/dist/index22.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getOwnCustomMetadata } from './index29.mjs';
|
|
2
2
|
import { ParameterDecoratorFactory } from './index17.mjs';
|
|
3
3
|
import { getParamValueKey } from './index25.mjs';
|
|
4
|
-
import { ResolverStore } from './
|
|
4
|
+
import { ResolverStore } from './index38.mjs';
|
|
5
5
|
|
|
6
6
|
let UseResolver = class UseResolver {
|
|
7
7
|
resolve(r, o, t) {
|
package/dist/index23.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
5
5
|
const reflection = require('./index29.js');
|
|
6
6
|
const parameterDecoratorFactory = require('./index17.js');
|
|
7
7
|
const helpers = require('./index25.js');
|
|
8
|
-
const resolverStore = require('./
|
|
8
|
+
const resolverStore = require('./index38.js');
|
|
9
9
|
|
|
10
10
|
let GlobalResolver = class GlobalResolver {
|
|
11
11
|
resolve(e, r, a) {
|
package/dist/index23.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getOwnCustomMetadata } from './index29.mjs';
|
|
2
2
|
import { ParameterDecoratorFactory } from './index17.mjs';
|
|
3
3
|
import { getParamValueKey } from './index25.mjs';
|
|
4
|
-
import { ResolverStore } from './
|
|
4
|
+
import { ResolverStore } from './index38.mjs';
|
|
5
5
|
|
|
6
6
|
let GlobalResolver = class GlobalResolver {
|
|
7
7
|
resolve(e, r, a) {
|
package/dist/index24.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
5
5
|
const reflection = require('./index29.js');
|
|
6
6
|
const parameterDecoratorFactory = require('./index17.js');
|
|
7
7
|
const helpers = require('./index25.js');
|
|
8
|
-
const resolverStore = require('./
|
|
8
|
+
const resolverStore = require('./index38.js');
|
|
9
9
|
|
|
10
10
|
let OptionalResolver = class OptionalResolver {
|
|
11
11
|
resolve(o, t, n) {
|
package/dist/index24.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getParamTypes, getOwnCustomMetadata } from './index29.mjs';
|
|
2
2
|
import { ParameterDecoratorFactory } from './index17.mjs';
|
|
3
3
|
import { getParamValueKey } from './index25.mjs';
|
|
4
|
-
import { ResolverStore } from './
|
|
4
|
+
import { ResolverStore } from './index38.mjs';
|
|
5
5
|
|
|
6
6
|
let OptionalResolver = class OptionalResolver {
|
|
7
7
|
resolve(o, t, n) {
|
package/dist/index31.js
CHANGED
|
@@ -38,19 +38,26 @@ class InjectableManager {
|
|
|
38
38
|
}
|
|
39
39
|
require(e, t, i) {
|
|
40
40
|
if (!this.injectables.has(e)) {
|
|
41
|
-
const t =
|
|
42
|
-
|
|
41
|
+
const t = this.resolvingStack.has(e);
|
|
42
|
+
const r = t ? 'Circular dependency detected' : 'Dependency not registered';
|
|
43
|
+
const n = t ? `Circular dependency detected: '${e.name}' is already being resolved.` : `Class with identifier '${e.name}' has not been registered.`;
|
|
44
|
+
debugLogger.DebugLogger.getInstance().log('error', r, {
|
|
43
45
|
identifier: e.name,
|
|
44
46
|
caller: i ? i?.name || String(i) : 'unknown',
|
|
45
|
-
error:
|
|
47
|
+
error: n
|
|
46
48
|
});
|
|
47
|
-
throw new Error(
|
|
49
|
+
throw new Error(n);
|
|
48
50
|
}
|
|
49
51
|
const r = this.injectables.get(e);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
this.resolvingStack.add(r.identifier);
|
|
53
|
+
try {
|
|
54
|
+
if (r.isSingleton) {
|
|
55
|
+
return this.singletonStrategy.resolve(r, t);
|
|
56
|
+
} else {
|
|
57
|
+
return this.transientStrategy.resolve(r, t);
|
|
58
|
+
}
|
|
59
|
+
} finally{
|
|
60
|
+
this.resolvingStack.delete(r.identifier);
|
|
54
61
|
}
|
|
55
62
|
}
|
|
56
63
|
concrete(e) {
|
|
@@ -71,12 +78,14 @@ class InjectableManager {
|
|
|
71
78
|
for (const [e, t] of this.injectables){
|
|
72
79
|
t.dispose();
|
|
73
80
|
}
|
|
81
|
+
this.resolvingStack.clear();
|
|
74
82
|
}
|
|
75
83
|
get size() {
|
|
76
84
|
return this.injectables.size;
|
|
77
85
|
}
|
|
78
86
|
constructor(){
|
|
79
87
|
this.injectables = new Map();
|
|
88
|
+
this.resolvingStack = new Set();
|
|
80
89
|
this.singletonStrategy = new resolutionStrategies.SingletonStrategy();
|
|
81
90
|
this.transientStrategy = new resolutionStrategies.TransientStrategy();
|
|
82
91
|
}
|
package/dist/index31.mjs
CHANGED
|
@@ -34,19 +34,26 @@ class InjectableManager {
|
|
|
34
34
|
}
|
|
35
35
|
require(e, t, i) {
|
|
36
36
|
if (!this.injectables.has(e)) {
|
|
37
|
-
const t =
|
|
38
|
-
|
|
37
|
+
const t = this.resolvingStack.has(e);
|
|
38
|
+
const r = t ? 'Circular dependency detected' : 'Dependency not registered';
|
|
39
|
+
const n = t ? `Circular dependency detected: '${e.name}' is already being resolved.` : `Class with identifier '${e.name}' has not been registered.`;
|
|
40
|
+
DebugLogger.getInstance().log('error', r, {
|
|
39
41
|
identifier: e.name,
|
|
40
42
|
caller: i ? i?.name || String(i) : 'unknown',
|
|
41
|
-
error:
|
|
43
|
+
error: n
|
|
42
44
|
});
|
|
43
|
-
throw new Error(
|
|
45
|
+
throw new Error(n);
|
|
44
46
|
}
|
|
45
47
|
const r = this.injectables.get(e);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
this.resolvingStack.add(r.identifier);
|
|
49
|
+
try {
|
|
50
|
+
if (r.isSingleton) {
|
|
51
|
+
return this.singletonStrategy.resolve(r, t);
|
|
52
|
+
} else {
|
|
53
|
+
return this.transientStrategy.resolve(r, t);
|
|
54
|
+
}
|
|
55
|
+
} finally{
|
|
56
|
+
this.resolvingStack.delete(r.identifier);
|
|
50
57
|
}
|
|
51
58
|
}
|
|
52
59
|
concrete(e) {
|
|
@@ -67,12 +74,14 @@ class InjectableManager {
|
|
|
67
74
|
for (const [e, t] of this.injectables){
|
|
68
75
|
t.dispose();
|
|
69
76
|
}
|
|
77
|
+
this.resolvingStack.clear();
|
|
70
78
|
}
|
|
71
79
|
get size() {
|
|
72
80
|
return this.injectables.size;
|
|
73
81
|
}
|
|
74
82
|
constructor(){
|
|
75
83
|
this.injectables = new Map();
|
|
84
|
+
this.resolvingStack = new Set();
|
|
76
85
|
this.singletonStrategy = new SingletonStrategy();
|
|
77
86
|
this.transientStrategy = new TransientStrategy();
|
|
78
87
|
}
|
package/dist/index38.js
CHANGED
|
@@ -2,110 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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;
|
|
25
|
-
}
|
|
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
|
-
});
|
|
5
|
+
class ResolverStore {
|
|
6
|
+
static register(e, r) {
|
|
7
|
+
this.resolvers.set(e, r);
|
|
44
8
|
}
|
|
45
|
-
static
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
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;
|
|
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}`);
|
|
90
13
|
}
|
|
14
|
+
return new r();
|
|
15
|
+
}
|
|
16
|
+
static hasResolver(e) {
|
|
17
|
+
return this.resolvers.has(e);
|
|
18
|
+
}
|
|
19
|
+
static getRegisteredTypes() {
|
|
20
|
+
return Array.from(this.resolvers.keys());
|
|
91
21
|
}
|
|
92
|
-
static
|
|
93
|
-
|
|
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);
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
return s();
|
|
22
|
+
static clear() {
|
|
23
|
+
this.resolvers.clear();
|
|
108
24
|
}
|
|
109
25
|
}
|
|
26
|
+
ResolverStore.resolvers = new Map();
|
|
110
27
|
|
|
111
|
-
exports.
|
|
28
|
+
exports.ResolverStore = ResolverStore;
|
package/dist/index38.mjs
CHANGED
|
@@ -1,107 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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;
|
|
21
|
-
}
|
|
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
|
-
});
|
|
1
|
+
class ResolverStore {
|
|
2
|
+
static register(e, r) {
|
|
3
|
+
this.resolvers.set(e, r);
|
|
40
4
|
}
|
|
41
|
-
static
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
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;
|
|
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}`);
|
|
86
9
|
}
|
|
10
|
+
return new r();
|
|
11
|
+
}
|
|
12
|
+
static hasResolver(e) {
|
|
13
|
+
return this.resolvers.has(e);
|
|
14
|
+
}
|
|
15
|
+
static getRegisteredTypes() {
|
|
16
|
+
return Array.from(this.resolvers.keys());
|
|
87
17
|
}
|
|
88
|
-
static
|
|
89
|
-
|
|
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);
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
return s();
|
|
18
|
+
static clear() {
|
|
19
|
+
this.resolvers.clear();
|
|
104
20
|
}
|
|
105
21
|
}
|
|
22
|
+
ResolverStore.resolvers = new Map();
|
|
106
23
|
|
|
107
|
-
export {
|
|
24
|
+
export { ResolverStore };
|
package/dist/index39.js
CHANGED
|
@@ -2,33 +2,110 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const transversalManager = require('./index13.js');
|
|
6
|
+
const affect = require('./index12.js');
|
|
7
|
+
|
|
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;
|
|
10
25
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
});
|
|
20
44
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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;
|
|
24
90
|
}
|
|
25
|
-
const e = t.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
|
|
26
|
-
return new RegExp(`^${e}$`);
|
|
27
91
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
return s();
|
|
31
108
|
}
|
|
32
|
-
}
|
|
109
|
+
}
|
|
33
110
|
|
|
34
|
-
exports.
|
|
111
|
+
exports.TransversalWeaver = TransversalWeaver;
|
package/dist/index39.mjs
CHANGED
|
@@ -1,30 +1,107 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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;
|
|
6
21
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
+
});
|
|
16
40
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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;
|
|
20
86
|
}
|
|
21
|
-
const e = t.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
|
|
22
|
-
return new RegExp(`^${e}$`);
|
|
23
87
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
return s();
|
|
27
104
|
}
|
|
28
|
-
}
|
|
105
|
+
}
|
|
29
106
|
|
|
30
|
-
export {
|
|
107
|
+
export { TransversalWeaver };
|
package/dist/index40.js
CHANGED
|
@@ -2,27 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
class
|
|
6
|
-
static
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const r = this.resolvers.get(e);
|
|
11
|
-
if (!r) {
|
|
12
|
-
throw new Error(`No resolver found for decorator type: ${e}`);
|
|
5
|
+
class PointcutMatcher {
|
|
6
|
+
static parse(t) {
|
|
7
|
+
const e = t.match(/^execution\(([^.]+)\.([^)]+)\)$/);
|
|
8
|
+
if (!e) {
|
|
9
|
+
throw new Error(`Invalid pointcut expression: ${t}`);
|
|
13
10
|
}
|
|
14
|
-
|
|
11
|
+
const [, c, r] = e;
|
|
12
|
+
return new ExecutionPointcutMatcher(c, r);
|
|
15
13
|
}
|
|
16
|
-
|
|
17
|
-
|
|
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);
|
|
18
20
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
patternToRegex(t) {
|
|
22
|
+
if (t === '*') {
|
|
23
|
+
return /.*/;
|
|
24
|
+
}
|
|
25
|
+
const e = t.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
|
|
26
|
+
return new RegExp(`^${e}$`);
|
|
21
27
|
}
|
|
22
|
-
|
|
23
|
-
this.
|
|
28
|
+
constructor(t, e){
|
|
29
|
+
this.classRegex = this.patternToRegex(t);
|
|
30
|
+
this.methodRegex = this.patternToRegex(e);
|
|
24
31
|
}
|
|
25
|
-
}
|
|
26
|
-
ResolverStore.resolvers = new Map();
|
|
32
|
+
};
|
|
27
33
|
|
|
28
|
-
exports.
|
|
34
|
+
exports.PointcutMatcher = PointcutMatcher;
|
package/dist/index40.mjs
CHANGED
|
@@ -1,24 +1,30 @@
|
|
|
1
|
-
class
|
|
2
|
-
static
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const r = this.resolvers.get(e);
|
|
7
|
-
if (!r) {
|
|
8
|
-
throw new Error(`No resolver found for decorator type: ${e}`);
|
|
1
|
+
class PointcutMatcher {
|
|
2
|
+
static parse(t) {
|
|
3
|
+
const e = t.match(/^execution\(([^.]+)\.([^)]+)\)$/);
|
|
4
|
+
if (!e) {
|
|
5
|
+
throw new Error(`Invalid pointcut expression: ${t}`);
|
|
9
6
|
}
|
|
10
|
-
|
|
7
|
+
const [, c, r] = e;
|
|
8
|
+
return new ExecutionPointcutMatcher(c, r);
|
|
11
9
|
}
|
|
12
|
-
|
|
13
|
-
|
|
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);
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
patternToRegex(t) {
|
|
18
|
+
if (t === '*') {
|
|
19
|
+
return /.*/;
|
|
20
|
+
}
|
|
21
|
+
const e = t.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
|
|
22
|
+
return new RegExp(`^${e}$`);
|
|
17
23
|
}
|
|
18
|
-
|
|
19
|
-
this.
|
|
24
|
+
constructor(t, e){
|
|
25
|
+
this.classRegex = this.patternToRegex(t);
|
|
26
|
+
this.methodRegex = this.patternToRegex(e);
|
|
20
27
|
}
|
|
21
|
-
}
|
|
22
|
-
ResolverStore.resolvers = new Map();
|
|
28
|
+
};
|
|
23
29
|
|
|
24
|
-
export {
|
|
30
|
+
export { PointcutMatcher };
|
package/dist/index48.js
CHANGED
package/dist/index48.mjs
CHANGED
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('./
|
|
6
|
+
const transversalWeaver = require('./index39.js');
|
|
7
7
|
const helpers = require('./index37.js');
|
|
8
8
|
|
|
9
9
|
class InjectableBuilder {
|
package/dist/index49.mjs
CHANGED
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.
|
|
4
|
+
"version": "1.1.6",
|
|
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",
|